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

SymSrvStoreSupplementW

関数
シンボルサーバーに補足ファイルを格納する(Unicode版)。
DLLdbghelp.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

LPWSTR SymSrvStoreSupplementW(
    HANDLE hProcess,
    LPCWSTR SymPath,   // optional
    LPCWSTR Node,
    LPCWSTR File,
    DWORD Flags
);

パラメーター

名前方向説明
hProcessHANDLEinプロセスへのハンドル。このハンドルは、事前に SymInitialize 関数に渡されている必要があります。
SymPathLPCWSTRinoptionalシンボルストアへのパス。
NodeLPCWSTRin補足ファイルに関連付けられたシンボルファイル。
FileLPCWSTRinファイルの名前。
FlagsDWORDinこのパラメーターが SYMSTOREOPT_COMPRESS の場合、ファイルはシンボルストア内で圧縮されます。現在、これ以外にサポートされている値はありません。

戻り値の型: LPWSTR

公式ドキュメント

SymSrvStoreSupplementW (Unicode) 関数 (dbghelp.h) は、シンボルストアの指定された補足ファイルにファイルを格納します。

戻り値

関数が成功した場合、戻り値は補足ファイルの完全修飾パスです。

関数が失敗した場合、戻り値は NULL です。拡張エラー情報を取得するには、 GetLastError を呼び出してください。

解説(Remarks)

この関数の重要な用途の 1 つは、デルタファイルの格納です。詳細については、SymSrvDeltaName を参照してください。

この関数は、別の関数によって再利用される可能性のあるバッファーへのポインターを返します。そのため、返されたデータは必ず直ちに別のバッファーにコピーしてください。

シンボルサーバーは、同じ拡張子を持つ補足ファイルを共通のディレクトリに格納します。たとえば、Sup1.xml は次のディレクトリに格納されます: SymPath\supplement\Node\xml。

ストアの管理者は、ストアのルートに Supplement という名前の読み取り専用ファイルを作成することで、ユーザーが補足ファイルを書き込めないようにすることができます。あるいは、管理者が supplement ディレクトリを作成し、ACL を使用してアクセスを制御することもできます。

この関数を含むすべての DbgHelp 関数はシングルスレッドです。そのため、複数のスレッドからこの関数を呼び出すと、予期しない動作やメモリ破損が発生する可能性があります。これを回避するには、複数のスレッドからこの関数への同時呼び出しをすべて同期する必要があります。

この関数の Unicode バージョンを呼び出すには、DBGHELP_TRANSLATE_TCHAR を定義してください。

メモ

dbghelp.h ヘッダーは、SymSrvStoreSupplement を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI バージョンまたは Unicode バージョンを自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスを、エンコーディング中立でないコードと混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// dbghelp.dll  (Unicode / -W)
#include <windows.h>

LPWSTR SymSrvStoreSupplementW(
    HANDLE hProcess,
    LPCWSTR SymPath,   // optional
    LPCWSTR Node,
    LPCWSTR File,
    DWORD Flags
);
[DllImport("dbghelp.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr SymSrvStoreSupplementW(
    IntPtr hProcess,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string SymPath,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string Node,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string File,   // LPCWSTR
    uint Flags   // DWORD
);
<DllImport("dbghelp.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SymSrvStoreSupplementW(
    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
    Flags As UInteger   ' DWORD
) As IntPtr
End Function
' hProcess : HANDLE
' SymPath : LPCWSTR optional
' Node : LPCWSTR
' File : LPCWSTR
' Flags : DWORD
Declare PtrSafe Function SymSrvStoreSupplementW Lib "dbghelp" ( _
    ByVal hProcess As LongPtr, _
    ByVal SymPath As LongPtr, _
    ByVal Node As LongPtr, _
    ByVal File As LongPtr, _
    ByVal Flags As Long) 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

SymSrvStoreSupplementW = ctypes.windll.dbghelp.SymSrvStoreSupplementW
SymSrvStoreSupplementW.restype = wintypes.LPWSTR
SymSrvStoreSupplementW.argtypes = [
    wintypes.HANDLE,  # hProcess : HANDLE
    wintypes.LPCWSTR,  # SymPath : LPCWSTR optional
    wintypes.LPCWSTR,  # Node : LPCWSTR
    wintypes.LPCWSTR,  # File : LPCWSTR
    wintypes.DWORD,  # Flags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
SymSrvStoreSupplementW = Fiddle::Function.new(
  lib['SymSrvStoreSupplementW'],
  [
    Fiddle::TYPE_VOIDP,  # hProcess : HANDLE
    Fiddle::TYPE_VOIDP,  # SymPath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # Node : LPCWSTR
    Fiddle::TYPE_VOIDP,  # File : LPCWSTR
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "dbghelp")]
extern "system" {
    fn SymSrvStoreSupplementW(
        hProcess: *mut core::ffi::c_void,  // HANDLE
        SymPath: *const u16,  // LPCWSTR optional
        Node: *const u16,  // LPCWSTR
        File: *const u16,  // LPCWSTR
        Flags: u32  // DWORD
    ) -> *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 SymSrvStoreSupplementW(IntPtr hProcess, [MarshalAs(UnmanagedType.LPWStr)] string SymPath, [MarshalAs(UnmanagedType.LPWStr)] string Node, [MarshalAs(UnmanagedType.LPWStr)] string File, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_SymSrvStoreSupplementW' -Namespace Win32 -PassThru
# $api::SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
#uselib "dbghelp.dll"
#func global SymSrvStoreSupplementW "SymSrvStoreSupplementW" wptr, wptr, wptr, wptr, wptr
; SymSrvStoreSupplementW hProcess, SymPath, Node, File, Flags   ; 戻り値は stat
; hProcess : HANDLE -> "wptr"
; SymPath : LPCWSTR optional -> "wptr"
; Node : LPCWSTR -> "wptr"
; File : LPCWSTR -> "wptr"
; Flags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dbghelp.dll"
#cfunc global SymSrvStoreSupplementW "SymSrvStoreSupplementW" sptr, wstr, wstr, wstr, int
; res = SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
; hProcess : HANDLE -> "sptr"
; SymPath : LPCWSTR optional -> "wstr"
; Node : LPCWSTR -> "wstr"
; File : LPCWSTR -> "wstr"
; Flags : DWORD -> "int"
; LPWSTR SymSrvStoreSupplementW(HANDLE hProcess, LPCWSTR SymPath, LPCWSTR Node, LPCWSTR File, DWORD Flags)
#uselib "dbghelp.dll"
#cfunc global SymSrvStoreSupplementW "SymSrvStoreSupplementW" intptr, wstr, wstr, wstr, int
; res = SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
; hProcess : HANDLE -> "intptr"
; SymPath : LPCWSTR optional -> "wstr"
; Node : LPCWSTR -> "wstr"
; File : LPCWSTR -> "wstr"
; Flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procSymSrvStoreSupplementW = dbghelp.NewProc("SymSrvStoreSupplementW")
)

// hProcess (HANDLE), SymPath (LPCWSTR optional), Node (LPCWSTR), File (LPCWSTR), Flags (DWORD)
r1, _, err := procSymSrvStoreSupplementW.Call(
	uintptr(hProcess),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SymPath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Node))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(File))),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPWSTR
function SymSrvStoreSupplementW(
  hProcess: THandle;   // HANDLE
  SymPath: PWideChar;   // LPCWSTR optional
  Node: PWideChar;   // LPCWSTR
  File: PWideChar;   // LPCWSTR
  Flags: DWORD   // DWORD
): PWideChar; stdcall;
  external 'dbghelp.dll' name 'SymSrvStoreSupplementW';
result := DllCall("dbghelp\SymSrvStoreSupplementW"
    , "Ptr", hProcess   ; HANDLE
    , "WStr", SymPath   ; LPCWSTR optional
    , "WStr", Node   ; LPCWSTR
    , "WStr", File   ; LPCWSTR
    , "UInt", Flags   ; DWORD
    , "Ptr")   ; return: LPWSTR
●SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags) = DLL("dbghelp.dll", "char* SymSrvStoreSupplementW(void*, char*, char*, char*, dword)")
# 呼び出し: SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
# hProcess : HANDLE -> "void*"
# SymPath : LPCWSTR optional -> "char*"
# Node : LPCWSTR -> "char*"
# File : LPCWSTR -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "dbghelp" fn SymSrvStoreSupplementW(
    hProcess: ?*anyopaque, // HANDLE
    SymPath: [*c]const u16, // LPCWSTR optional
    Node: [*c]const u16, // LPCWSTR
    File: [*c]const u16, // LPCWSTR
    Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) [*c]const u16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc SymSrvStoreSupplementW(
    hProcess: pointer,  # HANDLE
    SymPath: WideCString,  # LPCWSTR optional
    Node: WideCString,  # LPCWSTR
    File: WideCString,  # LPCWSTR
    Flags: uint32  # DWORD
): WideCString {.importc: "SymSrvStoreSupplementW", stdcall, dynlib: "dbghelp.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "dbghelp");
extern(Windows)
const(wchar)* SymSrvStoreSupplementW(
    void* hProcess,   // HANDLE
    const(wchar)* SymPath,   // LPCWSTR optional
    const(wchar)* Node,   // LPCWSTR
    const(wchar)* File,   // LPCWSTR
    uint Flags   // DWORD
);
ccall((:SymSrvStoreSupplementW, "dbghelp.dll"), stdcall, Cwstring,
      (Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, UInt32),
      hProcess, SymPath, Node, File, Flags)
# hProcess : HANDLE -> Ptr{Cvoid}
# SymPath : LPCWSTR optional -> Cwstring
# Node : LPCWSTR -> Cwstring
# File : LPCWSTR -> Cwstring
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
const uint16_t* SymSrvStoreSupplementW(
    void* hProcess,
    const uint16_t* SymPath,
    const uint16_t* Node,
    const uint16_t* File,
    uint32_t Flags);
]]
local dbghelp = ffi.load("dbghelp")
-- dbghelp.SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
-- hProcess : HANDLE
-- SymPath : LPCWSTR optional
-- Node : LPCWSTR
-- File : LPCWSTR
-- Flags : DWORD
-- 構造体/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 SymSrvStoreSupplementW = lib.func('__stdcall', 'SymSrvStoreSupplementW', 'void *', ['void *', 'str16', 'str16', 'str16', 'uint32_t']);
// SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
// hProcess : HANDLE -> 'void *'
// SymPath : LPCWSTR optional -> 'str16'
// Node : LPCWSTR -> 'str16'
// File : LPCWSTR -> 'str16'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("dbghelp.dll", {
  SymSrvStoreSupplementW: { parameters: ["pointer", "buffer", "buffer", "buffer", "u32"], result: "pointer" },
});
// lib.symbols.SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags)
// hProcess : HANDLE -> "pointer"
// SymPath : LPCWSTR optional -> "buffer"
// Node : LPCWSTR -> "buffer"
// File : LPCWSTR -> "buffer"
// Flags : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
const uint16_t* SymSrvStoreSupplementW(
    void* hProcess,
    const uint16_t* SymPath,
    const uint16_t* Node,
    const uint16_t* File,
    uint32_t Flags);
C, "dbghelp.dll");
// $ffi->SymSrvStoreSupplementW(hProcess, SymPath, Node, File, Flags);
// hProcess : HANDLE
// SymPath : LPCWSTR optional
// Node : LPCWSTR
// File : LPCWSTR
// Flags : DWORD
// 構造体/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 SymSrvStoreSupplementW(
        Pointer hProcess,   // HANDLE
        WString SymPath,   // LPCWSTR optional
        WString Node,   // LPCWSTR
        WString File,   // LPCWSTR
        int Flags   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("dbghelp")]
lib Libdbghelp
  fun SymSrvStoreSupplementW = SymSrvStoreSupplementW(
    hProcess : Void*,   # HANDLE
    SymPath : UInt16*,   # LPCWSTR optional
    Node : UInt16*,   # LPCWSTR
    File : UInt16*,   # LPCWSTR
    Flags : UInt32   # DWORD
  ) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SymSrvStoreSupplementWNative = Pointer<Utf16> Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef SymSrvStoreSupplementWDart = Pointer<Utf16> Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final SymSrvStoreSupplementW = DynamicLibrary.open('dbghelp.dll')
    .lookupFunction<SymSrvStoreSupplementWNative, SymSrvStoreSupplementWDart>('SymSrvStoreSupplementW');
// hProcess : HANDLE -> Pointer<Void>
// SymPath : LPCWSTR optional -> Pointer<Utf16>
// Node : LPCWSTR -> Pointer<Utf16>
// File : LPCWSTR -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SymSrvStoreSupplementW(
  hProcess: THandle;   // HANDLE
  SymPath: PWideChar;   // LPCWSTR optional
  Node: PWideChar;   // LPCWSTR
  File: PWideChar;   // LPCWSTR
  Flags: DWORD   // DWORD
): PWideChar; stdcall;
  external 'dbghelp.dll' name 'SymSrvStoreSupplementW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SymSrvStoreSupplementW"
  c_SymSrvStoreSupplementW :: Ptr () -> CWString -> CWString -> CWString -> Word32 -> IO CWString
-- hProcess : HANDLE -> Ptr ()
-- SymPath : LPCWSTR optional -> CWString
-- Node : LPCWSTR -> CWString
-- File : LPCWSTR -> CWString
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let symsrvstoresupplementw =
  foreign "SymSrvStoreSupplementW"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_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) *)
(* Flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dbghelp (t "dbghelp.dll"))
(cffi:use-foreign-library dbghelp)

(cffi:defcfun ("SymSrvStoreSupplementW" sym-srv-store-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
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SymSrvStoreSupplementW = Win32::API::More->new('dbghelp',
    'LPWSTR SymSrvStoreSupplementW(HANDLE hProcess, LPCWSTR SymPath, LPCWSTR Node, LPCWSTR File, DWORD Flags)');
# my $ret = $SymSrvStoreSupplementW->Call($hProcess, $SymPath, $Node, $File, $Flags);
# hProcess : HANDLE -> HANDLE
# SymPath : LPCWSTR optional -> LPCWSTR
# Node : LPCWSTR -> LPCWSTR
# File : LPCWSTR -> LPCWSTR
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

公式の関連項目