ホーム › System.Diagnostics.Debug › DecodeRemotePointer
DecodeRemotePointer
関数指定プロセスで符号化されたポインタ値を復号する。
シグネチャ
// api-ms-win-core-util-l1-1-1.dll
#include <windows.h>
HRESULT DecodeRemotePointer(
HANDLE ProcessHandle,
void* Ptr, // optional
void** DecodedPtr
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ProcessHandle | HANDLE | in | 対象プロセスのハンドル。そのプロセスのコンテキストで復号する。 |
| Ptr | void* | inoptional | 復号対象のエンコード済みポインタ値。 |
| DecodedPtr | void** | out | 復号結果のポインタを受け取る出力先へのポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-core-util-l1-1-1.dll
#include <windows.h>
HRESULT DecodeRemotePointer(
HANDLE ProcessHandle,
void* Ptr, // optional
void** DecodedPtr
);[DllImport("api-ms-win-core-util-l1-1-1.dll", ExactSpelling = true)]
static extern int DecodeRemotePointer(
IntPtr ProcessHandle, // HANDLE
IntPtr Ptr, // void* optional
IntPtr DecodedPtr // void** out
);<DllImport("api-ms-win-core-util-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function DecodeRemotePointer(
ProcessHandle As IntPtr, ' HANDLE
Ptr As IntPtr, ' void* optional
DecodedPtr As IntPtr ' void** out
) As Integer
End Function' ProcessHandle : HANDLE
' Ptr : void* optional
' DecodedPtr : void** out
Declare PtrSafe Function DecodeRemotePointer Lib "api-ms-win-core-util-l1-1-1" ( _
ByVal ProcessHandle As LongPtr, _
ByVal Ptr As LongPtr, _
ByVal DecodedPtr As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DecodeRemotePointer = ctypes.windll.LoadLibrary("api-ms-win-core-util-l1-1-1.dll").DecodeRemotePointer
DecodeRemotePointer.restype = ctypes.c_int
DecodeRemotePointer.argtypes = [
wintypes.HANDLE, # ProcessHandle : HANDLE
ctypes.POINTER(None), # Ptr : void* optional
ctypes.c_void_p, # DecodedPtr : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-util-l1-1-1.dll')
DecodeRemotePointer = Fiddle::Function.new(
lib['DecodeRemotePointer'],
[
Fiddle::TYPE_VOIDP, # ProcessHandle : HANDLE
Fiddle::TYPE_VOIDP, # Ptr : void* optional
Fiddle::TYPE_VOIDP, # DecodedPtr : void** out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-util-l1-1-1")]
extern "system" {
fn DecodeRemotePointer(
ProcessHandle: *mut core::ffi::c_void, // HANDLE
Ptr: *mut (), // void* optional
DecodedPtr: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-util-l1-1-1.dll")]
public static extern int DecodeRemotePointer(IntPtr ProcessHandle, IntPtr Ptr, IntPtr DecodedPtr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-util-l1-1-1_DecodeRemotePointer' -Namespace Win32 -PassThru
# $api::DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)#uselib "api-ms-win-core-util-l1-1-1.dll"
#func global DecodeRemotePointer "DecodeRemotePointer" sptr, sptr, sptr
; DecodeRemotePointer ProcessHandle, Ptr, DecodedPtr ; 戻り値は stat
; ProcessHandle : HANDLE -> "sptr"
; Ptr : void* optional -> "sptr"
; DecodedPtr : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-util-l1-1-1.dll"
#cfunc global DecodeRemotePointer "DecodeRemotePointer" sptr, sptr, sptr
; res = DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
; ProcessHandle : HANDLE -> "sptr"
; Ptr : void* optional -> "sptr"
; DecodedPtr : void** out -> "sptr"; HRESULT DecodeRemotePointer(HANDLE ProcessHandle, void* Ptr, void** DecodedPtr)
#uselib "api-ms-win-core-util-l1-1-1.dll"
#cfunc global DecodeRemotePointer "DecodeRemotePointer" intptr, intptr, intptr
; res = DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
; ProcessHandle : HANDLE -> "intptr"
; Ptr : void* optional -> "intptr"
; DecodedPtr : void** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_util_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-core-util-l1-1-1.dll")
procDecodeRemotePointer = api_ms_win_core_util_l1_1_1.NewProc("DecodeRemotePointer")
)
// ProcessHandle (HANDLE), Ptr (void* optional), DecodedPtr (void** out)
r1, _, err := procDecodeRemotePointer.Call(
uintptr(ProcessHandle),
uintptr(Ptr),
uintptr(DecodedPtr),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DecodeRemotePointer(
ProcessHandle: THandle; // HANDLE
Ptr: Pointer; // void* optional
DecodedPtr: Pointer // void** out
): Integer; stdcall;
external 'api-ms-win-core-util-l1-1-1.dll' name 'DecodeRemotePointer';result := DllCall("api-ms-win-core-util-l1-1-1\DecodeRemotePointer"
, "Ptr", ProcessHandle ; HANDLE
, "Ptr", Ptr ; void* optional
, "Ptr", DecodedPtr ; void** out
, "Int") ; return: HRESULT●DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr) = DLL("api-ms-win-core-util-l1-1-1.dll", "int DecodeRemotePointer(void*, void*, void*)")
# 呼び出し: DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
# ProcessHandle : HANDLE -> "void*"
# Ptr : void* optional -> "void*"
# DecodedPtr : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-util-l1-1-1" fn DecodeRemotePointer(
ProcessHandle: ?*anyopaque, // HANDLE
Ptr: ?*anyopaque, // void* optional
DecodedPtr: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc DecodeRemotePointer(
ProcessHandle: pointer, # HANDLE
Ptr: pointer, # void* optional
DecodedPtr: pointer # void** out
): int32 {.importc: "DecodeRemotePointer", stdcall, dynlib: "api-ms-win-core-util-l1-1-1.dll".}pragma(lib, "api-ms-win-core-util-l1-1-1");
extern(Windows)
int DecodeRemotePointer(
void* ProcessHandle, // HANDLE
void* Ptr, // void* optional
void** DecodedPtr // void** out
);ccall((:DecodeRemotePointer, "api-ms-win-core-util-l1-1-1.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
ProcessHandle, Ptr, DecodedPtr)
# ProcessHandle : HANDLE -> Ptr{Cvoid}
# Ptr : void* optional -> Ptr{Cvoid}
# DecodedPtr : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DecodeRemotePointer(
void* ProcessHandle,
void* Ptr,
void** DecodedPtr);
]]
local api-ms-win-core-util-l1-1-1 = ffi.load("api-ms-win-core-util-l1-1-1")
-- api-ms-win-core-util-l1-1-1.DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
-- ProcessHandle : HANDLE
-- Ptr : void* optional
-- DecodedPtr : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-util-l1-1-1.dll');
const DecodeRemotePointer = lib.func('__stdcall', 'DecodeRemotePointer', 'int32_t', ['void *', 'void *', 'void *']);
// DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
// ProcessHandle : HANDLE -> 'void *'
// Ptr : void* optional -> 'void *'
// DecodedPtr : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-util-l1-1-1.dll", {
DecodeRemotePointer: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr)
// ProcessHandle : HANDLE -> "pointer"
// Ptr : void* optional -> "pointer"
// DecodedPtr : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DecodeRemotePointer(
void* ProcessHandle,
void* Ptr,
void** DecodedPtr);
C, "api-ms-win-core-util-l1-1-1.dll");
// $ffi->DecodeRemotePointer(ProcessHandle, Ptr, DecodedPtr);
// ProcessHandle : HANDLE
// Ptr : void* optional
// DecodedPtr : void** 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-util-l1-1-1 extends StdCallLibrary {
Api-ms-win-core-util-l1-1-1 INSTANCE = Native.load("api-ms-win-core-util-l1-1-1", Api-ms-win-core-util-l1-1-1.class);
int DecodeRemotePointer(
Pointer ProcessHandle, // HANDLE
Pointer Ptr, // void* optional
Pointer DecodedPtr // void** out
);
}@[Link("api-ms-win-core-util-l1-1-1")]
lib Libapi-ms-win-core-util-l1-1-1
fun DecodeRemotePointer = DecodeRemotePointer(
ProcessHandle : Void*, # HANDLE
Ptr : Void*, # void* optional
DecodedPtr : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DecodeRemotePointerNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef DecodeRemotePointerDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final DecodeRemotePointer = DynamicLibrary.open('api-ms-win-core-util-l1-1-1.dll')
.lookupFunction<DecodeRemotePointerNative, DecodeRemotePointerDart>('DecodeRemotePointer');
// ProcessHandle : HANDLE -> Pointer<Void>
// Ptr : void* optional -> Pointer<Void>
// DecodedPtr : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DecodeRemotePointer(
ProcessHandle: THandle; // HANDLE
Ptr: Pointer; // void* optional
DecodedPtr: Pointer // void** out
): Integer; stdcall;
external 'api-ms-win-core-util-l1-1-1.dll' name 'DecodeRemotePointer';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DecodeRemotePointer"
c_DecodeRemotePointer :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- ProcessHandle : HANDLE -> Ptr ()
-- Ptr : void* optional -> Ptr ()
-- DecodedPtr : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let decoderemotepointer =
foreign "DecodeRemotePointer"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* ProcessHandle : HANDLE -> (ptr void) *)
(* Ptr : void* optional -> (ptr void) *)
(* DecodedPtr : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-util-l1-1-1 (t "api-ms-win-core-util-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-core-util-l1-1-1)
(cffi:defcfun ("DecodeRemotePointer" decode-remote-pointer :convention :stdcall) :int32
(process-handle :pointer) ; HANDLE
(ptr :pointer) ; void* optional
(decoded-ptr :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DecodeRemotePointer = Win32::API::More->new('api-ms-win-core-util-l1-1-1',
'int DecodeRemotePointer(HANDLE ProcessHandle, LPVOID Ptr, LPVOID DecodedPtr)');
# my $ret = $DecodeRemotePointer->Call($ProcessHandle, $Ptr, $DecodedPtr);
# ProcessHandle : HANDLE -> HANDLE
# Ptr : void* optional -> LPVOID
# DecodedPtr : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。