ホーム › System.Diagnostics.ToolHelp › Heap32First
Heap32First
関数指定ヒープ内の最初のヒープブロック情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL Heap32First(
HEAPENTRY32* lphe,
DWORD th32ProcessID,
UINT_PTR th32HeapID
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lphe | HEAPENTRY32* | inout |
| th32ProcessID | DWORD | in |
| th32HeapID | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL Heap32First(
HEAPENTRY32* lphe,
DWORD th32ProcessID,
UINT_PTR th32HeapID
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool Heap32First(
IntPtr lphe, // HEAPENTRY32* in/out
uint th32ProcessID, // DWORD
UIntPtr th32HeapID // UINT_PTR
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function Heap32First(
lphe As IntPtr, ' HEAPENTRY32* in/out
th32ProcessID As UInteger, ' DWORD
th32HeapID As UIntPtr ' UINT_PTR
) As Boolean
End Function' lphe : HEAPENTRY32* in/out
' th32ProcessID : DWORD
' th32HeapID : UINT_PTR
Declare PtrSafe Function Heap32First Lib "kernel32" ( _
ByVal lphe As LongPtr, _
ByVal th32ProcessID As Long, _
ByVal th32HeapID As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Heap32First = ctypes.windll.kernel32.Heap32First
Heap32First.restype = wintypes.BOOL
Heap32First.argtypes = [
ctypes.c_void_p, # lphe : HEAPENTRY32* in/out
wintypes.DWORD, # th32ProcessID : DWORD
ctypes.c_size_t, # th32HeapID : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
Heap32First = Fiddle::Function.new(
lib['Heap32First'],
[
Fiddle::TYPE_VOIDP, # lphe : HEAPENTRY32* in/out
-Fiddle::TYPE_INT, # th32ProcessID : DWORD
Fiddle::TYPE_UINTPTR_T, # th32HeapID : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn Heap32First(
lphe: *mut HEAPENTRY32, // HEAPENTRY32* in/out
th32ProcessID: u32, // DWORD
th32HeapID: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool Heap32First(IntPtr lphe, uint th32ProcessID, UIntPtr th32HeapID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_Heap32First' -Namespace Win32 -PassThru
# $api::Heap32First(lphe, th32ProcessID, th32HeapID)#uselib "KERNEL32.dll"
#func global Heap32First "Heap32First" sptr, sptr, sptr
; Heap32First varptr(lphe), th32ProcessID, th32HeapID ; 戻り値は stat
; lphe : HEAPENTRY32* in/out -> "sptr"
; th32ProcessID : DWORD -> "sptr"
; th32HeapID : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global Heap32First "Heap32First" var, int, sptr ; res = Heap32First(lphe, th32ProcessID, th32HeapID) ; lphe : HEAPENTRY32* in/out -> "var" ; th32ProcessID : DWORD -> "int" ; th32HeapID : UINT_PTR -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global Heap32First "Heap32First" sptr, int, sptr ; res = Heap32First(varptr(lphe), th32ProcessID, th32HeapID) ; lphe : HEAPENTRY32* in/out -> "sptr" ; th32ProcessID : DWORD -> "int" ; th32HeapID : UINT_PTR -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL Heap32First(HEAPENTRY32* lphe, DWORD th32ProcessID, UINT_PTR th32HeapID) #uselib "KERNEL32.dll" #cfunc global Heap32First "Heap32First" var, int, intptr ; res = Heap32First(lphe, th32ProcessID, th32HeapID) ; lphe : HEAPENTRY32* in/out -> "var" ; th32ProcessID : DWORD -> "int" ; th32HeapID : UINT_PTR -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL Heap32First(HEAPENTRY32* lphe, DWORD th32ProcessID, UINT_PTR th32HeapID) #uselib "KERNEL32.dll" #cfunc global Heap32First "Heap32First" intptr, int, intptr ; res = Heap32First(varptr(lphe), th32ProcessID, th32HeapID) ; lphe : HEAPENTRY32* in/out -> "intptr" ; th32ProcessID : DWORD -> "int" ; th32HeapID : UINT_PTR -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procHeap32First = kernel32.NewProc("Heap32First")
)
// lphe (HEAPENTRY32* in/out), th32ProcessID (DWORD), th32HeapID (UINT_PTR)
r1, _, err := procHeap32First.Call(
uintptr(lphe),
uintptr(th32ProcessID),
uintptr(th32HeapID),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction Heap32First(
lphe: Pointer; // HEAPENTRY32* in/out
th32ProcessID: DWORD; // DWORD
th32HeapID: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'Heap32First';result := DllCall("KERNEL32\Heap32First"
, "Ptr", lphe ; HEAPENTRY32* in/out
, "UInt", th32ProcessID ; DWORD
, "UPtr", th32HeapID ; UINT_PTR
, "Int") ; return: BOOL●Heap32First(lphe, th32ProcessID, th32HeapID) = DLL("KERNEL32.dll", "bool Heap32First(void*, dword, int)")
# 呼び出し: Heap32First(lphe, th32ProcessID, th32HeapID)
# lphe : HEAPENTRY32* in/out -> "void*"
# th32ProcessID : DWORD -> "dword"
# th32HeapID : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。