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