using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
/// Items from the DbgHelp.dll
public static partial class DbgHelp
{
///
///
/// An application-defined callback function used with the SymEnumSourceFileTokens function which enumerates the source server
/// version control information stored in the PDB for a module.
///
///
/// The PENUMSOURCEFILETOKENSCALLBACK type defines a pointer to this callback function. SymEnumSourceFileTokensProc is
/// a placeholder for the application-defined function name.
///
///
///
/// A pointer to an opaque data structure that contains the version control information corresponding to a particular individual
/// source file. The usage of this token is detailed below.
///
/// The size of the data in the token parameter.
///
/// If the function returns TRUE, the enumeration will continue.
/// If the function returns FALSE, the enumeration will stop.
///
///
/// An application can use this token to extract a source file from version control by calling SymGetSourceFileFromToken.
///
/// To get individual variables from the token, call SymGetSourceVarFromToken. The names of the variables differ based on the
/// scripts used to create the tokens. See Source Server for details.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-penumsourcefiletokenscallback PENUMSOURCEFILETOKENSCALLBACK
// Penumsourcefiletokenscallback; BOOL Penumsourcefiletokenscallback( PVOID token, size_t size ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PENUMSOURCEFILETOKENSCALLBACK")]
public delegate bool PENUMSOURCEFILETOKENSCALLBACK(IntPtr token, SizeT size);
///
/// An application-defined callback function used with the SymFindFileInPath function.
///
/// The PFINDFILEINPATHCALLBACK and PFINDFILEINPATHCALLBACKW types define a pointer to this callback function.
/// SymFindFileInPathProc is a placeholder for the application-defined function name.
///
///
///
///
/// The user-defined value specified in SymFindFileInPath, or NULL. This parameter is typically used by an application to
/// pass a pointer to a data structure that provides some context for the callback function.
///
///
/// Return TRUE to continue searching.
/// Return FALSE to end the search.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-pfindfileinpathcallback PFINDFILEINPATHCALLBACK
// Pfindfileinpathcallback; BOOL Pfindfileinpathcallback( PCSTR filename, PVOID context ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PFINDFILEINPATHCALLBACK")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PFINDFILEINPATHCALLBACK([MarshalAs(UnmanagedType.LPTStr)] string filename, [In, Optional] IntPtr context);
///
/// An application-defined callback function used with the SymEnumSymbols, SymEnumTypes, and SymEnumTypesByName functions.
///
/// The PSYM_ENUMERATESYMBOLS_CALLBACK and PSYM_ENUMERATESYMBOLS_CALLBACKW types define a pointer to this callback
/// function. SymEnumSymbolsProc is a placeholder for the application-defined function name.
///
///
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol.
///
/// The size of the symbol, in bytes. The size is calculated and is actually a guess. In some cases, this value can be zero.
///
///
/// The user-defined value passed from the SymEnumSymbols or SymEnumTypes function, or NULL. This parameter is typically used
/// by an application to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function returns TRUE, the enumeration will continue.
/// If the function returns FALSE, the enumeration will stop.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psym_enumeratesymbols_callback
// PSYM_ENUMERATESYMBOLS_CALLBACK PsymEnumeratesymbolsCallback; BOOL PsymEnumeratesymbolsCallback( PSYMBOL_INFO pSymInfo, ULONG
// SymbolSize, PVOID UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYM_ENUMERATESYMBOLS_CALLBACK")]
public delegate bool PSYM_ENUMERATESYMBOLS_CALLBACK([In] IntPtr pSymInfo, uint SymbolSize, [In, Optional] IntPtr UserContext);
///
/// An application-defined callback function used with the SymEnumLines and SymEnumSourceLines functions.
///
/// The PSYM_ENUMLINES_CALLBACK and PSYM_ENUMLINES_CALLBACKW types define a pointer to this callback function.
/// SymEnumLinesProc is a placeholder for the application-defined function name.
///
///
/// A pointer to a SRCCODEINFO structure that provides information about the line.
///
/// The user-defined value passed from the SymEnumLines function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function returns TRUE, the enumeration will continue.
/// If the function returns FALSE, the enumeration will stop.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psym_enumlines_callback PSYM_ENUMLINES_CALLBACK
// PsymEnumlinesCallback; BOOL PsymEnumlinesCallback( PSRCCODEINFO LineInfo, PVOID UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYM_ENUMLINES_CALLBACK")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PSYM_ENUMLINES_CALLBACK(in SRCCODEINFO LineInfo, [In, Optional] IntPtr UserContext);
///
/// An application-defined function used with the SymEnumProcesses function.
///
/// The PSYM_ENUMPROCESSES_CALLBACK type defines a pointer to this callback function. SymEnumProcessesProc is a
/// placeholder for the application-defined function name.
///
///
/// A handle to the process.
///
/// The user-defined value passed from the SymEnumProcesses function, or NULL. This parameter is typically used by an
/// application to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function returns TRUE, the enumeration will continue.
/// If the function returns FALSE, the enumeration will stop.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psym_enumprocesses_callback PSYM_ENUMPROCESSES_CALLBACK
// PsymEnumprocessesCallback; BOOL PsymEnumprocessesCallback( HANDLE hProcess, PVOID UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYM_ENUMPROCESSES_CALLBACK")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PSYM_ENUMPROCESSES_CALLBACK(HPROCESS hProcess, [In, Optional] IntPtr UserContext);
///
/// An application-defined callback function used with the SymEnumSourceFiles function.
///
/// The PSYM_ENUMSOURCEFILES_CALLBACK and PSYM_ENUMSOURCEFILES_CALLBACKW types define a pointer to this callback
/// function. SymEnumSourceFilesProc is a placeholder for the application-defined function name.
///
///
/// A pointer to a SOURCEFILE structure that provides information about the source file.
///
/// The user-defined value passed from the SymEnumSourceFiles function, or NULL. This parameter is typically used by an
/// application to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function returns TRUE, the enumeration will continue.
/// If the function returns FALSE, the enumeration will stop.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psym_enumsourcefiles_callback PSYM_ENUMSOURCEFILES_CALLBACK
// PsymEnumsourcefilesCallback; BOOL PsymEnumsourcefilesCallback( PSOURCEFILE pSourceFile, PVOID UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYM_ENUMSOURCEFILES_CALLBACK")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PSYM_ENUMSOURCEFILES_CALLBACK(in SOURCEFILE pSourceFile, [In, Optional] IntPtr UserContext);
///
///
/// An application-defined callback function used with the SymRegisterFunctionEntryCallback64 function. It is called by the stack
/// walking procedure.
///
///
/// The PSYMBOL_FUNCENTRY_CALLBACK64 type defines a pointer to this callback function.
/// SymRegisterFunctionEntryCallbackProc64 is a placeholder for the application-defined function name.
///
///
/// A handle to the process that was originally passed to the StackWalk64 function.
/// The address of an instruction for which the callback function should return a function table entry.
///
/// The user-defined value specified in SymRegisterFunctionEntryCallback64, or NULL. Typically, this parameter is used by an
/// application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// Return the value NULL if no function table entry is available.
///
/// On success, return a pointer to an IMAGE_RUNTIME_FUNCTION_ENTRY structure. Refer to the header file WinNT.h for the
/// definition of this function.
///
///
///
///
/// The structure must be returned in exactly the form it exists in the process being debugged. Some members may be pointers to
/// other locations in the process address space. The ReadProcessMemoryProc64 callback function may be called to retrieve the
/// information at these locations.
///
///
/// The calling application gets called through the registered callback function as a result of a call to the StackWalk64 function.
/// The calling application must be prepared for the possible side effects that this can cause. If the application has only one
/// callback function that is being used by multiple threads, then it may be necessary to synchronize some types of data access
/// while in the context of the callback function.
///
///
/// This function is similar to the FunctionTableAccessProc64 callback function. The difference is that
/// FunctionTableAccessProc64 returns an IMAGE_FUNCTION_ENTRY structure, while this function returns an
/// IMAGE_RUNTIME_FUNCTION_ENTRY structure.
///
///
/// This callback function supersedes the PSYMBOL_FUNCENTRY_CALLBACK callback function. PSYMBOL_FUNCENTRY_CALLBACK is defined as
/// follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64 #endif typedef PVOID (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)( __in HANDLE hProcess, __in DWORD AddrBase, __in_opt PVOID UserContext );
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psymbol_funcentry_callback PSYMBOL_FUNCENTRY_CALLBACK
// PsymbolFuncentryCallback; PVOID PsymbolFuncentryCallback( HANDLE hProcess, DWORD AddrBase, PVOID UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYMBOL_FUNCENTRY_CALLBACK")]
public delegate IntPtr PSYMBOL_FUNCENTRY_CALLBACK(HPROCESS hProcess, uint AddrBase, IntPtr UserContext);
///
///
/// An application-defined callback function used with the SymRegisterFunctionEntryCallback64 function. It is called by the stack
/// walking procedure.
///
///
/// The PSYMBOL_FUNCENTRY_CALLBACK64 type defines a pointer to this callback function.
/// SymRegisterFunctionEntryCallbackProc64 is a placeholder for the application-defined function name.
///
///
/// A handle to the process that was originally passed to the StackWalk64 function.
/// The address of an instruction for which the callback function should return a function table entry.
///
/// The user-defined value specified in SymRegisterFunctionEntryCallback64, or NULL. Typically, this parameter is used by an
/// application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// Return the value NULL if no function table entry is available.
///
/// On success, return a pointer to an IMAGE_RUNTIME_FUNCTION_ENTRY structure. Refer to the header file WinNT.h for the
/// definition of this function.
///
///
///
///
/// The structure must be returned in exactly the form it exists in the process being debugged. Some members may be pointers to
/// other locations in the process address space. The ReadProcessMemoryProc64 callback function may be called to retrieve the
/// information at these locations.
///
///
/// The calling application gets called through the registered callback function as a result of a call to the StackWalk64 function.
/// The calling application must be prepared for the possible side effects that this can cause. If the application has only one
/// callback function that is being used by multiple threads, then it may be necessary to synchronize some types of data access
/// while in the context of the callback function.
///
///
/// This function is similar to the FunctionTableAccessProc64 callback function. The difference is that
/// FunctionTableAccessProc64 returns an IMAGE_FUNCTION_ENTRY structure, while this function returns an
/// IMAGE_RUNTIME_FUNCTION_ENTRY structure.
///
///
/// This callback function supersedes the PSYMBOL_FUNCENTRY_CALLBACK callback function. PSYMBOL_FUNCENTRY_CALLBACK is defined as
/// follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64 #endif typedef PVOID (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)( __in HANDLE hProcess, __in DWORD AddrBase, __in_opt PVOID UserContext );
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psymbol_funcentry_callback64 PSYMBOL_FUNCENTRY_CALLBACK64
// PsymbolFuncentryCallback64; PVOID PsymbolFuncentryCallback64( HANDLE hProcess, ULONG64 AddrBase, ULONG64 UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYMBOL_FUNCENTRY_CALLBACK64")]
public delegate IntPtr PSYMBOL_FUNCENTRY_CALLBACK64(HPROCESS hProcess, ulong AddrBase, ulong UserContext);
///
/// An application-defined callback function used with the SymRegisterCallback64 function. It is called by the symbol handler.
///
/// The PSYMBOL_REGISTERED_CALLBACK64 type defines a pointer to this callback function. SymRegisterCallbackProc64 is a
/// placeholder for the application-defined function name.
///
///
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The callback code. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// CBA_DEBUG_INFO 0x10000000
/// Display verbose information. The CallbackData parameter is a pointer to a string.
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
///
/// Deferred symbol loading has started. To cancel the symbol load, return TRUE. The CallbackData parameter is a pointer to a
/// IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
/// Deferred symbol load has completed. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
///
/// Deferred symbol load has failed. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The
/// symbol handler will attempt to load the symbols again if the callback function sets the FileName member of this structure.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020
///
/// Deferred symbol load has partially completed. The symbol loader is unable to read the image header from either the image file or
/// the specified module. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The symbol handler
/// will attempt to load the symbols again if the callback function sets the FileName member of this structure. DbgHelp 5.1: This
/// value is not supported.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
/// Deferred symbol load has started. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
/// -
/// CBA_DUPLICATE_SYMBOL 0x00000005
///
/// Duplicate symbols were found. This reason is used only in COFF or CodeView format. The CallbackData parameter is a pointer to a
/// IMAGEHLP_DUPLICATE_SYMBOL64 structure. To specify which symbol to use, set the SelectedSymbol member of this structure.
///
///
/// -
/// CBA_EVENT 0x00000010
///
/// Display verbose information. If you do not handle this event, the information is resent through the CBA_DEBUG_INFO event. The
/// CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure.
///
///
/// -
/// CBA_READ_MEMORY 0x00000006
///
/// The loaded image has been read. The CallbackData parameter is a pointer to a IMAGEHLP_CBA_READ_MEMORY structure. The callback
/// function should read the number of bytes specified by the bytes member into the buffer specified by the buf member, and update
/// the bytesread member accordingly.
///
///
/// -
/// CBA_SET_OPTIONS 0x00000008
///
/// Symbol options have been updated. To retrieve the current options, call the SymGetOptions function. The CallbackData parameter
/// should be ignored.
///
///
/// -
/// CBA_SRCSRV_EVENT 0x40000000
///
/// Display verbose information for source server. If you do not handle this event, the information is resent through the
/// CBA_DEBUG_INFO event. The CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure. DbgHelp 6.6 and earlier: This
/// value is not supported.
///
///
/// -
/// CBA_SRCSRV_INFO 0x20000000
///
/// Display verbose information for source server. The CallbackData parameter is a pointer to a string. DbgHelp 6.6 and earlier:
/// This value is not supported.
///
///
/// -
/// CBA_SYMBOLS_UNLOADED 0x00000004
/// Symbols have been unloaded. The CallbackData parameter should be ignored.
///
///
///
///
/// Data for the operation. The format of this data depends on the value of the ActionCode parameter.
///
/// If the callback function was registered with SymRegisterCallbackW64, the data is a Unicode string or data structure. Otherwise,
/// the data uses ANSI format.
///
///
///
/// User-defined value specified in SymRegisterCallback64, or NULL. Typically, this parameter is used by an application to
/// pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// To indicate success handling the code, return TRUE.
///
/// To indicate failure handling the code, return FALSE. If your code does not handle a particular code, you should also
/// return FALSE. (Returning TRUE in this case may have unintended consequences.)
///
///
///
///
/// The calling application gets called through the registered callback function as a result of another call to one of the symbol
/// handler functions. The calling application must be prepared for the possible side effects that this can cause. If the
/// application has only one callback function that is being used by multiple threads, then care may be necessary to synchronize
/// some types of data access while in the context of the callback function.
///
///
/// This callback function supersedes the PSYMBOL_REGISTERED_CALLBACK callback function. PSYMBOL_REGISTERED_CALLBACK is defined as
/// follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64 #else typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)( __in HANDLE hProcess, __in ULONG ActionCode, __in_opt PVOID CallbackData, __in_opt PVOID UserContext ); #endif
///
/// For a more extensive example, read Getting Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psymbol_registered_callback PSYMBOL_REGISTERED_CALLBACK
// PsymbolRegisteredCallback; BOOL PsymbolRegisteredCallback( HANDLE hProcess, ULONG ActionCode, PVOID CallbackData, PVOID
// UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYMBOL_REGISTERED_CALLBACK")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PSYMBOL_REGISTERED_CALLBACK(HPROCESS hProcess, CBA ActionCode, IntPtr CallbackData, IntPtr UserContext);
///
/// An application-defined callback function used with the SymRegisterCallback64 function. It is called by the symbol handler.
///
/// The PSYMBOL_REGISTERED_CALLBACK64 type defines a pointer to this callback function. SymRegisterCallbackProc64 is a
/// placeholder for the application-defined function name.
///
///
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The callback code. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// CBA_DEBUG_INFO 0x10000000
/// Display verbose information. The CallbackData parameter is a pointer to a string.
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
///
/// Deferred symbol loading has started. To cancel the symbol load, return TRUE. The CallbackData parameter is a pointer to a
/// IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
/// Deferred symbol load has completed. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
///
/// Deferred symbol load has failed. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The
/// symbol handler will attempt to load the symbols again if the callback function sets the FileName member of this structure.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020
///
/// Deferred symbol load has partially completed. The symbol loader is unable to read the image header from either the image file or
/// the specified module. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The symbol handler
/// will attempt to load the symbols again if the callback function sets the FileName member of this structure. DbgHelp 5.1: This
/// value is not supported.
///
///
/// -
/// CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
/// Deferred symbol load has started. The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
/// -
/// CBA_DUPLICATE_SYMBOL 0x00000005
///
/// Duplicate symbols were found. This reason is used only in COFF or CodeView format. The CallbackData parameter is a pointer to a
/// IMAGEHLP_DUPLICATE_SYMBOL64 structure. To specify which symbol to use, set the SelectedSymbol member of this structure.
///
///
/// -
/// CBA_EVENT 0x00000010
///
/// Display verbose information. If you do not handle this event, the information is resent through the CBA_DEBUG_INFO event. The
/// CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure.
///
///
/// -
/// CBA_READ_MEMORY 0x00000006
///
/// The loaded image has been read. The CallbackData parameter is a pointer to a IMAGEHLP_CBA_READ_MEMORY structure. The callback
/// function should read the number of bytes specified by the bytes member into the buffer specified by the buf member, and update
/// the bytesread member accordingly.
///
///
/// -
/// CBA_SET_OPTIONS 0x00000008
///
/// Symbol options have been updated. To retrieve the current options, call the SymGetOptions function. The CallbackData parameter
/// should be ignored.
///
///
/// -
/// CBA_SRCSRV_EVENT 0x40000000
///
/// Display verbose information for source server. If you do not handle this event, the information is resent through the
/// CBA_DEBUG_INFO event. The CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure. DbgHelp 6.6 and earlier: This
/// value is not supported.
///
///
/// -
/// CBA_SRCSRV_INFO 0x20000000
///
/// Display verbose information for source server. The CallbackData parameter is a pointer to a string. DbgHelp 6.6 and earlier:
/// This value is not supported.
///
///
/// -
/// CBA_SYMBOLS_UNLOADED 0x00000004
/// Symbols have been unloaded. The CallbackData parameter should be ignored.
///
///
///
///
/// Data for the operation. The format of this data depends on the value of the ActionCode parameter.
///
/// If the callback function was registered with SymRegisterCallbackW64, the data is a Unicode string or data structure. Otherwise,
/// the data uses ANSI format.
///
///
///
/// User-defined value specified in SymRegisterCallback64, or NULL. Typically, this parameter is used by an application to
/// pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// To indicate success handling the code, return TRUE.
///
/// To indicate failure handling the code, return FALSE. If your code does not handle a particular code, you should also
/// return FALSE. (Returning TRUE in this case may have unintended consequences.)
///
///
///
///
/// The calling application gets called through the registered callback function as a result of another call to one of the symbol
/// handler functions. The calling application must be prepared for the possible side effects that this can cause. If the
/// application has only one callback function that is being used by multiple threads, then care may be necessary to synchronize
/// some types of data access while in the context of the callback function.
///
///
/// This callback function supersedes the PSYMBOL_REGISTERED_CALLBACK callback function. PSYMBOL_REGISTERED_CALLBACK is defined as
/// follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64 #else typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)( __in HANDLE hProcess, __in ULONG ActionCode, __in_opt PVOID CallbackData, __in_opt PVOID UserContext ); #endif
///
/// For a more extensive example, read Getting Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nc-dbghelp-psymbol_registered_callback64 PSYMBOL_REGISTERED_CALLBACK64
// PsymbolRegisteredCallback64; BOOL PsymbolRegisteredCallback64( HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64
// UserContext ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYMBOL_REGISTERED_CALLBACK64")]
[return: MarshalAs(UnmanagedType.Bool)]
public delegate bool PSYMBOL_REGISTERED_CALLBACK64(HPROCESS hProcess, CBA ActionCode, ulong CallbackData, ulong UserContext);
/// Callback code for PSYMBOL_REGISTERED_CALLBACK.
[PInvokeData("dbghelp.h", MSDNShortId = "NC:dbghelp.PSYMBOL_REGISTERED_CALLBACK64")]
[Flags]
public enum CBA : uint
{
///
CBA_CHECK_ARM_MACHINE_THUMB_TYPE_OVERRIDE = 0x80000000,
///
CBA_CHECK_ENGOPT_DISALLOW_NETWORK_PATHS = 0x70000000,
///
CBA_ENGINE_PRESENT = 0x60000000,
///
CBA_UPDATE_STATUS_BAR = 0x50000000,
///
CBA_XML_LOG = 0x90000000,
///
/// Display verbose information.
/// The CallbackData parameter is a pointer to a string.
///
CBA_DEBUG_INFO = 0x10000000,
///
/// Deferred symbol loading has started. To cancel the symbol load, return TRUE.
/// The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
CBA_DEFERRED_SYMBOL_LOAD_CANCEL = 0x00000007,
///
/// Deferred symbol load has completed.
/// The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
CBA_DEFERRED_SYMBOL_LOAD_COMPLETE = 0x00000002,
///
/// Deferred symbol load has failed.
///
/// The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The symbol handler will attempt to
/// load the symbols again if the callback function sets the FileName member of this structure.
///
///
CBA_DEFERRED_SYMBOL_LOAD_FAILURE = 0x00000003,
///
/// Deferred symbol load has partially completed. The symbol loader is unable to read the image header from either the image
/// file or the specified module.
///
/// The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure. The symbol handler will attempt to
/// load the symbols again if the callback function sets the FileName member of this structure.
///
/// DbgHelp 5.1: This value is not supported.
///
CBA_DEFERRED_SYMBOL_LOAD_PARTIAL = 0x00000020,
///
/// Deferred symbol load has started.
/// The CallbackData parameter is a pointer to a IMAGEHLP_DEFERRED_SYMBOL_LOAD64 structure.
///
CBA_DEFERRED_SYMBOL_LOAD_START = 0x00000001,
///
/// Duplicate symbols were found. This reason is used only in COFF or CodeView format.
///
/// The CallbackData parameter is a pointer to a IMAGEHLP_DUPLICATE_SYMBOL64 structure. To specify which symbol to use, set the
/// SelectedSymbol member of this structure.
///
///
CBA_DUPLICATE_SYMBOL = 0x00000005,
///
/// Display verbose information. If you do not handle this event, the information is resent through the CBA_DEBUG_INFO event.
/// The CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure.
///
CBA_EVENT = 0x00000010,
///
/// The loaded image has been read.
///
/// The CallbackData parameter is a pointer to a IMAGEHLP_CBA_READ_MEMORY structure. The callback function should read the
/// number of bytes specified by the bytes member into the buffer specified by the buf member, and update the bytesread member accordingly.
///
///
CBA_READ_MEMORY = 0x00000006,
///
/// Symbol options have been updated. To retrieve the current options, call the SymGetOptions function.
/// The CallbackData parameter should be ignored.
///
CBA_SET_OPTIONS = 0x00000008,
///
/// Display verbose information for source server. If you do not handle this event, the information is resent through the
/// CBA_DEBUG_INFO event.
/// The CallbackData parameter is a pointer to a IMAGEHLP_CBA_EVENT structure.
/// DbgHelp 6.6 and earlier: This value is not supported.
///
CBA_SRCSRV_EVENT = 0x40000000,
///
/// Display verbose information for source server.
/// The CallbackData parameter is a pointer to a string.
/// DbgHelp 6.6 and earlier: This value is not supported.
///
CBA_SRCSRV_INFO = 0x20000000,
///
/// Symbols have been unloaded.
/// The CallbackData parameter should be ignored.
///
CBA_SYMBOLS_UNLOADED = 0x00000004,
}
/// Flags for .
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSourceLines")]
[Flags]
public enum ESLFLAG
{
/// The function matches the full path in the File parameter.
ESLFLAG_FULLPATH = 0x00000001,
///
ESLFLAG_NEAREST = 0x00000002,
///
ESLFLAG_PREV = 0x00000004,
///
ESLFLAG_NEXT = 0x00000008,
///
ESLFLAG_INLINE_SITE = 0x00000010,
}
/// The directory to be retrieved.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetHomeDirectory")]
public enum IMAGEHLP_HD_TYPE
{
/// The home directory.
hdBase = 0,
/// The symbol directory.
hdSym,
/// The source directory.
hdSrc,
}
/// The type of symbol file.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymbolFile")]
public enum IMAGEHLP_SF_TYPE
{
/// A .exe or .dll file.
sfImage = 0,
/// A .dbg file.
sfDbg,
/// A .pdb file.
sfPdb,
/// Reserved.
sfMpd,
}
/// Flags for .
[Flags]
public enum SLMFLAG
{
///
/// Creates a virtual module named ModuleName at the address specified in BaseOfDll. To add symbols to this module, call the
/// SymAddSymbol function.
///
SLMFLAG_VIRTUAL = 0x1,
///
SLMFLAG_ALT_INDEX = 0x2,
/// Loads the module but not the symbols for the module.
SLMFLAG_NO_SYMBOLS = 0x4
}
/// The format of the id parameter. This parameter can be one of the following values.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFindFileInPath")]
[Flags]
public enum SSRVOPT
{
///
/// Callback function. The data parameter contains a pointer to the callback function. If data is NULL, any previously-set
/// callback function is ignored.
///
SSRVOPT_CALLBACK = 0x00000001,
/// The id parameter is a DWORD.
SSRVOPT_DWORD = 0x00000002,
/// The id parameter is a pointer to a DWORD.
SSRVOPT_DWORDPTR = 0x00000004,
/// The id parameter is a pointer to a GUID.
SSRVOPT_GUIDPTR = 0x00000008,
///
SSRVOPT_OLDGUIDPTR = 0x00000010,
///
/// If data is TRUE, SymSrv will not display dialog boxes or pop-ups. If data is FALSE, SymSrv will display these graphical
/// features when making connections.
///
SSRVOPT_UNATTENDED = 0x00000020,
///
/// If data is TRUE, SymSrv will not verify that the path parameter passed by the SymbolServer function actually exists. In this
/// case, SymbolServer will always return TRUE.
///
SSRVOPT_NOCOPY = 0x00000040,
///
SSRVOPT_GETPATH = 0x00000040,
///
/// The data parameter is an HWND value that specifies the handle to the parent window that should be used for all dialog boxes
/// and pop-ups. If data is NULL, SymSrv will use the desktop window as the parent (this is the default).
///
SSRVOPT_PARENTWIN = 0x00000080,
///
/// Data type of the id parameter passed to the SymbolServer function. The data parameter is of type UINT_PTR and can be one of
/// the following values: SSRVOPT_DWORD (default) SSRVOPT_DWORDPTR SSRVOPT_GUIDPTR
///
SSRVOPT_PARAMTYPE = 0x00000100,
///
/// If data is TRUE, SymSrv will not use the downstream store specified in _NT_SYMBOL_PATH. DbgHelp 6.0 and earlier: This value
/// is not supported.
///
SSRVOPT_SECURE = 0x00000200,
/// SymSrv will provide debug trace information. DbgHelp 5.1: This value is not supported.
SSRVOPT_TRACE = 0x00000400,
///
/// The data parameter specifies the value passed to the SymbolServerCallback function in the context parameter. DbgHelp 6.0 and
/// earlier: This value is not supported.
///
SSRVOPT_SETCONTEXT = 0x00000800,
///
/// If data is NULL, the default proxy server is used. Otherwise, data is a null-terminated string that specifies the name and
/// port number of the proxy server. The name and port number are separated by a colon (:). For more information, see Symbol
/// Servers and Internet Firewalls. DbgHelp 6.0 and earlier: This value is not supported.
///
SSRVOPT_PROXY = 0x00001000,
///
/// The data parameter contains a string that specifies the downstream store path. For more information, see Using SymSrv.
/// DbgHelp 6.0 and earlier: This value is not supported.
///
SSRVOPT_DOWNSTREAM_STORE = 0x00002000,
///
/// If data is TRUE, SymSrv will overwrite the downlevel store from the symbol store. DbgHelp 6.1 and earlier: This value is not supported.
///
SSRVOPT_OVERWRITE = 0x00004000,
///
SSRVOPT_RESETTOU = 0x00008000,
///
SSRVOPT_CALLBACKW = 0x00010000,
///
/// If data is TRUE, SymSrv uses the default downstream store as a flat directory. DbgHelp 6.1 and earlier: This value is not supported.
///
SSRVOPT_FLAT_DEFAULT_STORE = 0x00020000,
///
SSRVOPT_PROXYW = 0x00040000,
///
SSRVOPT_MESSAGE = 0x00080000,
///
SSRVOPT_SERVICE = 0x00100000,
///
/// If data is TRUE, SymSrv uses symbols that do not have an address. By default, SymSrv filters out symbols that do not have an address.
///
SSRVOPT_FAVOR_COMPRESSED = 0x00200000,
///
SSRVOPT_STRING = 0x00400000,
///
SSRVOPT_WINHTTP = 0x00800000,
///
SSRVOPT_WININET = 0x01000000,
///
SSRVOPT_DONT_UNCOMPRESS = 0x02000000,
///
SSRVOPT_DISABLE_PING_HOST = 0x04000000,
///
SSRVOPT_DISABLE_TIMEOUT = 0x08000000,
///
SSRVOPT_ENABLE_COMM_MSG = 0x10000000,
///
SSRVOPT_URI_FILTER = 0x20000000,
///
SSRVOPT_URI_TIERS = 0x40000000,
///
SSRVOPT_RETRY_APP_HANG = unchecked((int)0x80000000),
/// Resets default options.
SSRVOPT_RESET = -1,
}
/// Indicates possible options.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSymbolsEx")]
[Flags]
public enum SYMENUM
{
/// Use the default options.
SYMENUM_OPTIONS_DEFAULT = 0x00000001,
/// Enumerate inline symbols.
SYMENUM_OPTIONS_INLINE = 0x00000002
}
/// The symbol options. Zero is a valid value and indicates that all options are turned off.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetOptions")]
[Flags]
public enum SYMOPT : uint
{
///
/// Enables the use of symbols that are stored with absolute addresses. Most symbols are stored as RVAs from the base of the
/// module. DbgHelp translates them to absolute addresses. There are symbols that are stored as an absolute address. These have
/// very specialized purposes and are typically not used.
/// DbgHelp 5.1 and earlier: This value is not supported.
///
SYMOPT_ALLOW_ABSOLUTE_SYMBOLS = 0x00000800,
///
/// Enables the use of symbols that do not have an address. By default, DbgHelp filters out symbols that do not have an address.
///
SYMOPT_ALLOW_ZERO_ADDRESS = 0x01000000,
///
/// Do not search the public symbols when searching for symbols by address, or when enumerating symbols, unless they were not
/// found in the global symbols or within the current scope. This option has no effect with SYMOPT_PUBLICS_ONLY.
/// DbgHelp 5.1 and earlier: This value is not supported.
///
SYMOPT_AUTO_PUBLICS = 0x00010000,
/// All symbol searches are insensitive to case.
SYMOPT_CASE_INSENSITIVE = 0x00000001,
/// Pass debug output through OutputDebugString or the SymRegisterCallbackProc64 callback function.
SYMOPT_DEBUG = 0x80000000,
///
/// Symbols are not loaded until a reference is made requiring the symbols be loaded. This is the fastest, most efficient way to
/// use the symbol handler.
///
SYMOPT_DEFERRED_LOADS = 0x00000004,
///
/// Disables the auto-detection of symbol server stores in the symbol path, even without the "SRV*" designation, maintaining
/// compatibility with previous behavior.
/// DbgHelp 6.6 and earlier: This value is not supported.
///
SYMOPT_DISABLE_SYMSRV_AUTODETECT = 0x02000000,
/// Do not load an unmatched .pdb file. Do not load export symbols if all else fails.
SYMOPT_EXACT_SYMBOLS = 0x00000400,
///
/// Do not display system dialog boxes when there is a media failure such as no media in a drive. Instead, the failure happens silently.
///
SYMOPT_FAIL_CRITICAL_ERRORS = 0x00000200,
///
/// If there is both an uncompressed and a compressed file available, favor the compressed file. This option is good for slow connections.
///
SYMOPT_FAVOR_COMPRESSED = 0x00800000,
///
/// Symbols are stored in the root directory of the default downstream store.
/// DbgHelp 6.1 and earlier: This value is not supported.
///
SYMOPT_FLAT_DIRECTORY = 0x00400000,
/// Ignore path information in the CodeView record of the image header when loading a .pdb file.
SYMOPT_IGNORE_CVREC = 0x00000080,
///
/// Ignore the image directory.
/// DbgHelp 6.1 and earlier: This value is not supported.
///
SYMOPT_IGNORE_IMAGEDIR = 0x00200000,
///
/// Do not use the path specified by _NT_SYMBOL_PATH if the user calls SymSetSearchPath without a valid path.
/// DbgHelp 5.1: This value is not supported.
///
SYMOPT_IGNORE_NT_SYMPATH = 0x00001000,
/// When debugging on 64-bit Windows, include any 32-bit modules.
SYMOPT_INCLUDE_32BIT_MODULES = 0x00002000,
/// Disable checks to ensure a file (.exe, .dbg., or .pdb) is the correct file. Instead, load the first file located.
SYMOPT_LOAD_ANYTHING = 0x00000040,
/// Loads line number information.
SYMOPT_LOAD_LINES = 0x00000010,
///
/// All C++ decorated symbols containing the symbol separator "::" are replaced by "__". This option exists for debuggers that
/// cannot handle parsing real C++ symbol names.
///
SYMOPT_NO_CPP = 0x00000008,
///
/// Do not search the image for the symbol path when loading the symbols for a module if the module header cannot be read.
/// DbgHelp 5.1: This value is not supported.
///
SYMOPT_NO_IMAGE_SEARCH = 0x00020000,
/// Prevents prompting for validation from the symbol server.
SYMOPT_NO_PROMPTS = 0x00080000,
///
/// Do not search the publics table for symbols. This option should have little effect because there are copies of the public
/// symbols in the globals table.
/// DbgHelp 5.1: This value is not supported.
///
SYMOPT_NO_PUBLICS = 0x00008000,
///
/// Prevents symbols from being loaded when the caller examines symbols across multiple modules. Examine only the module whose
/// symbols have already been loaded.
///
SYMOPT_NO_UNQUALIFIED_LOADS = 0x00000100,
///
/// Overwrite the downlevel store from the symbol store.
/// DbgHelp 6.1 and earlier: This value is not supported.
///
SYMOPT_OVERWRITE = 0x00100000,
///
/// Do not use private symbols. The version of DbgHelp that shipped with earlier Windows release supported only public symbols;
/// this option provides compatibility with this limitation.
/// DbgHelp 5.1: This value is not supported.
///
SYMOPT_PUBLICS_ONLY = 0x00004000,
///
/// DbgHelp will not load any symbol server other than SymSrv. SymSrv will not use the downstream store specified in
/// _NT_SYMBOL_PATH. After this flag has been set, it cannot be cleared.
/// DbgHelp 6.0 and 6.1: This flag can be cleared.
/// DbgHelp 5.1: This value is not supported.
///
SYMOPT_SECURE = 0x00040000,
///
/// All symbols are presented in undecorated form.
///
/// This option has no effect on global or local symbols because they are stored undecorated. This option applies only to public symbols.
///
///
SYMOPT_UNDNAME = 0x00000002,
}
/// The options that control the behavior of .
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSearch")]
[Flags]
public enum SYMSEARCH
{
/// Include all symbols and other data in the .pdb files. DbgHelp 6.6 and earlier: This value is not supported.
SYMSEARCH_ALLITEMS = 0X08,
/// Search only for global symbols.
SYMSEARCH_GLOBALSONLY = 0X04,
/// For internal use only.
SYMSEARCH_MASKOBJS = 0x01,
/// Recurse from the top to find all symbols.
SYMSEARCH_RECURSE = 0X02,
}
/// The flags that control .
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvStoreFile")]
[Flags]
public enum SYMSTOREOPT
{
///
SYMSTOREOPT_ALT_INDEX = 0x10,
/// Compress the file.
SYMSTOREOPT_COMPRESS = 0x01,
/// Overwrite the file if it exists.
SYMSTOREOPT_OVERWRITE = 0x02,
/// Do not report an error if the file already exists in the symbol store.
SYMSTOREOPT_PASS_IF_EXISTS = 0x40,
/// Store in File.ptr.
SYMSTOREOPT_POINTER = 0x08,
/// Return the index only.
SYMSTOREOPT_RETURNINDEX = 0x04,
///
SYMSTOREOPT_UNICODE = 0x20,
}
/// Indicates whether the specified address is within an inline frame.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The address.
/// Returns zero if the address is not within an inline frame.
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symaddrincludeinlinetrace DWORD IMAGEAPI
// SymAddrIncludeInlineTrace( HANDLE hProcess, DWORD64 Address );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymAddrIncludeInlineTrace")]
public static extern uint SymAddrIncludeInlineTrace(HPROCESS hProcess, ulong Address);
/// Adds the stream to the specified module for use by the Source Server.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// A null-terminated string that contains the absolute or relative path to a file that contains the source indexing stream. Can be
/// NULL if Buffer is not NULL.
///
/// A buffer that contains the source indexing stream. Can be NULL if StreamFile is not NULL.
/// Size, in bytes, of the Buffer buffer.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// SymAddSourceStream adds a stream of data formatted for use by the source Server to a designated module. The caller can
/// pass the stream either as a buffer in the Buffer parameter or a file in the StreamFile parameter. If both parameters are filled,
/// then the function uses the Buffer parameter. If both parameters are NULL, then the function returns FALSE and the
/// last-error code is set to ERROR_INVALID_PARAMETER.
///
///
/// It is important to note that SymAddSourceStream does not add the stream to any corresponding PDB in order to persist the
/// data. This function is used by those programmatically implementing their own debuggers in scenarios in which a PDB is not available.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symaddsourcestream BOOL IMAGEAPI SymAddSourceStream( HANDLE
// hProcess, ULONG64 Base, PCSTR StreamFile, PBYTE Buffer, size_t Size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymAddSourceStream")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymAddSourceStream(HPROCESS hProcess, ulong Base, [Optional, MarshalAs(UnmanagedType.LPTStr)] string StreamFile, [In] IntPtr Buffer, SizeT Size);
/// Adds a virtual symbol to the specified module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The name of the symbol. The maximum size of a symbol name is MAX_SYM_NAME characters.
/// The address of the symbol. This address must be within the address range of the specified module.
/// The size of the symbol, in bytes. This parameter is optional.
/// This parameter is unused.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symaddsymbol BOOL IMAGEAPI SymAddSymbol( HANDLE hProcess,
// ULONG64 BaseOfDll, PCSTR Name, DWORD64 Address, DWORD Size, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymAddSymbol")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymAddSymbol(HPROCESS hProcess, ulong BaseOfDll, [MarshalAs(UnmanagedType.LPTStr)] string Name, ulong Address, uint Size, uint Flags = 0);
///
/// An entry point to the symbol server DLL. It is used to set the symbol server options.
///
/// The PSYMBOLSERVERSETOPTIONSPROC type defines a pointer to this callback function. SymbolServerSetOptions is a
/// placeholder for the library-defined function name.
///
///
/// [in] The option to be set (see Remarks).
/// [in] The server-specific option data. The format of this data depends on the value of options (see Remarks).
///
/// The server can return TRUE to indicate success, or return FALSE and call the SetLastError function to
/// indicate an error condition.
///
///
///
/// To call this function, you must use the LoadLibrary function to load the DLL and the GetProcAddress function to
/// get the address of the function. The default implementation is in Symsrv.dll.
///
/// If you are using Symsrv.dll as your symbol server, the options parameter should be one of the following values.
///
///
/// id
/// Meaning
///
/// -
/// SSRVOPT_CALLBACK
///
/// Callback function. The data parameter contains a pointer to the callback function. If data is NULL, any previously-set callback
/// function is ignored.
///
///
/// -
/// SSRVOPT_DOWNSTREAM_STORE
///
/// The data parameter contains a string that specifies the downstream store path. For more information, see Using SymSrv. DbgHelp
/// 6.0 and earlier: This value is not supported.
///
///
/// -
/// SSRVOPT_FLAT_DEFAULT_STORE
///
/// If data is TRUE, SymSrv uses the default downstream store as a flat directory. DbgHelp 6.1 and earlier: This value is not supported.
///
///
/// -
/// SSRVOPT_FAVOR_COMPRESSED
///
/// If data is TRUE, SymSrv uses symbols that do not have an address. By default, SymSrv filters out symbols that do not have an address.
///
///
/// -
/// SSRVOPT_NOCOPY
///
/// If data is TRUE, SymSrv will not verify that the path parameter passed by the SymbolServer function actually exists. In this
/// case, SymbolServer will always return TRUE.
///
///
/// -
/// SSRVOPT_OVERWRITE
///
/// If data is TRUE, SymSrv will overwrite the downlevel store from the symbol store. DbgHelp 6.1 and earlier: This value is not supported.
///
///
/// -
/// SSRVOPT_PARAMTYPE
///
/// Data type of the id parameter passed to the SymbolServer function. The data parameter is of type UINT_PTR and can be one of the
/// following values: SSRVOPT_DWORD (default) SSRVOPT_DWORDPTR SSRVOPT_GUIDPTR
///
///
/// -
/// SSRVOPT_PARENTWIN
///
/// The data parameter is an HWND value that specifies the handle to the parent window that should be used for all dialog boxes and
/// pop-ups. If data is NULL, SymSrv will use the desktop window as the parent (this is the default).
///
///
/// -
/// SSRVOPT_PROXY
///
/// If data is NULL, the default proxy server is used. Otherwise, data is a null-terminated string that specifies the name and port
/// number of the proxy server. The name and port number are separated by a colon (:). For more information, see Symbol Servers and
/// Internet Firewalls. DbgHelp 6.0 and earlier: This value is not supported.
///
///
/// -
/// SSRVOPT_RESET
/// Resets default options.
///
/// -
/// SSRVOPT_SECURE
///
/// If data is TRUE, SymSrv will not use the downstream store specified in _NT_SYMBOL_PATH. DbgHelp 6.0 and earlier: This value is
/// not supported.
///
///
/// -
/// SSRVOPT_SETCONTEXT
///
/// The data parameter specifies the value passed to the SymbolServerCallback function in the context parameter. DbgHelp 6.0 and
/// earlier: This value is not supported.
///
///
/// -
/// SSRVOPT_TRACE
/// SymSrv will provide debug trace information. DbgHelp 5.1: This value is not supported.
///
/// -
/// SSRVOPT_UNATTENDED
///
/// If data is TRUE, SymSrv will not display dialog boxes or pop-ups. If data is FALSE, SymSrv will display these graphical features
/// when making connections.
///
///
///
///
// https://docs.microsoft.com/en-us/previous-versions/ff797954(v=vs.85) BOOL CALLBACK SymbolServerSetOptions( _In_ UINT_PTR options,
// _In_ ULONG64 data );
[DllImport("Symsrv.dll", SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("DbgHelp.h")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymbolServerSetOptions([In] IntPtr options, [In] long data);
/// Deallocates all resources associated with the process handle.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function frees all resources associated with the process handle. Failure to call this function causes memory and resource
/// leaks in the calling application
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, call SymInitialize only when your process starts and
/// SymCleanup only when your process ends. It is not necessary for each thread in the process to call these functions.
///
/// Examples
/// For an example, see Terminating the Symbol Handler.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symcleanup BOOL IMAGEAPI SymCleanup( HANDLE hProcess );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymCleanup")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymCleanup(HPROCESS hProcess);
/// Compares two inline traces.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The first address to be compared.
/// The inline context for the first trace to be compared.
/// The return address of the first trace to be compared.
/// The second address to be compared.
/// The return address of the second trace to be compared.
///
/// Indicates the result of the comparison.
///
///
/// Return code/value
/// Description
///
/// -
/// SYM_INLINE_COMP_ERROR 0
/// An error occurred.
///
/// -
/// SYM_INLINE_COMP_IDENTICAL 1
/// The inline contexts are identical.
///
/// -
/// SYM_INLINE_COMP_STEPIN 2
/// The inline trace is a step-in of an inline function.
///
/// -
/// SYM_INLINE_COMP_STEPOUT 3
/// The inline trace is a step-out of an inline function.
///
/// -
/// SYM_INLINE_COMP_STEPOVER 4
/// The inline trace is a step-over of an inline function.
///
/// -
/// SYM_INLINE_COMP_DIFFERENT 5
/// The inline contexts are different.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symcompareinlinetrace DWORD IMAGEAPI SymCompareInlineTrace(
// HANDLE hProcess, DWORD64 Address1, DWORD InlineContext1, DWORD64 RetAddress1, DWORD64 Address2, DWORD64 RetAddress2 );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymCompareInlineTrace")]
public static extern SYM_INLINE_COMP SymCompareInlineTrace(HPROCESS hProcess, ulong Address1, uint InlineContext1, ulong RetAddress1, ulong Address2, ulong RetAddress2);
/// Deletes a virtual symbol from the specified module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The name of the symbol.
/// The address of the symbol. This address must be within the address range of the specified module.
/// This parameter is unused.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symdeletesymbol BOOL IMAGEAPI SymDeleteSymbol( HANDLE
// hProcess, ULONG64 BaseOfDll, PCSTR Name, DWORD64 Address, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymDeleteSymbol")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymDeleteSymbol(HPROCESS hProcess, ulong BaseOfDll, [MarshalAs(UnmanagedType.LPTStr)] string Name, ulong Address, uint Flags = 0);
/// Enumerates all modules that have been loaded for the process by the SymLoadModule64 or SymLoadModuleEx function.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The enumeration callback function. This function is called once per module. For more information, see SymEnumerateModulesProc64.
///
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some type of context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymEnumerateModules64 function enumerates all modules that have been loaded for the process by SymLoadModule64, even
/// if the symbol loading is deferred. The enumeration callback function is called once for each module and is passed the module information.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymEnumerateModulesW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymEnumerateModulesW64( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, __in_opt PVOID UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymEnumerateModules64 SymEnumerateModulesW64 #endif
///
///
/// This function supersedes the SymEnumerateModules function. For more information, see Updated Platform Support.
/// SymEnumerateModules is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymEnumerateModules SymEnumerateModules64 #else BOOL IMAGEAPI SymEnumerateModules( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, __in_opt PVOID UserContext ); #endif
///
/// Examples
/// For an example, see Enumerating Symbol Modules.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumeratemodules BOOL IMAGEAPI SymEnumerateModules(
// HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumerateModules")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumerateModules(HPROCESS hProcess, PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all modules that have been loaded for the process by the SymLoadModule64 or SymLoadModuleEx function.
/// A handle to the process that was originally passed to the SymInitialize function.
/// If set to , force loading a 32-bit module, even on 64-bit systems.
/// A list of loaded module names and bases.
///
///
/// The SymEnumerateModules function enumerates all modules that have been loaded for the process by SymLoadModule, even if
/// the symbol loading is deferred.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// This function supersedes the SymEnumerateModules function. For more information, see Updated Platform Support.
///
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumerateModules")]
public static IList<(string ModuleName, IntPtr BaseOfDll)> SymEnumerateModules(HPROCESS hProcess, bool force32bit = false)
{
var ret = new List<(string, IntPtr)>();
bool success;
if (!LibHelper.Is64BitProcess || force32bit)
success = SymEnumerateModules(hProcess, Callback);
else
success = SymEnumerateModulesW64(hProcess, Callback64);
if (!success)
Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_NOT_FOUND);
return ret;
bool Callback64(string ModuleName, ulong BaseOfDll, IntPtr UserContext) { ret.Add((ModuleName, new IntPtr(unchecked((long)BaseOfDll)))); return true; }
bool Callback(string ModuleName, uint BaseOfDll, IntPtr UserContext) { ret.Add((ModuleName, new IntPtr(unchecked((int)BaseOfDll)))); return true; }
}
/// Enumerates all modules that have been loaded for the process by the SymLoadModule64 or SymLoadModuleEx function.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The enumeration callback function. This function is called once per module. For more information, see SymEnumerateModulesProc64.
///
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some type of context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymEnumerateModules64 function enumerates all modules that have been loaded for the process by SymLoadModule64, even
/// if the symbol loading is deferred. The enumeration callback function is called once for each module and is passed the module information.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymEnumerateModulesW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymEnumerateModulesW64( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, __in_opt PVOID UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymEnumerateModules64 SymEnumerateModulesW64 #endif
///
///
/// This function supersedes the SymEnumerateModules function. For more information, see Updated Platform Support.
/// SymEnumerateModules is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymEnumerateModules SymEnumerateModules64 #else BOOL IMAGEAPI SymEnumerateModules( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, __in_opt PVOID UserContext ); #endif
///
/// Examples
/// For an example, see Enumerating Symbol Modules.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumeratemodules64 BOOL IMAGEAPI SymEnumerateModules64(
// HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumerateModules64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumerateModules64(HPROCESS hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all modules that have been loaded for the process by the SymLoadModule64 or SymLoadModuleEx function.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The enumeration callback function. This function is called once per module. For more information, see SymEnumerateModulesProc64.
///
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some type of context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymEnumerateModules64 function enumerates all modules that have been loaded for the process by SymLoadModule64, even
/// if the symbol loading is deferred. The enumeration callback function is called once for each module and is passed the module information.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymEnumerateModulesW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymEnumerateModulesW64( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, __in_opt PVOID UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymEnumerateModules64 SymEnumerateModulesW64 #endif
///
///
/// This function supersedes the SymEnumerateModules function. For more information, see Updated Platform Support.
/// SymEnumerateModules is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymEnumerateModules SymEnumerateModules64 #else BOOL IMAGEAPI SymEnumerateModules( __in HANDLE hProcess, __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, __in_opt PVOID UserContext ); #endif
///
/// Examples
/// For an example, see Enumerating Symbol Modules.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumeratemodulesw64 BOOL IMAGEAPI
// SymEnumerateModulesW64( HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumerateModulesW64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumerateModulesW64(HPROCESS hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all lines in the specified module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// The name of an .obj file within the module. The scope of the enumeration is limited to this file. If this parameter is
/// NULL or an empty string, all .obj files are searched.
///
///
/// A wildcard expression that indicates the names of the source files to be searched. If this parameter is NULL or an empty
/// string, all files are searched.
///
/// A SymEnumLinesProc callback function that receives the line information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function is supported for PDB information only. If you have COFF information, try using one of the SymGetLineXXX functions.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumlines BOOL IMAGEAPI SymEnumLines( HANDLE hProcess,
// ULONG64 Base, PCSTR Obj, PCSTR File, PSYM_ENUMLINES_CALLBACK EnumLinesCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumLines")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumLines(HPROCESS hProcess, ulong Base, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Obj, [Optional, MarshalAs(UnmanagedType.LPTStr)] string File,
PSYM_ENUMLINES_CALLBACK EnumLinesCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all lines in the specified module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// The name of an .obj file within the module. The scope of the enumeration is limited to this file. If this parameter is
/// NULL or an empty string, all .obj files are searched.
///
///
/// A wildcard expression that indicates the names of the source files to be searched. If this parameter is NULL or an empty
/// string, all files are searched.
///
///
/// A list of the line information items (.obj file name, sourc file name, line number and the address of the first line).
///
///
///
/// This function is supported for PDB information only. If you have COFF information, try using one of the SymGetLineXXX functions.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
public static IList<(string Obj, string FileName, uint LineNumber, ulong Address)> SymEnumLines(HPROCESS hProcess, ulong Base, string Obj = null, string File = null)
{
var ret = new List<(string, string, uint, ulong)>();
if (!SymEnumLines(hProcess, Base, Obj, File, Callback))
Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_NOT_FOUND);
return ret;
bool Callback(in SRCCODEINFO LineInfo, IntPtr UserContext) { ret.Add((LineInfo.Obj, LineInfo.FileName, LineInfo.LineNumber, LineInfo.Address)); return true; }
}
/// Enumerates each process that has called the SymInitialize function.
/// A SymEnumProcessesProc callback function that receives the process information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumprocesses BOOL IMAGEAPI SymEnumProcesses(
// PSYM_ENUMPROCESSES_CALLBACK EnumProcessesCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumProcesses")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumProcesses(PSYM_ENUMPROCESSES_CALLBACK EnumProcessesCallback, [In, Optional] IntPtr UserContext);
/// Enumerates each process that has called the SymInitialize function.
/// A list of process handles.
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumProcesses")]
public static IList SymEnumProcesses()
{
var ret = new List();
if (!SymEnumProcesses(Callback))
Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_NOT_FOUND);
return ret;
bool Callback(HPROCESS hProcess, IntPtr UserContext) { ret.Add(hProcess); return true; }
}
/// Enumerates all source files in a process.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across
/// modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the
/// SymSetContext function.
///
///
///
/// A wildcard expression that indicates the names of the source files to be enumerated. To specify a module name, use the !mod syntax.
///
/// If this parameter is NULL, the function will enumerate all files.
///
/// Pointer to a SymEnumSourceFilesProc callback function that receives the source file information.
///
/// User-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsourcefiles BOOL IMAGEAPI SymEnumSourceFiles( HANDLE
// hProcess, ULONG64 ModBase, PCSTR Mask, PSYM_ENUMSOURCEFILES_CALLBACK cbSrcFiles, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSourceFiles")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSourceFiles(HPROCESS hProcess, ulong ModBase, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Mask,
PSYM_ENUMSOURCEFILES_CALLBACK cbSrcFiles, [In, Optional] IntPtr UserContext);
/// Enumerates all individual entries in a module's source server data, if available.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// A SymEnumSourceFileTokensProc callback function that receives the symbol information.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// Some modules have PDB files with source server information detailing the version control information for each of the source
/// files used to create each individual module. An application can use this function to enumerate the data for every source file
/// that was "source indexed".
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsourcefiletokens BOOL IMAGEAPI
// SymEnumSourceFileTokens( HANDLE hProcess, ULONG64 Base, PENUMSOURCEFILETOKENSCALLBACK Callback );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSourceFileTokens")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSourceFileTokens(HPROCESS hProcess, ulong Base, PENUMSOURCEFILETOKENSCALLBACK Callback);
/// Enumerates all source lines in a module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// The name of an .obj file within the module. The scope of the enumeration is limited to this file. If this parameter is
/// NULL or an empty string, all .obj files are searched.
///
///
/// A wildcard expression that indicates the names of the source files to be searched. If this parameter is NULL or an empty
/// string, all files are searched.
///
///
/// The line number of a line within the module. The scope of the enumeration is limited to this line. If this parameter is 0, all
/// lines are searched.
///
/// If this parameter is ESLFLAG_FULLPATH, the function matches the full path in the File parameter.
/// A SymEnumLinesProc callback function that receives the line information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsourcelines BOOL IMAGEAPI SymEnumSourceLines( HANDLE
// hProcess, ULONG64 Base, PCSTR Obj, PCSTR File, DWORD Line, DWORD Flags, PSYM_ENUMLINES_CALLBACK EnumLinesCallback, PVOID
// UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSourceLines")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSourceLines(HPROCESS hProcess, ulong Base, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Obj,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string File, [Optional] uint Line, ESLFLAG Flags, PSYM_ENUMLINES_CALLBACK EnumLinesCallback,
[In, Optional] IntPtr UserContext);
/// Enumerates all symbols in a process.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across
/// modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the
/// SymSetContext function.
///
///
///
/// A wildcard string that indicates the names of the symbols to be enumerated. The text can optionally contain the wildcards, "*"
/// and "?".
///
///
/// To specify a specific module or set of modules, begin the text with a wildcard string specifying the module, followed by an
/// exclamation point. When specifying a module, BaseOfDll is ignored.
///
///
///
/// Value
/// Meaning
///
/// -
/// foo
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol named "foo". If BaseOfDll is zero, then
/// SymEnumSymbols will look for a local symbol named "foo" within the scope established by the most recent call to the
/// SymSetContext function.
///
///
/// -
/// foo?
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol that starts with "foo" and contains one extra
/// character afterwards, such as "fool" and "foot". If BaseOfDll is zero, then SymEnumSymbols will look for a symbol that starts
/// with "foo" and contains one extra character afterwards, such as "fool" and "foot". The search would be within the scope
/// established by the most recent call to the SymSetContext function.
///
///
/// -
/// foo*!bar
///
/// SymEnumSymbols will look in every loaded module that starts with the text "foo" for a symbol called "bar". It could find matches
/// such as these, "foot!bar", "footlocker!bar", and "fool!bar".
///
///
/// -
/// *!*
/// SymEnumSymbols will enumerate every symbol in every loaded module.
///
///
///
/// A SymEnumSymbolsProc callback function that receives the symbol information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Enumerating Symbols.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsymbols BOOL IMAGEAPI SymEnumSymbols( HANDLE
// hProcess, ULONG64 BaseOfDll, PCSTR Mask, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSymbols")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSymbols(HPROCESS hProcess, [Optional] ulong BaseOfDll, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Mask,
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all symbols in a process.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across
/// modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the
/// SymSetContext function.
///
///
///
/// A wildcard string that indicates the names of the symbols to be enumerated. The text can optionally contain the wildcards, "*"
/// and "?".
///
///
/// To specify a specific module or set of modules, begin the text with a wildcard string specifying the module, followed by an
/// exclamation point. When specifying a module, BaseOfDll is ignored.
///
///
///
/// Value
/// Meaning
///
/// -
/// foo
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol named "foo". If BaseOfDll is zero, then
/// SymEnumSymbols will look for a local symbol named "foo" within the scope established by the most recent call to the SymSetContext function.
///
///
/// -
/// foo?
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol that starts with "foo" and contains one extra
/// character afterwards, such as "fool" and "foot". If BaseOfDll is zero, then SymEnumSymbols will look for a symbol that starts
/// with "foo" and contains one extra character afterwards, such as "fool" and "foot". The search would be within the scope
/// established by the most recent call to the SymSetContext function.
///
///
/// -
/// foo*!bar
///
/// SymEnumSymbols will look in every loaded module that starts with the text "foo" for a symbol called "bar". It could find matches
/// such as these, "foot!bar", "footlocker!bar", and "fool!bar".
///
///
/// -
/// *!*
/// SymEnumSymbols will enumerate every symbol in every loaded module.
///
///
///
///
/// Indicates possible options.
///
///
/// Value
/// Meaning
///
/// -
/// SYMENUM_OPTIONS_DEFAULT 1
/// Use the default options.
///
/// -
/// SYMENUM_OPTIONS_INLINE 2
/// Enumerate inline symbols.
///
///
///
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
/// A list of structures.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// Examples
/// For an example, see Enumerating Symbols.
///
public static IList SymEnumSymbolsEx(HPROCESS hProcess, [Optional] ulong BaseOfDll, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Mask,
SYMENUM Options = SYMENUM.SYMENUM_OPTIONS_DEFAULT, [In] IntPtr UserContext = default)
{
List list = new();
Win32Error.ThrowLastErrorIfFalse(SymEnumSymbolsEx(hProcess, BaseOfDll, Mask, EnumProc, UserContext, Options));
return list;
bool EnumProc(IntPtr pSymInfo, uint SymbolSize, IntPtr UserContext)
{
try { list.Add(pSymInfo.ToStructure(SymbolSize)); return true; }
catch { }
return false;
}
}
/// Enumerates all symbols in a process.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across
/// modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the
/// SymSetContext function.
///
///
///
/// A wildcard string that indicates the names of the symbols to be enumerated. The text can optionally contain the wildcards, "*"
/// and "?".
///
///
/// To specify a specific module or set of modules, begin the text with a wildcard string specifying the module, followed by an
/// exclamation point. When specifying a module, BaseOfDll is ignored.
///
///
///
/// Value
/// Meaning
///
/// -
/// foo
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol named "foo". If BaseOfDll is zero, then
/// SymEnumSymbols will look for a local symbol named "foo" within the scope established by the most recent call to the
/// SymSetContext function.
///
///
/// -
/// foo?
///
/// If BaseOfDll is not zero, then SymEnumSymbols will look for a global symbol that starts with "foo" and contains one extra
/// character afterwards, such as "fool" and "foot". If BaseOfDll is zero, then SymEnumSymbols will look for a symbol that starts
/// with "foo" and contains one extra character afterwards, such as "fool" and "foot". The search would be within the scope
/// established by the most recent call to the SymSetContext function.
///
///
/// -
/// foo*!bar
///
/// SymEnumSymbols will look in every loaded module that starts with the text "foo" for a symbol called "bar". It could find matches
/// such as these, "foot!bar", "footlocker!bar", and "fool!bar".
///
///
/// -
/// *!*
/// SymEnumSymbols will enumerate every symbol in every loaded module.
///
///
///
/// A SymEnumSymbolsProc callback function that receives the symbol information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// Indicates possible options.
///
///
/// Value
/// Meaning
///
/// -
/// SYMENUM_OPTIONS_DEFAULT 1
/// Use the default options.
///
/// -
/// SYMENUM_OPTIONS_INLINE 2
/// Enumerate inline symbols.
///
///
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsymbolsex BOOL IMAGEAPI SymEnumSymbolsEx( HANDLE
// hProcess, ULONG64 BaseOfDll, PCSTR Mask, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext, DWORD Options );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSymbolsEx")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSymbolsEx(HPROCESS hProcess, [Optional] ulong BaseOfDll, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Mask,
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext, SYMENUM Options);
/// Enumerates the symbols for the specified address.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The address for which symbols are to be located. The address does not have to be on a symbol boundary. If the address comes
/// after the beginning of a symbol and before the end of the symbol (the beginning of the symbol plus the symbol size), the
/// function will find the symbol.
///
///
/// An application-defined callback function. This function is called for every symbol found at Address. For more information, see SymEnumSymbolsProc.
///
/// Optional user-defined data. This value is passed to the callback function.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumsymbolsforaddr BOOL IMAGEAPI SymEnumSymbolsForAddr(
// HANDLE hProcess, DWORD64 Address, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumSymbolsForAddr")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumSymbolsForAddr(HPROCESS hProcess, ulong Address, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all user-defined types.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// A pointer to an SymEnumSymbolsProc callback function that receives the symbol information.
///
/// A user-defined value to be passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumtypes BOOL IMAGEAPI SymEnumTypes( HANDLE hProcess,
// ULONG64 BaseOfDll, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumTypes")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumTypes(HPROCESS hProcess, ulong BaseOfDll, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext);
/// Enumerates all user-defined types.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// A wildcard expression that indicates the names of the symbols to be enumerated. To specify a module name, use the !mod syntax.
///
/// A pointer to an SymEnumSymbolsProc callback function that receives the symbol information.
///
/// A user-defined value to be passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context information for the callback function.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symenumtypesbyname BOOL IMAGEAPI SymEnumTypesByName( HANDLE
// hProcess, ULONG64 BaseOfDll, PCSTR mask, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymEnumTypesByName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymEnumTypesByName(HPROCESS hProcess, ulong BaseOfDll, [Optional, MarshalAs(UnmanagedType.LPTStr)] string mask,
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext);
/// Locates a .dbg file in the process search path.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The name of the .dbg file. You can use a partial path.
/// The fully qualified path of the .dbg file. This buffer must be at least MAX_PATH characters.
///
///
/// An application-defined callback function that verifies whether the correct file was found or the function should continue its
/// search. For more information, see FindDebugInfoFileProc.
///
/// This parameter can be NULL.
///
///
/// A user-defined value or NULL. This value is simply passed to the callback function. This parameter is typically used by
/// an application to pass a pointer to a data structure that provides some context for the callback function.
///
///
/// If the function succeeds, the return value is an open handle to the .dbg file.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// This function uses the search path set using the SymInitialize or SymSetSearchPath function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfinddebuginfofile HANDLE IMAGEAPI SymFindDebugInfoFile(
// HANDLE hProcess, PCSTR FileName, PSTR DebugFilePath, PFIND_DEBUG_FILE_CALLBACK Callback, PVOID CallerData );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFindDebugInfoFile")]
public static extern HFILE SymFindDebugInfoFile(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPTStr)] string FileName,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder DebugFilePath, [Optional] PFIND_DEBUG_FILE_CALLBACK Callback, [In, Optional] IntPtr CallerData);
/// Locates an executable file in the process search path.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The name of the executable file. You can use a partial path.
/// The fully qualified path of the executable file. This buffer must be at least MAX_PATH characters.
///
///
/// An application-defined callback function that verifies whether the correct executable file was found, or whether the function
/// should continue its search. For more information, see FindExecutableImageProc.
///
/// This parameter can be NULL.
///
///
/// A user-defined value or NULL. This value is simply passed to the callback function. This parameter is typically used by
/// an application to pass a pointer to a data structure that provides some context for the callback function.
///
///
/// If the function succeeds, the return value is an open handle to the executable file.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// This function uses the search path set using the SymInitialize or SymSetSearchPath function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfindexecutableimage HANDLE IMAGEAPI
// SymFindExecutableImage( HANDLE hProcess, PCSTR FileName, PSTR ImageFilePath, PFIND_EXE_FILE_CALLBACK Callback, PVOID CallerData );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFindExecutableImage")]
public static extern HFILE SymFindExecutableImage(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPTStr)] string FileName,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder ImageFilePath, [Optional] PFIND_EXE_FILE_CALLBACK Callback, [In, Optional] IntPtr CallerData);
/// Locates a symbol file or executable image.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The search path. This can be multiple paths separated by semicolons. It can include both directories and symbol servers. If this
/// parameter is NULL, the function uses the search path set using the SymSetSearchPath or SymInitialize function.
///
/// The name of the file. You can specify a path; however, only the file name is used.
/// The first of three identifying parameters (see Remarks).
/// The second of three identifying parameters (see Remarks).
/// The third of three identifying parameters (see Remarks).
///
/// The format of the id parameter. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SSRVOPT_DWORD 0x0002
/// The id parameter is a DWORD.
///
/// -
/// SSRVOPT_DWORDPTR 0x0004
/// The id parameter is a pointer to a DWORD.
///
/// -
/// SSRVOPT_GUIDPTR 0x0008
/// The id parameter is a pointer to a GUID.
///
///
///
///
/// A pointer to a buffer that receives the fully qualified path to the symbol file. This buffer must be at least MAX_PATH characters.
///
/// A SymFindFileInPathProc callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. This parameter is typically used by
/// an application to pass a pointer to a data structure that provides some context for the callback function.
///
///
/// If the server locates a valid symbol file, it returns TRUE; otherwise, it returns FALSE and GetLastError returns a
/// value that indicates why the symbol file was not returned.
///
///
/// The identifying parameters are filled in as follows:
///
/// -
///
/// If DbgHelp is looking for a .pdb file, the id parameter specifies the PDB signature as found in the codeview debug directory of
/// the original image. Parameter two specifies the PDB age. Parameter three is unused and set to zero.
///
///
/// -
///
/// If DbgHelp is looking for any other type of image, such as an executable file or .dbg file, the id parameter specifies the
/// TimeDateStamp of the original image as found in its PE header. Parameter two specifies the SizeOfImage field, also extracted
/// from the PE header. Parameter three is unused and set to zero.
///
///
///
/// All of these values can be obtained by calling SymSrvGetFileIndexInfo.
///
/// When searching a directory, this function does not verify that the symbol identifiers match by default. To ensure the matching
/// symbol files are located, call the SymSetOptions function with SYMOPT_EXACT_SYMBOLS.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfindfileinpath BOOL IMAGEAPI SymFindFileInPath( HANDLE
// hprocess, PCSTR SearchPath, PCSTR FileName, PVOID id, DWORD two, DWORD three, DWORD flags, PSTR FoundFile,
// PFINDFILEINPATHCALLBACK callback, PVOID context );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFindFileInPath")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFindFileInPath(HPROCESS hprocess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SearchPath,
[MarshalAs(UnmanagedType.LPTStr)] string FileName, [In, Optional] IntPtr id, uint two, uint three, SSRVOPT flags,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder FoundFile, [In, Optional] PFINDFILEINPATHCALLBACK callback, [In, Optional] IntPtr context);
/// Retrieves symbol information for the specified address.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The address for which a symbol should be located. The address does not have to be on a symbol boundary. If the address comes
/// after the beginning of a symbol and before the end of the symbol, the symbol is found.
///
/// The displacement from the beginning of the symbol, or zero.
///
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol. The symbol name is variable in length;
/// therefore this buffer must be large enough to hold the name stored at the end of the SYMBOL_INFO structure. Be sure to
/// set the MaxNameLen member to the number of bytes reserved for the name.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Retrieving Symbol Information by Address.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfromaddr BOOL IMAGEAPI SymFromAddr( HANDLE hProcess,
// DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFromAddr")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFromAddr(HPROCESS hProcess, ulong Address, out ulong Displacement, ref SYMBOL_INFO Symbol);
/// Retrieves symbol information for the specified index.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// A unique value for the symbol.
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfromindex BOOL IMAGEAPI SymFromIndex( HANDLE hProcess,
// ULONG64 BaseOfDll, DWORD Index, PSYMBOL_INFO Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFromIndex")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFromIndex(HPROCESS hProcess, ulong BaseOfDll, uint Index, ref SYMBOL_INFO Symbol);
/// Retrieves symbol information for the specified address and inline context.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The address for which a symbol should be located. The address does not have to be on a symbol boundary. If the address comes
/// after the beginning of a symbol and before the end of the symbol, the symbol is found.
///
/// The inline context for which a symbol should be located.
/// The displacement from the beginning of the symbol, or zero.
///
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol. The symbol name is variable in length;
/// therefore this buffer must be large enough to hold the name stored at the end of the SYMBOL_INFO structure. Be sure to
/// set the MaxNameLen member to the number of bytes reserved for the name.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfrominlinecontextw BOOL IMAGEAPI SymFromInlineContextW(
// HANDLE hProcess, DWORD64 Address, ULONG InlineContext, PDWORD64 Displacement, PSYMBOL_INFOW Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFromInlineContextW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFromInlineContext(HPROCESS hProcess, ulong Address, uint InlineContext, out ulong Displacement, ref SYMBOL_INFO Symbol);
/// Retrieves symbol information for the specified name.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The name of the symbol to be located.
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Retrieving Symbol Information by Name.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfromname BOOL IMAGEAPI SymFromName( HANDLE hProcess,
// PCSTR Name, PSYMBOL_INFO Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFromName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFromName(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPTStr)] string Name, ref SYMBOL_INFO Symbol);
/// Retrieves symbol information for the specified managed code token.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the managed code module.
/// The managed code token.
/// A pointer to a SYMBOL_INFO structure that provides information about the symbol.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfromtokenw BOOL IMAGEAPI SymFromTokenW( HANDLE hProcess,
// DWORD64 Base, DWORD Token, PSYMBOL_INFOW Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFromTokenW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymFromToken(HPROCESS hProcess, ulong Base, uint Token, ref SYMBOL_INFO Symbol);
/// Retrieves the function table entry for the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The base address for which function table information is required.
///
/// If the function succeeds, the return value is a pointer to the function table entry.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// The type of pointer returned is specific to the image from which symbols are loaded.
/// x86: If the image is for an x86 system, this is a pointer to an FPO_DATA structure.
/// x64: If the image is for an x64 system, this is a pointer to an _IMAGE_RUNTIME_FUNCTION_ENTRY structure.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymFunctionTableAccess function. For more information, see Updated Platform Support.
/// SymFunctionTableAccess is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymFunctionTableAccess SymFunctionTableAccess64 #else PVOID IMAGEAPI SymFunctionTableAccess( __in HANDLE hProcess, __in DWORD AddrBase ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfunctiontableaccess PVOID IMAGEAPI
// SymFunctionTableAccess( HANDLE hProcess, DWORD AddrBase );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFunctionTableAccess")]
public static extern IntPtr SymFunctionTableAccess(HPROCESS hProcess, uint AddrBase);
/// Retrieves the function table entry for the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The base address for which function table information is required.
///
/// If the function succeeds, the return value is a pointer to the function table entry.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// The type of pointer returned is specific to the image from which symbols are loaded.
/// x86: If the image is for an x86 system, this is a pointer to an FPO_DATA structure.
/// x64: If the image is for an x64 system, this is a pointer to an _IMAGE_RUNTIME_FUNCTION_ENTRY structure.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymFunctionTableAccess function. For more information, see Updated Platform Support.
/// SymFunctionTableAccess is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymFunctionTableAccess SymFunctionTableAccess64 #else PVOID IMAGEAPI SymFunctionTableAccess( __in HANDLE hProcess, __in DWORD AddrBase ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfunctiontableaccess64 PVOID IMAGEAPI
// SymFunctionTableAccess64( HANDLE hProcess, DWORD64 AddrBase );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFunctionTableAccess64")]
public static extern IntPtr SymFunctionTableAccess64(HPROCESS hProcess, ulong AddrBase);
///
/// Finds a function table entry or frame pointer omission (FPO) record for an address.
/// Use SymFunctionTableAccess64 instead.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// The base address for which function table information is required.
/// Pointer to a read memory callback function.
/// Pointer to a get module base callback function.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symfunctiontableaccess64accessroutines PVOID IMAGEAPI
// SymFunctionTableAccess64AccessRoutines( HANDLE hProcess, DWORD64 AddrBase, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
// PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymFunctionTableAccess64AccessRoutines")]
public static extern IntPtr SymFunctionTableAccess64AccessRoutines(HPROCESS hProcess, ulong AddrBase, [Optional] PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
[Optional] PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine);
/// Gets whether the specified extended symbol option on or off.
///
/// The extended symbol option to check. The following are valid values.
///
///
/// Value
/// Meaning
///
/// -
/// SYMOPT_EX_DISABLEACCESSTIMEUPDATE 0
///
/// Turns off explicit updates to the last access time of a symbol that is loaded. By default, DbgHelp updates the last access time
/// of a symbol file that is consumed so that a symbol cache can be maintained by using a least recently used mechanism.
///
///
///
///
/// The value of the specified symbol option.
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetextendedoption BOOL IMAGEAPI SymGetExtendedOption(
// IMAGEHLP_EXTENDED_OPTIONS option );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetExtendedOption")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetExtendedOption(IMAGEHLP_EXTENDED_OPTIONS option);
/// Locates line information for the specified module and file name.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The name of the module in which lines are to be located. If this parameter is NULL, the function searches all modules.
///
/// The name of the file in which lines are to be located.
///
/// An array of offsets for each line. The offset for the line n is stored in element n-1. Array elements for lines that do not have
/// line information are left unchanged.
///
/// The size of the Buffer array, in elements.
///
///
/// If the function succeeds, the return value is the highest line number found. This value is zero if no line information was found.
///
/// If the function fails, the return value is LINE_ERROR. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetfilelineoffsets64 ULONG IMAGEAPI
// SymGetFileLineOffsets64( HANDLE hProcess, PCSTR ModuleName, PCSTR FileName, PDWORD64 Buffer, ULONG BufferLines );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetFileLineOffsets64")]
public static extern uint SymGetFileLineOffsets64(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPStr)] string ModuleName,
[MarshalAs(UnmanagedType.LPStr)] string FileName, out ulong Buffer, uint BufferLines);
/// Retrieves the home directory used by Dbghelp.
///
/// The directory to be retrieved. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// hdBase 0
/// The home directory.
///
/// -
/// hdSrc 2
/// The source directory.
///
/// -
/// hdSym 1
/// The symbol directory.
///
///
///
/// A pointer to a string that receives the directory.
/// The size of the output buffer, in characters.
///
/// If the function succeeds, the return value is a pointer to the dir parameter.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgethomedirectory PCHAR IMAGEAPI SymGetHomeDirectory(
// DWORD type, PSTR dir, size_t size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetHomeDirectory")]
[return: MarshalAs(UnmanagedType.LPTStr)]
public static extern StrPtrAuto SymGetHomeDirectory(IMAGEHLP_HD_TYPE type, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder dir, SizeT size);
/// Locates the source line for the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The address for which a line should be located. It is not necessary for the address to be on a line boundary. If the address
/// appears after the beginning of a line and before the end of the line, the line is found.
///
/// The displacement in bytes from the beginning of the line, or zero.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromAddr64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromAddrW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromAddrW64( _In_ HANDLE hProcess, _In_ DWORD64 dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromAddr64 SymGetLineFromAddrW64 #endif
///
///
/// This function supersedes the SymGetLineFromAddr function. For more information, see Updated Platform Support.
/// SymGetLineFromAddr is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromAddr SymGetLineFromAddr64 #define SymGetLineFromAddrW SymGetLineFromAddrW64 #else BOOL IMAGEAPI SymGetLineFromAddr( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineFromAddrW( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Address.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromaddr
// BOOL IMAGEAPI SymGetLineFromAddr( HANDLE hProcess, DWORD dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromAddr")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromAddr(HPROCESS hProcess, uint dwAddr, out uint pdwDisplacement, ref IMAGEHLP_LINE Line);
/// Locates the source line for the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
/// The displacement in bytes from the beginning of the line, or zero.
/// TBD
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromAddr64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromAddrW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromAddrW64( _In_ HANDLE hProcess, _In_ DWORD64 dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromAddr64 SymGetLineFromAddrW64 #endif
///
///
/// This function supersedes the SymGetLineFromAddr function. For more information, see Updated Platform Support.
/// SymGetLineFromAddr is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromAddr SymGetLineFromAddr64 #define SymGetLineFromAddrW SymGetLineFromAddrW64 #else BOOL IMAGEAPI SymGetLineFromAddr( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineFromAddrW( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Address.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromaddr64 BOOL IMAGEAPI SymGetLineFromAddr64(
// HANDLE hProcess, DWORD64 qwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64 );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromAddr64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromAddr64(HPROCESS hProcess, ulong qwAddr, out uint pdwDisplacement, ref IMAGEHLP_LINE64 Line64);
/// Locates the source line for the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
/// The displacement in bytes from the beginning of the line, or zero.
/// TBD
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromAddr64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromAddrW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromAddrW64( _In_ HANDLE hProcess, _In_ DWORD64 dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromAddr64 SymGetLineFromAddrW64 #endif
///
///
/// This function supersedes the SymGetLineFromAddr function. For more information, see Updated Platform Support.
/// SymGetLineFromAddr is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromAddr SymGetLineFromAddr64 #define SymGetLineFromAddrW SymGetLineFromAddrW64 #else BOOL IMAGEAPI SymGetLineFromAddr( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineFromAddrW( _In_ HANDLE hProcess, _In_ DWORD dwAddr, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Address.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromaddr64 BOOL IMAGEAPI SymGetLineFromAddr64(
// HANDLE hProcess, DWORD64 qwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64 );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromAddr64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromAddrW64(HPROCESS hProcess, ulong qwAddr, out uint pdwDisplacement, ref IMAGEHLP_LINE64 Line64);
/// Locates the source line for the specified inline context.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
/// The inline context.
/// The base address of the module.
/// The displacement in bytes from the beginning of the line, or zero.
/// TBD
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromInlineContext.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromInlineContext is
/// defined as follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromInlineContextW( _In_ HANDLE hProcess, _In_ DWORD64 dwAddr, _In_ ULONG InlineContext, _In_opt_ DWORD64 qwModuleBaseAddress, _Out_ PDWORD pdwDisplacement, _Out_ PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromInlineContext SymGetLineFromInlineContextW #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefrominlinecontext BOOL IMAGEAPI
// SymGetLineFromInlineContext( HANDLE hProcess, DWORD64 qwAddr, ULONG InlineContext, DWORD64 qwModuleBaseAddress, PDWORD
// pdwDisplacement, PIMAGEHLP_LINE64 Line64 );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromInlineContext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromInlineContext(HPROCESS hProcess, ulong qwAddr, uint InlineContext, [Optional] ulong qwModuleBaseAddress,
out uint pdwDisplacement, ref IMAGEHLP_LINE64 Line64);
/// Locates a source line for the specified module, file name, and line number.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The name of the module in which a line is to be located.
///
/// The name of the file in which a line is to be located. If the application has more than one source file with this name, be sure
/// to specify a full path.
///
/// The line number to be located.
/// The displacement in bytes from the beginning of the line, or zero.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromName64.
///
///
/// Before calling this function, ensure that the symbols are initialized correctly by first calling SymInitialize, SymSetOptions,
/// and SymLoadModule64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromNameW64 is defined as follows
/// in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromNameW64( __in HANDLE hProcess, __in_opt PCWSTR ModuleName, __in_opt PCWSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromName64 SymGetLineFromNameW64 #endif
///
///
/// This function supersedes the SymGetLineFromName function. For more information, see Updated Platform Support.
/// SymGetLineFromName is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromName SymGetLineFromName64 #else BOOL IMAGEAPI SymGetLineFromName( __in HANDLE hProcess, __in_opt PCSTR ModuleName, __in_opt PCSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINE Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Name.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromname BOOL IMAGEAPI SymGetLineFromName( HANDLE
// hProcess, PCSTR ModuleName, PCSTR FileName, DWORD dwLineNumber, PLONG plDisplacement, PIMAGEHLP_LINE Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromName(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPStr)] string ModuleName,
[MarshalAs(UnmanagedType.LPStr)] string FileName, uint dwLineNumber, out int plDisplacement, ref IMAGEHLP_LINE Line);
/// Locates a source line for the specified module, file name, and line number.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The name of the module in which a line is to be located.
///
/// The name of the file in which a line is to be located. If the application has more than one source file with this name, be sure
/// to specify a full path.
///
/// The line number to be located.
/// The displacement in bytes from the beginning of the line, or zero.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromName64.
///
///
/// Before calling this function, ensure that the symbols are initialized correctly by first calling SymInitialize, SymSetOptions,
/// and SymLoadModule64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromNameW64 is defined as follows
/// in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromNameW64( __in HANDLE hProcess, __in_opt PCWSTR ModuleName, __in_opt PCWSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromName64 SymGetLineFromNameW64 #endif
///
///
/// This function supersedes the SymGetLineFromName function. For more information, see Updated Platform Support.
/// SymGetLineFromName is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromName SymGetLineFromName64 #else BOOL IMAGEAPI SymGetLineFromName( __in HANDLE hProcess, __in_opt PCSTR ModuleName, __in_opt PCSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINE Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Name.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromname64 BOOL IMAGEAPI SymGetLineFromName64(
// HANDLE hProcess, PCSTR ModuleName, PCSTR FileName, DWORD dwLineNumber, PLONG plDisplacement, PIMAGEHLP_LINE64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromName64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromName64(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPStr)] string ModuleName,
[MarshalAs(UnmanagedType.LPStr)] string FileName, uint dwLineNumber, out int plDisplacement, ref IMAGEHLP_LINE64 Line);
/// Locates a source line for the specified module, file name, and line number.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The name of the module in which a line is to be located.
///
/// The name of the file in which a line is to be located. If the application has more than one source file with this name, be sure
/// to specify a full path.
///
/// The line number to be located.
/// The displacement in bytes from the beginning of the line, or zero.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The caller must allocate the Line buffer properly and fill in the required members of the IMAGEHLP_LINE64 structure before
/// calling SymGetLineFromName64.
///
///
/// Before calling this function, ensure that the symbols are initialized correctly by first calling SymInitialize, SymSetOptions,
/// and SymLoadModule64.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineFromNameW64 is defined as follows
/// in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineFromNameW64( __in HANDLE hProcess, __in_opt PCWSTR ModuleName, __in_opt PCWSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineFromName64 SymGetLineFromNameW64 #endif
///
///
/// This function supersedes the SymGetLineFromName function. For more information, see Updated Platform Support.
/// SymGetLineFromName is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineFromName SymGetLineFromName64 #else BOOL IMAGEAPI SymGetLineFromName( __in HANDLE hProcess, __in_opt PCSTR ModuleName, __in_opt PCSTR FileName, __in DWORD dwLineNumber, __out PLONG plDisplacement, __inout PIMAGEHLP_LINE Line ); #endif
///
/// Examples
/// For an example, see Retrieving Symbol Information by Name.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinefromnamew64 BOOL IMAGEAPI SymGetLineFromNameW64(
// HANDLE hProcess, PCWSTR ModuleName, PCWSTR FileName, DWORD dwLineNumber, PLONG plDisplacement, PIMAGEHLP_LINEW64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineFromNameW64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineFromNameW64(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPWStr)] string ModuleName,
[MarshalAs(UnmanagedType.LPWStr)] string FileName, uint dwLineNumber, out int plDisplacement, ref IMAGEHLP_LINE64 Line);
/// Retrieves the line information for the next source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure that contains the line information.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLineNext64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure receives the line information for the next
/// line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineNextW64 is defined as follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineNext64 SymGetLineNextW64 #endif
///
///
/// This function supersedes the SymGetLineNext function. For more information, see Updated Platform Support.
/// SymGetLineNext is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineNext SymGetLineNext64 #else BOOL IMAGEAPI SymGetLineNext( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineNextW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinenext BOOL IMAGEAPI SymGetLineNext( HANDLE
// hProcess, PIMAGEHLP_LINE Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineNext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineNext(HPROCESS hProcess, ref IMAGEHLP_LINE Line);
/// Retrieves the line information for the next source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure that contains the line information.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLineNext64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure receives the line information for the next
/// line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineNextW64 is defined as follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineNext64 SymGetLineNextW64 #endif
///
///
/// This function supersedes the SymGetLineNext function. For more information, see Updated Platform Support.
/// SymGetLineNext is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineNext SymGetLineNext64 #else BOOL IMAGEAPI SymGetLineNext( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineNextW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinenext64 BOOL IMAGEAPI SymGetLineNext64( HANDLE
// hProcess, PIMAGEHLP_LINE64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineNext64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineNext64(HPROCESS hProcess, ref IMAGEHLP_LINE64 Line);
/// Retrieves the line information for the next source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure that contains the line information.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLineNext64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure receives the line information for the next
/// line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLineNextW64 is defined as follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymGetLineNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLineNext64 SymGetLineNextW64 #endif
///
///
/// This function supersedes the SymGetLineNext function. For more information, see Updated Platform Support.
/// SymGetLineNext is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLineNext SymGetLineNext64 #else BOOL IMAGEAPI SymGetLineNext( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLineNextW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlinenextw64 BOOL IMAGEAPI SymGetLineNextW64( HANDLE
// hProcess, PIMAGEHLP_LINEW64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLineNextW64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLineNextW64(HPROCESS hProcess, ref IMAGEHLP_LINE64 Line);
/// Retrieves the line information for the previous source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLinePrev64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure is filled with the line information for the
/// previous line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLinePrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetLinePrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLinePrev64 SymGetLinePrevW64 #endif
///
///
/// This function supersedes the SymGetLinePrev function. For more information, see Updated Platform Support.
/// SymGetLinePrev is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLinePrev SymGetLinePrev64 #else BOOL IMAGEAPI SymGetLinePrev( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLinePrevW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlineprev BOOL IMAGEAPI SymGetLinePrev( HANDLE
// hProcess, PIMAGEHLP_LINE Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLinePrev")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLinePrev(HPROCESS hProcess, ref IMAGEHLP_LINE Line);
/// Retrieves the line information for the previous source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLinePrev64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure is filled with the line information for the
/// previous line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLinePrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetLinePrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLinePrev64 SymGetLinePrevW64 #endif
///
///
/// This function supersedes the SymGetLinePrev function. For more information, see Updated Platform Support.
/// SymGetLinePrev is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLinePrev SymGetLinePrev64 #else BOOL IMAGEAPI SymGetLinePrev( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLinePrevW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlineprev64 BOOL IMAGEAPI SymGetLinePrev64( HANDLE
// hProcess, PIMAGEHLP_LINE64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLinePrev64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLinePrev64(HPROCESS hProcess, ref IMAGEHLP_LINE64 Line);
/// Retrieves the line information for the previous source line.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_LINE64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetLinePrev64 function requires that the IMAGEHLP_LINE64 structure have valid data, presumably obtained from a
/// call to the SymGetLineFromAddr64 or SymGetLineFromName64 function. This structure is filled with the line information for the
/// previous line in sequence.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetLinePrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetLinePrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW64 Line ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetLinePrev64 SymGetLinePrevW64 #endif
///
///
/// This function supersedes the SymGetLinePrev function. For more information, see Updated Platform Support.
/// SymGetLinePrev is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetLinePrev SymGetLinePrev64 #else BOOL IMAGEAPI SymGetLinePrev( __in HANDLE hProcess, __inout PIMAGEHLP_LINE Line ); BOOL IMAGEAPI SymGetLinePrevW( __in HANDLE hProcess, __inout PIMAGEHLP_LINEW Line ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetlineprevw64 BOOL IMAGEAPI SymGetLinePrevW64( HANDLE
// hProcess, PIMAGEHLP_LINEW64 Line );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetLinePrevW64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetLinePrevW64(HPROCESS hProcess, ref IMAGEHLP_LINE64 Line);
/// Retrieves the base address of the module that contains the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The virtual address that is contained in one of the modules loaded by the SymLoadModule64 function.
///
///
/// If the function succeeds, the return value is a nonzero virtual address. The value is the base address of the module containing
/// the address specified by the dwAddr parameter.
///
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
///
///
///
/// The module table is searched for a module that contains dwAddr. The module is located based on the load address and size of each module.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetModuleBase function. For more information, see Updated Platform Support.
/// SymGetModuleBase is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetModuleBase SymGetModuleBase64 #else DWORD IMAGEAPI SymGetModuleBase( __in HANDLE hProcess, __in DWORD dwAddr ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetmodulebase DWORD IMAGEAPI SymGetModuleBase( HANDLE
// hProcess, DWORD dwAddr );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetModuleBase")]
public static extern uint SymGetModuleBase(HPROCESS hProcess, uint dwAddr);
/// Retrieves the base address of the module that contains the specified address.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
///
///
/// If the function succeeds, the return value is a nonzero virtual address. The value is the base address of the module containing
/// the address specified by the dwAddr parameter.
///
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
///
///
///
/// The module table is searched for a module that contains dwAddr. The module is located based on the load address and size of each module.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetModuleBase function. For more information, see Updated Platform Support.
/// SymGetModuleBase is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetModuleBase SymGetModuleBase64 #else DWORD IMAGEAPI SymGetModuleBase( __in HANDLE hProcess, __in DWORD dwAddr ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetmodulebase64 DWORD64 IMAGEAPI SymGetModuleBase64(
// HANDLE hProcess, DWORD64 qwAddr );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetModuleBase64")]
public static extern ulong SymGetModuleBase64(HPROCESS hProcess, ulong qwAddr);
/// Retrieves the module information of the specified module.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The virtual address that is contained in one of the modules loaded by the SymLoadModule64 function
///
/// A pointer to an IMAGEHLP_MODULE64 structure. The SizeOfStruct member must be set to the size of the
/// IMAGEHLP_MODULE64 structure. An invalid value will result in an error.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The module table is searched for a module that contains the dwAddr. The module is located based on the load address and size of
/// each module. If a valid module is found, the ModuleInfo parameter is filled with the information about the module.
///
///
/// The size of the IMAGEHLP_MODULE64 structure used by this function has changed over the years. If a version of DbgHelp.dll is
/// called that is older than the DbgHelp.h used to compile the calling code, then this function may fail with an error code of
/// ERROR_INVALID_PARAMETER. This most commonly occurs when the system version (%WinDir%\System32\DbgHelp.dll) is called.
/// Code that calls the system version of DbgHelp.dll must be compiled using the appropriate SDK for that Windows release or the SDK
/// for a previous release.
///
///
/// The recommended model is to redistribute the required version of DbgHelp.dll along with the calling software. This allows the
/// caller to use the most robust versions of DbgHelp.dll as well as a simplifying upgrades. The most recent version of DbgHelp.dll
/// can always be found in the Debugging Tools for Windows package. As a general rule, code that is compiled to work with older
/// versions will always work with newer versions.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetModuleInfoW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetModuleInfoW64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PIMAGEHLP_MODULEW64 ModuleInfo ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetModuleInfo64 SymGetModuleInfoW64 #endif
///
///
/// This function supersedes the SymGetModuleInfo function. For more information, see Updated Platform Support.
/// SymGetModuleInfo is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetModuleInfo SymGetModuleInfo64 #define SymGetModuleInfoW SymGetModuleInfoW64 #else BOOL IMAGEAPI SymGetModuleInfo( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULE ModuleInfo ); BOOL IMAGEAPI SymGetModuleInfoW( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULEW ModuleInfo ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetmoduleinfo BOOL IMAGEAPI SymGetModuleInfo( HANDLE
// hProcess, DWORD dwAddr, PIMAGEHLP_MODULE ModuleInfo );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetModuleInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetModuleInfo(HPROCESS hProcess, uint dwAddr, ref IMAGEHLP_MODULE ModuleInfo);
/// Retrieves the module information of the specified module.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
///
/// A pointer to an IMAGEHLP_MODULE64 structure. The SizeOfStruct member must be set to the size of the
/// IMAGEHLP_MODULE64 structure. An invalid value will result in an error.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The module table is searched for a module that contains the dwAddr. The module is located based on the load address and size of
/// each module. If a valid module is found, the ModuleInfo parameter is filled with the information about the module.
///
///
/// The size of the IMAGEHLP_MODULE64 structure used by this function has changed over the years. If a version of DbgHelp.dll is
/// called that is older than the DbgHelp.h used to compile the calling code, then this function may fail with an error code of
/// ERROR_INVALID_PARAMETER. This most commonly occurs when the system version (%WinDir%\System32\DbgHelp.dll) is called.
/// Code that calls the system version of DbgHelp.dll must be compiled using the appropriate SDK for that Windows release or the SDK
/// for a previous release.
///
///
/// The recommended model is to redistribute the required version of DbgHelp.dll along with the calling software. This allows the
/// caller to use the most robust versions of DbgHelp.dll as well as a simplifying upgrades. The most recent version of DbgHelp.dll
/// can always be found in the Debugging Tools for Windows package. As a general rule, code that is compiled to work with older
/// versions will always work with newer versions.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetModuleInfoW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetModuleInfoW64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PIMAGEHLP_MODULEW64 ModuleInfo ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetModuleInfo64 SymGetModuleInfoW64 #endif
///
///
/// This function supersedes the SymGetModuleInfo function. For more information, see Updated Platform Support.
/// SymGetModuleInfo is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetModuleInfo SymGetModuleInfo64 #define SymGetModuleInfoW SymGetModuleInfoW64 #else BOOL IMAGEAPI SymGetModuleInfo( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULE ModuleInfo ); BOOL IMAGEAPI SymGetModuleInfoW( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULEW ModuleInfo ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetmoduleinfo64 BOOL IMAGEAPI SymGetModuleInfo64( HANDLE
// hProcess, DWORD64 qwAddr, PIMAGEHLP_MODULE64 ModuleInfo );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetModuleInfo64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetModuleInfo64(HPROCESS hProcess, ulong qwAddr, ref IMAGEHLP_MODULE64 ModuleInfo);
/// Retrieves the module information of the specified module.
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
///
/// A pointer to an IMAGEHLP_MODULE64 structure. The SizeOfStruct member must be set to the size of the
/// IMAGEHLP_MODULE64 structure. An invalid value will result in an error.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The module table is searched for a module that contains the dwAddr. The module is located based on the load address and size of
/// each module. If a valid module is found, the ModuleInfo parameter is filled with the information about the module.
///
///
/// The size of the IMAGEHLP_MODULE64 structure used by this function has changed over the years. If a version of DbgHelp.dll is
/// called that is older than the DbgHelp.h used to compile the calling code, then this function may fail with an error code of
/// ERROR_INVALID_PARAMETER. This most commonly occurs when the system version (%WinDir%\System32\DbgHelp.dll) is called.
/// Code that calls the system version of DbgHelp.dll must be compiled using the appropriate SDK for that Windows release or the SDK
/// for a previous release.
///
///
/// The recommended model is to redistribute the required version of DbgHelp.dll along with the calling software. This allows the
/// caller to use the most robust versions of DbgHelp.dll as well as a simplifying upgrades. The most recent version of DbgHelp.dll
/// can always be found in the Debugging Tools for Windows package. As a general rule, code that is compiled to work with older
/// versions will always work with newer versions.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetModuleInfoW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetModuleInfoW64( __in HANDLE hProcess, __in DWORD64 qwAddr, __out PIMAGEHLP_MODULEW64 ModuleInfo ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymGetModuleInfo64 SymGetModuleInfoW64 #endif
///
///
/// This function supersedes the SymGetModuleInfo function. For more information, see Updated Platform Support.
/// SymGetModuleInfo is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetModuleInfo SymGetModuleInfo64 #define SymGetModuleInfoW SymGetModuleInfoW64 #else BOOL IMAGEAPI SymGetModuleInfo( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULE ModuleInfo ); BOOL IMAGEAPI SymGetModuleInfoW( __in HANDLE hProcess, __in DWORD dwAddr, __out PIMAGEHLP_MODULEW ModuleInfo ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetmoduleinfo64 BOOL IMAGEAPI SymGetModuleInfo64( HANDLE
// hProcess, DWORD64 qwAddr, PIMAGEHLP_MODULE64 ModuleInfo );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetModuleInfo64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetModuleInfoW64(HPROCESS hProcess, ulong qwAddr, ref IMAGEHLP_MODULE64 ModuleInfo);
/// Retrieves the omap tables within a loaded module.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// An array of address map entries to the new image layout taken from the original layout. For details on the map entries, see the
/// OMAP structure.
///
/// The number of entries in the OmapTo array.
///
/// An array of address map entries from the new image layout to the original layout (as described by the debug symbols). For
/// details on the map entries, see the OMAP structure.
///
/// The number of entries in the OmapFrom array.
///
/// If the function succeeds, the return value is TRUE.
///
/// If the function fails (the omap is not found), the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetomaps BOOL IMAGEAPI SymGetOmaps( HANDLE hProcess,
// DWORD64 BaseOfDll, POMAP *OmapTo, PDWORD64 cOmapTo, POMAP *OmapFrom, PDWORD64 cOmapFrom );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetOmaps")]
[return: MarshalAs(UnmanagedType.Bool)]
public static unsafe extern bool SymGetOmaps(HPROCESS hProcess, ulong BaseOfDll,
//[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] out OMAP[] OmapTo, out ulong cOmapTo,
//[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] out OMAP[] OmapFrom, out ulong cOmapFrom);
out OMAP* OmapTo, out ulong cOmapTo, out OMAP* OmapFrom, out ulong cOmapFrom);
/// Retrieves the current option mask.
///
/// The function returns the current options that have been set. Zero is a valid value and indicates that all options are turned off.
///
///
///
/// These options can be changed several times while the library is in use by an application. Any option change affects all future
/// calls to the symbol handler.
///
/// The return value is the combination of the following values that have been set using the SymSetOptions function.
///
/// -
/// SYMOPT_ALLOW_ABSOLUTE_SYMBOLS
///
/// -
/// SYMOPT_ALLOW_ZERO_ADDRESS
///
/// -
/// SYMOPT_AUTO_PUBLICS
///
/// -
/// SYMOPT_CASE_INSENSITIVE
///
/// -
/// SYMOPT_DEBUG
///
/// -
/// SYMOPT_DEFERRED_LOADS
///
/// -
/// SYMOPT_EXACT_SYMBOLS
///
/// -
/// SYMOPT_FAIL_CRITICAL_ERRORS
///
/// -
/// SYMOPT_FAVOR_COMPRESSED
///
/// -
/// SYMOPT_FLAT_DIRECTORY
///
/// -
/// SYMOPT_IGNORE_CVREC
///
/// -
/// SYMOPT_IGNORE_IMAGEDIR
///
/// -
/// SYMOPT_IGNORE_NT_SYMPATH
///
/// -
/// SYMOPT_INCLUDE_32BIT_MODULES
///
/// -
/// SYMOPT_LOAD_ANYTHING
///
/// -
/// SYMOPT_LOAD_LINES
///
/// -
/// SYMOPT_NO_CPP
///
/// -
/// SYMOPT_NO_IMAGE_SEARCH
///
/// -
/// SYMOPT_NO_PROMPTS
///
/// -
/// SYMOPT_NO_PUBLICS
///
/// -
/// SYMOPT_NO_UNQUALIFIED_LOADS
///
/// -
/// SYMOPT_OVERWRITE
///
/// -
/// SYMOPT_PUBLICS_ONLY
///
/// -
/// SYMOPT_SECURE
///
/// -
/// SYMOPT_UNDNAME
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetoptions DWORD IMAGEAPI SymGetOptions();
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetOptions")]
public static extern SYMOPT SymGetOptions();
/// Retrieves the scope for the specified index.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// A unique value for the symbol.
/// A pointer to a SYMBOL_INFO structure. The Scope member contains the scope.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetscope BOOL IMAGEAPI SymGetScope( HANDLE hProcess,
// ULONG64 BaseOfDll, DWORD Index, PSYMBOL_INFO Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetScope")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetScope(HPROCESS hProcess, ulong BaseOfDll, uint Index, ref SYMBOL_INFO Symbol);
/// Retrieves the symbol search path for the specified process.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to the buffer that receives the symbol search path.
/// The size of the SearchPath buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSearchPath function copies the symbol search path for the specified process into the SearchPath buffer. If the
/// function fails, the contents of the buffer are undefined.
///
/// To specify a symbol search path for the process, use the SymSetSearchPath function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsearchpath BOOL IMAGEAPI SymGetSearchPath( HANDLE
// hProcess, PSTR SearchPath, DWORD SearchPathLength );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSearchPath")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSearchPath(HPROCESS hProcess, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder SearchPath, uint SearchPathLength);
/// Retrieves the specified source file from the source server.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// This parameter is unused.
/// The name of the source file.
/// A pointer to a buffer that receives the fully qualified path of the source file.
/// The size of the FilePath buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// To control which directory receives the source files, use the SymSetHomeDirectory function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsourcefile BOOL IMAGEAPI SymGetSourceFile( HANDLE
// hProcess, ULONG64 Base, PCSTR Params, PCSTR FileSpec, PSTR FilePath, DWORD Size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSourceFile")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSourceFile(HPROCESS hProcess, ulong Base, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Params,
[MarshalAs(UnmanagedType.LPTStr)] string FileSpec, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder FilePath, uint Size);
/// Retrieves the specified source file checksum from the source server.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The name of the source file.
/// On success, points to the checksum type.
///
/// pointer to a buffer that receives the checksum. If NULL, then when the call returns pActualBytesWritten returns the
/// number of bytes required.
///
/// The size of the pChecksum buffer, in bytes.
/// Pointer to the actual bytes written in the buffer.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsourcefilechecksum BOOL IMAGEAPI
// SymGetSourceFileChecksum( HANDLE hProcess, ULONG64 Base, PCSTR FileSpec, DWORD *pCheckSumType, BYTE *pChecksum, DWORD
// checksumSize, DWORD *pActualBytesWritten );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSourceFileChecksum")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSourceFileChecksum(HPROCESS hProcess, ulong Base, [MarshalAs(UnmanagedType.LPTStr)] string FileSpec,
out uint pCheckSumType, [Out] IntPtr pChecksum, uint checksumSize, out uint pActualBytesWritten);
/// Retrieves the source file associated with the specified token from the source server.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// A pointer to the token.
/// This parameter is unused.
/// A pointer to a buffer that receives the fully qualified path of the source file.
/// The size of the FilePath buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsourcefilefromtoken BOOL IMAGEAPI
// SymGetSourceFileFromToken( HANDLE hProcess, PVOID Token, PCSTR Params, PSTR FilePath, DWORD Size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSourceFileFromToken")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSourceFileFromToken(HPROCESS hProcess, [In] IntPtr Token, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Params,
[Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder FilePath, uint Size);
/// Retrieves token for the specified source file from the source server.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The name of the source file.
/// A pointer to a buffer that receives the token.
/// The size of the Token buffer, in bytes.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsourcefiletoken BOOL IMAGEAPI SymGetSourceFileToken(
// HANDLE hProcess, ULONG64 Base, PCSTR FileSpec, PVOID *Token, DWORD *Size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSourceFileToken")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSourceFileToken(HPROCESS hProcess, ulong Base, [MarshalAs(UnmanagedType.LPTStr)] string FileSpec, out IntPtr Token, out uint Size);
/// Retrieves the value associated with the specified variable name from the Source Server token.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// A pointer to the token.
/// This parameter is unused.
/// The name of the variable token whose value you want to retrieve.
///
/// A pointer to a buffer that receives the value associated with the variable token specified in the VarName parameter.
///
/// The size of the Value buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsourcevarfromtoken BOOL IMAGEAPI
// SymGetSourceVarFromToken( HANDLE hProcess, PVOID Token, PCSTR Params, PCSTR VarName, PSTR Value, DWORD Size );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSourceVarFromToken")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSourceVarFromToken(HPROCESS hProcess, [In] IntPtr Token, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Params,
[MarshalAs(UnmanagedType.LPTStr)] string VarName, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder Value, uint Size);
/// Locates a symbol file in the specified symbol path.
///
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// If this handle is 0, SymPath cannot be NULL. Use this option to load a symbol file without calling SymInitialize or SymCleanup.
///
///
///
/// The symbol path. If this parameter is NULL or an empty string, the function uses the symbol path set using the
/// SymInitialize or SymSetSearchPath function.
///
/// The name of the image file.
///
/// The type of symbol file. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// sfImage 0
/// A .exe or .dll file.
///
/// -
/// sfDbg 1
/// A .dbg file.
///
/// -
/// sfPdb 2
/// A .pdb file.
///
/// -
/// sfMpd 3
/// Reserved.
///
///
///
/// A pointer to a null-terminated string that receives the name of the symbol file.
/// The size of the SymbolFile buffer, in characters.
///
/// A pointer to a buffer that receives the fully qualified path to the symbol file. This buffer must be at least MAX_PATH characters.
///
/// The size of the DbgFile buffer, in characters.
///
/// If the server locates a valid symbol file, it returns TRUE; otherwise, it returns FALSE and GetLastError returns a
/// value that indicates why the symbol file was not returned.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymbolfile BOOL IMAGEAPI SymGetSymbolFile( HANDLE
// hProcess, PCSTR SymPath, PCSTR ImageFile, DWORD Type, PSTR SymbolFile, size_t cSymbolFile, PSTR DbgFile, size_t cDbgFile );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymbolFile")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymbolFile([Optional] HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SymPath,
[MarshalAs(UnmanagedType.LPTStr)] string ImageFile, IMAGEHLP_SF_TYPE Type, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder SymbolFile,
SizeT cSymbolFile, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder DbgFile, SizeT cDbgFile);
///
/// Locates the symbol for the specified address.
/// Note This function is provided only for compatibility. Applications should use SymFromAddr.
///
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// The address for which a symbol is to be located. The address does not have to be on a symbol boundary. If the address comes
/// after the beginning of a symbol and before the end of the symbol (the beginning of the symbol plus the symbol size), the symbol
/// is found.
///
/// The displacement from the beginning of the symbol, or zero.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymFromAddr64 function locates the symbol for a specified address. The modules are searched for the one the
/// address belongs to. When the module is found, its symbol table is searched for a match. When the symbol is found, the symbol
/// information is copied into the Symbol buffer provided by the caller. The caller must allocate the Symbol buffer properly and
/// fill in the required parameters in the IMAGEHLP_SYMBOL64 structure before calling SymGetSymFromAddr64.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetSymFromAddr function. For more information, see Updated Platform Support.
/// SymGetSymFromAddr is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymFromAddr SymGetSymFromAddr64 #else BOOL IMAGEAPI SymGetSymFromAddr( __in HANDLE hProcess, __in DWORD dwAddr, __out_opt PDWORD pdwDisplacement, __inout PIMAGEHLP_SYMBOL Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymfromaddr BOOL IMAGEAPI SymGetSymFromAddr( HANDLE
// hProcess, DWORD dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_SYMBOL Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymFromAddr")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymFromAddr(HPROCESS hProcess, uint dwAddr, out uint pdwDisplacement, SafeIMAGEHLP_SYMBOL Symbol);
///
/// Locates the symbol for the specified address.
/// Note This function is provided only for compatibility. Applications should use SymFromAddr.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// TBD
/// The displacement from the beginning of the symbol, or zero.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymFromAddr64 function locates the symbol for a specified address. The modules are searched for the one the
/// address belongs to. When the module is found, its symbol table is searched for a match. When the symbol is found, the symbol
/// information is copied into the Symbol buffer provided by the caller. The caller must allocate the Symbol buffer properly and
/// fill in the required parameters in the IMAGEHLP_SYMBOL64 structure before calling SymGetSymFromAddr64.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetSymFromAddr function. For more information, see Updated Platform Support.
/// SymGetSymFromAddr is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymFromAddr SymGetSymFromAddr64 #else BOOL IMAGEAPI SymGetSymFromAddr( __in HANDLE hProcess, __in DWORD dwAddr, __out_opt PDWORD pdwDisplacement, __inout PIMAGEHLP_SYMBOL Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymfromaddr64 BOOL IMAGEAPI SymGetSymFromAddr64(
// HANDLE hProcess, DWORD64 qwAddr, PDWORD64 pdwDisplacement, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymFromAddr64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymFromAddr64(HPROCESS hProcess, ulong qwAddr, out ulong pdwDisplacement, SafeIMAGEHLP_SYMBOL64 Symbol);
///
/// Locates a symbol for the specified name.
/// Note This function is provided only for compatibility. Applications should use SymFromName.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// The symbol name for which a symbol is to be located.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymFromName64 function is used to locate a symbol for a specified name. The name can contain a module prefix
/// that isolates the symbol search to a single module's symbol table.
///
///
/// The module prefix is in the form of "module!". The "!" character is the delimiter between the module name and the symbol name.
/// If there is no module prefix, then the search is performed on each module's symbol table in a linear manner, beginning with the
/// first module that is loaded.
///
///
/// Using the module prefix is preferable for two reasons. First, the symbol search occurs much faster. Second, when deferred symbol
/// loading is turned on, the search causes symbols to be loaded for each module that is searched. When the symbol is found, the
/// symbol information is copied into the Symbol buffer provided by the caller. The caller must allocate the Symbol buffer properly
/// and fill in the required parameters in the IMAGEHLP_SYMBOL64 structure before calling SymGetSymFromName64.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetSymFromName function. For more information, see Updated Platform Support.
/// SymGetSymFromName is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymFromName SymGetSymFromName64 #else BOOL IMAGEAPI SymGetSymFromName( __in HANDLE hProcess, __in PCSTR Name, __inout PIMAGEHLP_SYMBOL Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymfromname BOOL IMAGEAPI SymGetSymFromName( HANDLE
// hProcess, PCSTR Name, PIMAGEHLP_SYMBOL Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymFromName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymFromName(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPStr)] string Name, SafeIMAGEHLP_SYMBOL Symbol);
///
/// Locates a symbol for the specified name.
/// Note This function is provided only for compatibility. Applications should use SymFromName.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// The symbol name for which a symbol is to be located.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymFromName64 function is used to locate a symbol for a specified name. The name can contain a module prefix
/// that isolates the symbol search to a single module's symbol table.
///
///
/// The module prefix is in the form of "module!". The "!" character is the delimiter between the module name and the symbol name.
/// If there is no module prefix, then the search is performed on each module's symbol table in a linear manner, beginning with the
/// first module that is loaded.
///
///
/// Using the module prefix is preferable for two reasons. First, the symbol search occurs much faster. Second, when deferred symbol
/// loading is turned on, the search causes symbols to be loaded for each module that is searched. When the symbol is found, the
/// symbol information is copied into the Symbol buffer provided by the caller. The caller must allocate the Symbol buffer properly
/// and fill in the required parameters in the IMAGEHLP_SYMBOL64 structure before calling SymGetSymFromName64.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymGetSymFromName function. For more information, see Updated Platform Support.
/// SymGetSymFromName is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymFromName SymGetSymFromName64 #else BOOL IMAGEAPI SymGetSymFromName( __in HANDLE hProcess, __in PCSTR Name, __inout PIMAGEHLP_SYMBOL Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymfromname64 BOOL IMAGEAPI SymGetSymFromName64(
// HANDLE hProcess, PCSTR Name, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymFromName64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymFromName64(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPStr)] string Name, SafeIMAGEHLP_SYMBOL64 Symbol);
///
/// Retrieves the symbol information for the next symbol.
/// Note This function is provided only for compatibility. Applications should use SymNext.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymNext64 function requires that the IMAGEHLP_SYMBOL64 structure have valid data, presumably obtained from a
/// call to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled with the symbol information for the
/// next symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymNextW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymNext function. For more information, see Updated Platform Support.
/// SymGetSymNext is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymNext SymGetSymNext64 #define SymGetSymNextW SymGetSymNextW64 #else BOOL IMAGEAPI SymGetSymNext( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymNextW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymnext BOOL IMAGEAPI SymGetSymNext( HANDLE hProcess,
// PIMAGEHLP_SYMBOL Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymNext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymNext(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL Symbol);
///
/// Retrieves the symbol information for the next symbol.
/// Note This function is provided only for compatibility. Applications should use SymNext.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymNext64 function requires that the IMAGEHLP_SYMBOL64 structure have valid data, presumably obtained from a
/// call to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled with the symbol information for the
/// next symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymNextW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymNext function. For more information, see Updated Platform Support.
/// SymGetSymNext is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymNext SymGetSymNext64 #define SymGetSymNextW SymGetSymNextW64 #else BOOL IMAGEAPI SymGetSymNext( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymNextW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymnext64 BOOL IMAGEAPI SymGetSymNext64( HANDLE
// hProcess, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymNext64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymNext64(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL64 Symbol);
///
/// Retrieves the symbol information for the next symbol.
/// Note This function is provided only for compatibility. Applications should use SymNext.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymNext64 function requires that the IMAGEHLP_SYMBOL64 structure have valid data, presumably obtained from a
/// call to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled with the symbol information for the
/// next symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymNextW64 is defined as
/// follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymNextW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymNext function. For more information, see Updated Platform Support.
/// SymGetSymNext is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymNext SymGetSymNext64 #define SymGetSymNextW SymGetSymNextW64 #else BOOL IMAGEAPI SymGetSymNext( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymNextW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymnext64 BOOL IMAGEAPI SymGetSymNext64( HANDLE
// hProcess, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymNext64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymNextW64(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL64 Symbol);
///
/// Retrieves the symbol information for the previous symbol.
/// Note This function is provided only for compatibility. Applications should use SymPrev.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymPrev64 function requires the IMAGEHLP_SYMBOL64 structure to have valid data, presumably obtained from a call
/// to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled in with the symbol information for the
/// previous symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymPrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymPrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymPrev function. For more information, see Updated Platform Support.
/// SymGetSymPrev is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymPrev SymGetSymPrev64 #define SymGetSymPrevW SymGetSymPrevW64 #else BOOL IMAGEAPI SymGetSymPrev( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymPrevW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymprev BOOL IMAGEAPI SymGetSymPrev( HANDLE hProcess,
// PIMAGEHLP_SYMBOL Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymPrev")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymPrev(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL Symbol);
///
/// Retrieves the symbol information for the previous symbol.
/// Note This function is provided only for compatibility. Applications should use SymPrev.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymPrev64 function requires the IMAGEHLP_SYMBOL64 structure to have valid data, presumably obtained from a call
/// to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled in with the symbol information for the
/// previous symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymPrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymPrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymPrev function. For more information, see Updated Platform Support.
/// SymGetSymPrev is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymPrev SymGetSymPrev64 #define SymGetSymPrevW SymGetSymPrevW64 #else BOOL IMAGEAPI SymGetSymPrev( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymPrevW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymprev64 BOOL IMAGEAPI SymGetSymPrev64( HANDLE
// hProcess, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymPrev64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymPrev64(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL64 Symbol);
///
/// Retrieves the symbol information for the previous symbol.
/// Note This function is provided only for compatibility. Applications should use SymPrev.
///
/// A handle to the process that was originally passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_SYMBOL64 structure.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymGetSymPrev64 function requires the IMAGEHLP_SYMBOL64 structure to have valid data, presumably obtained from a call
/// to the SymGetSymFromAddr64 or SymGetSymFromName64 function. This structure is filled in with the symbol information for the
/// previous symbol in sequence by virtual address.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymGetSymPrevW64 is defined as follows in DbgHelp.h.
///
///
/// BOOL IMAGEAPI SymGetSymPrevW64( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW64 Symbol );
///
///
/// This function supersedes the SymGetSymPrev function. For more information, see Updated Platform Support.
/// SymGetSymPrev is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymGetSymPrev SymGetSymPrev64 #define SymGetSymPrevW SymGetSymPrevW64 #else BOOL IMAGEAPI SymGetSymPrev( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOL Symbol ); BOOL IMAGEAPI SymGetSymPrevW( __in HANDLE hProcess, __inout PIMAGEHLP_SYMBOLW Symbol ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgetsymprev64 BOOL IMAGEAPI SymGetSymPrev64( HANDLE
// hProcess, PIMAGEHLP_SYMBOL64 Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetSymPrev64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetSymPrevW64(HPROCESS hProcess, SafeIMAGEHLP_SYMBOL64 Symbol);
/// Retrieves a type index for the specified type name.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The name of the type.
/// A pointer to a SYMBOL_INFO structure. The TypeIndex member contains the type index.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// To retrieve information about the type, pass the type index to the SymGetTypeInfo function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgettypefromname BOOL IMAGEAPI SymGetTypeFromName( HANDLE
// hProcess, ULONG64 BaseOfDll, PCSTR Name, PSYMBOL_INFO Symbol );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetTypeFromName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetTypeFromName(HPROCESS hProcess, ulong BaseOfDll, [MarshalAs(UnmanagedType.LPTStr)] string Name, ref SYMBOL_INFO Symbol);
/// Retrieves type information for the specified type index. For larger queries, use the SymGetTypeInfoEx function.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// The type index. (A number of functions return a type index in the TypeIndex member of the SYMBOL_INFO structure.)
///
///
/// The information type. This parameter can be one of more of the values from the IMAGEHLP_SYMBOL_TYPE_INFO enumeration type.
///
/// The data. The format of the data depends on the value of the GetType parameter.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// For more details on the type information, see the documentation for the PDB format.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgettypeinfo BOOL IMAGEAPI SymGetTypeInfo( HANDLE
// hProcess, DWORD64 ModBase, ULONG TypeId, IMAGEHLP_SYMBOL_TYPE_INFO GetType, PVOID pInfo );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetTypeInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetTypeInfo(HPROCESS hProcess, ulong ModBase, uint TypeId, IMAGEHLP_SYMBOL_TYPE_INFO GetType, [Out] IntPtr pInfo);
/// Retrieves multiple pieces of type information.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
///
/// A pointer to an IMAGEHLP_GET_TYPE_INFO_PARAMS structure that specifies input and output information for the query.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symgettypeinfoex BOOL IMAGEAPI SymGetTypeInfoEx( HANDLE
// hProcess, DWORD64 ModBase, PIMAGEHLP_GET_TYPE_INFO_PARAMS Params );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymGetTypeInfoEx")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymGetTypeInfoEx(HPROCESS hProcess, ulong ModBase, ref IMAGEHLP_GET_TYPE_INFO_PARAMS Params);
/// Initializes the symbol handler for a process.
///
///
/// A handle that identifies the caller. This value should be unique and nonzero, but need not be a process handle. However, if you
/// do use a process handle, be sure to use the correct handle. If the application is a debugger, use the process handle for the
/// process being debugged. Do not use the handle returned by GetCurrentProcess when debugging another process, because calling
/// functions like SymLoadModuleEx can have unexpected results.
///
/// This parameter cannot be NULL.
///
///
///
/// The path, or series of paths separated by a semicolon (;), that is used to search for symbol files. If this parameter is
/// NULL, the library attempts to form a symbol path from the following sources:
///
///
/// -
/// The current working directory of the application
///
/// -
/// The _NT_SYMBOL_PATH environment variable
///
/// -
/// The _NT_ALTERNATE_SYMBOL_PATH environment variable
///
///
/// Note that the search path can also be set using the
/// SymSetSearchPath
/// function.
///
///
/// If this value is TRUE, enumerates the loaded modules for the process and effectively calls the SymLoadModule64 function
/// for each module.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymInitialize function is used to initialize the symbol handler for a process. In the context of the symbol handler,
/// a process is a convenient object to use when collecting symbol information. Usually, symbol handlers are used by debuggers and
/// other tools that need to load symbols for a process being debugged.
///
///
/// The handle passed to SymInitialize must be the same value passed to all other symbol handler functions called by the
/// process. It is the handle that the functions use to identify the caller and locate the correct symbol information. When you have
/// finished using the symbol information, call the SymCleanup function to deallocate all resources associated with the process for
/// which symbols are loaded.
///
///
/// The search for symbols files is performed recursively for all paths specified in the UserSearchPath parameter. Therefore, if you
/// specify the root directory in a search, the whole drive is searched, which can take significant time. Note that the directory
/// that contains the executable file for the process is not automatically part of the search path. To include this directory in the
/// search path, call the GetModuleFileNameEx function, then add the path returned to UserSearchPath.
///
///
/// A process that calls SymInitialize should not call it again unless it calls SymCleanup first. If the call to
/// SymInitialize set fInvadeProcess to TRUE and you simply need to reload the module list, use the
/// SymRefreshModuleList function.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, call SymInitialize only when your process
/// starts and SymCleanup only when your process ends. It is not necessary for each thread in the process to call these functions.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Initializing the Symbol Handler.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize BOOL IMAGEAPI SymInitialize( HANDLE hProcess,
// PCSTR UserSearchPath, BOOL fInvadeProcess );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymInitialize")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymInitialize(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string UserSearchPath, [MarshalAs(UnmanagedType.Bool)] bool fInvadeProcess);
///
/// Loads the symbol table.
/// This function has been superseded by the SymLoadModuleEx function.
///
/// A handle to the process. This handle must have been previously passed to the SymInitialize function.
///
/// A handle to the file for the executable image. This argument is used mostly by debuggers, where the debugger passes the file
/// handle obtained from a debugging event. A value of NULL indicates that hFile is not used.
///
///
/// The name of the executable image. This name can contain a partial path, a full path, or no path at all. If the file cannot be
/// located by the name provided, the symbol search path is used.
///
///
/// A shortcut name for the module. If the pointer value is NULL, the library creates a name using the base name of the
/// symbol file.
///
///
///
/// The load address of the module. If the value is zero, the library obtains the load address from the symbol file. The load
/// address contained in the symbol file is not necessarily the actual load address. Debuggers and other applications having an
/// actual load address should use the real load address when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
///
/// The size of the module, in bytes. If the value is zero, the library obtains the size from the symbol file. The size contained in
/// the symbol file is not necessarily the actual size. Debuggers and other applications having an actual size should use the real
/// size when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
/// If the function succeeds, the return value is the base address of the loaded module.
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
/// If the module is already loaded, the return value is zero and GetLastError returns ERROR_SUCCESS.
///
///
///
/// The symbol handler creates an entry for the module and if the deferred symbol loading option is turned off, an attempt is made
/// to load the symbols. If deferred symbol loading is enabled, the module is marked as deferred and the symbols are not loaded
/// until a reference is made to a symbol in the module.
///
/// To unload the symbol table, use the SymUnloadModule64 function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymLoadModule function. For more information, see Updated Platform Support.
/// SymLoadModule is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymLoadModule SymLoadModule64 #else DWORD IMAGEAPI SymLoadModule( __in HANDLE hProcess, __in_opt HANDLE hFile, __in_opt PCSTR ImageName, __in_opt PCSTR ModuleName, __in DWORD BaseOfDll, __in DWORD SizeOfDll ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symloadmodule DWORD IMAGEAPI SymLoadModule( HANDLE
// hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD BaseOfDll, DWORD SizeOfDll );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymLoadModule")]
public static extern uint SymLoadModule(HPROCESS hProcess, [Optional] HFILE hFile, [Optional, MarshalAs(UnmanagedType.LPStr)] string ImageName,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string ModuleName, uint BaseOfDll, uint SizeOfDll);
///
/// Loads the symbol table.
/// This function has been superseded by the SymLoadModuleEx function.
///
/// A handle to the process. This handle must have been previously passed to the SymInitialize function.
///
/// A handle to the file for the executable image. This argument is used mostly by debuggers, where the debugger passes the file
/// handle obtained from a debugging event. A value of NULL indicates that hFile is not used.
///
///
/// The name of the executable image. This name can contain a partial path, a full path, or no path at all. If the file cannot be
/// located by the name provided, the symbol search path is used.
///
///
/// A shortcut name for the module. If the pointer value is NULL, the library creates a name using the base name of the
/// symbol file.
///
///
///
/// The load address of the module. If the value is zero, the library obtains the load address from the symbol file. The load
/// address contained in the symbol file is not necessarily the actual load address. Debuggers and other applications having an
/// actual load address should use the real load address when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
///
/// The size of the module, in bytes. If the value is zero, the library obtains the size from the symbol file. The size contained in
/// the symbol file is not necessarily the actual size. Debuggers and other applications having an actual size should use the real
/// size when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
/// If the function succeeds, the return value is the base address of the loaded module.
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
/// If the module is already loaded, the return value is zero and GetLastError returns ERROR_SUCCESS.
///
///
///
/// The symbol handler creates an entry for the module and if the deferred symbol loading option is turned off, an attempt is made
/// to load the symbols. If deferred symbol loading is enabled, the module is marked as deferred and the symbols are not loaded
/// until a reference is made to a symbol in the module.
///
/// To unload the symbol table, use the SymUnloadModule64 function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymLoadModule function. For more information, see Updated Platform Support.
/// SymLoadModule is defined as follows in DbgHelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymLoadModule SymLoadModule64 #else DWORD IMAGEAPI SymLoadModule( __in HANDLE hProcess, __in_opt HANDLE hFile, __in_opt PCSTR ImageName, __in_opt PCSTR ModuleName, __in DWORD BaseOfDll, __in DWORD SizeOfDll ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symloadmodule64 DWORD64 IMAGEAPI SymLoadModule64( HANDLE
// hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymLoadModule64")]
public static extern ulong SymLoadModule64(HPROCESS hProcess, [Optional] HFILE hFile, [Optional, MarshalAs(UnmanagedType.LPStr)] string ImageName,
[Optional, MarshalAs(UnmanagedType.LPStr)] string ModuleName, ulong BaseOfDll, uint SizeOfDll);
/// Loads the symbol table for the specified module.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// A handle to the file for the executable image. This argument is used mostly by debuggers, where the debugger passes the file
/// handle obtained from a debugging event. A value of NULL indicates that hFile is not used.
///
///
/// The name of the executable image. This name can contain a partial path, a full path, or no path at all. If the file cannot be
/// located by the name provided, the symbol search path is used.
///
///
/// A shortcut name for the module. If the pointer value is NULL, the library creates a name using the base name of the
/// symbol file.
///
///
///
/// The load address of the module. If the value is zero, the library obtains the load address from the symbol file. The load
/// address contained in the symbol file is not necessarily the actual load address. Debuggers and other applications having an
/// actual load address should use the real load address when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
///
/// The size of the module, in bytes. If the value is zero, the library obtains the size from the symbol file. The size contained in
/// the symbol file is not necessarily the actual size. Debuggers and other applications having an actual size should use the real
/// size when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
/// A pointer to a MODLOAD_DATA structure that represents headers other than the standard PE header. This parameter is optional and
/// can be NULL.
///
///
///
/// This parameter can be zero or one or more of the following values. If this parameter is zero, the function loads the modules and
/// the symbols for the module.
///
///
///
/// Value
/// Meaning
///
/// -
/// SLMFLAG_NO_SYMBOLS 0x4
/// Loads the module but not the symbols for the module.
///
/// -
/// SLMFLAG_VIRTUAL 0x1
///
/// Creates a virtual module named ModuleName at the address specified in BaseOfDll. To add symbols to this module, call the
/// SymAddSymbol function.
///
///
///
///
///
/// If the function succeeds, the return value is the base address of the loaded module.
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
/// If the module is already loaded, the return value is zero and GetLastError returns ERROR_SUCCESS.
///
///
///
/// The symbol handler creates an entry for the module and if the deferred symbol loading option is turned off, an attempt is made
/// to load the symbols. If deferred symbol loading is enabled, the module is marked as deferred and the symbols are not loaded
/// until a reference is made to a symbol in the module. Therefore, you should always call the SymGetModuleInfo64 function after
/// calling SymLoadModuleEx.
///
/// To unload the symbol table, use the SymUnloadModule64 function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Loading a Symbol Module.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symloadmoduleex DWORD64 IMAGEAPI SymLoadModuleEx( HANDLE
// hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymLoadModuleEx")]
public static extern ulong SymLoadModuleEx(HPROCESS hProcess, [Optional] HFILE hFile, [Optional, MarshalAs(UnmanagedType.LPTStr)] string ImageName,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string ModuleName, ulong BaseOfDll, uint DllSize, in MODLOAD_DATA Data, [Optional] SLMFLAG Flags);
/// Loads the symbol table for the specified module.
/// A handle to the process that was originally passed to the SymInitialize function.
///
/// A handle to the file for the executable image. This argument is used mostly by debuggers, where the debugger passes the file
/// handle obtained from a debugging event. A value of NULL indicates that hFile is not used.
///
///
/// The name of the executable image. This name can contain a partial path, a full path, or no path at all. If the file cannot be
/// located by the name provided, the symbol search path is used.
///
///
/// A shortcut name for the module. If the pointer value is NULL, the library creates a name using the base name of the
/// symbol file.
///
///
///
/// The load address of the module. If the value is zero, the library obtains the load address from the symbol file. The load
/// address contained in the symbol file is not necessarily the actual load address. Debuggers and other applications having an
/// actual load address should use the real load address when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
///
/// The size of the module, in bytes. If the value is zero, the library obtains the size from the symbol file. The size contained in
/// the symbol file is not necessarily the actual size. Debuggers and other applications having an actual size should use the real
/// size when calling this function.
///
/// If the image is a .pdb file, this parameter cannot be zero.
///
///
/// A pointer to a MODLOAD_DATA structure that represents headers other than the standard PE header. This parameter is optional and
/// can be NULL.
///
///
///
/// This parameter can be zero or one or more of the following values. If this parameter is zero, the function loads the modules and
/// the symbols for the module.
///
///
///
/// Value
/// Meaning
///
/// -
/// SLMFLAG_NO_SYMBOLS 0x4
/// Loads the module but not the symbols for the module.
///
/// -
/// SLMFLAG_VIRTUAL 0x1
///
/// Creates a virtual module named ModuleName at the address specified in BaseOfDll. To add symbols to this module, call the
/// SymAddSymbol function.
///
///
///
///
///
/// If the function succeeds, the return value is the base address of the loaded module.
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
/// If the module is already loaded, the return value is zero and GetLastError returns ERROR_SUCCESS.
///
///
///
/// The symbol handler creates an entry for the module and if the deferred symbol loading option is turned off, an attempt is made
/// to load the symbols. If deferred symbol loading is enabled, the module is marked as deferred and the symbols are not loaded
/// until a reference is made to a symbol in the module. Therefore, you should always call the SymGetModuleInfo64 function after
/// calling SymLoadModuleEx.
///
/// To unload the symbol table, use the SymUnloadModule64 function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
/// Examples
/// For an example, see Loading a Symbol Module.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symloadmoduleex DWORD64 IMAGEAPI SymLoadModuleEx( HANDLE
// hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymLoadModuleEx")]
public static extern ulong SymLoadModuleEx(HPROCESS hProcess, [Optional] HFILE hFile, [Optional, MarshalAs(UnmanagedType.LPTStr)] string ImageName,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string ModuleName, [Optional] ulong BaseOfDll, [Optional] uint DllSize, [In, Optional] IntPtr Data,
[Optional] SLMFLAG Flags);
/// Compares a string to a file name and path.
/// The file name to be compared to the Match parameter.
/// The string to be compared to the FileName parameter.
///
/// A pointer to a string buffer that receives a pointer to the location in FileName where matching stopped. For a complete match,
/// this value can be one character before FileName. This value can also be NULL.
///
///
/// A pointer to a string buffer that receives a pointer to the location in Match where matching stopped. For a complete match, this
/// value may be one character before Match. This value may be NULL.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// Because the match string can be a suffix of the complete file name, this function can be used to match a plain file name to a
/// fully qualified file name.
///
///
/// Matching begins from the end of both strings and proceeds backward. Matching is case-insensitive and equates a backslash ('')
/// with a forward slash ('/').
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symmatchfilename BOOL IMAGEAPI SymMatchFileName( PCSTR
// FileName, PCSTR Match, PSTR *FileNameStop, PSTR *MatchStop );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymMatchFileName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymMatchFileName([MarshalAs(UnmanagedType.LPTStr)] string FileName, [MarshalAs(UnmanagedType.LPTStr)] string Match,
out StrPtrAuto FileNameStop, out StrPtrAuto MatchStop);
/// Compares the specified string to the specified wildcard expression.
/// The string, such as a symbol name, to be compared to the expression parameter.
///
/// The wildcard expression to compare to the string parameter. The wildcard expression supports the inclusion of the * and ?
/// characters. * matches any string and ? matches any single character.
///
/// A variable that indicates whether or not the comparison is to be case sensitive.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symmatchstring BOOL IMAGEAPI SymMatchString( PCSTR string,
// PCSTR expression, BOOL fCase );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymMatchString")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymMatchString([MarshalAs(UnmanagedType.LPTStr)] string @string, [MarshalAs(UnmanagedType.LPTStr)] string expression,
[MarshalAs(UnmanagedType.Bool)] bool fCase);
/// Retrieves symbol information for the next symbol.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// A pointer to a SYMBOL_INFO structure that provides information about the current symbol. Upon return, the structure contains
/// information about the next symbol.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function requires that the SYMBOL_INFO structure have valid data for the current symbol. The next symbol is the symbol with
/// the virtual address that is next in the sequence.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symnext BOOL IMAGEAPI SymNext( HANDLE hProcess,
// PSYMBOL_INFO si );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymNext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymNext(HPROCESS hProcess, ref SYMBOL_INFO si);
/// Retrieves symbol information for the previous symbol.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// A pointer to a SYMBOL_INFO structure that provides information about the current symbol. Upon return, the structure contains
/// information about the previous symbol.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function requires that the SYMBOL_INFO structure have valid data for the current symbol. The previous symbol is the symbol
/// with a virtual address that immediately precedes this symbol.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symprev BOOL IMAGEAPI SymPrev( HANDLE hProcess,
// PSYMBOL_INFO si );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymPrev")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymPrev(HPROCESS hProcess, ref SYMBOL_INFO si);
/// Queries an inline trace.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The start address.
/// Contains the context of the start of block.
/// Contains the return address of the start of the current block/
/// Contains the current address.
/// Address of a DWORD that receives the current context.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
/// None
///
/// Either the StartAddress or StartRetAddress parameters must be within the same function scope as the CurAddress parameter. The
/// former indicates a step-over within the same function and the latter indicates a step-over from StartAddress.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symqueryinlinetrace BOOL IMAGEAPI SymQueryInlineTrace(
// HANDLE hProcess, DWORD64 StartAddress, DWORD StartContext, DWORD64 StartRetAddress, DWORD64 CurAddress, LPDWORD CurContext,
// LPDWORD CurFrameIndex );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymQueryInlineTrace")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymQueryInlineTrace(HPROCESS hProcess, ulong StartAddress, uint StartContext, ulong StartRetAddress, ulong CurAddress,
out uint CurContext, out uint CurFrameIndex);
/// Refreshes the module list for the process.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function enumerates the loaded modules for the process and effectively calls the SymLoadModule64 function for each module.
/// This same process is performed by SymInitialize if fInvadeProcess is TRUE.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symrefreshmodulelist BOOL IMAGEAPI SymRefreshModuleList(
// HANDLE hProcess );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRefreshModuleList")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRefreshModuleList(HPROCESS hProcess);
/// Registers a callback function for use by the symbol handler.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A SymRegisterCallbackProc64 callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymRegisterCallback64 function lets an application register a callback function for use by the symbol handler. The
/// symbol handler calls the registered callback function when there is status or progress information for the application.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymRegisterCallbackW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymRegisterCallbackW64( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, __in ULONG64 UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymRegisterCallback64 SymRegisterCallbackW64 #endif
///
///
/// This function supersedes the SymRegisterCallback function. For more information, see Updated Platform Support.
/// SymRegisterCallback is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymRegisterCallback SymRegisterCallback64 #else BOOL IMAGEAPI SymRegisterCallback( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction, __in_opt PVOID UserContext ); #endif
///
/// For a more extensive example, read Getting Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symregistercallback BOOL IMAGEAPI SymRegisterCallback(
// HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK CallbackFunction, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRegisterCallback")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRegisterCallback(HPROCESS hProcess, PSYMBOL_REGISTERED_CALLBACK CallbackFunction, IntPtr UserContext);
/// Registers a callback function for use by the symbol handler.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A SymRegisterCallbackProc64 callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymRegisterCallback64 function lets an application register a callback function for use by the symbol handler. The
/// symbol handler calls the registered callback function when there is status or progress information for the application.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymRegisterCallbackW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymRegisterCallbackW64( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, __in ULONG64 UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymRegisterCallback64 SymRegisterCallbackW64 #endif
///
///
/// This function supersedes the SymRegisterCallback function. For more information, see Updated Platform Support.
/// SymRegisterCallback is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymRegisterCallback SymRegisterCallback64 #else BOOL IMAGEAPI SymRegisterCallback( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction, __in_opt PVOID UserContext ); #endif
///
/// For a more extensive example, read Getting Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symregistercallback64 BOOL IMAGEAPI SymRegisterCallback64(
// HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRegisterCallback64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRegisterCallback64(HPROCESS hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext);
/// Registers a callback function for use by the symbol handler.
/// A handle to the process that was originally passed to the SymInitialize function.
/// A SymRegisterCallbackProc64 callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymRegisterCallback64 function lets an application register a callback function for use by the symbol handler. The
/// symbol handler calls the registered callback function when there is status or progress information for the application.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR. SymRegisterCallbackW64 is defined as
/// follows in Dbghelp.h.
///
///
/// BOOL IMAGEAPI SymRegisterCallbackW64( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, __in ULONG64 UserContext ); #ifdef DBGHELP_TRANSLATE_TCHAR #define SymRegisterCallback64 SymRegisterCallbackW64 #endif
///
///
/// This function supersedes the SymRegisterCallback function. For more information, see Updated Platform Support.
/// SymRegisterCallback is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymRegisterCallback SymRegisterCallback64 #else BOOL IMAGEAPI SymRegisterCallback( __in HANDLE hProcess, __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction, __in_opt PVOID UserContext ); #endif
///
/// For a more extensive example, read Getting Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symregistercallbackw64 BOOL IMAGEAPI
// SymRegisterCallbackW64( HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRegisterCallbackW64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRegisterCallbackW64(HPROCESS hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext);
/// Registers a callback function for use by the stack walking procedure on Alpha computers.
/// A handle to the process that was originally passed to the StackWalk64 function.
/// A SymRegisterFunctionEntryCallbackProc64 callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymRegisterFunctionEntryCallback64 function lets an application register a callback function for use by the stack
/// walking procedure. The stack walking procedure calls the registered callback function when it is unable to locate a function
/// table entry for an address. In most cases, the stack walking procedure locates the function table entries in the function table
/// of the image containing the address. However, in situations where the function table entries are not in the image, this callback
/// allows the debugger to provide the function table entry from another source. For example, run-time generated code on Alpha
/// computers can define dynamic function tables to support exception handling and stack tracing.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymRegisterFunctionEntryCallback function. For more information, see Updated Platform
/// Support. SymRegisterFunctionEntryCallback is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64 #else BOOL IMAGEAPI SymRegisterFunctionEntryCallback( __in HANDLE hProcess, __in PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, __in_opt PVOID UserContext ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symregisterfunctionentrycallback BOOL IMAGEAPI
// SymRegisterFunctionEntryCallback( HANDLE hProcess, PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, PVOID UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRegisterFunctionEntryCallback")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRegisterFunctionEntryCallback(HPROCESS hProcess, PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, IntPtr UserContext);
/// Registers a callback function for use by the stack walking procedure on Alpha computers.
/// A handle to the process that was originally passed to the StackWalk64 function.
/// A SymRegisterFunctionEntryCallbackProc64 callback function.
///
/// A user-defined value or NULL. This value is simply passed to the callback function. Normally, this parameter is used by
/// an application to pass a pointer to a data structure that lets the callback function establish some context.
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The SymRegisterFunctionEntryCallback64 function lets an application register a callback function for use by the stack
/// walking procedure. The stack walking procedure calls the registered callback function when it is unable to locate a function
/// table entry for an address. In most cases, the stack walking procedure locates the function table entries in the function table
/// of the image containing the address. However, in situations where the function table entries are not in the image, this callback
/// allows the debugger to provide the function table entry from another source. For example, run-time generated code on Alpha
/// computers can define dynamic function tables to support exception handling and stack tracing.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymRegisterFunctionEntryCallback function. For more information, see Updated Platform
/// Support. SymRegisterFunctionEntryCallback is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64 #else BOOL IMAGEAPI SymRegisterFunctionEntryCallback( __in HANDLE hProcess, __in PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, __in_opt PVOID UserContext ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symregisterfunctionentrycallback64 BOOL IMAGEAPI
// SymRegisterFunctionEntryCallback64( HANDLE hProcess, PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction, ULONG64 UserContext );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymRegisterFunctionEntryCallback64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymRegisterFunctionEntryCallback64(HPROCESS hProcess, PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction, ulong UserContext);
/// Searches for PDB symbols that meet the specified criteria.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The base address of the module. If this value is zero and Mask contains an exclamation point (!), the function looks across
/// modules. If this value is zero and Mask does not contain an exclamation point, the function uses the scope established by the
/// SymSetContext function.
///
/// A unique value for the symbol.
///
/// The PDB classification. These values are defined in Dbghelp.h in the SymTagEnum enumeration type. For descriptions, see
/// the PDB documentation.
///
///
/// A wildcard expression that indicates the names of the symbols to be enumerated. To specify a module name, use the !mod syntax.
///
/// The address of the symbol.
/// A SymEnumSymbolsProc callback function that receives the symbol information.
///
/// A user-defined value that is passed to the callback function, or NULL. This parameter is typically used by an application
/// to pass a pointer to a data structure that provides context for the callback function.
///
///
/// The options that control the behavior of this function.
///
///
/// Value
/// Meaning
///
/// -
/// SYMSEARCH_ALLITEMS 0x08
/// Include all symbols and other data in the .pdb files. DbgHelp 6.6 and earlier: This value is not supported.
///
/// -
/// SYMSEARCH_GLOBALSONLY 0x04
/// Search only for global symbols.
///
/// -
/// SYMSEARCH_MASKOBJS 0x01
/// For internal use only.
///
/// -
/// SYMSEARCH_RECURSE 0x02
/// Recurse from the top to find all symbols.
///
///
///
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsearch BOOL IMAGEAPI SymSearch( HANDLE hProcess, ULONG64
// BaseOfDll, DWORD Index, DWORD SymTag, PCSTR Mask, DWORD64 Address, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID
// UserContext, DWORD Options );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSearch")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSearch(HPROCESS hProcess, ulong BaseOfDll, [Optional] uint Index, [Optional] uint SymTag, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Mask,
[Optional] ulong Address, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, [In, Optional] IntPtr UserContext, SYMSEARCH Options);
/// Sets context information used by the SymEnumSymbols function. This function only works with PDB symbols.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// A pointer to an IMAGEHLP_STACK_FRAME structure that contains frame information.
/// This parameter is ignored.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// If you call SymSetContext to set the context to its current value, the function fails but GetLastError returns ERROR_SUCCESS.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetcontext BOOL IMAGEAPI SymSetContext( HANDLE hProcess,
// PIMAGEHLP_STACK_FRAME StackFrame, PIMAGEHLP_CONTEXT Context );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetContext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetContext(HPROCESS hProcess, in IMAGEHLP_STACK_FRAME StackFrame, [In, Optional] IntPtr Context);
/// Turns the specified extended symbol option on or off.
///
/// The extended symbol option to turn on or off. The following are valid values.
///
///
/// Value
/// Meaning
///
/// -
/// SYMOPT_EX_DISABLEACCESSTIMEUPDATE 0
///
/// When set to TRUE, turns off explicitly updating the last access time of a symbol that is loaded. By default, DbgHelp updates the
/// last access time of a symbol file that is consumed so that a symbol cache can be maintained by using a least recently used mechanism.
///
///
///
///
/// The value to set for the specified option, either TRUE or FALSE.
/// The previous value of the specified extended option.
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetextendedoption BOOL IMAGEAPI SymSetExtendedOption(
// IMAGEHLP_EXTENDED_OPTIONS option, BOOL value );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetExtendedOption")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetExtendedOption(IMAGEHLP_EXTENDED_OPTIONS option, [MarshalAs(UnmanagedType.Bool)] bool value);
/// Sets the home directory used by Dbghelp.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The home directory. This directory must be writable, otherwise the home directory is the common application directory specified
/// with CSIDL_COMMON_APPDATA. If this parameter is NULL, the function uses the default directory.
///
///
/// If the function succeeds, the return value is a pointer to the dir parameter.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
///
/// The default home directory is the directory in which Dbghelp.dll resides. Dbghelp uses this directory as a basis for other
/// directories, such as the default downstream store directory (the sym subdirectory of the home directory).
///
///
/// The home directory used for the default symbol store and the source server cache location is stored in the DBGHELP_HOMEDIR
/// environment variable.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsethomedirectory PCHAR IMAGEAPI SymSetHomeDirectory(
// HANDLE hProcess, PCSTR dir );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetHomeDirectory")]
public static extern StrPtrAuto SymSetHomeDirectory([Optional] HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string dir);
/// Sets the options mask.
///
///
/// The symbol options. Zero is a valid value and indicates that all options are turned off. The options values are combined using
/// the OR operator to form a valid options value. The following are valid values.
///
///
///
/// Value
/// Meaning
///
/// -
/// SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800
///
/// Enables the use of symbols that are stored with absolute addresses. Most symbols are stored as RVAs from the base of the module.
/// DbgHelp translates them to absolute addresses. There are symbols that are stored as an absolute address. These have very
/// specialized purposes and are typically not used. DbgHelp 5.1 and earlier: This value is not supported.
///
///
/// -
/// SYMOPT_ALLOW_ZERO_ADDRESS 0x01000000
/// Enables the use of symbols that do not have an address. By default, DbgHelp filters out symbols that do not have an address.
///
/// -
/// SYMOPT_AUTO_PUBLICS 0x00010000
///
/// Do not search the public symbols when searching for symbols by address, or when enumerating symbols, unless they were not found
/// in the global symbols or within the current scope. This option has no effect with SYMOPT_PUBLICS_ONLY. DbgHelp 5.1 and earlier:
/// This value is not supported.
///
///
/// -
/// SYMOPT_CASE_INSENSITIVE 0x00000001
/// All symbol searches are insensitive to case.
///
/// -
/// SYMOPT_DEBUG 0x80000000
/// Pass debug output through OutputDebugString or the SymRegisterCallbackProc64 callback function.
///
/// -
/// SYMOPT_DEFERRED_LOADS 0x00000004
///
/// Symbols are not loaded until a reference is made requiring the symbols be loaded. This is the fastest, most efficient way to use
/// the symbol handler.
///
///
/// -
/// SYMOPT_DISABLE_SYMSRV_AUTODETECT 0x02000000
///
/// Disables the auto-detection of symbol server stores in the symbol path, even without the "SRV*" designation, maintaining
/// compatibility with previous behavior. DbgHelp 6.6 and earlier: This value is not supported.
///
///
/// -
/// SYMOPT_EXACT_SYMBOLS 0x00000400
/// Do not load an unmatched .pdb file. Do not load export symbols if all else fails.
///
/// -
/// SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
///
/// Do not display system dialog boxes when there is a media failure such as no media in a drive. Instead, the failure happens silently.
///
///
/// -
/// SYMOPT_FAVOR_COMPRESSED 0x00800000
///
/// If there is both an uncompressed and a compressed file available, favor the compressed file. This option is good for slow connections.
///
///
/// -
/// SYMOPT_FLAT_DIRECTORY 0x00400000
/// Symbols are stored in the root directory of the default downstream store. DbgHelp 6.1 and earlier: This value is not supported.
///
/// -
/// SYMOPT_IGNORE_CVREC 0x00000080
/// Ignore path information in the CodeView record of the image header when loading a .pdb file.
///
/// -
/// SYMOPT_IGNORE_IMAGEDIR 0x00200000
/// Ignore the image directory. DbgHelp 6.1 and earlier: This value is not supported.
///
/// -
/// SYMOPT_IGNORE_NT_SYMPATH 0x00001000
///
/// Do not use the path specified by _NT_SYMBOL_PATH if the user calls SymSetSearchPath without a valid path. DbgHelp 5.1: This
/// value is not supported.
///
///
/// -
/// SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
/// When debugging on 64-bit Windows, include any 32-bit modules.
///
/// -
/// SYMOPT_LOAD_ANYTHING 0x00000040
/// Disable checks to ensure a file (.exe, .dbg., or .pdb) is the correct file. Instead, load the first file located.
///
/// -
/// SYMOPT_LOAD_LINES 0x00000010
/// Loads line number information.
///
/// -
/// SYMOPT_NO_CPP 0x00000008
///
/// All C++ decorated symbols containing the symbol separator "::" are replaced by "__". This option exists for debuggers that
/// cannot handle parsing real C++ symbol names.
///
///
/// -
/// SYMOPT_NO_IMAGE_SEARCH 0x00020000
///
/// Do not search the image for the symbol path when loading the symbols for a module if the module header cannot be read. DbgHelp
/// 5.1: This value is not supported.
///
///
/// -
/// SYMOPT_NO_PROMPTS 0x00080000
/// Prevents prompting for validation from the symbol server.
///
/// -
/// SYMOPT_NO_PUBLICS 0x00008000
///
/// Do not search the publics table for symbols. This option should have little effect because there are copies of the public
/// symbols in the globals table. DbgHelp 5.1: This value is not supported.
///
///
/// -
/// SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
///
/// Prevents symbols from being loaded when the caller examines symbols across multiple modules. Examine only the module whose
/// symbols have already been loaded.
///
///
/// -
/// SYMOPT_OVERWRITE 0x00100000
/// Overwrite the downlevel store from the symbol store. DbgHelp 6.1 and earlier: This value is not supported.
///
/// -
/// SYMOPT_PUBLICS_ONLY 0x00004000
///
/// Do not use private symbols. The version of DbgHelp that shipped with earlier Windows release supported only public symbols; this
/// option provides compatibility with this limitation. DbgHelp 5.1: This value is not supported.
///
///
/// -
/// SYMOPT_SECURE 0x00040000
///
/// DbgHelp will not load any symbol server other than SymSrv. SymSrv will not use the downstream store specified in
/// _NT_SYMBOL_PATH. After this flag has been set, it cannot be cleared. DbgHelp 6.0 and 6.1: This flag can be cleared. DbgHelp 5.1:
/// This value is not supported.
///
///
/// -
/// SYMOPT_UNDNAME 0x00000002
///
/// All symbols are presented in undecorated form. This option has no effect on global or local symbols because they are stored
/// undecorated. This option applies only to public symbols.
///
///
///
///
/// The function returns the current options mask.
///
///
/// The options value can be changed any number of times while the library is in use by an application. The option change affects
/// all future calls to the symbol handler.
///
/// To get the current options mask, call the SymGetOptions function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// Examples
/// For an example, see Initializing the Symbol Handler.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetoptions DWORD IMAGEAPI SymSetOptions( DWORD
// SymOptions );
[DllImport(Lib_DbgHelp, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetOptions")]
public static extern SYMOPT SymSetOptions(SYMOPT SymOptions);
/// Sets the window that the caller will use to display a user interface.
/// A handle to the window.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetparentwindow BOOL IMAGEAPI SymSetParentWindow( HWND
// hwnd );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetParentWindow")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetParentWindow(HWND hwnd);
/// Sets the local scope to the symbol that matches the specified address.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The address.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetscopefromaddr BOOL IMAGEAPI SymSetScopeFromAddr(
// HANDLE hProcess, ULONG64 Address );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetScopeFromAddr")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetScopeFromAddr(HPROCESS hProcess, ulong Address);
/// Sets the local scope to the symbol that matches the specified index.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The base address of the module.
/// The unique value for the symbol.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetscopefromindex BOOL IMAGEAPI SymSetScopeFromIndex(
// HANDLE hProcess, ULONG64 BaseOfDll, DWORD Index );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetScopeFromIndex")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetScopeFromIndex(HPROCESS hProcess, ulong BaseOfDll, uint Index);
/// Sets the local scope to the symbol that matches the specified address and inline context.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The address.
/// The inline context.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetscopefrominlinecontext BOOL IMAGEAPI
// SymSetScopeFromInlineContext( HANDLE hProcess, ULONG64 Address, ULONG InlineContext );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetScopeFromInlineContext")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetScopeFromInlineContext(HPROCESS hProcess, ulong Address, uint InlineContext);
/// Sets the search path for the specified process.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The symbol search path. The string can contain multiple paths separated by semicolons.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// The symbol search path can be changed any number of times while the library is in use by an application. The change affects all
/// future calls to the symbol handler.
///
/// To get the current search path, call the SymGetSearchPath function.
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetsearchpath BOOL IMAGEAPI SymSetSearchPath( HANDLE
// hProcess, PCSTR SearchPath );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSetSearchPath")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSetSearchPath(HPROCESS hProcess, [MarshalAs(UnmanagedType.LPTStr)] string SearchPath);
///
/// Generates the name for a file that describes the relationship between two different versions of the same symbol or image file.
/// Using this feature prevents applications from having to regenerate such information every time they analyze two files.
///
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The symbol path. The function uses only the symbol stores described in standard syntax for symbol stores. All other paths are
/// ignored. If this parameter is NULL, the function uses the symbol path set using the SymInitialize or SymSetSearchPath function.
///
/// The extension for the generated file name.
/// The path of the first version of the symbol or image file.
/// The path of the second version of the symbol or image file.
///
/// If the function succeeds, the return value is the resulting file name.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
///
/// This function opens the two specified files, reads the indexing information from the header, and passes this information to the
/// symbol server so it can create the file name. If you specify the Type parameter as "xml", the name is the index of File1,
/// followed by a dash, followed by the index of File2, followed by an .xml extension. For example:
///
/// 3F3D5C755000-3F3D647621000.xml
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvdeltaname PCSTR IMAGEAPI SymSrvDeltaName( HANDLE
// hProcess, PCSTR SymPath, PCSTR Type, PCSTR File1, PCSTR File2 );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvDeltaName")]
[return: MarshalAs(UnmanagedType.LPTStr)]
public static extern string SymSrvDeltaName(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SymPath,
[MarshalAs(UnmanagedType.LPTStr)] string Type, [MarshalAs(UnmanagedType.LPTStr)] string File1, [MarshalAs(UnmanagedType.LPTStr)] string File2);
///
/// Retrieves the indexes for the specified .pdb, .dbg, or image file that would be used to store the file. The combination of these
/// values uniquely identifies the file in the symbol server. They can be used when calling the SymFindFileInPath function to search
/// for a file in a symbol store.
///
/// The name of the file.
/// The first of three identifying parameters.
/// The second of three identifying parameters.
/// The third of three identifying parameters.
/// This parameter is reserved for future use.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvgetfileindexes BOOL IMAGEAPI SymSrvGetFileIndexes(
// PCSTR File, GUID *Id, PDWORD Val1, PDWORD Val2, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvGetFileIndexes")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSrvGetFileIndexes([MarshalAs(UnmanagedType.LPTStr)] string File, out Guid Id, out uint Val1, out uint Val2, uint Flags = 0);
/// Retrieves the index information for the specified .pdb, .dbg, or image file.
/// The name of the file.
/// A SYMSRV_INDEX_INFO structure that receives the index information.
/// This parameter is reserved for future use.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function is not for general use. Those writing utilities for the management of files in symbol server stores may use to
/// this function to predict the relative path the symbol server will look for a file. It is used by srctool.exe to actually
/// populate symbol server stores. It may also be of use to those looking to find the parameters to feed the SymFindFileInPath function.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvgetfileindexinfo BOOL IMAGEAPI
// SymSrvGetFileIndexInfo( PCSTR File, PSYMSRV_INDEX_INFO Info, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvGetFileIndexInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSrvGetFileIndexInfo([MarshalAs(UnmanagedType.LPTStr)] string File, ref SYMSRV_INDEX_INFO Info, uint Flags = 0);
/// Retrieves the index string for the specified .pdb, .dbg, or image file.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The path to the symbol server.
/// The name of the file.
/// A pointer to a buffer that receives the index string.
/// The size of the Index buffer, in characters.
/// This parameter is reserved for future use.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// This function is not for general use. Those writing utilities for the management of files in symbol server stores may use to
/// this function to predict the relative path the symbol server will look for a file. It is used by srctool.exe to actually
/// populate symbol server stores.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvgetfileindexstring BOOL IMAGEAPI
// SymSrvGetFileIndexString( HANDLE hProcess, PCSTR SrvPath, PCSTR File, PSTR Index, size_t Size, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvGetFileIndexString")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSrvGetFileIndexString(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SrvPath,
[MarshalAs(UnmanagedType.LPTStr)] string File, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder Index, SizeT Size, uint Flags = 0);
/// Retrieves the specified file from the supplement for a symbol store.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
///
/// The symbol path. The function uses only the symbol stores described in standard syntax for symbol stores. All other paths are
/// ignored. If this parameter is NULL, the function uses the symbol path set using the SymInitialize or SymSetSearchPath function.
///
/// The symbol file associated with the supplemental file.
/// The name of the file.
///
/// If the function succeeds, the return value is the fully qualified path for the supplemental file.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// For more information on supplemental files, see SymSrvStoreSupplement.
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvgetsupplement PCSTR IMAGEAPI SymSrvGetSupplement(
// HANDLE hProcess, PCSTR SymPath, PCSTR Node, PCSTR File );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvGetSupplement")]
[return: MarshalAs(UnmanagedType.LPTStr)]
public static extern string SymSrvGetSupplement(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SymPath,
[MarshalAs(UnmanagedType.LPTStr)] string Node, [MarshalAs(UnmanagedType.LPTStr)] string File);
/// Determines whether the specified path points to a symbol store.
///
/// The handle of a process that you previously passed to the SymInitialize function. If this parameter is set to NULL, the
/// function determines only whether the store exists; otherwise, the function determines whether the store exists and contains a
/// process entry for the specified process handle.
///
///
/// The path to a symbol store. The path can specify the default symbol store (for example, SRV*), point to an HTTP or HTTPS symbol
/// server, or specify a UNC, absolute, or relative path to the store.
///
///
/// If the path specifies a symbol store, the function returns TRUE. Otherwise, it returns FALSE. To get extended
/// error information, call the GetLastError function.
///
///
///
/// If the path points to the default symbol store (for example, SRV*) or to an HTTP or HTTPS symbol server, the function assumes
/// the store exists.
///
///
/// If there is a proxy computer between the client computer and the server, the version of the SymSrv.dll on the proxy cannot be
/// less than the version that is on the client.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvisstore BOOL IMAGEAPI SymSrvIsStore( HANDLE hProcess,
// PCSTR path );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvIsStore")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymSrvIsStore([Optional] HPROCESS hProcess, [MarshalAs(UnmanagedType.LPTStr)] string path);
/// Stores a file in the specified symbol store.
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// The symbol store.
/// The name of the file.
///
/// The flags that control the function. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SYMSTOREOPT_COMPRESS 0x01
/// Compress the file.
///
/// -
/// SYMSTOREOPT_OVERWRITE 0x02
/// Overwrite the file if it exists.
///
/// -
/// SYMSTOREOPT_PASS_IF_EXISTS 0x40
/// Do not report an error if the file already exists in the symbol store.
///
/// -
/// SYMSTOREOPT_POINTER 0x08
/// Store in File.ptr.
///
/// -
/// SYMSTOREOPT_RETURNINDEX 0x04
/// Return the index only.
///
///
///
///
///
/// If the function succeeds, the return value is a pointer to a null-terminated string that specifies the full-qualified path to
/// the stored file.
///
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvstorefile PCSTR IMAGEAPI SymSrvStoreFile( HANDLE
// hProcess, PCSTR SrvPath, PCSTR File, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvStoreFile")]
[return: MarshalAs(UnmanagedType.LPTStr)]
public static extern string SymSrvStoreFile(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SrvPath,
[MarshalAs(UnmanagedType.LPTStr)] string File, SYMSTOREOPT Flags);
///
/// Stores a file in the specified supplement to a symbol store. The file is typically associated with a file in the symbol server.
///
/// A handle to a process. This handle must have been previously passed to the SymInitialize function.
/// TBD
/// The symbol file associated with the supplemental file.
/// The name of the file.
///
/// If this parameter is SYMSTOREOPT_COMPRESS, the file is compressed in the symbol store. Currently, there are no other
/// supported values.
///
///
/// If the function succeeds, the return value is the fully qualified path for the supplemental file.
/// If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.
///
///
/// An important use for this function is to store delta files. For more information, see SymSrvDeltaName.
///
/// This function returns a pointer to a buffer that may be reused by another function. Therefore, be sure to copy the data returned
/// to another buffer immediately.
///
///
/// The symbol server stores supplemental files with the same extension in a common directory. For example, Sup1.xml would be stored
/// in the following directory: SymPath\supplement<i>Node\xml.
///
///
/// The administrator of a store can prevent users from writing supplemental files by creating a read-only file in the root of the
/// store named Supplement. Alternatively, the administrator can create the supplement directory and use ACLs to control access.
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
/// To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsrvstoresupplement PCSTR IMAGEAPI SymSrvStoreSupplement(
// HANDLE hProcess, PCSTR SrvPath, PCSTR Node, PCSTR File, DWORD Flags );
[DllImport(Lib_DbgHelp, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymSrvStoreSupplement")]
[return: MarshalAs(UnmanagedType.LPTStr)]
public static extern string SymSrvStoreSupplement(HPROCESS hProcess, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SrvPath,
[MarshalAs(UnmanagedType.LPTStr)] string Node, [MarshalAs(UnmanagedType.LPTStr)] string File, SYMSTOREOPT Flags);
///
/// Undecorates a decorated C++ symbol name.
/// Applications can also use the UnDecorateSymbolName function.
///
/// A pointer to an IMAGEHLP_SYMBOL64 structure that specifies the symbol to be undecorated.
/// A pointer to a buffer that receives the undecorated name.
/// The size of the UnDecName buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymUnDName function. For more information, see Updated Platform Support. SymUnDName
/// is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymUnDName SymUnDName64 #else BOOL IMAGEAPI SymUnDName( __in PIMAGEHLP_SYMBOL sym, __out_ecount(UnDecNameLength) PSTR UnDecName, __in DWORD UnDecNameLength ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symundname BOOL IMAGEAPI SymUnDName( PIMAGEHLP_SYMBOL sym,
// PSTR UnDecName, DWORD UnDecNameLength );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymUnDName")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymUnDName([In] SafeIMAGEHLP_SYMBOL sym, [Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder UnDecName, uint UnDecNameLength);
///
/// Undecorates a decorated C++ symbol name.
/// Applications can also use the UnDecorateSymbolName function.
///
/// A pointer to an IMAGEHLP_SYMBOL64 structure that specifies the symbol to be undecorated.
/// A pointer to a buffer that receives the undecorated name.
/// The size of the UnDecName buffer, in characters.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymUnDName function. For more information, see Updated Platform Support. SymUnDName
/// is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymUnDName SymUnDName64 #else BOOL IMAGEAPI SymUnDName( __in PIMAGEHLP_SYMBOL sym, __out_ecount(UnDecNameLength) PSTR UnDecName, __in DWORD UnDecNameLength ); #endif
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symundname64 BOOL IMAGEAPI SymUnDName64( PIMAGEHLP_SYMBOL64
// sym, PSTR UnDecName, DWORD UnDecNameLength );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymUnDName64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymUnDName64([In] SafeIMAGEHLP_SYMBOL64 sym, [Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder UnDecName, uint UnDecNameLength);
/// Unloads the symbol table.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The base address of the module that is to be unloaded.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymUnloadedModule function. For more information, see Updated Platform Support.
/// SymUnloadedModule is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymUnloadModule SymUnloadModule64 #else BOOL IMAGEAPI SymUnloadModule( __in HANDLE hProcess, __in DWORD BaseOfDll ); #endif
///
/// Examples
/// For an example, see Unloading a Symbol Module.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symunloadmodule BOOL IMAGEAPI SymUnloadModule( HANDLE
// hProcess, DWORD BaseOfDll );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymUnloadModule")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymUnloadModule(HPROCESS hProcess, uint BaseOfDll);
/// Unloads the symbol table.
/// A handle to the process that was originally passed to the SymInitialize function.
/// The base address of the module that is to be unloaded.
///
/// If the function succeeds, the return value is TRUE.
/// If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
///
///
///
/// All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will
/// likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more
/// than one thread to this function.
///
///
/// This function supersedes the SymUnloadedModule function. For more information, see Updated Platform Support.
/// SymUnloadedModule is defined as follows in Dbghelp.h.
///
///
/// #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) #define SymUnloadModule SymUnloadModule64 #else BOOL IMAGEAPI SymUnloadModule( __in HANDLE hProcess, __in DWORD BaseOfDll ); #endif
///
/// Examples
/// For an example, see Unloading a Symbol Module.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symunloadmodule64 BOOL IMAGEAPI SymUnloadModule64( HANDLE
// hProcess, DWORD64 BaseOfDll );
[DllImport(Lib_DbgHelp, SetLastError = true, ExactSpelling = true)]
[PInvokeData("dbghelp.h", MSDNShortId = "NF:dbghelp.SymUnloadModule64")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SymUnloadModule64(HPROCESS hProcess, ulong BaseOfDll);
///
/// A managed life-cycle symbol handler for a process which calls at construction and at disposal.
///
public class ProcessSymbolHandler : IDisposable
{
private HPROCESS hProc;
/// Initializes the symbol handler for a process.
///
///
/// A handle that identifies the caller. This value should be unique and nonzero, but need not be a process handle. However, if
/// you do use a process handle, be sure to use the correct handle. If the application is a debugger, use the process handle for
/// the process being debugged. Do not use the handle returned by GetCurrentProcess when debugging another process, because
/// calling functions like SymLoadModuleEx can have unexpected results.
///
/// This parameter cannot be .
///
///
///
/// The path, or series of paths separated by a semicolon (;), that is used to search for symbol files. If this parameter is
/// , the library attempts to form a symbol path from the following sources:
///
///
/// -
/// The current working directory of the application
///
/// -
/// The _NT_SYMBOL_PATH environment variable
///
/// -
/// The _NT_ALTERNATE_SYMBOL_PATH environment variable
///
///
/// Note that the search path can also be set using the function.
///
///
/// If this value is , enumerates the loaded modules for the process and effectively calls the
/// SymLoadModule64 function for each module.
///
public ProcessSymbolHandler(HPROCESS hProcess, string UserSearchPath = null, bool fInvadeProcess = true) =>
SymInitialize(hProc = hProcess, UserSearchPath, fInvadeProcess);
/// Performs an implicit conversion from to .
/// The instance.
/// The resulting instance from the conversion.
public static implicit operator HPROCESS(ProcessSymbolHandler h) => h.hProc;
/// Deallocates all resources associated with this process handle.
public void Dispose() => SymCleanup(hProc);
/// Refreshes the module list for the process.
public void RefreshModuleList() => SymRefreshModuleList(hProc);
}
}
}