ホーム › System.Memory › RtlCrc64
RtlCrc64
関数バッファの64ビットCRCチェックサムを計算する。
シグネチャ
// ntdll.dll
#include <windows.h>
ULONGLONG RtlCrc64(
const void* Buffer,
UINT_PTR Size,
ULONGLONG InitialCrc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Buffer | void* | in | CRC64を計算する対象データへのポインタ。 |
| Size | UINT_PTR | in | 計算対象データのバイト数。 |
| InitialCrc | ULONGLONG | in | 計算の初期CRC値。連結計算時に前回の結果を渡す。 |
戻り値の型: 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 // ULONGLONGfunction 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)。const std = @import("std");
extern "ntdll" fn RtlCrc64(
Buffer: ?*anyopaque, // void*
Size: usize, // UINT_PTR
InitialCrc: u64 // ULONGLONG
) callconv(std.os.windows.WINAPI) u64;proc RtlCrc64(
Buffer: pointer, # void*
Size: uint, # UINT_PTR
InitialCrc: uint64 # ULONGLONG
): uint64 {.importc: "RtlCrc64", stdcall, dynlib: "ntdll.dll".}pragma(lib, "ntdll");
extern(Windows)
ulong RtlCrc64(
void* Buffer, // void*
size_t Size, // UINT_PTR
ulong InitialCrc // ULONGLONG
);ccall((:RtlCrc64, "ntdll.dll"), stdcall, UInt64,
(Ptr{Cvoid}, Csize_t, UInt64),
Buffer, Size, InitialCrc)
# Buffer : void* -> Ptr{Cvoid}
# Size : UINT_PTR -> Csize_t
# InitialCrc : ULONGLONG -> UInt64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint64_t RtlCrc64(
void* Buffer,
uintptr_t Size,
uint64_t InitialCrc);
]]
local ntdll = ffi.load("ntdll")
-- ntdll.RtlCrc64(Buffer, Size, InitialCrc)
-- Buffer : void*
-- Size : UINT_PTR
-- InitialCrc : ULONGLONG
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ntdll.dll');
const RtlCrc64 = lib.func('__stdcall', 'RtlCrc64', 'uint64_t', ['void *', 'uintptr_t', 'uint64_t']);
// RtlCrc64(Buffer, Size, InitialCrc)
// Buffer : void* -> 'void *'
// Size : UINT_PTR -> 'uintptr_t'
// InitialCrc : ULONGLONG -> 'uint64_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ntdll.dll", {
RtlCrc64: { parameters: ["pointer", "usize", "u64"], result: "u64" },
});
// lib.symbols.RtlCrc64(Buffer, Size, InitialCrc)
// Buffer : void* -> "pointer"
// Size : UINT_PTR -> "usize"
// InitialCrc : ULONGLONG -> "u64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint64_t RtlCrc64(
void* Buffer,
size_t Size,
uint64_t InitialCrc);
C, "ntdll.dll");
// $ffi->RtlCrc64(Buffer, Size, InitialCrc);
// Buffer : void*
// Size : UINT_PTR
// InitialCrc : ULONGLONG
// 構造体/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 Ntdll extends StdCallLibrary {
Ntdll INSTANCE = Native.load("ntdll", Ntdll.class);
long RtlCrc64(
Pointer Buffer, // void*
long Size, // UINT_PTR
long InitialCrc // ULONGLONG
);
}@[Link("ntdll")]
lib Libntdll
fun RtlCrc64 = RtlCrc64(
Buffer : Void*, # void*
Size : LibC::SizeT, # UINT_PTR
InitialCrc : UInt64 # ULONGLONG
) : UInt64
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtlCrc64Native = Uint64 Function(Pointer<Void>, UintPtr, Uint64);
typedef RtlCrc64Dart = int Function(Pointer<Void>, int, int);
final RtlCrc64 = DynamicLibrary.open('ntdll.dll')
.lookupFunction<RtlCrc64Native, RtlCrc64Dart>('RtlCrc64');
// Buffer : void* -> Pointer<Void>
// Size : UINT_PTR -> UintPtr
// InitialCrc : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtlCrc64(
Buffer: Pointer; // void*
Size: NativeUInt; // UINT_PTR
InitialCrc: UInt64 // ULONGLONG
): UInt64; stdcall;
external 'ntdll.dll' name 'RtlCrc64';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtlCrc64"
c_RtlCrc64 :: Ptr () -> CUIntPtr -> Word64 -> IO Word64
-- Buffer : void* -> Ptr ()
-- Size : UINT_PTR -> CUIntPtr
-- InitialCrc : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtlcrc64 =
foreign "RtlCrc64"
((ptr void) @-> size_t @-> uint64_t @-> returning uint64_t)
(* Buffer : void* -> (ptr void) *)
(* Size : UINT_PTR -> size_t *)
(* InitialCrc : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ntdll (t "ntdll.dll"))
(cffi:use-foreign-library ntdll)
(cffi:defcfun ("RtlCrc64" rtl-crc64 :convention :stdcall) :uint64
(buffer :pointer) ; void*
(size :uint64) ; UINT_PTR
(initial-crc :uint64)) ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtlCrc64 = Win32::API::More->new('ntdll',
'UINT64 RtlCrc64(LPVOID Buffer, WPARAM Size, UINT64 InitialCrc)');
# my $ret = $RtlCrc64->Call($Buffer, $Size, $InitialCrc);
# Buffer : void* -> LPVOID
# Size : UINT_PTR -> WPARAM
# InitialCrc : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f RtlCrc32 — バッファの32ビットCRCチェックサムを計算する。