ホーム › System.Diagnostics.ToolHelp › Heap32ListFirst
Heap32ListFirst
関数スナップショット内の最初のヒープリスト情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL Heap32ListFirst(
HANDLE hSnapshot,
HEAPLIST32* lphl
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hSnapshot | HANDLE | in | CreateToolhelp32Snapshotで取得したスナップショットハンドル。 |
| lphl | HEAPLIST32* | inout | 最初のヒープリスト情報を受け取るHEAPLIST32へのポインタ。dwSizeを事前設定する必要がある。 |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL Heap32ListFirst(
HANDLE hSnapshot,
HEAPLIST32* lphl
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool Heap32ListFirst(
IntPtr hSnapshot, // HANDLE
IntPtr lphl // HEAPLIST32* in/out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function Heap32ListFirst(
hSnapshot As IntPtr, ' HANDLE
lphl As IntPtr ' HEAPLIST32* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hSnapshot : HANDLE
' lphl : HEAPLIST32* in/out
Declare PtrSafe Function Heap32ListFirst Lib "kernel32" ( _
ByVal hSnapshot As LongPtr, _
ByVal lphl As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Heap32ListFirst = ctypes.windll.kernel32.Heap32ListFirst
Heap32ListFirst.restype = wintypes.BOOL
Heap32ListFirst.argtypes = [
wintypes.HANDLE, # hSnapshot : HANDLE
ctypes.c_void_p, # lphl : HEAPLIST32* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
Heap32ListFirst = Fiddle::Function.new(
lib['Heap32ListFirst'],
[
Fiddle::TYPE_VOIDP, # hSnapshot : HANDLE
Fiddle::TYPE_VOIDP, # lphl : HEAPLIST32* in/out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn Heap32ListFirst(
hSnapshot: *mut core::ffi::c_void, // HANDLE
lphl: *mut HEAPLIST32 // HEAPLIST32* in/out
) -> 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 Heap32ListFirst(IntPtr hSnapshot, IntPtr lphl);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_Heap32ListFirst' -Namespace Win32 -PassThru
# $api::Heap32ListFirst(hSnapshot, lphl)#uselib "KERNEL32.dll"
#func global Heap32ListFirst "Heap32ListFirst" sptr, sptr
; Heap32ListFirst hSnapshot, varptr(lphl) ; 戻り値は stat
; hSnapshot : HANDLE -> "sptr"
; lphl : HEAPLIST32* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global Heap32ListFirst "Heap32ListFirst" sptr, var ; res = Heap32ListFirst(hSnapshot, lphl) ; hSnapshot : HANDLE -> "sptr" ; lphl : HEAPLIST32* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global Heap32ListFirst "Heap32ListFirst" sptr, sptr ; res = Heap32ListFirst(hSnapshot, varptr(lphl)) ; hSnapshot : HANDLE -> "sptr" ; lphl : HEAPLIST32* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL Heap32ListFirst(HANDLE hSnapshot, HEAPLIST32* lphl) #uselib "KERNEL32.dll" #cfunc global Heap32ListFirst "Heap32ListFirst" intptr, var ; res = Heap32ListFirst(hSnapshot, lphl) ; hSnapshot : HANDLE -> "intptr" ; lphl : HEAPLIST32* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL Heap32ListFirst(HANDLE hSnapshot, HEAPLIST32* lphl) #uselib "KERNEL32.dll" #cfunc global Heap32ListFirst "Heap32ListFirst" intptr, intptr ; res = Heap32ListFirst(hSnapshot, varptr(lphl)) ; hSnapshot : HANDLE -> "intptr" ; lphl : HEAPLIST32* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procHeap32ListFirst = kernel32.NewProc("Heap32ListFirst")
)
// hSnapshot (HANDLE), lphl (HEAPLIST32* in/out)
r1, _, err := procHeap32ListFirst.Call(
uintptr(hSnapshot),
uintptr(lphl),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction Heap32ListFirst(
hSnapshot: THandle; // HANDLE
lphl: Pointer // HEAPLIST32* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'Heap32ListFirst';result := DllCall("KERNEL32\Heap32ListFirst"
, "Ptr", hSnapshot ; HANDLE
, "Ptr", lphl ; HEAPLIST32* in/out
, "Int") ; return: BOOL●Heap32ListFirst(hSnapshot, lphl) = DLL("KERNEL32.dll", "bool Heap32ListFirst(void*, void*)")
# 呼び出し: Heap32ListFirst(hSnapshot, lphl)
# hSnapshot : HANDLE -> "void*"
# lphl : HEAPLIST32* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn Heap32ListFirst(
hSnapshot: ?*anyopaque, // HANDLE
lphl: [*c]HEAPLIST32 // HEAPLIST32* in/out
) callconv(std.os.windows.WINAPI) i32;proc Heap32ListFirst(
hSnapshot: pointer, # HANDLE
lphl: ptr HEAPLIST32 # HEAPLIST32* in/out
): int32 {.importc: "Heap32ListFirst", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int Heap32ListFirst(
void* hSnapshot, // HANDLE
HEAPLIST32* lphl // HEAPLIST32* in/out
);ccall((:Heap32ListFirst, "KERNEL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{HEAPLIST32}),
hSnapshot, lphl)
# hSnapshot : HANDLE -> Ptr{Cvoid}
# lphl : HEAPLIST32* in/out -> Ptr{HEAPLIST32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t Heap32ListFirst(
void* hSnapshot,
void* lphl);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.Heap32ListFirst(hSnapshot, lphl)
-- hSnapshot : HANDLE
-- lphl : HEAPLIST32* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const Heap32ListFirst = lib.func('__stdcall', 'Heap32ListFirst', 'int32_t', ['void *', 'void *']);
// Heap32ListFirst(hSnapshot, lphl)
// hSnapshot : HANDLE -> 'void *'
// lphl : HEAPLIST32* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
Heap32ListFirst: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.Heap32ListFirst(hSnapshot, lphl)
// hSnapshot : HANDLE -> "pointer"
// lphl : HEAPLIST32* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t Heap32ListFirst(
void* hSnapshot,
void* lphl);
C, "KERNEL32.dll");
// $ffi->Heap32ListFirst(hSnapshot, lphl);
// hSnapshot : HANDLE
// lphl : HEAPLIST32* in/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
boolean Heap32ListFirst(
Pointer hSnapshot, // HANDLE
Pointer lphl // HEAPLIST32* in/out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun Heap32ListFirst = Heap32ListFirst(
hSnapshot : Void*, # HANDLE
lphl : HEAPLIST32* # HEAPLIST32* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef Heap32ListFirstNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef Heap32ListFirstDart = int Function(Pointer<Void>, Pointer<Void>);
final Heap32ListFirst = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<Heap32ListFirstNative, Heap32ListFirstDart>('Heap32ListFirst');
// hSnapshot : HANDLE -> Pointer<Void>
// lphl : HEAPLIST32* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function Heap32ListFirst(
hSnapshot: THandle; // HANDLE
lphl: Pointer // HEAPLIST32* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'Heap32ListFirst';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "Heap32ListFirst"
c_Heap32ListFirst :: Ptr () -> Ptr () -> IO CInt
-- hSnapshot : HANDLE -> Ptr ()
-- lphl : HEAPLIST32* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let heap32listfirst =
foreign "Heap32ListFirst"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hSnapshot : HANDLE -> (ptr void) *)
(* lphl : HEAPLIST32* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("Heap32ListFirst" heap32-list-first :convention :stdcall) :int32
(h-snapshot :pointer) ; HANDLE
(lphl :pointer)) ; HEAPLIST32* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $Heap32ListFirst = Win32::API::More->new('KERNEL32',
'BOOL Heap32ListFirst(HANDLE hSnapshot, LPVOID lphl)');
# my $ret = $Heap32ListFirst->Call($hSnapshot, $lphl);
# hSnapshot : HANDLE -> HANDLE
# lphl : HEAPLIST32* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型