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

SymFindFileInPath

関数
検索パス内から条件に一致するシンボルファイルを検索する。
DLLdbghelp.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり

シグネチャ

// dbghelp.dll  (ANSI / -A)
#include <windows.h>

BOOL SymFindFileInPath(
    HANDLE hprocess,
    LPCSTR SearchPathA,   // optional
    LPCSTR FileName,
    void* id,   // optional
    DWORD two,
    DWORD three,
    SYM_FIND_ID_OPTION flags,
    LPSTR FoundFile,
    PFINDFILEINPATHCALLBACK callback,   // optional
    void* context   // optional
);

パラメーター

名前方向
hprocessHANDLEin
SearchPathALPCSTRinoptional
FileNameLPCSTRin
idvoid*inoptional
twoDWORDin
threeDWORDin
flagsSYM_FIND_ID_OPTIONin
FoundFileLPSTRout
callbackPFINDFILEINPATHCALLBACKinoptional
contextvoid*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

// dbghelp.dll  (ANSI / -A)
#include <windows.h>

BOOL SymFindFileInPath(
    HANDLE hprocess,
    LPCSTR SearchPathA,   // optional
    LPCSTR FileName,
    void* id,   // optional
    DWORD two,
    DWORD three,
    SYM_FIND_ID_OPTION flags,
    LPSTR FoundFile,
    PFINDFILEINPATHCALLBACK callback,   // optional
    void* context   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SymFindFileInPath(
    IntPtr hprocess,   // HANDLE
    [MarshalAs(UnmanagedType.LPStr)] string SearchPathA,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string FileName,   // LPCSTR
    IntPtr id,   // void* optional
    uint two,   // DWORD
    uint three,   // DWORD
    uint flags,   // SYM_FIND_ID_OPTION
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder FoundFile,   // LPSTR out
    IntPtr callback,   // PFINDFILEINPATHCALLBACK optional
    IntPtr context   // void* optional
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymFindFileInPath(
    hprocess As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPStr)> SearchPathA As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> FileName As String,   ' LPCSTR
    id As IntPtr,   ' void* optional
    two As UInteger,   ' DWORD
    three As UInteger,   ' DWORD
    flags As UInteger,   ' SYM_FIND_ID_OPTION
    <MarshalAs(UnmanagedType.LPStr)> FoundFile As System.Text.StringBuilder,   ' LPSTR out
    callback As IntPtr,   ' PFINDFILEINPATHCALLBACK optional
    context As IntPtr   ' void* optional
) As Boolean
End Function
' hprocess : HANDLE
' SearchPathA : LPCSTR optional
' FileName : LPCSTR
' id : void* optional
' two : DWORD
' three : DWORD
' flags : SYM_FIND_ID_OPTION
' FoundFile : LPSTR out
' callback : PFINDFILEINPATHCALLBACK optional
' context : void* optional
Declare PtrSafe Function SymFindFileInPath Lib "dbghelp" ( _
    ByVal hprocess As LongPtr, _
    ByVal SearchPathA As String, _
    ByVal FileName As String, _
    ByVal id As LongPtr, _
    ByVal two As Long, _
    ByVal three As Long, _
    ByVal flags As Long, _
    ByVal FoundFile As String, _
    ByVal callback As LongPtr, _
    ByVal context As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SymFindFileInPath = ctypes.windll.dbghelp.SymFindFileInPath
SymFindFileInPath.restype = wintypes.BOOL
SymFindFileInPath.argtypes = [
    wintypes.HANDLE,  # hprocess : HANDLE
    wintypes.LPCSTR,  # SearchPathA : LPCSTR optional
    wintypes.LPCSTR,  # FileName : LPCSTR
    ctypes.POINTER(None),  # id : void* optional
    wintypes.DWORD,  # two : DWORD
    wintypes.DWORD,  # three : DWORD
    wintypes.DWORD,  # flags : SYM_FIND_ID_OPTION
    wintypes.LPSTR,  # FoundFile : LPSTR out
    ctypes.c_void_p,  # callback : PFINDFILEINPATHCALLBACK optional
    ctypes.POINTER(None),  # context : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymFindFileInPath = Fiddle::Function.new(
  lib['SymFindFileInPath'],
  [
    Fiddle::TYPE_VOIDP,  # hprocess : HANDLE
    Fiddle::TYPE_VOIDP,  # SearchPathA : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # FileName : LPCSTR
    Fiddle::TYPE_VOIDP,  # id : void* optional
    -Fiddle::TYPE_INT,  # two : DWORD
    -Fiddle::TYPE_INT,  # three : DWORD
    -Fiddle::TYPE_INT,  # flags : SYM_FIND_ID_OPTION
    Fiddle::TYPE_VOIDP,  # FoundFile : LPSTR out
    Fiddle::TYPE_VOIDP,  # callback : PFINDFILEINPATHCALLBACK optional
    Fiddle::TYPE_VOIDP,  # context : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "dbghelp")]
extern "system" {
    fn SymFindFileInPath(
        hprocess: *mut core::ffi::c_void,  // HANDLE
        SearchPathA: *const u8,  // LPCSTR optional
        FileName: *const u8,  // LPCSTR
        id: *mut (),  // void* optional
        two: u32,  // DWORD
        three: u32,  // DWORD
        flags: u32,  // SYM_FIND_ID_OPTION
        FoundFile: *mut u8,  // LPSTR out
        callback: *const core::ffi::c_void,  // PFINDFILEINPATHCALLBACK optional
        context: *mut ()  // void* optional
    ) -> 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 SymFindFileInPath(IntPtr hprocess, [MarshalAs(UnmanagedType.LPStr)] string SearchPathA, [MarshalAs(UnmanagedType.LPStr)] string FileName, IntPtr id, uint two, uint three, uint flags, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder FoundFile, IntPtr callback, IntPtr context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymFindFileInPath' -Namespace Win32 -PassThru
# $api::SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
#uselib "dbghelp.dll"
#func global SymFindFileInPath "SymFindFileInPath" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SymFindFileInPath hprocess, SearchPathA, FileName, id, two, three, flags, varptr(FoundFile), callback, context   ; 戻り値は stat
; hprocess : HANDLE -> "sptr"
; SearchPathA : LPCSTR optional -> "sptr"
; FileName : LPCSTR -> "sptr"
; id : void* optional -> "sptr"
; two : DWORD -> "sptr"
; three : DWORD -> "sptr"
; flags : SYM_FIND_ID_OPTION -> "sptr"
; FoundFile : LPSTR out -> "sptr"
; callback : PFINDFILEINPATHCALLBACK optional -> "sptr"
; context : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "dbghelp.dll"
#cfunc global SymFindFileInPath "SymFindFileInPath" sptr, str, str, sptr, int, int, int, var, sptr, sptr
; res = SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
; hprocess : HANDLE -> "sptr"
; SearchPathA : LPCSTR optional -> "str"
; FileName : LPCSTR -> "str"
; id : void* optional -> "sptr"
; two : DWORD -> "int"
; three : DWORD -> "int"
; flags : SYM_FIND_ID_OPTION -> "int"
; FoundFile : LPSTR out -> "var"
; callback : PFINDFILEINPATHCALLBACK optional -> "sptr"
; context : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SymFindFileInPath(HANDLE hprocess, LPCSTR SearchPathA, LPCSTR FileName, void* id, DWORD two, DWORD three, SYM_FIND_ID_OPTION flags, LPSTR FoundFile, PFINDFILEINPATHCALLBACK callback, void* context)
#uselib "dbghelp.dll"
#cfunc global SymFindFileInPath "SymFindFileInPath" intptr, str, str, intptr, int, int, int, var, intptr, intptr
; res = SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
; hprocess : HANDLE -> "intptr"
; SearchPathA : LPCSTR optional -> "str"
; FileName : LPCSTR -> "str"
; id : void* optional -> "intptr"
; two : DWORD -> "int"
; three : DWORD -> "int"
; flags : SYM_FIND_ID_OPTION -> "int"
; FoundFile : LPSTR out -> "var"
; callback : PFINDFILEINPATHCALLBACK optional -> "intptr"
; context : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymFindFileInPath = dbghelp.NewProc("SymFindFileInPath")
)

// hprocess (HANDLE), SearchPathA (LPCSTR optional), FileName (LPCSTR), id (void* optional), two (DWORD), three (DWORD), flags (SYM_FIND_ID_OPTION), FoundFile (LPSTR out), callback (PFINDFILEINPATHCALLBACK optional), context (void* optional)
r1, _, err := procSymFindFileInPath.Call(
	uintptr(hprocess),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SearchPathA))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(FileName))),
	uintptr(id),
	uintptr(two),
	uintptr(three),
	uintptr(flags),
	uintptr(FoundFile),
	uintptr(callback),
	uintptr(context),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SymFindFileInPath(
  hprocess: THandle;   // HANDLE
  SearchPathA: PAnsiChar;   // LPCSTR optional
  FileName: PAnsiChar;   // LPCSTR
  id: Pointer;   // void* optional
  two: DWORD;   // DWORD
  three: DWORD;   // DWORD
  flags: DWORD;   // SYM_FIND_ID_OPTION
  FoundFile: PAnsiChar;   // LPSTR out
  callback: Pointer;   // PFINDFILEINPATHCALLBACK optional
  context: Pointer   // void* optional
): BOOL; stdcall;
  external 'dbghelp.dll' name 'SymFindFileInPath';
result := DllCall("dbghelp\SymFindFileInPath"
    , "Ptr", hprocess   ; HANDLE
    , "AStr", SearchPathA   ; LPCSTR optional
    , "AStr", FileName   ; LPCSTR
    , "Ptr", id   ; void* optional
    , "UInt", two   ; DWORD
    , "UInt", three   ; DWORD
    , "UInt", flags   ; SYM_FIND_ID_OPTION
    , "Ptr", FoundFile   ; LPSTR out
    , "Ptr", callback   ; PFINDFILEINPATHCALLBACK optional
    , "Ptr", context   ; void* optional
    , "Int")   ; return: BOOL
●SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context) = DLL("dbghelp.dll", "bool SymFindFileInPath(void*, char*, char*, void*, dword, dword, dword, char*, void*, void*)")
# 呼び出し: SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
# hprocess : HANDLE -> "void*"
# SearchPathA : LPCSTR optional -> "char*"
# FileName : LPCSTR -> "char*"
# id : void* optional -> "void*"
# two : DWORD -> "dword"
# three : DWORD -> "dword"
# flags : SYM_FIND_ID_OPTION -> "dword"
# FoundFile : LPSTR out -> "char*"
# callback : PFINDFILEINPATHCALLBACK optional -> "void*"
# context : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。