ホーム › System.Diagnostics.Debug › MapFileAndCheckSumW
MapFileAndCheckSumW
関数ファイルをマップしチェックサムを計算する。
シグネチャ
// imagehlp.dll (Unicode / -W)
#include <windows.h>
DWORD MapFileAndCheckSumW(
LPCWSTR Filename,
DWORD* HeaderSum,
DWORD* CheckSum
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Filename | LPCWSTR | in |
| HeaderSum | DWORD* | out |
| CheckSum | DWORD* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// imagehlp.dll (Unicode / -W)
#include <windows.h>
DWORD MapFileAndCheckSumW(
LPCWSTR Filename,
DWORD* HeaderSum,
DWORD* CheckSum
);[DllImport("imagehlp.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MapFileAndCheckSumW(
[MarshalAs(UnmanagedType.LPWStr)] string Filename, // LPCWSTR
out uint HeaderSum, // DWORD* out
out uint CheckSum // DWORD* out
);<DllImport("imagehlp.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MapFileAndCheckSumW(
<MarshalAs(UnmanagedType.LPWStr)> Filename As String, ' LPCWSTR
<Out> ByRef HeaderSum As UInteger, ' DWORD* out
<Out> ByRef CheckSum As UInteger ' DWORD* out
) As UInteger
End Function' Filename : LPCWSTR
' HeaderSum : DWORD* out
' CheckSum : DWORD* out
Declare PtrSafe Function MapFileAndCheckSumW Lib "imagehlp" ( _
ByVal Filename As LongPtr, _
ByRef HeaderSum As Long, _
ByRef CheckSum As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MapFileAndCheckSumW = ctypes.windll.imagehlp.MapFileAndCheckSumW
MapFileAndCheckSumW.restype = wintypes.DWORD
MapFileAndCheckSumW.argtypes = [
wintypes.LPCWSTR, # Filename : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # HeaderSum : DWORD* out
ctypes.POINTER(wintypes.DWORD), # CheckSum : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('imagehlp.dll')
MapFileAndCheckSumW = Fiddle::Function.new(
lib['MapFileAndCheckSumW'],
[
Fiddle::TYPE_VOIDP, # Filename : LPCWSTR
Fiddle::TYPE_VOIDP, # HeaderSum : DWORD* out
Fiddle::TYPE_VOIDP, # CheckSum : DWORD* out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "imagehlp")]
extern "system" {
fn MapFileAndCheckSumW(
Filename: *const u16, // LPCWSTR
HeaderSum: *mut u32, // DWORD* out
CheckSum: *mut u32 // DWORD* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("imagehlp.dll", CharSet = CharSet.Unicode)]
public static extern uint MapFileAndCheckSumW([MarshalAs(UnmanagedType.LPWStr)] string Filename, out uint HeaderSum, out uint CheckSum);
"@
$api = Add-Type -MemberDefinition $sig -Name 'imagehlp_MapFileAndCheckSumW' -Namespace Win32 -PassThru
# $api::MapFileAndCheckSumW(Filename, HeaderSum, CheckSum)#uselib "imagehlp.dll"
#func global MapFileAndCheckSumW "MapFileAndCheckSumW" wptr, wptr, wptr
; MapFileAndCheckSumW Filename, varptr(HeaderSum), varptr(CheckSum) ; 戻り値は stat
; Filename : LPCWSTR -> "wptr"
; HeaderSum : DWORD* out -> "wptr"
; CheckSum : DWORD* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "imagehlp.dll" #cfunc global MapFileAndCheckSumW "MapFileAndCheckSumW" wstr, var, var ; res = MapFileAndCheckSumW(Filename, HeaderSum, CheckSum) ; Filename : LPCWSTR -> "wstr" ; HeaderSum : DWORD* out -> "var" ; CheckSum : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "imagehlp.dll" #cfunc global MapFileAndCheckSumW "MapFileAndCheckSumW" wstr, sptr, sptr ; res = MapFileAndCheckSumW(Filename, varptr(HeaderSum), varptr(CheckSum)) ; Filename : LPCWSTR -> "wstr" ; HeaderSum : DWORD* out -> "sptr" ; CheckSum : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MapFileAndCheckSumW(LPCWSTR Filename, DWORD* HeaderSum, DWORD* CheckSum) #uselib "imagehlp.dll" #cfunc global MapFileAndCheckSumW "MapFileAndCheckSumW" wstr, var, var ; res = MapFileAndCheckSumW(Filename, HeaderSum, CheckSum) ; Filename : LPCWSTR -> "wstr" ; HeaderSum : DWORD* out -> "var" ; CheckSum : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MapFileAndCheckSumW(LPCWSTR Filename, DWORD* HeaderSum, DWORD* CheckSum) #uselib "imagehlp.dll" #cfunc global MapFileAndCheckSumW "MapFileAndCheckSumW" wstr, intptr, intptr ; res = MapFileAndCheckSumW(Filename, varptr(HeaderSum), varptr(CheckSum)) ; Filename : LPCWSTR -> "wstr" ; HeaderSum : DWORD* out -> "intptr" ; CheckSum : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
procMapFileAndCheckSumW = imagehlp.NewProc("MapFileAndCheckSumW")
)
// Filename (LPCWSTR), HeaderSum (DWORD* out), CheckSum (DWORD* out)
r1, _, err := procMapFileAndCheckSumW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Filename))),
uintptr(HeaderSum),
uintptr(CheckSum),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MapFileAndCheckSumW(
Filename: PWideChar; // LPCWSTR
HeaderSum: Pointer; // DWORD* out
CheckSum: Pointer // DWORD* out
): DWORD; stdcall;
external 'imagehlp.dll' name 'MapFileAndCheckSumW';result := DllCall("imagehlp\MapFileAndCheckSumW"
, "WStr", Filename ; LPCWSTR
, "Ptr", HeaderSum ; DWORD* out
, "Ptr", CheckSum ; DWORD* out
, "UInt") ; return: DWORD●MapFileAndCheckSumW(Filename, HeaderSum, CheckSum) = DLL("imagehlp.dll", "dword MapFileAndCheckSumW(char*, void*, void*)")
# 呼び出し: MapFileAndCheckSumW(Filename, HeaderSum, CheckSum)
# Filename : LPCWSTR -> "char*"
# HeaderSum : DWORD* out -> "void*"
# CheckSum : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。