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

UpdateDebugInfoFile

関数
イメージのデバッグ情報ファイルを更新する。
DLLimagehlp.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL UpdateDebugInfoFile(
    LPCSTR ImageFileName,
    LPCSTR SymbolPath,
    LPSTR DebugFilePath,
    IMAGE_NT_HEADERS32* NtHeaders
);

パラメーター

名前方向
ImageFileNameLPCSTRin
SymbolPathLPCSTRin
DebugFilePathLPSTRout
NtHeadersIMAGE_NT_HEADERS32*in

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL UpdateDebugInfoFile(
    LPCSTR ImageFileName,
    LPCSTR SymbolPath,
    LPSTR DebugFilePath,
    IMAGE_NT_HEADERS32* NtHeaders
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool UpdateDebugInfoFile(
    [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*
);
<DllImport("imagehlp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function UpdateDebugInfoFile(
    <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*
) As Boolean
End Function
' ImageFileName : LPCSTR
' SymbolPath : LPCSTR
' DebugFilePath : LPSTR out
' NtHeaders : IMAGE_NT_HEADERS32*
Declare PtrSafe Function UpdateDebugInfoFile Lib "imagehlp" ( _
    ByVal ImageFileName As String, _
    ByVal SymbolPath As String, _
    ByVal DebugFilePath As String, _
    ByVal NtHeaders As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UpdateDebugInfoFile = ctypes.windll.imagehlp.UpdateDebugInfoFile
UpdateDebugInfoFile.restype = wintypes.BOOL
UpdateDebugInfoFile.argtypes = [
    wintypes.LPCSTR,  # ImageFileName : LPCSTR
    wintypes.LPCSTR,  # SymbolPath : LPCSTR
    wintypes.LPSTR,  # DebugFilePath : LPSTR out
    ctypes.c_void_p,  # NtHeaders : IMAGE_NT_HEADERS32*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
	procUpdateDebugInfoFile = imagehlp.NewProc("UpdateDebugInfoFile")
)

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