Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › UpdateDebugInfoFileEx

UpdateDebugInfoFileEx

関数
旧チェックサム検証付きでデバッグ情報ファイルを更新する拡張版である。
DLLimagehlp.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL UpdateDebugInfoFileEx(
    LPCSTR ImageFileName,
    LPCSTR SymbolPath,
    LPSTR DebugFilePath,
    IMAGE_NT_HEADERS32* NtHeaders,
    DWORD OldCheckSum
);

パラメーター

名前方向
ImageFileNameLPCSTRin
SymbolPathLPCSTRin
DebugFilePathLPSTRout
NtHeadersIMAGE_NT_HEADERS32*in
OldCheckSumDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL UpdateDebugInfoFileEx(
    LPCSTR ImageFileName,
    LPCSTR SymbolPath,
    LPSTR DebugFilePath,
    IMAGE_NT_HEADERS32* NtHeaders,
    DWORD OldCheckSum
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", ExactSpelling = true)]
static extern bool UpdateDebugInfoFileEx(
    [MarshalAs(UnmanagedType.LPStr)] string ImageFileName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string SymbolPath,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder DebugFilePath,   // LPSTR out
    IntPtr NtHeaders,   // IMAGE_NT_HEADERS32*
    uint OldCheckSum   // DWORD
);
<DllImport("imagehlp.dll", ExactSpelling:=True)>
Public Shared Function UpdateDebugInfoFileEx(
    <MarshalAs(UnmanagedType.LPStr)> ImageFileName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> SymbolPath As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> DebugFilePath As System.Text.StringBuilder,   ' LPSTR out
    NtHeaders As IntPtr,   ' IMAGE_NT_HEADERS32*
    OldCheckSum As UInteger   ' DWORD
) As Boolean
End Function
' ImageFileName : LPCSTR
' SymbolPath : LPCSTR
' DebugFilePath : LPSTR out
' NtHeaders : IMAGE_NT_HEADERS32*
' OldCheckSum : DWORD
Declare PtrSafe Function UpdateDebugInfoFileEx Lib "imagehlp" ( _
    ByVal ImageFileName As String, _
    ByVal SymbolPath As String, _
    ByVal DebugFilePath As String, _
    ByVal NtHeaders As LongPtr, _
    ByVal OldCheckSum As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UpdateDebugInfoFileEx = ctypes.windll.imagehlp.UpdateDebugInfoFileEx
UpdateDebugInfoFileEx.restype = wintypes.BOOL
UpdateDebugInfoFileEx.argtypes = [
    wintypes.LPCSTR,  # ImageFileName : LPCSTR
    wintypes.LPCSTR,  # SymbolPath : LPCSTR
    wintypes.LPSTR,  # DebugFilePath : LPSTR out
    ctypes.c_void_p,  # NtHeaders : IMAGE_NT_HEADERS32*
    wintypes.DWORD,  # OldCheckSum : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('imagehlp.dll')
UpdateDebugInfoFileEx = Fiddle::Function.new(
  lib['UpdateDebugInfoFileEx'],
  [
    Fiddle::TYPE_VOIDP,  # ImageFileName : LPCSTR
    Fiddle::TYPE_VOIDP,  # SymbolPath : LPCSTR
    Fiddle::TYPE_VOIDP,  # DebugFilePath : LPSTR out
    Fiddle::TYPE_VOIDP,  # NtHeaders : IMAGE_NT_HEADERS32*
    -Fiddle::TYPE_INT,  # OldCheckSum : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "imagehlp")]
extern "system" {
    fn UpdateDebugInfoFileEx(
        ImageFileName: *const u8,  // LPCSTR
        SymbolPath: *const u8,  // LPCSTR
        DebugFilePath: *mut u8,  // LPSTR out
        NtHeaders: *mut IMAGE_NT_HEADERS32,  // IMAGE_NT_HEADERS32*
        OldCheckSum: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll")]
public static extern bool UpdateDebugInfoFileEx([MarshalAs(UnmanagedType.LPStr)] string ImageFileName, [MarshalAs(UnmanagedType.LPStr)] string SymbolPath, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder DebugFilePath, IntPtr NtHeaders, uint OldCheckSum);
"@
$api = Add-Type -MemberDefinition $sig -Name 'imagehlp_UpdateDebugInfoFileEx' -Namespace Win32 -PassThru
# $api::UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath, NtHeaders, OldCheckSum)
#uselib "imagehlp.dll"
#func global UpdateDebugInfoFileEx "UpdateDebugInfoFileEx" sptr, sptr, sptr, sptr, sptr
; UpdateDebugInfoFileEx ImageFileName, SymbolPath, varptr(DebugFilePath), varptr(NtHeaders), OldCheckSum   ; 戻り値は stat
; ImageFileName : LPCSTR -> "sptr"
; SymbolPath : LPCSTR -> "sptr"
; DebugFilePath : LPSTR out -> "sptr"
; NtHeaders : IMAGE_NT_HEADERS32* -> "sptr"
; OldCheckSum : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "imagehlp.dll"
#cfunc global UpdateDebugInfoFileEx "UpdateDebugInfoFileEx" str, str, var, var, int
; res = UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath, NtHeaders, OldCheckSum)
; ImageFileName : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"
; DebugFilePath : LPSTR out -> "var"
; NtHeaders : IMAGE_NT_HEADERS32* -> "var"
; OldCheckSum : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL UpdateDebugInfoFileEx(LPCSTR ImageFileName, LPCSTR SymbolPath, LPSTR DebugFilePath, IMAGE_NT_HEADERS32* NtHeaders, DWORD OldCheckSum)
#uselib "imagehlp.dll"
#cfunc global UpdateDebugInfoFileEx "UpdateDebugInfoFileEx" str, str, var, var, int
; res = UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath, NtHeaders, OldCheckSum)
; ImageFileName : LPCSTR -> "str"
; SymbolPath : LPCSTR -> "str"
; DebugFilePath : LPSTR out -> "var"
; NtHeaders : IMAGE_NT_HEADERS32* -> "var"
; OldCheckSum : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
	procUpdateDebugInfoFileEx = imagehlp.NewProc("UpdateDebugInfoFileEx")
)

// ImageFileName (LPCSTR), SymbolPath (LPCSTR), DebugFilePath (LPSTR out), NtHeaders (IMAGE_NT_HEADERS32*), OldCheckSum (DWORD)
r1, _, err := procUpdateDebugInfoFileEx.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ImageFileName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SymbolPath))),
	uintptr(DebugFilePath),
	uintptr(NtHeaders),
	uintptr(OldCheckSum),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function UpdateDebugInfoFileEx(
  ImageFileName: PAnsiChar;   // LPCSTR
  SymbolPath: PAnsiChar;   // LPCSTR
  DebugFilePath: PAnsiChar;   // LPSTR out
  NtHeaders: Pointer;   // IMAGE_NT_HEADERS32*
  OldCheckSum: DWORD   // DWORD
): BOOL; stdcall;
  external 'imagehlp.dll' name 'UpdateDebugInfoFileEx';
result := DllCall("imagehlp\UpdateDebugInfoFileEx"
    , "AStr", ImageFileName   ; LPCSTR
    , "AStr", SymbolPath   ; LPCSTR
    , "Ptr", DebugFilePath   ; LPSTR out
    , "Ptr", NtHeaders   ; IMAGE_NT_HEADERS32*
    , "UInt", OldCheckSum   ; DWORD
    , "Int")   ; return: BOOL
●UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath, NtHeaders, OldCheckSum) = DLL("imagehlp.dll", "bool UpdateDebugInfoFileEx(char*, char*, char*, void*, dword)")
# 呼び出し: UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath, NtHeaders, OldCheckSum)
# ImageFileName : LPCSTR -> "char*"
# SymbolPath : LPCSTR -> "char*"
# DebugFilePath : LPSTR out -> "char*"
# NtHeaders : IMAGE_NT_HEADERS32* -> "void*"
# OldCheckSum : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。