ホーム › System.Diagnostics.Debug › SymFindFileInPath
SymFindFileInPath
関数検索パス内から条件に一致するシンボルファイルを検索する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hprocess | HANDLE | in | もともと SymInitialize 関数に渡されたプロセスのハンドル。 | ||||||||
| SearchPathA | LPCSTR | inoptional | ファイルを検索するパスを指すANSI文字列へのポインタ。NULLで設定済みパス。 | ||||||||
| FileName | LPCSTR | in | ファイルの名前。パスを指定することもできますが、ファイル名のみが使用されます。 | ||||||||
| id | void* | inoptional | 3 つの識別パラメーターのうち 1 番目 (「解説」を参照)。 | ||||||||
| two | DWORD | in | 3 つの識別パラメーターのうち 2 番目 (「解説」を参照)。 | ||||||||
| three | DWORD | in | 3 つの識別パラメーターのうち 3 番目 (「解説」を参照)。 | ||||||||
| flags | SYM_FIND_ID_OPTION | in | id パラメーターの形式。このパラメーターには、次の値のいずれかを指定できます。
| ||||||||
| FoundFile | LPSTR | out | シンボル ファイルへの完全修飾パスを受け取るバッファーへのポインター。このバッファーは少なくとも MAX_PATH+1 文字でなければなりません。 | ||||||||
| callback | PFINDFILEINPATHCALLBACK | inoptional | SymFindFileInPathProc コールバック関数。 | ||||||||
| context | void* | inoptional | ユーザー定義の値または NULL。この値は単にコールバック関数に渡されます。このパラメーターは通常、コールバック関数に何らかのコンテキストを提供するデータ構造体へのポインターをアプリケーションが渡すために使用されます。 |
戻り値の型: BOOL
公式ドキュメント
SymFindFileInPath 関数 (dbghelp.h) は、シンボル ファイルまたは実行可能イメージを検索します。
戻り値
サーバーが有効なシンボル ファイルを見つけた場合は TRUE を返します。それ以外の場合は FALSE を返し、 GetLastError はシンボル ファイルが返されなかった理由を示す値を返します。
解説(Remarks)
識別パラメーターは次のように設定されます。
- DbgHelp が .pdb ファイルを検索している場合、id パラメーターは元のイメージの codeview デバッグ ディレクトリに格納されている PDB シグネチャを指定します。two パラメーターは PDB の age を指定します。three パラメーターは使用されず、ゼロに設定されます。
- DbgHelp が実行可能ファイルや .dbg ファイルなど、その他の種類のイメージを検索している場合、id パラメーターは元のイメージの PE ヘッダーに格納されている TimeDateStamp を指定します。two パラメーターは、同じく PE ヘッダーから抽出された SizeOfImage フィールドを指定します。three パラメーターは使用されず、ゼロに設定されます。
ディレクトリを検索する際、この関数は既定ではシンボル識別子が一致するかどうかを検証しません。一致するシンボル ファイルが確実に見つかるようにするには、SymSetOptions 関数を SYMOPT_EXACT_SYMBOLS を指定して呼び出します。
この関数を含むすべての DbgHelp 関数はシングル スレッドです。そのため、複数のスレッドからこの関数を呼び出すと、予期しない動作やメモリ破損が発生する可能性があります。これを避けるには、複数のスレッドからこの関数への同時呼び出しをすべて同期する必要があります。
この関数の Unicode バージョンを呼び出すには、DBGHELP_TRANSLATE_TCHAR を定義します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "dbghelp.dll" #cfunc global SymFindFileInPath "SymFindFileInPath" sptr, str, str, sptr, int, int, int, sptr, sptr, sptr ; res = SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, varptr(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 -> "sptr" ; callback : PFINDFILEINPATHCALLBACK optional -> "sptr" ; context : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, intptr, intptr ; res = SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, varptr(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 -> "intptr" ; callback : PFINDFILEINPATHCALLBACK optional -> "intptr" ; context : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "dbghelp" fn SymFindFileInPath(
hprocess: ?*anyopaque, // HANDLE
SearchPathA: [*c]const u8, // LPCSTR optional
FileName: [*c]const u8, // LPCSTR
id: ?*anyopaque, // void* optional
two: u32, // DWORD
three: u32, // DWORD
flags: u32, // SYM_FIND_ID_OPTION
FoundFile: [*c]u8, // LPSTR out
callback: ?*anyopaque, // PFINDFILEINPATHCALLBACK optional
context: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc SymFindFileInPath(
hprocess: pointer, # HANDLE
SearchPathA: cstring, # LPCSTR optional
FileName: cstring, # LPCSTR
id: pointer, # void* optional
two: uint32, # DWORD
three: uint32, # DWORD
flags: uint32, # SYM_FIND_ID_OPTION
FoundFile: ptr char, # LPSTR out
callback: pointer, # PFINDFILEINPATHCALLBACK optional
context: pointer # void* optional
): int32 {.importc: "SymFindFileInPath", stdcall, dynlib: "dbghelp.dll".}pragma(lib, "dbghelp");
extern(Windows)
int SymFindFileInPath(
void* hprocess, // HANDLE
const(char)* SearchPathA, // LPCSTR optional
const(char)* FileName, // LPCSTR
void* id, // void* optional
uint two, // DWORD
uint three, // DWORD
uint flags, // SYM_FIND_ID_OPTION
char* FoundFile, // LPSTR out
void* callback, // PFINDFILEINPATHCALLBACK optional
void* context // void* optional
);ccall((:SymFindFileInPath, "dbghelp.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cstring, Cstring, Ptr{Cvoid}, UInt32, UInt32, UInt32, Ptr{UInt8}, Ptr{Cvoid}, Ptr{Cvoid}),
hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
# hprocess : HANDLE -> Ptr{Cvoid}
# SearchPathA : LPCSTR optional -> Cstring
# FileName : LPCSTR -> Cstring
# id : void* optional -> Ptr{Cvoid}
# two : DWORD -> UInt32
# three : DWORD -> UInt32
# flags : SYM_FIND_ID_OPTION -> UInt32
# FoundFile : LPSTR out -> Ptr{UInt8}
# callback : PFINDFILEINPATHCALLBACK optional -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SymFindFileInPath(
void* hprocess,
const char* SearchPathA,
const char* FileName,
void* id,
uint32_t two,
uint32_t three,
uint32_t flags,
char* FoundFile,
void* callback,
void* context);
]]
local dbghelp = ffi.load("dbghelp")
-- dbghelp.SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
-- 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
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dbghelp.dll');
const SymFindFileInPath = lib.func('__stdcall', 'SymFindFileInPath', 'int32_t', ['void *', 'str', 'str', 'void *', 'uint32_t', 'uint32_t', 'uint32_t', 'char *', 'void *', 'void *']);
// SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
// hprocess : HANDLE -> 'void *'
// SearchPathA : LPCSTR optional -> 'str'
// FileName : LPCSTR -> 'str'
// id : void* optional -> 'void *'
// two : DWORD -> 'uint32_t'
// three : DWORD -> 'uint32_t'
// flags : SYM_FIND_ID_OPTION -> 'uint32_t'
// FoundFile : LPSTR out -> 'char *'
// callback : PFINDFILEINPATHCALLBACK optional -> 'void *'
// context : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("dbghelp.dll", {
SymFindFileInPath: { parameters: ["pointer", "buffer", "buffer", "pointer", "u32", "u32", "u32", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context)
// hprocess : HANDLE -> "pointer"
// SearchPathA : LPCSTR optional -> "buffer"
// FileName : LPCSTR -> "buffer"
// id : void* optional -> "pointer"
// two : DWORD -> "u32"
// three : DWORD -> "u32"
// flags : SYM_FIND_ID_OPTION -> "u32"
// FoundFile : LPSTR out -> "buffer"
// callback : PFINDFILEINPATHCALLBACK optional -> "pointer"
// context : void* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SymFindFileInPath(
void* hprocess,
const char* SearchPathA,
const char* FileName,
void* id,
uint32_t two,
uint32_t three,
uint32_t flags,
char* FoundFile,
void* callback,
void* context);
C, "dbghelp.dll");
// $ffi->SymFindFileInPath(hprocess, SearchPathA, FileName, id, two, three, flags, FoundFile, callback, context);
// 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
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Dbghelp extends StdCallLibrary {
Dbghelp INSTANCE = Native.load("dbghelp", Dbghelp.class, W32APIOptions.ASCII_OPTIONS);
boolean SymFindFileInPath(
Pointer hprocess, // HANDLE
String SearchPathA, // LPCSTR optional
String FileName, // LPCSTR
Pointer id, // void* optional
int two, // DWORD
int three, // DWORD
int flags, // SYM_FIND_ID_OPTION
byte[] FoundFile, // LPSTR out
Callback callback, // PFINDFILEINPATHCALLBACK optional
Pointer context // void* optional
);
}@[Link("dbghelp")]
lib Libdbghelp
fun SymFindFileInPath = SymFindFileInPath(
hprocess : Void*, # HANDLE
SearchPathA : UInt8*, # LPCSTR optional
FileName : UInt8*, # LPCSTR
id : Void*, # void* optional
two : UInt32, # DWORD
three : UInt32, # DWORD
flags : UInt32, # SYM_FIND_ID_OPTION
FoundFile : UInt8*, # LPSTR out
callback : Void*, # PFINDFILEINPATHCALLBACK optional
context : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SymFindFileInPathNative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Utf8>, Pointer<Void>, Pointer<Void>);
typedef SymFindFileInPathDart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Void>, int, int, int, Pointer<Utf8>, Pointer<Void>, Pointer<Void>);
final SymFindFileInPath = DynamicLibrary.open('dbghelp.dll')
.lookupFunction<SymFindFileInPathNative, SymFindFileInPathDart>('SymFindFileInPath');
// hprocess : HANDLE -> Pointer<Void>
// SearchPathA : LPCSTR optional -> Pointer<Utf8>
// FileName : LPCSTR -> Pointer<Utf8>
// id : void* optional -> Pointer<Void>
// two : DWORD -> Uint32
// three : DWORD -> Uint32
// flags : SYM_FIND_ID_OPTION -> Uint32
// FoundFile : LPSTR out -> Pointer<Utf8>
// callback : PFINDFILEINPATHCALLBACK optional -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SymFindFileInPath"
c_SymFindFileInPath :: Ptr () -> CString -> CString -> Ptr () -> Word32 -> Word32 -> Word32 -> CString -> Ptr () -> Ptr () -> IO CInt
-- hprocess : HANDLE -> Ptr ()
-- SearchPathA : LPCSTR optional -> CString
-- FileName : LPCSTR -> CString
-- id : void* optional -> Ptr ()
-- two : DWORD -> Word32
-- three : DWORD -> Word32
-- flags : SYM_FIND_ID_OPTION -> Word32
-- FoundFile : LPSTR out -> CString
-- callback : PFINDFILEINPATHCALLBACK optional -> Ptr ()
-- context : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let symfindfileinpath =
foreign "SymFindFileInPath"
((ptr void) @-> string @-> string @-> (ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> string @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hprocess : HANDLE -> (ptr void) *)
(* SearchPathA : LPCSTR optional -> string *)
(* FileName : LPCSTR -> string *)
(* id : void* optional -> (ptr void) *)
(* two : DWORD -> uint32_t *)
(* three : DWORD -> uint32_t *)
(* flags : SYM_FIND_ID_OPTION -> uint32_t *)
(* FoundFile : LPSTR out -> string *)
(* callback : PFINDFILEINPATHCALLBACK optional -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dbghelp (t "dbghelp.dll"))
(cffi:use-foreign-library dbghelp)
(cffi:defcfun ("SymFindFileInPath" sym-find-file-in-path :convention :stdcall) :int32
(hprocess :pointer) ; HANDLE
(search-path-a :string) ; LPCSTR optional
(file-name :string) ; LPCSTR
(id :pointer) ; void* optional
(two :uint32) ; DWORD
(three :uint32) ; DWORD
(flags :uint32) ; SYM_FIND_ID_OPTION
(found-file :pointer) ; LPSTR out
(callback :pointer) ; PFINDFILEINPATHCALLBACK optional
(context :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SymFindFileInPath = Win32::API::More->new('dbghelp',
'BOOL SymFindFileInPath(HANDLE hprocess, LPCSTR SearchPathA, LPCSTR FileName, LPVOID id, DWORD two, DWORD three, DWORD flags, LPSTR FoundFile, LPVOID callback, LPVOID context)');
# my $ret = $SymFindFileInPath->Call($hprocess, $SearchPathA, $FileName, $id, $two, $three, $flags, $FoundFile, $callback, $context);
# hprocess : HANDLE -> HANDLE
# SearchPathA : LPCSTR optional -> LPCSTR
# FileName : LPCSTR -> LPCSTR
# id : void* optional -> LPVOID
# two : DWORD -> DWORD
# three : DWORD -> DWORD
# flags : SYM_FIND_ID_OPTION -> DWORD
# FoundFile : LPSTR out -> LPSTR
# callback : PFINDFILEINPATHCALLBACK optional -> LPVOID
# context : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
文字セット違い
- f SymFindFileInPathW (Unicode版) — 検索パス内から条件に一致するシンボルファイルを検索する。
公式の関連項目
- f SymInitialize — プロセスのシンボルハンドラを初期化する。
- f SymSetSearchPath — シンボル検索パスを設定する。
- f SymSrvGetFileIndexInfo — ファイルのインデックス情報を取得する。