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

RtlCrc64

関数
バッファの64ビットCRCチェックサムを計算する。
DLLntdll.dll呼出規約winapi

シグネチャ

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

ULONGLONG RtlCrc64(
    const void* Buffer,
    UINT_PTR Size,
    ULONGLONG InitialCrc
);

パラメーター

名前方向
Buffervoid*in
SizeUINT_PTRin
InitialCrcULONGLONGin

戻り値の型: ULONGLONG

各言語での呼び出し定義

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

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

RtlCrc64 = ctypes.windll.ntdll.RtlCrc64
RtlCrc64.restype = ctypes.c_ulonglong
RtlCrc64.argtypes = [
    ctypes.POINTER(None),  # Buffer : void*
    ctypes.c_size_t,  # Size : UINT_PTR
    ctypes.c_ulonglong,  # InitialCrc : ULONGLONG
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ntdll.dll')
RtlCrc64 = Fiddle::Function.new(
  lib['RtlCrc64'],
  [
    Fiddle::TYPE_VOIDP,  # Buffer : void*
    Fiddle::TYPE_UINTPTR_T,  # Size : UINT_PTR
    -Fiddle::TYPE_LONG_LONG,  # InitialCrc : ULONGLONG
  ],
  -Fiddle::TYPE_LONG_LONG)
#[link(name = "ntdll")]
extern "system" {
    fn RtlCrc64(
        Buffer: *const (),  // void*
        Size: usize,  // UINT_PTR
        InitialCrc: u64  // ULONGLONG
    ) -> u64;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ntdll.dll")]
public static extern ulong RtlCrc64(IntPtr Buffer, UIntPtr Size, ulong InitialCrc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlCrc64' -Namespace Win32 -PassThru
# $api::RtlCrc64(Buffer, Size, InitialCrc)
#uselib "ntdll.dll"
#func global RtlCrc64 "RtlCrc64" sptr, sptr, sptr
; RtlCrc64 Buffer, Size, InitialCrc   ; 戻り値は stat
; Buffer : void* -> "sptr"
; Size : UINT_PTR -> "sptr"
; InitialCrc : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ntdll.dll"
#cfunc global RtlCrc64 "RtlCrc64" sptr, sptr, int64
; res = RtlCrc64(Buffer, Size, InitialCrc)
; Buffer : void* -> "sptr"
; Size : UINT_PTR -> "sptr"
; InitialCrc : ULONGLONG -> "int64"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; ULONGLONG RtlCrc64(void* Buffer, UINT_PTR Size, ULONGLONG InitialCrc)
#uselib "ntdll.dll"
#cfunc global RtlCrc64 "RtlCrc64" intptr, intptr, int64
; res = RtlCrc64(Buffer, Size, InitialCrc)
; Buffer : void* -> "intptr"
; Size : UINT_PTR -> "intptr"
; InitialCrc : ULONGLONG -> "int64"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdll = windows.NewLazySystemDLL("ntdll.dll")
	procRtlCrc64 = ntdll.NewProc("RtlCrc64")
)

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