ホーム › System.WindowsProgramming › IsBadHugeReadPtr
IsBadHugeReadPtr
関数巨大メモリ領域への読み取りアクセス可否を検査する旧式関数。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL IsBadHugeReadPtr(
const void* lp, // optional
UINT_PTR ucb
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lp | void* | inoptional |
| ucb | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL IsBadHugeReadPtr(
const void* lp, // optional
UINT_PTR ucb
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool IsBadHugeReadPtr(
IntPtr lp, // void* optional
UIntPtr ucb // UINT_PTR
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function IsBadHugeReadPtr(
lp As IntPtr, ' void* optional
ucb As UIntPtr ' UINT_PTR
) As Boolean
End Function' lp : void* optional
' ucb : UINT_PTR
Declare PtrSafe Function IsBadHugeReadPtr Lib "kernel32" ( _
ByVal lp As LongPtr, _
ByVal ucb As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsBadHugeReadPtr = ctypes.windll.kernel32.IsBadHugeReadPtr
IsBadHugeReadPtr.restype = wintypes.BOOL
IsBadHugeReadPtr.argtypes = [
ctypes.POINTER(None), # lp : void* optional
ctypes.c_size_t, # ucb : UINT_PTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
IsBadHugeReadPtr = Fiddle::Function.new(
lib['IsBadHugeReadPtr'],
[
Fiddle::TYPE_VOIDP, # lp : void* optional
Fiddle::TYPE_UINTPTR_T, # ucb : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn IsBadHugeReadPtr(
lp: *const (), // void* optional
ucb: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool IsBadHugeReadPtr(IntPtr lp, UIntPtr ucb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsBadHugeReadPtr' -Namespace Win32 -PassThru
# $api::IsBadHugeReadPtr(lp, ucb)#uselib "KERNEL32.dll"
#func global IsBadHugeReadPtr "IsBadHugeReadPtr" sptr, sptr
; IsBadHugeReadPtr lp, ucb ; 戻り値は stat
; lp : void* optional -> "sptr"
; ucb : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global IsBadHugeReadPtr "IsBadHugeReadPtr" sptr, sptr
; res = IsBadHugeReadPtr(lp, ucb)
; lp : void* optional -> "sptr"
; ucb : UINT_PTR -> "sptr"; BOOL IsBadHugeReadPtr(void* lp, UINT_PTR ucb)
#uselib "KERNEL32.dll"
#cfunc global IsBadHugeReadPtr "IsBadHugeReadPtr" intptr, intptr
; res = IsBadHugeReadPtr(lp, ucb)
; lp : void* optional -> "intptr"
; ucb : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procIsBadHugeReadPtr = kernel32.NewProc("IsBadHugeReadPtr")
)
// lp (void* optional), ucb (UINT_PTR)
r1, _, err := procIsBadHugeReadPtr.Call(
uintptr(lp),
uintptr(ucb),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsBadHugeReadPtr(
lp: Pointer; // void* optional
ucb: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'IsBadHugeReadPtr';result := DllCall("KERNEL32\IsBadHugeReadPtr"
, "Ptr", lp ; void* optional
, "UPtr", ucb ; UINT_PTR
, "Int") ; return: BOOL●IsBadHugeReadPtr(lp, ucb) = DLL("KERNEL32.dll", "bool IsBadHugeReadPtr(void*, int)")
# 呼び出し: IsBadHugeReadPtr(lp, ucb)
# lp : void* optional -> "void*"
# ucb : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。