Win32 API 日本語リファレンス
ホームSystem.Memory › RtlIsZeroMemory

RtlIsZeroMemory

関数
指定バッファがすべてゼロかどうかを判定する。
DLLntdll.dll呼出規約winapi

シグネチャ

// ntdll.dll
#include <windows.h>

BOOLEAN RtlIsZeroMemory(
    void* Buffer,
    UINT_PTR Length
);

パラメーター

名前方向
Buffervoid*in
LengthUINT_PTRin

戻り値の型: BOOLEAN

各言語での呼び出し定義

// ntdll.dll
#include <windows.h>

BOOLEAN RtlIsZeroMemory(
    void* Buffer,
    UINT_PTR Length
);
[DllImport("ntdll.dll", ExactSpelling = true)]
static extern byte RtlIsZeroMemory(
    IntPtr Buffer,   // void*
    UIntPtr Length   // UINT_PTR
);
<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlIsZeroMemory(
    Buffer As IntPtr,   ' void*
    Length As UIntPtr   ' UINT_PTR
) As Byte
End Function
' Buffer : void*
' Length : UINT_PTR
Declare PtrSafe Function RtlIsZeroMemory Lib "ntdll" ( _
    ByVal Buffer As LongPtr, _
    ByVal Length As LongPtr) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlIsZeroMemory = ctypes.windll.ntdll.RtlIsZeroMemory
RtlIsZeroMemory.restype = ctypes.c_byte
RtlIsZeroMemory.argtypes = [
    ctypes.POINTER(None),  # Buffer : void*
    ctypes.c_size_t,  # Length : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ntdll.dll')
RtlIsZeroMemory = Fiddle::Function.new(
  lib['RtlIsZeroMemory'],
  [
    Fiddle::TYPE_VOIDP,  # Buffer : void*
    Fiddle::TYPE_UINTPTR_T,  # Length : UINT_PTR
  ],
  Fiddle::TYPE_CHAR)
#[link(name = "ntdll")]
extern "system" {
    fn RtlIsZeroMemory(
        Buffer: *mut (),  // void*
        Length: usize  // UINT_PTR
    ) -> u8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ntdll.dll")]
public static extern byte RtlIsZeroMemory(IntPtr Buffer, UIntPtr Length);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlIsZeroMemory' -Namespace Win32 -PassThru
# $api::RtlIsZeroMemory(Buffer, Length)
#uselib "ntdll.dll"
#func global RtlIsZeroMemory "RtlIsZeroMemory" sptr, sptr
; RtlIsZeroMemory Buffer, Length   ; 戻り値は stat
; Buffer : void* -> "sptr"
; Length : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ntdll.dll"
#cfunc global RtlIsZeroMemory "RtlIsZeroMemory" sptr, sptr
; res = RtlIsZeroMemory(Buffer, Length)
; Buffer : void* -> "sptr"
; Length : UINT_PTR -> "sptr"
; BOOLEAN RtlIsZeroMemory(void* Buffer, UINT_PTR Length)
#uselib "ntdll.dll"
#cfunc global RtlIsZeroMemory "RtlIsZeroMemory" intptr, intptr
; res = RtlIsZeroMemory(Buffer, Length)
; Buffer : void* -> "intptr"
; Length : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdll = windows.NewLazySystemDLL("ntdll.dll")
	procRtlIsZeroMemory = ntdll.NewProc("RtlIsZeroMemory")
)

// Buffer (void*), Length (UINT_PTR)
r1, _, err := procRtlIsZeroMemory.Call(
	uintptr(Buffer),
	uintptr(Length),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOLEAN
function RtlIsZeroMemory(
  Buffer: Pointer;   // void*
  Length: NativeUInt   // UINT_PTR
): ByteBool; stdcall;
  external 'ntdll.dll' name 'RtlIsZeroMemory';
result := DllCall("ntdll\RtlIsZeroMemory"
    , "Ptr", Buffer   ; void*
    , "UPtr", Length   ; UINT_PTR
    , "Char")   ; return: BOOLEAN
●RtlIsZeroMemory(Buffer, Length) = DLL("ntdll.dll", "byte RtlIsZeroMemory(void*, int)")
# 呼び出し: RtlIsZeroMemory(Buffer, Length)
# Buffer : void* -> "void*"
# Length : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。