SymSrvGetSupplementW
関数シグネチャ
// dbghelp.dll (Unicode / -W)
#include <windows.h>
LPWSTR SymSrvGetSupplementW(
HANDLE hProcess,
LPCWSTR SymPath, // optional
LPCWSTR Node,
LPCWSTR File
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hProcess | HANDLE | in | プロセスへのハンドル。このハンドルは、事前に SymInitialize 関数に渡されている必要があります。 |
| SymPath | LPCWSTR | inoptional | シンボル パス。この関数は、シンボル ストアの標準的な構文で記述されたシンボル ストアのみを使用します。その他のパスはすべて無視されます。このパラメーターが NULL の場合、関数は SymInitialize または SymSetSearchPath 関数で設定されたシンボル パスを使用します。 |
| Node | LPCWSTR | in | サプリメンタル ファイルに関連付けられたシンボル ファイル。 |
| File | LPCWSTR | in | ファイルの名前。 |
戻り値の型: LPWSTR
公式ドキュメント
SymSrvGetSupplementW (Unicode) 関数 (dbghelp.h) は、指定されたファイルをシンボル ストアのサプリメントから取得します。
戻り値
関数が成功した場合、戻り値はサプリメンタル ファイルの完全修飾パスです。
関数が失敗した場合、戻り値は NULL です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
サプリメンタル ファイルの詳細については、SymSrvStoreSupplement を参照してください。
この関数は、別の関数によって再利用される可能性のあるバッファーへのポインターを返します。そのため、返されたデータは直ちに別のバッファーにコピーしてください。
この関数を含むすべての DbgHelp 関数はシングル スレッドです。そのため、複数のスレッドからこの関数を呼び出すと、予期しない動作やメモリ破損が発生する可能性があります。これを回避するには、複数のスレッドからこの関数への同時呼び出しをすべて同期する必要があります。
この関数の Unicode バージョンを呼び出すには、DBGHELP_TRANSLATE_TCHAR を定義します。
dbghelp.h ヘッダーは、SymSrvGetSupplement を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI バージョンまたは Unicode バージョンを自動的に選択するエイリアスとして定義します。エンコーディング ニュートラルなエイリアスの使用を、エンコーディング ニュートラルではないコードと混在させると、コンパイル エラーまたは実行時エラーを引き起こす不整合が生じる可能性があります。詳細については、「Conventions for Function Prototypes」を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// dbghelp.dll (Unicode / -W)
#include <windows.h>
LPWSTR SymSrvGetSupplementW(
HANDLE hProcess,
LPCWSTR SymPath, // optional
LPCWSTR Node,
LPCWSTR File
);[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr SymSrvGetSupplementW(
IntPtr hProcess, // HANDLE
[MarshalAs(UnmanagedType.LPWStr)] string SymPath, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string Node, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string File // LPCWSTR
);<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymSrvGetSupplementW(
hProcess As IntPtr, ' HANDLE
<MarshalAs(UnmanagedType.LPWStr)> SymPath As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> Node As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> File As String ' LPCWSTR
) As IntPtr
End Function' hProcess : HANDLE
' SymPath : LPCWSTR optional
' Node : LPCWSTR
' File : LPCWSTR
Declare PtrSafe Function SymSrvGetSupplementW Lib "dbghelp" ( _
ByVal hProcess As LongPtr, _
ByVal SymPath As LongPtr, _
ByVal Node As LongPtr, _
ByVal File As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SymSrvGetSupplementW = ctypes.windll.dbghelp.SymSrvGetSupplementW
SymSrvGetSupplementW.restype = wintypes.LPWSTR
SymSrvGetSupplementW.argtypes = [
wintypes.HANDLE, # hProcess : HANDLE
wintypes.LPCWSTR, # SymPath : LPCWSTR optional
wintypes.LPCWSTR, # Node : LPCWSTR
wintypes.LPCWSTR, # File : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dbghelp.dll')
SymSrvGetSupplementW = Fiddle::Function.new(
lib['SymSrvGetSupplementW'],
[
Fiddle::TYPE_VOIDP, # hProcess : HANDLE
Fiddle::TYPE_VOIDP, # SymPath : LPCWSTR optional
Fiddle::TYPE_VOIDP, # Node : LPCWSTR
Fiddle::TYPE_VOIDP, # File : LPCWSTR
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "dbghelp")]
extern "system" {
fn SymSrvGetSupplementW(
hProcess: *mut core::ffi::c_void, // HANDLE
SymPath: *const u16, // LPCWSTR optional
Node: *const u16, // LPCWSTR
File: *const u16 // LPCWSTR
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr SymSrvGetSupplementW(IntPtr hProcess, [MarshalAs(UnmanagedType.LPWStr)] string SymPath, [MarshalAs(UnmanagedType.LPWStr)] string Node, [MarshalAs(UnmanagedType.LPWStr)] string File);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymSrvGetSupplementW' -Namespace Win32 -PassThru
# $api::SymSrvGetSupplementW(hProcess, SymPath, Node, File)#uselib "dbghelp.dll"
#func global SymSrvGetSupplementW "SymSrvGetSupplementW" wptr, wptr, wptr, wptr
; SymSrvGetSupplementW hProcess, SymPath, Node, File ; 戻り値は stat
; hProcess : HANDLE -> "wptr"
; SymPath : LPCWSTR optional -> "wptr"
; Node : LPCWSTR -> "wptr"
; File : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "dbghelp.dll"
#cfunc global SymSrvGetSupplementW "SymSrvGetSupplementW" sptr, wstr, wstr, wstr
; res = SymSrvGetSupplementW(hProcess, SymPath, Node, File)
; hProcess : HANDLE -> "sptr"
; SymPath : LPCWSTR optional -> "wstr"
; Node : LPCWSTR -> "wstr"
; File : LPCWSTR -> "wstr"; LPWSTR SymSrvGetSupplementW(HANDLE hProcess, LPCWSTR SymPath, LPCWSTR Node, LPCWSTR File)
#uselib "dbghelp.dll"
#cfunc global SymSrvGetSupplementW "SymSrvGetSupplementW" intptr, wstr, wstr, wstr
; res = SymSrvGetSupplementW(hProcess, SymPath, Node, File)
; hProcess : HANDLE -> "intptr"
; SymPath : LPCWSTR optional -> "wstr"
; Node : LPCWSTR -> "wstr"
; File : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
procSymSrvGetSupplementW = dbghelp.NewProc("SymSrvGetSupplementW")
)
// hProcess (HANDLE), SymPath (LPCWSTR optional), Node (LPCWSTR), File (LPCWSTR)
r1, _, err := procSymSrvGetSupplementW.Call(
uintptr(hProcess),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SymPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Node))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(File))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction SymSrvGetSupplementW(
hProcess: THandle; // HANDLE
SymPath: PWideChar; // LPCWSTR optional
Node: PWideChar; // LPCWSTR
File: PWideChar // LPCWSTR
): PWideChar; stdcall;
external 'dbghelp.dll' name 'SymSrvGetSupplementW';result := DllCall("dbghelp\SymSrvGetSupplementW"
, "Ptr", hProcess ; HANDLE
, "WStr", SymPath ; LPCWSTR optional
, "WStr", Node ; LPCWSTR
, "WStr", File ; LPCWSTR
, "Ptr") ; return: LPWSTR●SymSrvGetSupplementW(hProcess, SymPath, Node, File) = DLL("dbghelp.dll", "char* SymSrvGetSupplementW(void*, char*, char*, char*)")
# 呼び出し: SymSrvGetSupplementW(hProcess, SymPath, Node, File)
# hProcess : HANDLE -> "void*"
# SymPath : LPCWSTR optional -> "char*"
# Node : LPCWSTR -> "char*"
# File : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "dbghelp" fn SymSrvGetSupplementW(
hProcess: ?*anyopaque, // HANDLE
SymPath: [*c]const u16, // LPCWSTR optional
Node: [*c]const u16, // LPCWSTR
File: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) [*c]const u16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SymSrvGetSupplementW(
hProcess: pointer, # HANDLE
SymPath: WideCString, # LPCWSTR optional
Node: WideCString, # LPCWSTR
File: WideCString # LPCWSTR
): WideCString {.importc: "SymSrvGetSupplementW", stdcall, dynlib: "dbghelp.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "dbghelp");
extern(Windows)
const(wchar)* SymSrvGetSupplementW(
void* hProcess, // HANDLE
const(wchar)* SymPath, // LPCWSTR optional
const(wchar)* Node, // LPCWSTR
const(wchar)* File // LPCWSTR
);ccall((:SymSrvGetSupplementW, "dbghelp.dll"), stdcall, Cwstring,
(Ptr{Cvoid}, Cwstring, Cwstring, Cwstring),
hProcess, SymPath, Node, File)
# hProcess : HANDLE -> Ptr{Cvoid}
# SymPath : LPCWSTR optional -> Cwstring
# Node : LPCWSTR -> Cwstring
# File : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
const uint16_t* SymSrvGetSupplementW(
void* hProcess,
const uint16_t* SymPath,
const uint16_t* Node,
const uint16_t* File);
]]
local dbghelp = ffi.load("dbghelp")
-- dbghelp.SymSrvGetSupplementW(hProcess, SymPath, Node, File)
-- hProcess : HANDLE
-- SymPath : LPCWSTR optional
-- Node : LPCWSTR
-- File : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('dbghelp.dll');
const SymSrvGetSupplementW = lib.func('__stdcall', 'SymSrvGetSupplementW', 'void *', ['void *', 'str16', 'str16', 'str16']);
// SymSrvGetSupplementW(hProcess, SymPath, Node, File)
// hProcess : HANDLE -> 'void *'
// SymPath : LPCWSTR optional -> 'str16'
// Node : LPCWSTR -> 'str16'
// File : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dbghelp.dll", {
SymSrvGetSupplementW: { parameters: ["pointer", "buffer", "buffer", "buffer"], result: "pointer" },
});
// lib.symbols.SymSrvGetSupplementW(hProcess, SymPath, Node, File)
// hProcess : HANDLE -> "pointer"
// SymPath : LPCWSTR optional -> "buffer"
// Node : LPCWSTR -> "buffer"
// File : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
const uint16_t* SymSrvGetSupplementW(
void* hProcess,
const uint16_t* SymPath,
const uint16_t* Node,
const uint16_t* File);
C, "dbghelp.dll");
// $ffi->SymSrvGetSupplementW(hProcess, SymPath, Node, File);
// hProcess : HANDLE
// SymPath : LPCWSTR optional
// Node : LPCWSTR
// File : LPCWSTR
// 構造体/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.UNICODE_OPTIONS);
Pointer SymSrvGetSupplementW(
Pointer hProcess, // HANDLE
WString SymPath, // LPCWSTR optional
WString Node, // LPCWSTR
WString File // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("dbghelp")]
lib Libdbghelp
fun SymSrvGetSupplementW = SymSrvGetSupplementW(
hProcess : Void*, # HANDLE
SymPath : UInt16*, # LPCWSTR optional
Node : UInt16*, # LPCWSTR
File : UInt16* # LPCWSTR
) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SymSrvGetSupplementWNative = Pointer<Utf16> Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef SymSrvGetSupplementWDart = Pointer<Utf16> Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final SymSrvGetSupplementW = DynamicLibrary.open('dbghelp.dll')
.lookupFunction<SymSrvGetSupplementWNative, SymSrvGetSupplementWDart>('SymSrvGetSupplementW');
// hProcess : HANDLE -> Pointer<Void>
// SymPath : LPCWSTR optional -> Pointer<Utf16>
// Node : LPCWSTR -> Pointer<Utf16>
// File : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SymSrvGetSupplementW(
hProcess: THandle; // HANDLE
SymPath: PWideChar; // LPCWSTR optional
Node: PWideChar; // LPCWSTR
File: PWideChar // LPCWSTR
): PWideChar; stdcall;
external 'dbghelp.dll' name 'SymSrvGetSupplementW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SymSrvGetSupplementW"
c_SymSrvGetSupplementW :: Ptr () -> CWString -> CWString -> CWString -> IO CWString
-- hProcess : HANDLE -> Ptr ()
-- SymPath : LPCWSTR optional -> CWString
-- Node : LPCWSTR -> CWString
-- File : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let symsrvgetsupplementw =
foreign "SymSrvGetSupplementW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning (ptr uint16_t))
(* hProcess : HANDLE -> (ptr void) *)
(* SymPath : LPCWSTR optional -> (ptr uint16_t) *)
(* Node : LPCWSTR -> (ptr uint16_t) *)
(* File : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dbghelp (t "dbghelp.dll"))
(cffi:use-foreign-library dbghelp)
(cffi:defcfun ("SymSrvGetSupplementW" sym-srv-get-supplement-w :convention :stdcall) (:string :encoding :utf-16le)
(h-process :pointer) ; HANDLE
(sym-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(node (:string :encoding :utf-16le)) ; LPCWSTR
(file (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SymSrvGetSupplementW = Win32::API::More->new('dbghelp',
'LPWSTR SymSrvGetSupplementW(HANDLE hProcess, LPCWSTR SymPath, LPCWSTR Node, LPCWSTR File)');
# my $ret = $SymSrvGetSupplementW->Call($hProcess, $SymPath, $Node, $File);
# hProcess : HANDLE -> HANDLE
# SymPath : LPCWSTR optional -> LPCWSTR
# Node : LPCWSTR -> LPCWSTR
# File : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f SymSrvStoreSupplementW — シンボルサーバーに補足ファイルを格納する(Unicode版)。