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