ホーム › System.Diagnostics.Debug › SymGetSymbolFile
SymGetSymbolFile
関数イメージに対応するシンボルファイルを検索取得する。
シグネチャ
// dbghelp.dll (ANSI / -A)
#include <windows.h>
BOOL SymGetSymbolFile(
HANDLE hProcess, // optional
LPCSTR SymPath, // optional
LPCSTR ImageFile,
DWORD Type,
LPSTR SymbolFile,
UINT_PTR cSymbolFile,
LPSTR DbgFile,
UINT_PTR cDbgFile
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hProcess | HANDLE | inoptional |
| SymPath | LPCSTR | inoptional |
| ImageFile | LPCSTR | in |
| Type | DWORD | in |
| SymbolFile | LPSTR | out |
| cSymbolFile | UINT_PTR | in |
| DbgFile | LPSTR | out |
| cDbgFile | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// dbghelp.dll (ANSI / -A)
#include <windows.h>
BOOL SymGetSymbolFile(
HANDLE hProcess, // optional
LPCSTR SymPath, // optional
LPCSTR ImageFile,
DWORD Type,
LPSTR SymbolFile,
UINT_PTR cSymbolFile,
LPSTR DbgFile,
UINT_PTR cDbgFile
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SymGetSymbolFile(
IntPtr hProcess, // HANDLE optional
[MarshalAs(UnmanagedType.LPStr)] string SymPath, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string ImageFile, // LPCSTR
uint Type, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder SymbolFile, // LPSTR out
UIntPtr cSymbolFile, // UINT_PTR
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder DbgFile, // LPSTR out
UIntPtr cDbgFile // UINT_PTR
);<DllImport("dbghelp.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymGetSymbolFile(
hProcess As IntPtr, ' HANDLE optional
<MarshalAs(UnmanagedType.LPStr)> SymPath As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> ImageFile As String, ' LPCSTR
Type As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> SymbolFile As System.Text.StringBuilder, ' LPSTR out
cSymbolFile As UIntPtr, ' UINT_PTR
<MarshalAs(UnmanagedType.LPStr)> DbgFile As System.Text.StringBuilder, ' LPSTR out
cDbgFile As UIntPtr ' UINT_PTR
) As Boolean
End Function' hProcess : HANDLE optional
' SymPath : LPCSTR optional
' ImageFile : LPCSTR
' Type : DWORD
' SymbolFile : LPSTR out
' cSymbolFile : UINT_PTR
' DbgFile : LPSTR out
' cDbgFile : UINT_PTR
Declare PtrSafe Function SymGetSymbolFile Lib "dbghelp" ( _
ByVal hProcess As LongPtr, _
ByVal SymPath As String, _
ByVal ImageFile As String, _
ByVal Type As Long, _
ByVal SymbolFile As String, _
ByVal cSymbolFile As LongPtr, _
ByVal DbgFile As String, _
ByVal cDbgFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SymGetSymbolFile = ctypes.windll.dbghelp.SymGetSymbolFile
SymGetSymbolFile.restype = wintypes.BOOL
SymGetSymbolFile.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE optional
wintypes.LPCSTR, # SymPath : LPCSTR optional
wintypes.LPCSTR, # ImageFile : LPCSTR
wintypes.DWORD, # Type : DWORD
wintypes.LPSTR, # SymbolFile : LPSTR out
ctypes.c_size_t, # cSymbolFile : UINT_PTR
wintypes.LPSTR, # DbgFile : LPSTR out
ctypes.c_size_t, # cDbgFile : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
SymGetSymbolFile = Fiddle::Function.new(
lib['SymGetSymbolFile'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE optional
Fiddle::TYPE_VOIDP, # SymPath : LPCSTR optional
Fiddle::TYPE_VOIDP, # ImageFile : LPCSTR
-Fiddle::TYPE_INT, # Type : DWORD
Fiddle::TYPE_VOIDP, # SymbolFile : LPSTR out
Fiddle::TYPE_UINTPTR_T, # cSymbolFile : UINT_PTR
Fiddle::TYPE_VOIDP, # DbgFile : LPSTR out
Fiddle::TYPE_UINTPTR_T, # cDbgFile : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "dbghelp")]
extern "system" {
fn SymGetSymbolFile(
hProcess: *mut core::ffi::c_void, // HANDLE optional
SymPath: *const u8, // LPCSTR optional
ImageFile: *const u8, // LPCSTR
Type: u32, // DWORD
SymbolFile: *mut u8, // LPSTR out
cSymbolFile: usize, // UINT_PTR
DbgFile: *mut u8, // LPSTR out
cDbgFile: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool SymGetSymbolFile(IntPtr hProcess, [MarshalAs(UnmanagedType.LPStr)] string SymPath, [MarshalAs(UnmanagedType.LPStr)] string ImageFile, uint Type, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder SymbolFile, UIntPtr cSymbolFile, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder DbgFile, UIntPtr cDbgFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymGetSymbolFile' -Namespace Win32 -PassThru
# $api::SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, SymbolFile, cSymbolFile, DbgFile, cDbgFile)#uselib "dbghelp.dll"
#func global SymGetSymbolFile "SymGetSymbolFile" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SymGetSymbolFile hProcess, SymPath, ImageFile, Type, varptr(SymbolFile), cSymbolFile, varptr(DbgFile), cDbgFile ; 戻り値は stat
; hProcess : HANDLE optional -> "sptr"
; SymPath : LPCSTR optional -> "sptr"
; ImageFile : LPCSTR -> "sptr"
; Type : DWORD -> "sptr"
; SymbolFile : LPSTR out -> "sptr"
; cSymbolFile : UINT_PTR -> "sptr"
; DbgFile : LPSTR out -> "sptr"
; cDbgFile : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dbghelp.dll" #cfunc global SymGetSymbolFile "SymGetSymbolFile" sptr, str, str, int, var, sptr, var, sptr ; res = SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, SymbolFile, cSymbolFile, DbgFile, cDbgFile) ; hProcess : HANDLE optional -> "sptr" ; SymPath : LPCSTR optional -> "str" ; ImageFile : LPCSTR -> "str" ; Type : DWORD -> "int" ; SymbolFile : LPSTR out -> "var" ; cSymbolFile : UINT_PTR -> "sptr" ; DbgFile : LPSTR out -> "var" ; cDbgFile : UINT_PTR -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dbghelp.dll" #cfunc global SymGetSymbolFile "SymGetSymbolFile" sptr, str, str, int, sptr, sptr, sptr, sptr ; res = SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, varptr(SymbolFile), cSymbolFile, varptr(DbgFile), cDbgFile) ; hProcess : HANDLE optional -> "sptr" ; SymPath : LPCSTR optional -> "str" ; ImageFile : LPCSTR -> "str" ; Type : DWORD -> "int" ; SymbolFile : LPSTR out -> "sptr" ; cSymbolFile : UINT_PTR -> "sptr" ; DbgFile : LPSTR out -> "sptr" ; cDbgFile : UINT_PTR -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SymGetSymbolFile(HANDLE hProcess, LPCSTR SymPath, LPCSTR ImageFile, DWORD Type, LPSTR SymbolFile, UINT_PTR cSymbolFile, LPSTR DbgFile, UINT_PTR cDbgFile) #uselib "dbghelp.dll" #cfunc global SymGetSymbolFile "SymGetSymbolFile" intptr, str, str, int, var, intptr, var, intptr ; res = SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, SymbolFile, cSymbolFile, DbgFile, cDbgFile) ; hProcess : HANDLE optional -> "intptr" ; SymPath : LPCSTR optional -> "str" ; ImageFile : LPCSTR -> "str" ; Type : DWORD -> "int" ; SymbolFile : LPSTR out -> "var" ; cSymbolFile : UINT_PTR -> "intptr" ; DbgFile : LPSTR out -> "var" ; cDbgFile : UINT_PTR -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SymGetSymbolFile(HANDLE hProcess, LPCSTR SymPath, LPCSTR ImageFile, DWORD Type, LPSTR SymbolFile, UINT_PTR cSymbolFile, LPSTR DbgFile, UINT_PTR cDbgFile) #uselib "dbghelp.dll" #cfunc global SymGetSymbolFile "SymGetSymbolFile" intptr, str, str, int, intptr, intptr, intptr, intptr ; res = SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, varptr(SymbolFile), cSymbolFile, varptr(DbgFile), cDbgFile) ; hProcess : HANDLE optional -> "intptr" ; SymPath : LPCSTR optional -> "str" ; ImageFile : LPCSTR -> "str" ; Type : DWORD -> "int" ; SymbolFile : LPSTR out -> "intptr" ; cSymbolFile : UINT_PTR -> "intptr" ; DbgFile : LPSTR out -> "intptr" ; cDbgFile : UINT_PTR -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procSymGetSymbolFile = dbghelp.NewProc("SymGetSymbolFile")
)
// hProcess (HANDLE optional), SymPath (LPCSTR optional), ImageFile (LPCSTR), Type (DWORD), SymbolFile (LPSTR out), cSymbolFile (UINT_PTR), DbgFile (LPSTR out), cDbgFile (UINT_PTR)
r1, _, err := procSymGetSymbolFile.Call(
uintptr(hProcess),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SymPath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(ImageFile))),
uintptr(Type),
uintptr(SymbolFile),
uintptr(cSymbolFile),
uintptr(DbgFile),
uintptr(cDbgFile),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SymGetSymbolFile(
hProcess: THandle; // HANDLE optional
SymPath: PAnsiChar; // LPCSTR optional
ImageFile: PAnsiChar; // LPCSTR
Type: DWORD; // DWORD
SymbolFile: PAnsiChar; // LPSTR out
cSymbolFile: NativeUInt; // UINT_PTR
DbgFile: PAnsiChar; // LPSTR out
cDbgFile: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'dbghelp.dll' name 'SymGetSymbolFile';result := DllCall("dbghelp\SymGetSymbolFile"
, "Ptr", hProcess ; HANDLE optional
, "AStr", SymPath ; LPCSTR optional
, "AStr", ImageFile ; LPCSTR
, "UInt", Type ; DWORD
, "Ptr", SymbolFile ; LPSTR out
, "UPtr", cSymbolFile ; UINT_PTR
, "Ptr", DbgFile ; LPSTR out
, "UPtr", cDbgFile ; UINT_PTR
, "Int") ; return: BOOL●SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, SymbolFile, cSymbolFile, DbgFile, cDbgFile) = DLL("dbghelp.dll", "bool SymGetSymbolFile(void*, char*, char*, dword, char*, int, char*, int)")
# 呼び出し: SymGetSymbolFile(hProcess, SymPath, ImageFile, Type, SymbolFile, cSymbolFile, DbgFile, cDbgFile)
# hProcess : HANDLE optional -> "void*"
# SymPath : LPCSTR optional -> "char*"
# ImageFile : LPCSTR -> "char*"
# Type : DWORD -> "dword"
# SymbolFile : LPSTR out -> "char*"
# cSymbolFile : UINT_PTR -> "int"
# DbgFile : LPSTR out -> "char*"
# cDbgFile : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。