HeapQueryInformation
関数シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL HeapQueryInformation(
HANDLE HeapHandle, // optional
HEAP_INFORMATION_CLASS HeapInformationClass,
void* HeapInformation, // optional
UINT_PTR HeapInformationLength,
UINT_PTR* ReturnLength // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||
|---|---|---|---|---|---|---|---|
| HeapHandle | HANDLE | inoptional | 情報を取得するヒープへのハンドルです。このハンドルは、 HeapCreate 関数または GetProcessHeap 関数によって返されます。 | ||||
| HeapInformationClass | HEAP_INFORMATION_CLASS | in | 取得する情報のクラスです。このパラメーターには、HEAP_INFORMATION_CLASS 列挙型の次の値を指定できます。
| ||||
| HeapInformation | void* | outoptional | ヒープ情報を受け取るバッファーへのポインターです。このデータの形式は、HeapInformationClass パラメーターの値によって異なります。 | ||||
| HeapInformationLength | UINT_PTR | in | 照会するヒープ情報のサイズ (バイト単位) です。 | ||||
| ReturnLength | UINT_PTR* | outoptional | HeapInformation バッファーに書き込まれたデータの長さを受け取る変数へのポインターです。バッファーが小さすぎる場合、関数は失敗し、ReturnLength にはバッファーに必要な最小サイズが格納されます。 この情報を受け取る必要がない場合は、NULL を指定します。 |
戻り値の型: BOOL
公式ドキュメント
指定されたヒープに関する情報を取得します。
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
LFH または破損時終了 (terminate-on-corruption) 機能を有効にするには、 HeapSetInformation 関数を使用します。
Windows XP および Windows Server 2003: ルックアサイドリストは、固定サイズのブロックのみを含む高速なメモリ割り当て機構です。ルックアサイドリストは、それをサポートするヒープでは既定で有効になっています。Windows Vista 以降では、ルックアサイドリストは使用されず、既定で LFH が有効になります。
ルックアサイドリストは、サイズが可変な一般的なプール割り当てよりも高速です。これは、システムが割り当てに適合する空きメモリを検索しないためです。さらに、ルックアサイドリストへのアクセスは、一般にミューテックスやスピンロックではなく、高速なアトミックプロセッサ交換命令を使用して同期されます。ルックアサイドリストは、システムまたはドライバーによって作成できます。これらは、ページプールまたは非ページプールから割り当てることができます。
例
次の例では、GetProcessHeap を使用して既定のプロセスヒープへのハンドルを取得し、 HeapQueryInformation を使用してヒープに関する情報を取得します。
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#define HEAP_STANDARD 0
#define HEAP_LAL 1
#define HEAP_LFH 2
int __cdecl _tmain()
{
BOOL bResult;
HANDLE hHeap;
ULONG HeapInformation;
//
// Get a handle to the default process heap.
//
hHeap = GetProcessHeap();
if (hHeap == NULL) {
_tprintf(TEXT("Failed to retrieve default process heap with LastError %d.\n"),
GetLastError());
return 1;
}
//
// Query heap features that are enabled.
//
bResult = HeapQueryInformation(hHeap,
HeapCompatibilityInformation,
&HeapInformation,
sizeof(HeapInformation),
NULL);
if (bResult == FALSE) {
_tprintf(TEXT("Failed to retrieve heap features with LastError %d.\n"),
GetLastError());
return 1;
}
//
// Print results of the query.
//
_tprintf(TEXT("HeapCompatibilityInformation is %d.\n"), HeapInformation);
switch(HeapInformation)
{
case HEAP_STANDARD:
_tprintf(TEXT("The default process heap is a standard heap.\n"));
break;
case HEAP_LAL:
_tprintf(TEXT("The default process heap supports look-aside lists.\n"));
break;
case HEAP_LFH:
_tprintf(TEXT("The default process heap has the low-fragmentation ") \
TEXT("heap enabled.\n"));
break;
default:
_tprintf(TEXT("Unrecognized HeapInformation reported for the default ") \
TEXT("process heap.\n"));
break;
}
return 0;
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL HeapQueryInformation(
HANDLE HeapHandle, // optional
HEAP_INFORMATION_CLASS HeapInformationClass,
void* HeapInformation, // optional
UINT_PTR HeapInformationLength,
UINT_PTR* ReturnLength // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool HeapQueryInformation(
IntPtr HeapHandle, // HANDLE optional
int HeapInformationClass, // HEAP_INFORMATION_CLASS
IntPtr HeapInformation, // void* optional, out
UIntPtr HeapInformationLength, // UINT_PTR
IntPtr ReturnLength // UINT_PTR* optional, out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function HeapQueryInformation(
HeapHandle As IntPtr, ' HANDLE optional
HeapInformationClass As Integer, ' HEAP_INFORMATION_CLASS
HeapInformation As IntPtr, ' void* optional, out
HeapInformationLength As UIntPtr, ' UINT_PTR
ReturnLength As IntPtr ' UINT_PTR* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' HeapHandle : HANDLE optional
' HeapInformationClass : HEAP_INFORMATION_CLASS
' HeapInformation : void* optional, out
' HeapInformationLength : UINT_PTR
' ReturnLength : UINT_PTR* optional, out
Declare PtrSafe Function HeapQueryInformation Lib "kernel32" ( _
ByVal HeapHandle As LongPtr, _
ByVal HeapInformationClass As Long, _
ByVal HeapInformation As LongPtr, _
ByVal HeapInformationLength As LongPtr, _
ByVal ReturnLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HeapQueryInformation = ctypes.windll.kernel32.HeapQueryInformation
HeapQueryInformation.restype = wintypes.BOOL
HeapQueryInformation.argtypes = [
wintypes.HANDLE, # HeapHandle : HANDLE optional
ctypes.c_int, # HeapInformationClass : HEAP_INFORMATION_CLASS
ctypes.POINTER(None), # HeapInformation : void* optional, out
ctypes.c_size_t, # HeapInformationLength : UINT_PTR
ctypes.POINTER(ctypes.c_size_t), # ReturnLength : UINT_PTR* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
HeapQueryInformation = Fiddle::Function.new(
lib['HeapQueryInformation'],
[
Fiddle::TYPE_VOIDP, # HeapHandle : HANDLE optional
Fiddle::TYPE_INT, # HeapInformationClass : HEAP_INFORMATION_CLASS
Fiddle::TYPE_VOIDP, # HeapInformation : void* optional, out
Fiddle::TYPE_UINTPTR_T, # HeapInformationLength : UINT_PTR
Fiddle::TYPE_VOIDP, # ReturnLength : UINT_PTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn HeapQueryInformation(
HeapHandle: *mut core::ffi::c_void, // HANDLE optional
HeapInformationClass: i32, // HEAP_INFORMATION_CLASS
HeapInformation: *mut (), // void* optional, out
HeapInformationLength: usize, // UINT_PTR
ReturnLength: *mut usize // UINT_PTR* optional, 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 HeapQueryInformation(IntPtr HeapHandle, int HeapInformationClass, IntPtr HeapInformation, UIntPtr HeapInformationLength, IntPtr ReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_HeapQueryInformation' -Namespace Win32 -PassThru
# $api::HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)#uselib "KERNEL32.dll"
#func global HeapQueryInformation "HeapQueryInformation" sptr, sptr, sptr, sptr, sptr
; HeapQueryInformation HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, varptr(ReturnLength) ; 戻り値は stat
; HeapHandle : HANDLE optional -> "sptr"
; HeapInformationClass : HEAP_INFORMATION_CLASS -> "sptr"
; HeapInformation : void* optional, out -> "sptr"
; HeapInformationLength : UINT_PTR -> "sptr"
; ReturnLength : UINT_PTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll" #cfunc global HeapQueryInformation "HeapQueryInformation" sptr, int, sptr, sptr, var ; res = HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength) ; HeapHandle : HANDLE optional -> "sptr" ; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int" ; HeapInformation : void* optional, out -> "sptr" ; HeapInformationLength : UINT_PTR -> "sptr" ; ReturnLength : UINT_PTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global HeapQueryInformation "HeapQueryInformation" sptr, int, sptr, sptr, sptr ; res = HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, varptr(ReturnLength)) ; HeapHandle : HANDLE optional -> "sptr" ; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int" ; HeapInformation : void* optional, out -> "sptr" ; HeapInformationLength : UINT_PTR -> "sptr" ; ReturnLength : UINT_PTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; BOOL HeapQueryInformation(HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, void* HeapInformation, UINT_PTR HeapInformationLength, UINT_PTR* ReturnLength) #uselib "KERNEL32.dll" #cfunc global HeapQueryInformation "HeapQueryInformation" intptr, int, intptr, intptr, var ; res = HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength) ; HeapHandle : HANDLE optional -> "intptr" ; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int" ; HeapInformation : void* optional, out -> "intptr" ; HeapInformationLength : UINT_PTR -> "intptr" ; ReturnLength : UINT_PTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL HeapQueryInformation(HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, void* HeapInformation, UINT_PTR HeapInformationLength, UINT_PTR* ReturnLength) #uselib "KERNEL32.dll" #cfunc global HeapQueryInformation "HeapQueryInformation" intptr, int, intptr, intptr, intptr ; res = HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, varptr(ReturnLength)) ; HeapHandle : HANDLE optional -> "intptr" ; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int" ; HeapInformation : void* optional, out -> "intptr" ; HeapInformationLength : UINT_PTR -> "intptr" ; ReturnLength : UINT_PTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procHeapQueryInformation = kernel32.NewProc("HeapQueryInformation")
)
// HeapHandle (HANDLE optional), HeapInformationClass (HEAP_INFORMATION_CLASS), HeapInformation (void* optional, out), HeapInformationLength (UINT_PTR), ReturnLength (UINT_PTR* optional, out)
r1, _, err := procHeapQueryInformation.Call(
uintptr(HeapHandle),
uintptr(HeapInformationClass),
uintptr(HeapInformation),
uintptr(HeapInformationLength),
uintptr(ReturnLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction HeapQueryInformation(
HeapHandle: THandle; // HANDLE optional
HeapInformationClass: Integer; // HEAP_INFORMATION_CLASS
HeapInformation: Pointer; // void* optional, out
HeapInformationLength: NativeUInt; // UINT_PTR
ReturnLength: Pointer // UINT_PTR* optional, out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'HeapQueryInformation';result := DllCall("KERNEL32\HeapQueryInformation"
, "Ptr", HeapHandle ; HANDLE optional
, "Int", HeapInformationClass ; HEAP_INFORMATION_CLASS
, "Ptr", HeapInformation ; void* optional, out
, "UPtr", HeapInformationLength ; UINT_PTR
, "Ptr", ReturnLength ; UINT_PTR* optional, out
, "Int") ; return: BOOL●HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength) = DLL("KERNEL32.dll", "bool HeapQueryInformation(void*, int, void*, int, void*)")
# 呼び出し: HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)
# HeapHandle : HANDLE optional -> "void*"
# HeapInformationClass : HEAP_INFORMATION_CLASS -> "int"
# HeapInformation : void* optional, out -> "void*"
# HeapInformationLength : UINT_PTR -> "int"
# ReturnLength : UINT_PTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn HeapQueryInformation(
HeapHandle: ?*anyopaque, // HANDLE optional
HeapInformationClass: i32, // HEAP_INFORMATION_CLASS
HeapInformation: ?*anyopaque, // void* optional, out
HeapInformationLength: usize, // UINT_PTR
ReturnLength: [*c]usize // UINT_PTR* optional, out
) callconv(std.os.windows.WINAPI) i32;proc HeapQueryInformation(
HeapHandle: pointer, # HANDLE optional
HeapInformationClass: int32, # HEAP_INFORMATION_CLASS
HeapInformation: pointer, # void* optional, out
HeapInformationLength: uint, # UINT_PTR
ReturnLength: ptr uint # UINT_PTR* optional, out
): int32 {.importc: "HeapQueryInformation", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int HeapQueryInformation(
void* HeapHandle, // HANDLE optional
int HeapInformationClass, // HEAP_INFORMATION_CLASS
void* HeapInformation, // void* optional, out
size_t HeapInformationLength, // UINT_PTR
size_t* ReturnLength // UINT_PTR* optional, out
);ccall((:HeapQueryInformation, "KERNEL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Ptr{Cvoid}, Csize_t, Ptr{Csize_t}),
HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)
# HeapHandle : HANDLE optional -> Ptr{Cvoid}
# HeapInformationClass : HEAP_INFORMATION_CLASS -> Int32
# HeapInformation : void* optional, out -> Ptr{Cvoid}
# HeapInformationLength : UINT_PTR -> Csize_t
# ReturnLength : UINT_PTR* optional, out -> Ptr{Csize_t}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HeapQueryInformation(
void* HeapHandle,
int32_t HeapInformationClass,
void* HeapInformation,
uintptr_t HeapInformationLength,
uintptr_t* ReturnLength);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)
-- HeapHandle : HANDLE optional
-- HeapInformationClass : HEAP_INFORMATION_CLASS
-- HeapInformation : void* optional, out
-- HeapInformationLength : UINT_PTR
-- ReturnLength : UINT_PTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const HeapQueryInformation = lib.func('__stdcall', 'HeapQueryInformation', 'int32_t', ['void *', 'int32_t', 'void *', 'uintptr_t', 'uintptr_t *']);
// HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)
// HeapHandle : HANDLE optional -> 'void *'
// HeapInformationClass : HEAP_INFORMATION_CLASS -> 'int32_t'
// HeapInformation : void* optional, out -> 'void *'
// HeapInformationLength : UINT_PTR -> 'uintptr_t'
// ReturnLength : UINT_PTR* optional, out -> 'uintptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
HeapQueryInformation: { parameters: ["pointer", "i32", "pointer", "usize", "pointer"], result: "i32" },
});
// lib.symbols.HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength)
// HeapHandle : HANDLE optional -> "pointer"
// HeapInformationClass : HEAP_INFORMATION_CLASS -> "i32"
// HeapInformation : void* optional, out -> "pointer"
// HeapInformationLength : UINT_PTR -> "usize"
// ReturnLength : UINT_PTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HeapQueryInformation(
void* HeapHandle,
int32_t HeapInformationClass,
void* HeapInformation,
size_t HeapInformationLength,
size_t* ReturnLength);
C, "KERNEL32.dll");
// $ffi->HeapQueryInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength, ReturnLength);
// HeapHandle : HANDLE optional
// HeapInformationClass : HEAP_INFORMATION_CLASS
// HeapInformation : void* optional, out
// HeapInformationLength : UINT_PTR
// ReturnLength : UINT_PTR* optional, 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 HeapQueryInformation(
Pointer HeapHandle, // HANDLE optional
int HeapInformationClass, // HEAP_INFORMATION_CLASS
Pointer HeapInformation, // void* optional, out
long HeapInformationLength, // UINT_PTR
LongByReference ReturnLength // UINT_PTR* optional, out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun HeapQueryInformation = HeapQueryInformation(
HeapHandle : Void*, # HANDLE optional
HeapInformationClass : Int32, # HEAP_INFORMATION_CLASS
HeapInformation : Void*, # void* optional, out
HeapInformationLength : LibC::SizeT, # UINT_PTR
ReturnLength : LibC::SizeT* # UINT_PTR* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HeapQueryInformationNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, UintPtr, Pointer<UintPtr>);
typedef HeapQueryInformationDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<UintPtr>);
final HeapQueryInformation = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<HeapQueryInformationNative, HeapQueryInformationDart>('HeapQueryInformation');
// HeapHandle : HANDLE optional -> Pointer<Void>
// HeapInformationClass : HEAP_INFORMATION_CLASS -> Int32
// HeapInformation : void* optional, out -> Pointer<Void>
// HeapInformationLength : UINT_PTR -> UintPtr
// ReturnLength : UINT_PTR* optional, out -> Pointer<UintPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HeapQueryInformation(
HeapHandle: THandle; // HANDLE optional
HeapInformationClass: Integer; // HEAP_INFORMATION_CLASS
HeapInformation: Pointer; // void* optional, out
HeapInformationLength: NativeUInt; // UINT_PTR
ReturnLength: Pointer // UINT_PTR* optional, out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'HeapQueryInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HeapQueryInformation"
c_HeapQueryInformation :: Ptr () -> Int32 -> Ptr () -> CUIntPtr -> Ptr CUIntPtr -> IO CInt
-- HeapHandle : HANDLE optional -> Ptr ()
-- HeapInformationClass : HEAP_INFORMATION_CLASS -> Int32
-- HeapInformation : void* optional, out -> Ptr ()
-- HeapInformationLength : UINT_PTR -> CUIntPtr
-- ReturnLength : UINT_PTR* optional, out -> Ptr CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let heapqueryinformation =
foreign "HeapQueryInformation"
((ptr void) @-> int32_t @-> (ptr void) @-> size_t @-> (ptr size_t) @-> returning int32_t)
(* HeapHandle : HANDLE optional -> (ptr void) *)
(* HeapInformationClass : HEAP_INFORMATION_CLASS -> int32_t *)
(* HeapInformation : void* optional, out -> (ptr void) *)
(* HeapInformationLength : UINT_PTR -> size_t *)
(* ReturnLength : UINT_PTR* optional, out -> (ptr size_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("HeapQueryInformation" heap-query-information :convention :stdcall) :int32
(heap-handle :pointer) ; HANDLE optional
(heap-information-class :int32) ; HEAP_INFORMATION_CLASS
(heap-information :pointer) ; void* optional, out
(heap-information-length :uint64) ; UINT_PTR
(return-length :pointer)) ; UINT_PTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HeapQueryInformation = Win32::API::More->new('KERNEL32',
'BOOL HeapQueryInformation(HANDLE HeapHandle, int HeapInformationClass, LPVOID HeapInformation, WPARAM HeapInformationLength, LPVOID ReturnLength)');
# my $ret = $HeapQueryInformation->Call($HeapHandle, $HeapInformationClass, $HeapInformation, $HeapInformationLength, $ReturnLength);
# HeapHandle : HANDLE optional -> HANDLE
# HeapInformationClass : HEAP_INFORMATION_CLASS -> int
# HeapInformation : void* optional, out -> LPVOID
# HeapInformationLength : UINT_PTR -> WPARAM
# ReturnLength : UINT_PTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f GetProcessHeap — プロセス既定のヒープハンドルを取得する。
- f HeapCreate — プライベートヒープオブジェクトを作成する。
- f HeapSetInformation — ヒープの動作に関する情報を設定する。