ホーム › System.WinRT › WindowsInspectString2
WindowsInspectString2
関数別プロセス内のHSTRINGを64ビット対応で調査する。
シグネチャ
// api-ms-win-core-winrt-string-l1-1-1.dll
#include <windows.h>
HRESULT WindowsInspectString2(
ULONGLONG targetHString,
WORD machine,
PINSPECT_HSTRING_CALLBACK2 callback,
void* context, // optional
DWORD* length,
ULONGLONG* targetStringAddress
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| targetHString | ULONGLONG | in | 検査対象プロセス内のHSTRINGのアドレス(64ビット)。 |
| machine | WORD | in | 対象プロセスのマシンアーキテクチャを示すIMAGE_FILE_MACHINE値。 |
| callback | PINSPECT_HSTRING_CALLBACK2 | in | 対象プロセスのメモリを読み取るPINSPECT_HSTRING_CALLBACK2コールバック。 |
| context | void* | inoptional | コールバックに渡すユーザー定義コンテキストポインタ。NULL可。 |
| length | DWORD* | out | 出力として文字列長を受け取るDWORDポインタ。 |
| targetStringAddress | ULONGLONG* | out | 出力として対象プロセス内の文字列バッファアドレス(64ビット)を受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-core-winrt-string-l1-1-1.dll
#include <windows.h>
HRESULT WindowsInspectString2(
ULONGLONG targetHString,
WORD machine,
PINSPECT_HSTRING_CALLBACK2 callback,
void* context, // optional
DWORD* length,
ULONGLONG* targetStringAddress
);[DllImport("api-ms-win-core-winrt-string-l1-1-1.dll", ExactSpelling = true)]
static extern int WindowsInspectString2(
ulong targetHString, // ULONGLONG
ushort machine, // WORD
IntPtr callback, // PINSPECT_HSTRING_CALLBACK2
IntPtr context, // void* optional
out uint length, // DWORD* out
out ulong targetStringAddress // ULONGLONG* out
);<DllImport("api-ms-win-core-winrt-string-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function WindowsInspectString2(
targetHString As ULong, ' ULONGLONG
machine As UShort, ' WORD
callback As IntPtr, ' PINSPECT_HSTRING_CALLBACK2
context As IntPtr, ' void* optional
<Out> ByRef length As UInteger, ' DWORD* out
<Out> ByRef targetStringAddress As ULong ' ULONGLONG* out
) As Integer
End Function' targetHString : ULONGLONG
' machine : WORD
' callback : PINSPECT_HSTRING_CALLBACK2
' context : void* optional
' length : DWORD* out
' targetStringAddress : ULONGLONG* out
Declare PtrSafe Function WindowsInspectString2 Lib "api-ms-win-core-winrt-string-l1-1-1" ( _
ByVal targetHString As LongLong, _
ByVal machine As Integer, _
ByVal callback As LongPtr, _
ByVal context As LongPtr, _
ByRef length As Long, _
ByRef targetStringAddress As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WindowsInspectString2 = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-string-l1-1-1.dll").WindowsInspectString2
WindowsInspectString2.restype = ctypes.c_int
WindowsInspectString2.argtypes = [
ctypes.c_ulonglong, # targetHString : ULONGLONG
ctypes.c_ushort, # machine : WORD
ctypes.c_void_p, # callback : PINSPECT_HSTRING_CALLBACK2
ctypes.POINTER(None), # context : void* optional
ctypes.POINTER(wintypes.DWORD), # length : DWORD* out
ctypes.POINTER(ctypes.c_ulonglong), # targetStringAddress : ULONGLONG* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-winrt-string-l1-1-1.dll')
WindowsInspectString2 = Fiddle::Function.new(
lib['WindowsInspectString2'],
[
-Fiddle::TYPE_LONG_LONG, # targetHString : ULONGLONG
-Fiddle::TYPE_SHORT, # machine : WORD
Fiddle::TYPE_VOIDP, # callback : PINSPECT_HSTRING_CALLBACK2
Fiddle::TYPE_VOIDP, # context : void* optional
Fiddle::TYPE_VOIDP, # length : DWORD* out
Fiddle::TYPE_VOIDP, # targetStringAddress : ULONGLONG* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-winrt-string-l1-1-1")]
extern "system" {
fn WindowsInspectString2(
targetHString: u64, // ULONGLONG
machine: u16, // WORD
callback: *const core::ffi::c_void, // PINSPECT_HSTRING_CALLBACK2
context: *mut (), // void* optional
length: *mut u32, // DWORD* out
targetStringAddress: *mut u64 // ULONGLONG* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-winrt-string-l1-1-1.dll")]
public static extern int WindowsInspectString2(ulong targetHString, ushort machine, IntPtr callback, IntPtr context, out uint length, out ulong targetStringAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-string-l1-1-1_WindowsInspectString2' -Namespace Win32 -PassThru
# $api::WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress)#uselib "api-ms-win-core-winrt-string-l1-1-1.dll"
#func global WindowsInspectString2 "WindowsInspectString2" sptr, sptr, sptr, sptr, sptr, sptr
; WindowsInspectString2 targetHString, machine, callback, context, varptr(length), varptr(targetStringAddress) ; 戻り値は stat
; targetHString : ULONGLONG -> "sptr"
; machine : WORD -> "sptr"
; callback : PINSPECT_HSTRING_CALLBACK2 -> "sptr"
; context : void* optional -> "sptr"
; length : DWORD* out -> "sptr"
; targetStringAddress : ULONGLONG* out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-winrt-string-l1-1-1.dll" #cfunc global WindowsInspectString2 "WindowsInspectString2" int64, int, sptr, sptr, var, var ; res = WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress) ; targetHString : ULONGLONG -> "int64" ; machine : WORD -> "int" ; callback : PINSPECT_HSTRING_CALLBACK2 -> "sptr" ; context : void* optional -> "sptr" ; length : DWORD* out -> "var" ; targetStringAddress : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "api-ms-win-core-winrt-string-l1-1-1.dll" #cfunc global WindowsInspectString2 "WindowsInspectString2" int64, int, sptr, sptr, sptr, sptr ; res = WindowsInspectString2(targetHString, machine, callback, context, varptr(length), varptr(targetStringAddress)) ; targetHString : ULONGLONG -> "int64" ; machine : WORD -> "int" ; callback : PINSPECT_HSTRING_CALLBACK2 -> "sptr" ; context : void* optional -> "sptr" ; length : DWORD* out -> "sptr" ; targetStringAddress : ULONGLONG* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT WindowsInspectString2(ULONGLONG targetHString, WORD machine, PINSPECT_HSTRING_CALLBACK2 callback, void* context, DWORD* length, ULONGLONG* targetStringAddress) #uselib "api-ms-win-core-winrt-string-l1-1-1.dll" #cfunc global WindowsInspectString2 "WindowsInspectString2" int64, int, intptr, intptr, var, var ; res = WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress) ; targetHString : ULONGLONG -> "int64" ; machine : WORD -> "int" ; callback : PINSPECT_HSTRING_CALLBACK2 -> "intptr" ; context : void* optional -> "intptr" ; length : DWORD* out -> "var" ; targetStringAddress : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WindowsInspectString2(ULONGLONG targetHString, WORD machine, PINSPECT_HSTRING_CALLBACK2 callback, void* context, DWORD* length, ULONGLONG* targetStringAddress) #uselib "api-ms-win-core-winrt-string-l1-1-1.dll" #cfunc global WindowsInspectString2 "WindowsInspectString2" int64, int, intptr, intptr, intptr, intptr ; res = WindowsInspectString2(targetHString, machine, callback, context, varptr(length), varptr(targetStringAddress)) ; targetHString : ULONGLONG -> "int64" ; machine : WORD -> "int" ; callback : PINSPECT_HSTRING_CALLBACK2 -> "intptr" ; context : void* optional -> "intptr" ; length : DWORD* out -> "intptr" ; targetStringAddress : ULONGLONG* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_winrt_string_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-core-winrt-string-l1-1-1.dll")
procWindowsInspectString2 = api_ms_win_core_winrt_string_l1_1_1.NewProc("WindowsInspectString2")
)
// targetHString (ULONGLONG), machine (WORD), callback (PINSPECT_HSTRING_CALLBACK2), context (void* optional), length (DWORD* out), targetStringAddress (ULONGLONG* out)
r1, _, err := procWindowsInspectString2.Call(
uintptr(targetHString),
uintptr(machine),
uintptr(callback),
uintptr(context),
uintptr(length),
uintptr(targetStringAddress),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WindowsInspectString2(
targetHString: UInt64; // ULONGLONG
machine: Word; // WORD
callback: Pointer; // PINSPECT_HSTRING_CALLBACK2
context: Pointer; // void* optional
length: Pointer; // DWORD* out
targetStringAddress: Pointer // ULONGLONG* out
): Integer; stdcall;
external 'api-ms-win-core-winrt-string-l1-1-1.dll' name 'WindowsInspectString2';result := DllCall("api-ms-win-core-winrt-string-l1-1-1\WindowsInspectString2"
, "Int64", targetHString ; ULONGLONG
, "UShort", machine ; WORD
, "Ptr", callback ; PINSPECT_HSTRING_CALLBACK2
, "Ptr", context ; void* optional
, "Ptr", length ; DWORD* out
, "Ptr", targetStringAddress ; ULONGLONG* out
, "Int") ; return: HRESULT●WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress) = DLL("api-ms-win-core-winrt-string-l1-1-1.dll", "int WindowsInspectString2(qword, int, void*, void*, void*, void*)")
# 呼び出し: WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress)
# targetHString : ULONGLONG -> "qword"
# machine : WORD -> "int"
# callback : PINSPECT_HSTRING_CALLBACK2 -> "void*"
# context : void* optional -> "void*"
# length : DWORD* out -> "void*"
# targetStringAddress : ULONGLONG* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-winrt-string-l1-1-1" fn WindowsInspectString2(
targetHString: u64, // ULONGLONG
machine: u16, // WORD
callback: ?*anyopaque, // PINSPECT_HSTRING_CALLBACK2
context: ?*anyopaque, // void* optional
length: [*c]u32, // DWORD* out
targetStringAddress: [*c]u64 // ULONGLONG* out
) callconv(std.os.windows.WINAPI) i32;proc WindowsInspectString2(
targetHString: uint64, # ULONGLONG
machine: uint16, # WORD
callback: pointer, # PINSPECT_HSTRING_CALLBACK2
context: pointer, # void* optional
length: ptr uint32, # DWORD* out
targetStringAddress: ptr uint64 # ULONGLONG* out
): int32 {.importc: "WindowsInspectString2", stdcall, dynlib: "api-ms-win-core-winrt-string-l1-1-1.dll".}pragma(lib, "api-ms-win-core-winrt-string-l1-1-1");
extern(Windows)
int WindowsInspectString2(
ulong targetHString, // ULONGLONG
ushort machine, // WORD
void* callback, // PINSPECT_HSTRING_CALLBACK2
void* context, // void* optional
uint* length, // DWORD* out
ulong* targetStringAddress // ULONGLONG* out
);ccall((:WindowsInspectString2, "api-ms-win-core-winrt-string-l1-1-1.dll"), stdcall, Int32,
(UInt64, UInt16, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{UInt32}, Ptr{UInt64}),
targetHString, machine, callback, context, length, targetStringAddress)
# targetHString : ULONGLONG -> UInt64
# machine : WORD -> UInt16
# callback : PINSPECT_HSTRING_CALLBACK2 -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# length : DWORD* out -> Ptr{UInt32}
# targetStringAddress : ULONGLONG* out -> Ptr{UInt64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WindowsInspectString2(
uint64_t targetHString,
uint16_t machine,
void* callback,
void* context,
uint32_t* length,
uint64_t* targetStringAddress);
]]
local api-ms-win-core-winrt-string-l1-1-1 = ffi.load("api-ms-win-core-winrt-string-l1-1-1")
-- api-ms-win-core-winrt-string-l1-1-1.WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress)
-- targetHString : ULONGLONG
-- machine : WORD
-- callback : PINSPECT_HSTRING_CALLBACK2
-- context : void* optional
-- length : DWORD* out
-- targetStringAddress : ULONGLONG* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-winrt-string-l1-1-1.dll');
const WindowsInspectString2 = lib.func('__stdcall', 'WindowsInspectString2', 'int32_t', ['uint64_t', 'uint16_t', 'void *', 'void *', 'uint32_t *', 'uint64_t *']);
// WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress)
// targetHString : ULONGLONG -> 'uint64_t'
// machine : WORD -> 'uint16_t'
// callback : PINSPECT_HSTRING_CALLBACK2 -> 'void *'
// context : void* optional -> 'void *'
// length : DWORD* out -> 'uint32_t *'
// targetStringAddress : ULONGLONG* out -> 'uint64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("api-ms-win-core-winrt-string-l1-1-1.dll", {
WindowsInspectString2: { parameters: ["u64", "u16", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress)
// targetHString : ULONGLONG -> "u64"
// machine : WORD -> "u16"
// callback : PINSPECT_HSTRING_CALLBACK2 -> "pointer"
// context : void* optional -> "pointer"
// length : DWORD* out -> "pointer"
// targetStringAddress : ULONGLONG* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WindowsInspectString2(
uint64_t targetHString,
uint16_t machine,
void* callback,
void* context,
uint32_t* length,
uint64_t* targetStringAddress);
C, "api-ms-win-core-winrt-string-l1-1-1.dll");
// $ffi->WindowsInspectString2(targetHString, machine, callback, context, length, targetStringAddress);
// targetHString : ULONGLONG
// machine : WORD
// callback : PINSPECT_HSTRING_CALLBACK2
// context : void* optional
// length : DWORD* out
// targetStringAddress : ULONGLONG* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Api-ms-win-core-winrt-string-l1-1-1 extends StdCallLibrary {
Api-ms-win-core-winrt-string-l1-1-1 INSTANCE = Native.load("api-ms-win-core-winrt-string-l1-1-1", Api-ms-win-core-winrt-string-l1-1-1.class);
int WindowsInspectString2(
long targetHString, // ULONGLONG
short machine, // WORD
Callback callback, // PINSPECT_HSTRING_CALLBACK2
Pointer context, // void* optional
IntByReference length, // DWORD* out
LongByReference targetStringAddress // ULONGLONG* out
);
}@[Link("api-ms-win-core-winrt-string-l1-1-1")]
lib Libapi-ms-win-core-winrt-string-l1-1-1
fun WindowsInspectString2 = WindowsInspectString2(
targetHString : UInt64, # ULONGLONG
machine : UInt16, # WORD
callback : Void*, # PINSPECT_HSTRING_CALLBACK2
context : Void*, # void* optional
length : UInt32*, # DWORD* out
targetStringAddress : UInt64* # ULONGLONG* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WindowsInspectString2Native = Int32 Function(Uint64, Uint16, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint64>);
typedef WindowsInspectString2Dart = int Function(int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint64>);
final WindowsInspectString2 = DynamicLibrary.open('api-ms-win-core-winrt-string-l1-1-1.dll')
.lookupFunction<WindowsInspectString2Native, WindowsInspectString2Dart>('WindowsInspectString2');
// targetHString : ULONGLONG -> Uint64
// machine : WORD -> Uint16
// callback : PINSPECT_HSTRING_CALLBACK2 -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// length : DWORD* out -> Pointer<Uint32>
// targetStringAddress : ULONGLONG* out -> Pointer<Uint64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WindowsInspectString2(
targetHString: UInt64; // ULONGLONG
machine: Word; // WORD
callback: Pointer; // PINSPECT_HSTRING_CALLBACK2
context: Pointer; // void* optional
length: Pointer; // DWORD* out
targetStringAddress: Pointer // ULONGLONG* out
): Integer; stdcall;
external 'api-ms-win-core-winrt-string-l1-1-1.dll' name 'WindowsInspectString2';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WindowsInspectString2"
c_WindowsInspectString2 :: Word64 -> Word16 -> Ptr () -> Ptr () -> Ptr Word32 -> Ptr Word64 -> IO Int32
-- targetHString : ULONGLONG -> Word64
-- machine : WORD -> Word16
-- callback : PINSPECT_HSTRING_CALLBACK2 -> Ptr ()
-- context : void* optional -> Ptr ()
-- length : DWORD* out -> Ptr Word32
-- targetStringAddress : ULONGLONG* out -> Ptr Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let windowsinspectstring2 =
foreign "WindowsInspectString2"
(uint64_t @-> uint16_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint64_t) @-> returning int32_t)
(* targetHString : ULONGLONG -> uint64_t *)
(* machine : WORD -> uint16_t *)
(* callback : PINSPECT_HSTRING_CALLBACK2 -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* length : DWORD* out -> (ptr uint32_t) *)
(* targetStringAddress : ULONGLONG* out -> (ptr uint64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-winrt-string-l1-1-1 (t "api-ms-win-core-winrt-string-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-core-winrt-string-l1-1-1)
(cffi:defcfun ("WindowsInspectString2" windows-inspect-string2 :convention :stdcall) :int32
(target-hstring :uint64) ; ULONGLONG
(machine :uint16) ; WORD
(callback :pointer) ; PINSPECT_HSTRING_CALLBACK2
(context :pointer) ; void* optional
(length :pointer) ; DWORD* out
(target-string-address :pointer)) ; ULONGLONG* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WindowsInspectString2 = Win32::API::More->new('api-ms-win-core-winrt-string-l1-1-1',
'int WindowsInspectString2(UINT64 targetHString, WORD machine, LPVOID callback, LPVOID context, LPVOID length, LPVOID targetStringAddress)');
# my $ret = $WindowsInspectString2->Call($targetHString, $machine, $callback, $context, $length, $targetStringAddress);
# targetHString : ULONGLONG -> UINT64
# machine : WORD -> WORD
# callback : PINSPECT_HSTRING_CALLBACK2 -> LPVOID
# context : void* optional -> LPVOID
# length : DWORD* out -> LPVOID
# targetStringAddress : ULONGLONG* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
類似 API
- f WindowsInspectString — 別プロセス内のHSTRING内容をコールバック経由で調査する。