ホーム › System.Diagnostics.Debug › SymSrvGetSupplement
SymSrvGetSupplement
関数シンボルサーバーから補足ファイルを取得する。
シグネチャ
// dbghelp.dll (ANSI / -A)
#include <windows.h>
LPSTR SymSrvGetSupplement(
HANDLE hProcess,
LPCSTR SymPath, // optional
LPCSTR Node,
LPCSTR File
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hProcess | HANDLE | in | プロセスへのハンドル。このハンドルは、事前に SymInitialize 関数に渡されている必要があります。 |
| SymPath | LPCSTR | inoptional | シンボルパス。この関数は、シンボルストアの標準構文で記述されたシンボルストアのみを使用します。その他のパスはすべて無視されます。このパラメーターが NULL の場合、関数は SymInitialize または SymSetSearchPath 関数で設定されたシンボルパスを使用します。 |
| Node | LPCSTR | in | サプリメントファイルに関連付けられたシンボルファイル。 |
| File | LPCSTR | in | ファイルの名前。 |
戻り値の型: LPSTR
公式ドキュメント
SymSrvGetSupplement 関数 (dbghelp.h) は、シンボルストアのサプリメントから指定されたファイルを取得します。
戻り値
関数が成功した場合、戻り値はサプリメントファイルの完全修飾パスです。
関数が失敗した場合、戻り値は NULL です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
サプリメントファイルの詳細については、SymSrvStoreSupplement を参照してください。
この関数は、別の関数によって再利用される可能性のあるバッファーへのポインターを返します。そのため、返されたデータは必ずすぐに別のバッファーにコピーしてください。
この関数を含むすべての 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>
LPSTR SymSrvGetSupplement(
HANDLE hProcess,
LPCSTR SymPath, // optional
LPCSTR Node,
LPCSTR File
);[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr SymSrvGetSupplement(
IntPtr hProcess, // HANDLE
[MarshalAs(UnmanagedType.LPStr)] string SymPath, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string Node, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string File // LPCSTR
);<DllImport("dbghelp.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymSrvGetSupplement(
hProcess As IntPtr, ' HANDLE
<MarshalAs(UnmanagedType.LPStr)> SymPath As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> Node As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> File As String ' LPCSTR
) As IntPtr
End Function' hProcess : HANDLE
' SymPath : LPCSTR optional
' Node : LPCSTR
' File : LPCSTR
Declare PtrSafe Function SymSrvGetSupplement Lib "dbghelp" ( _
ByVal hProcess As LongPtr, _
ByVal SymPath As String, _
ByVal Node As String, _
ByVal File As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SymSrvGetSupplement = ctypes.windll.dbghelp.SymSrvGetSupplement
SymSrvGetSupplement.restype = wintypes.LPSTR
SymSrvGetSupplement.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
wintypes.LPCSTR, # SymPath : LPCSTR optional
wintypes.LPCSTR, # Node : LPCSTR
wintypes.LPCSTR, # File : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
SymSrvGetSupplement = Fiddle::Function.new(
lib['SymSrvGetSupplement'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # SymPath : LPCSTR optional
Fiddle::TYPE_VOIDP, # Node : LPCSTR
Fiddle::TYPE_VOIDP, # File : LPCSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "dbghelp")]
extern "system" {
fn SymSrvGetSupplement(
hProcess: *mut core::ffi::c_void, // HANDLE
SymPath: *const u8, // LPCSTR optional
Node: *const u8, // LPCSTR
File: *const u8 // LPCSTR
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dbghelp.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr SymSrvGetSupplement(IntPtr hProcess, [MarshalAs(UnmanagedType.LPStr)] string SymPath, [MarshalAs(UnmanagedType.LPStr)] string Node, [MarshalAs(UnmanagedType.LPStr)] string File);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymSrvGetSupplement' -Namespace Win32 -PassThru
# $api::SymSrvGetSupplement(hProcess, SymPath, Node, File)#uselib "dbghelp.dll"
#func global SymSrvGetSupplement "SymSrvGetSupplement" sptr, sptr, sptr, sptr
; SymSrvGetSupplement hProcess, SymPath, Node, File ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; SymPath : LPCSTR optional -> "sptr"
; Node : LPCSTR -> "sptr"
; File : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "dbghelp.dll"
#cfunc global SymSrvGetSupplement "SymSrvGetSupplement" sptr, str, str, str
; res = SymSrvGetSupplement(hProcess, SymPath, Node, File)
; hProcess : HANDLE -> "sptr"
; SymPath : LPCSTR optional -> "str"
; Node : LPCSTR -> "str"
; File : LPCSTR -> "str"; LPSTR SymSrvGetSupplement(HANDLE hProcess, LPCSTR SymPath, LPCSTR Node, LPCSTR File)
#uselib "dbghelp.dll"
#cfunc global SymSrvGetSupplement "SymSrvGetSupplement" intptr, str, str, str
; res = SymSrvGetSupplement(hProcess, SymPath, Node, File)
; hProcess : HANDLE -> "intptr"
; SymPath : LPCSTR optional -> "str"
; Node : LPCSTR -> "str"
; File : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procSymSrvGetSupplement = dbghelp.NewProc("SymSrvGetSupplement")
)
// hProcess (HANDLE), SymPath (LPCSTR optional), Node (LPCSTR), File (LPCSTR)
r1, _, err := procSymSrvGetSupplement.Call(
uintptr(hProcess),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SymPath))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Node))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(File))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPSTRfunction SymSrvGetSupplement(
hProcess: THandle; // HANDLE
SymPath: PAnsiChar; // LPCSTR optional
Node: PAnsiChar; // LPCSTR
File: PAnsiChar // LPCSTR
): PAnsiChar; stdcall;
external 'dbghelp.dll' name 'SymSrvGetSupplement';result := DllCall("dbghelp\SymSrvGetSupplement"
, "Ptr", hProcess ; HANDLE
, "AStr", SymPath ; LPCSTR optional
, "AStr", Node ; LPCSTR
, "AStr", File ; LPCSTR
, "Ptr") ; return: LPSTR●SymSrvGetSupplement(hProcess, SymPath, Node, File) = DLL("dbghelp.dll", "char* SymSrvGetSupplement(void*, char*, char*, char*)")
# 呼び出し: SymSrvGetSupplement(hProcess, SymPath, Node, File)
# hProcess : HANDLE -> "void*"
# SymPath : LPCSTR optional -> "char*"
# Node : LPCSTR -> "char*"
# File : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dbghelp" fn SymSrvGetSupplement(
hProcess: ?*anyopaque, // HANDLE
SymPath: [*c]const u8, // LPCSTR optional
Node: [*c]const u8, // LPCSTR
File: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) [*c]const u8;proc SymSrvGetSupplement(
hProcess: pointer, # HANDLE
SymPath: cstring, # LPCSTR optional
Node: cstring, # LPCSTR
File: cstring # LPCSTR
): cstring {.importc: "SymSrvGetSupplement", stdcall, dynlib: "dbghelp.dll".}pragma(lib, "dbghelp");
extern(Windows)
const(char)* SymSrvGetSupplement(
void* hProcess, // HANDLE
const(char)* SymPath, // LPCSTR optional
const(char)* Node, // LPCSTR
const(char)* File // LPCSTR
);ccall((:SymSrvGetSupplement, "dbghelp.dll"), stdcall, Cstring,
(Ptr{Cvoid}, Cstring, Cstring, Cstring),
hProcess, SymPath, Node, File)
# hProcess : HANDLE -> Ptr{Cvoid}
# SymPath : LPCSTR optional -> Cstring
# Node : LPCSTR -> Cstring
# File : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
const char* SymSrvGetSupplement(
void* hProcess,
const char* SymPath,
const char* Node,
const char* File);
]]
local dbghelp = ffi.load("dbghelp")
-- dbghelp.SymSrvGetSupplement(hProcess, SymPath, Node, File)
-- hProcess : HANDLE
-- SymPath : LPCSTR optional
-- Node : LPCSTR
-- File : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dbghelp.dll');
const SymSrvGetSupplement = lib.func('__stdcall', 'SymSrvGetSupplement', 'void *', ['void *', 'str', 'str', 'str']);
// SymSrvGetSupplement(hProcess, SymPath, Node, File)
// hProcess : HANDLE -> 'void *'
// SymPath : LPCSTR optional -> 'str'
// Node : LPCSTR -> 'str'
// File : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dbghelp.dll", {
SymSrvGetSupplement: { parameters: ["pointer", "buffer", "buffer", "buffer"], result: "pointer" },
});
// lib.symbols.SymSrvGetSupplement(hProcess, SymPath, Node, File)
// hProcess : HANDLE -> "pointer"
// SymPath : LPCSTR optional -> "buffer"
// Node : LPCSTR -> "buffer"
// File : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
const char* SymSrvGetSupplement(
void* hProcess,
const char* SymPath,
const char* Node,
const char* File);
C, "dbghelp.dll");
// $ffi->SymSrvGetSupplement(hProcess, SymPath, Node, File);
// hProcess : HANDLE
// SymPath : LPCSTR optional
// Node : LPCSTR
// File : LPCSTR
// 構造体/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);
Pointer SymSrvGetSupplement(
Pointer hProcess, // HANDLE
String SymPath, // LPCSTR optional
String Node, // LPCSTR
String File // LPCSTR
);
}@[Link("dbghelp")]
lib Libdbghelp
fun SymSrvGetSupplement = SymSrvGetSupplement(
hProcess : Void*, # HANDLE
SymPath : UInt8*, # LPCSTR optional
Node : UInt8*, # LPCSTR
File : UInt8* # LPCSTR
) : UInt8*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SymSrvGetSupplementNative = Pointer<Utf8> Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef SymSrvGetSupplementDart = Pointer<Utf8> Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final SymSrvGetSupplement = DynamicLibrary.open('dbghelp.dll')
.lookupFunction<SymSrvGetSupplementNative, SymSrvGetSupplementDart>('SymSrvGetSupplement');
// hProcess : HANDLE -> Pointer<Void>
// SymPath : LPCSTR optional -> Pointer<Utf8>
// Node : LPCSTR -> Pointer<Utf8>
// File : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SymSrvGetSupplement(
hProcess: THandle; // HANDLE
SymPath: PAnsiChar; // LPCSTR optional
Node: PAnsiChar; // LPCSTR
File: PAnsiChar // LPCSTR
): PAnsiChar; stdcall;
external 'dbghelp.dll' name 'SymSrvGetSupplement';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SymSrvGetSupplement"
c_SymSrvGetSupplement :: Ptr () -> CString -> CString -> CString -> IO CString
-- hProcess : HANDLE -> Ptr ()
-- SymPath : LPCSTR optional -> CString
-- Node : LPCSTR -> CString
-- File : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let symsrvgetsupplement =
foreign "SymSrvGetSupplement"
((ptr void) @-> string @-> string @-> string @-> returning string)
(* hProcess : HANDLE -> (ptr void) *)
(* SymPath : LPCSTR optional -> string *)
(* Node : LPCSTR -> string *)
(* File : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dbghelp (t "dbghelp.dll"))
(cffi:use-foreign-library dbghelp)
(cffi:defcfun ("SymSrvGetSupplement" sym-srv-get-supplement :convention :stdcall) :string
(h-process :pointer) ; HANDLE
(sym-path :string) ; LPCSTR optional
(node :string) ; LPCSTR
(file :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SymSrvGetSupplement = Win32::API::More->new('dbghelp',
'LPSTR SymSrvGetSupplement(HANDLE hProcess, LPCSTR SymPath, LPCSTR Node, LPCSTR File)');
# my $ret = $SymSrvGetSupplement->Call($hProcess, $SymPath, $Node, $File);
# hProcess : HANDLE -> HANDLE
# SymPath : LPCSTR optional -> LPCSTR
# Node : LPCSTR -> LPCSTR
# File : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SymSrvGetSupplementW (Unicode版) — シンボルサーバーから補足ファイルを取得する(Unicode版)。
公式の関連項目
- f SymSrvStoreSupplement — シンボルサーバーに補足ファイルを格納する。