ReactOS 0.4.15-dev-7961-gdcf9eb0
dbghelp.c File Reference
#include <unistd.h>
#include "dbghelp_private.h"
#include "winternl.h"
#include "winerror.h"
#include "psapi.h"
#include "wine/debug.h"
#include "wdbgexts.h"
#include "winnls.h"
Include dependency graph for dbghelp.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp)
 
BOOL WINAPI DllMain (HINSTANCE instance, DWORD reason, LPVOID reserved)
 
struct processprocess_find_by_handle (HANDLE hProcess)
 
BOOL validate_addr64 (DWORD64 addr)
 
voidfetch_buffer (struct process *pcs, unsigned size)
 
const charwine_dbgstr_addr (const ADDRESS64 *addr)
 
struct cpucpu_find (DWORD machine)
 
static WCHARmake_default_search_path (void)
 
BOOL WINAPI SymSetSearchPathW (HANDLE hProcess, PCWSTR searchPath)
 
BOOL WINAPI SymSetSearchPath (HANDLE hProcess, PCSTR searchPath)
 
BOOL WINAPI SymGetSearchPathW (HANDLE hProcess, PWSTR szSearchPath, DWORD SearchPathLength)
 
BOOL WINAPI SymGetSearchPath (HANDLE hProcess, PSTR szSearchPath, DWORD SearchPathLength)
 
static BOOL WINAPI process_invade_cb (PCWSTR name, ULONG64 base, ULONG size, PVOID user)
 
const WCHARprocess_getenv (const struct process *process, const WCHAR *name)
 
static BOOL check_live_target (struct process *pcs)
 
BOOL WINAPI SymInitializeW (HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess)
 
BOOL WINAPI SymInitialize (HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess)
 
BOOL WINAPI SymCleanup (HANDLE hProcess)
 
DWORD WINAPI SymSetOptions (DWORD opts)
 
DWORD WINAPI SymGetOptions (void)
 
BOOL WINAPI SymSetExtendedOption (IMAGEHLP_EXTENDED_OPTIONS option, BOOL value)
 
BOOL WINAPI SymGetExtendedOption (IMAGEHLP_EXTENDED_OPTIONS option)
 
BOOL WINAPI SymSetParentWindow (HWND hwnd)
 
BOOL WINAPI SymSetContext (HANDLE hProcess, PIMAGEHLP_STACK_FRAME StackFrame, PIMAGEHLP_CONTEXT Context)
 
static BOOL CALLBACK reg_cb64to32 (HANDLE hProcess, ULONG action, ULONG64 data, ULONG64 user)
 
BOOL pcs_callback (const struct process *pcs, ULONG action, void *data)
 
static BOOL sym_register_cb (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
 
BOOL WINAPI SymRegisterCallback (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK CallbackFunction, PVOID UserContext)
 
BOOL WINAPI SymRegisterCallback64 (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
 
BOOL WINAPI SymRegisterCallbackW64 (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
 
LPAPI_VERSION WINAPI ImagehlpApiVersion (VOID)
 
LPAPI_VERSION WINAPI ImagehlpApiVersionEx (LPAPI_VERSION AppVersion)
 
LPEXT_API_VERSION WINAPI ExtensionApiVersion (void)
 
void WINAPI WinDbgExtensionDllInit (PWINDBG_EXTENSION_APIS lpExtensionApis, unsigned short major, unsigned short minor)
 
DWORD calc_crc32 (HANDLE handle)
 

Variables

unsigned dbghelp_options = SYMOPT_UNDNAME
 
BOOL dbghelp_opt_native = FALSE
 
SYSTEM_INFO sysinfo
 
static struct processprocess_first
 
struct cpu cpu_i386 cpu_x86_64 cpu_arm cpu_arm64
 
static struct cpudbghelp_cpus [] = {&cpu_i386, &cpu_x86_64, &cpu_arm, &cpu_arm64, NULL}
 
struct cpudbghelp_current_cpu =
 
static API_VERSION api_version = { 4, 0, 2, 0 }
 

Function Documentation

◆ calc_crc32()

DWORD calc_crc32 ( HANDLE  handle)

Definition at line 874 of file dbghelp.c.

875{
876 BYTE buffer[8192];
877 DWORD crc = 0;
878 DWORD len;
879
881 while (ReadFile(handle, buffer, sizeof(buffer), &len, NULL) && len)
882 crc = RtlComputeCrc32(crc, buffer, len);
883 return crc;
884}
#define NULL
Definition: types.h:112
#define FILE_BEGIN
Definition: compat.h:761
#define RtlComputeCrc32
Definition: compat.h:810
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193

Referenced by elf_fetch_file_info(), elf_load_file_from_fmap(), image_check_debug_link(), macho_fetch_file_info(), and macho_load_file().

◆ check_live_target()

static BOOL check_live_target ( struct process pcs)
static

Definition at line 356 of file dbghelp.c.

357{
359 ULONG_PTR base = 0, env = 0;
360
361 if (!GetProcessId(pcs->handle)) return FALSE;
362 if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE;
363
365 &pbi, sizeof(pbi), NULL ))
366 return FALSE;
367
368 if (!pcs->is_64bit)
369 {
370 DWORD env32;
371 PEB32 peb32;
372 C_ASSERT(sizeof(void*) != 4 || FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment) == 0x48);
373 if (!ReadProcessMemory(pcs->handle, pbi.PebBaseAddress, &peb32, sizeof(peb32), NULL)) return FALSE;
374 base = peb32.Reserved[0];
375 if (read_process_memory(pcs, peb32.ProcessParameters + 0x48, &env32, sizeof(env32))) env = env32;
376 }
377 else
378 {
379 PEB peb;
380 if (!ReadProcessMemory(pcs->handle, pbi.PebBaseAddress, &peb, sizeof(peb), NULL)) return FALSE;
381 base = peb.Reserved[0];
383 }
384
385#ifdef __REACTOS__
386 /* Wine store their loader base address in peb.reserved[0] and load its symbol from there.
387 * ReactOS does not care about it, we are just happy if we managed to read the value */
388 base = 1;
389#endif
390
391 /* read debuggee environment block */
392 if (env)
393 {
394 size_t buf_size = 0, i, last_null = -1;
395 WCHAR *buf = NULL;
396
397 do
398 {
400 if (buf)
401 {
402 WCHAR *new_buf;
403 if (!(new_buf = realloc(buf, buf_size + read_size))) break;
404 buf = new_buf;
405 }
406 else if(!(buf = malloc(read_size))) break;
407
408 if (!read_process_memory(pcs, env, (char*)buf + buf_size, read_size)) break;
409 for (i = buf_size / sizeof(WCHAR); i < (buf_size + read_size) / sizeof(WCHAR); i++)
410 {
411 if (buf[i]) continue;
412 if (last_null + 1 == i)
413 {
414 pcs->environment = realloc(buf, (i + 1) * sizeof(WCHAR));
415 buf = NULL;
416 break;
417 }
418 last_null = i;
419 }
420 env += read_size;
421 buf_size += read_size;
422 }
423 while (buf);
424 free(buf);
425 }
426
427 if (!base) return FALSE;
428
429 TRACE("got debug info address %#lx from PEB %p\n", base, pbi.PebBaseAddress);
430#ifndef __REACTOS__
432 WARN("couldn't load process debug info at %#lx\n", base);
433#endif
434 return TRUE;
435}
#define WARN(fmt,...)
Definition: debug.h:112
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
static BOOL read_process_memory(const struct process *process, UINT64 addr, void *buf, size_t size)
BOOL elf_read_wine_loader_dbg_info(struct process *pcs, ULONG_PTR addr) DECLSPEC_HIDDEN
Definition: elf_module.c:1753
BOOL macho_read_wine_loader_dbg_info(struct process *pcs, ULONG_PTR addr) DECLSPEC_HIDDEN
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define GetProcessId(x)
Definition: compat.h:737
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:754
SYSTEM_INFO sysinfo
Definition: dbghelp.c:76
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ ProcessBasicInformation
Definition: winternl.h:394
#define C_ASSERT(e)
Definition: intsafe.h:73
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ProcessParameters
ULONG Reserved[2]
ULONG Reserved[2]
Definition: winternl.h:310
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
DWORD dwAllocationGranularity
Definition: winbase.h:1179
WCHAR * environment
HANDLE handle
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by SymInitializeW().

◆ cpu_find()

struct cpu * cpu_find ( DWORD  machine)

Definition at line 183 of file dbghelp.c.

184{
185 struct cpu** cpu;
186
187 for (cpu = dbghelp_cpus ; *cpu; cpu++)
188 {
189 if (cpu[0]->machine == machine) return cpu[0];
190 }
191 return NULL;
192}
static struct cpu * dbghelp_cpus[]
Definition: dbghelp.c:164
static const char machine[]
Definition: profile.c:104

Referenced by StackWalk(), and StackWalk64().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  instance,
DWORD  reason,
LPVOID  reserved 
)

Definition at line 82 of file dbghelp.c.

83{
84 switch (reason)
85 {
89 break;
90 }
91 return TRUE;
92}
static HINSTANCE instance
Definition: main.c:40
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143

◆ ExtensionApiVersion()

LPEXT_API_VERSION WINAPI ExtensionApiVersion ( void  )

Definition at line 860 of file dbghelp.c.

861{
862 static EXT_API_VERSION eav = {5, 5, 5, 0};
863 return &eav;
864}

◆ fetch_buffer()

void * fetch_buffer ( struct process pcs,
unsigned  size 
)

Definition at line 128 of file dbghelp.c.

129{
130 if (size > pcs->buffer_size)
131 {
132 if (pcs->buffer)
133 pcs->buffer = HeapReAlloc(GetProcessHeap(), 0, pcs->buffer, size);
134 else
135 pcs->buffer = HeapAlloc(GetProcessHeap(), 0, size);
136 pcs->buffer_size = (pcs->buffer) ? size : 0;
137 }
138 return pcs->buffer;
139}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
GLsizeiptr size
Definition: glext.h:5919
void * buffer
unsigned buffer_size

Referenced by copy_line_W64_from_64(), and symt_fill_func_line_info().

◆ ImagehlpApiVersion()

LPAPI_VERSION WINAPI ImagehlpApiVersion ( VOID  )

Definition at line 837 of file dbghelp.c.

838{
839 return &api_version;
840}
static API_VERSION api_version
Definition: dbghelp.c:832

Referenced by init_dbghelp_version().

◆ ImagehlpApiVersionEx()

LPAPI_VERSION WINAPI ImagehlpApiVersionEx ( LPAPI_VERSION  AppVersion)

Definition at line 845 of file dbghelp.c.

846{
847 if (!AppVersion) return NULL;
848
851 AppVersion->Revision = api_version.Revision;
852 AppVersion->Reserved = api_version.Reserved;
853
854 return AppVersion;
855}
USHORT MajorVersion
Definition: compat.h:1571
USHORT Revision
Definition: compat.h:1573
USHORT Reserved
Definition: compat.h:1574
USHORT MinorVersion
Definition: compat.h:1572

◆ make_default_search_path()

static WCHAR * make_default_search_path ( void  )
static

Definition at line 194 of file dbghelp.c.

195{
196 WCHAR* search_path;
197 WCHAR* p;
198 unsigned sym_path_len;
199 unsigned alt_sym_path_len;
200
201 sym_path_len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0);
202 alt_sym_path_len = GetEnvironmentVariableW(L"_NT_ALT_SYMBOL_PATH", NULL, 0);
203
204 /* The default symbol path is ".[;%_NT_SYMBOL_PATH%][;%_NT_ALT_SYMBOL_PATH%]".
205 * If the variables exist, the lengths include a null-terminator. We use that
206 * space for the semicolons, and only add the initial dot and the final null. */
207 search_path = HeapAlloc(GetProcessHeap(), 0,
208 (1 + sym_path_len + alt_sym_path_len + 1) * sizeof(WCHAR));
209 if (!search_path) return NULL;
210
211 p = search_path;
212 *p++ = L'.';
213 if (sym_path_len)
214 {
215 *p++ = L';';
216 GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", p, sym_path_len);
217 p += sym_path_len - 1;
218 }
219
220 if (alt_sym_path_len)
221 {
222 *p++ = L';';
223 GetEnvironmentVariableW(L"_NT_ALT_SYMBOL_PATH", p, alt_sym_path_len);
224 p += alt_sym_path_len - 1;
225 }
226 *p = L'\0';
227
228 return search_path;
229}
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
GLfloat GLfloat p
Definition: glext.h:8902
#define L(x)
Definition: ntvdm.h:50

Referenced by SymInitializeW(), and SymSetSearchPathW().

◆ pcs_callback()

BOOL pcs_callback ( const struct process pcs,
ULONG  action,
void data 
)

Definition at line 731 of file dbghelp.c.

732{
734
735 TRACE("%p %u %p\n", pcs, action, data);
736
737 if (!pcs->reg_cb) return FALSE;
738 if (!pcs->reg_is_unicode)
739 {
741
742 switch (action)
743 {
744 case CBA_DEBUG_INFO:
746 case CBA_SET_OPTIONS:
748 break;
753 idslW = data;
754 idsl.SizeOfStruct = sizeof(idsl);
755 idsl.BaseOfImage = idslW->BaseOfImage;
756 idsl.CheckSum = idslW->CheckSum;
757 idsl.TimeDateStamp = idslW->TimeDateStamp;
758 WideCharToMultiByte(CP_ACP, 0, idslW->FileName, -1,
759 idsl.FileName, sizeof(idsl.FileName), NULL, NULL);
760 idsl.Reparse = idslW->Reparse;
761 data = &idsl;
762 break;
764 case CBA_EVENT:
765 case CBA_READ_MEMORY:
766 default:
767 FIXME("No mapping for action %u\n", action);
768 return FALSE;
769 }
770 }
771 return pcs->reg_cb(pcs->handle, action, (ULONG64)(DWORD_PTR)data, pcs->reg_user);
772}
#define FIXME(fmt,...)
Definition: debug.h:111
#define CBA_DUPLICATE_SYMBOL
Definition: compat.h:980
#define CP_ACP
Definition: compat.h:109
#define CBA_SYMBOLS_UNLOADED
Definition: compat.h:979
#define CBA_SET_OPTIONS
Definition: compat.h:983
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:977
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:978
#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL
Definition: compat.h:982
#define CBA_DEBUG_INFO
Definition: compat.h:986
#define CBA_READ_MEMORY
Definition: compat.h:981
#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL
Definition: compat.h:985
#define CBA_EVENT
Definition: compat.h:984
#define WideCharToMultiByte
Definition: compat.h:111
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:976
const WCHAR * action
Definition: action.c:7479
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned __int64 ULONG64
Definition: imports.h:198
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:1167
PSYMBOL_REGISTERED_CALLBACK64 reg_cb
BOOL reg_is_unicode
DWORD64 reg_user
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by module_get_debug(), and SymSetOptions().

◆ process_find_by_handle()

◆ process_getenv()

const WCHAR * process_getenv ( const struct process process,
const WCHAR name 
)

Definition at line 335 of file dbghelp.c.

336{
337 size_t name_len;
338 const WCHAR *iter;
339
340 if (!process->environment) return NULL;
341 name_len = lstrlenW(name);
342
343 for (iter = process->environment; *iter; iter += lstrlenW(iter) + 1)
344 {
345 if (!wcsnicmp(iter, name, name_len) && iter[name_len] == '=')
346 return iter + name_len + 1;
347 }
348
349 return NULL;
350}
#define wcsnicmp
Definition: compat.h:14
#define lstrlenW
Definition: compat.h:750
Definition: name.c:39

Referenced by elf_search_and_load_file(), macho_search_and_load_file(), and search_dll_path().

◆ process_invade_cb()

static BOOL WINAPI process_invade_cb ( PCWSTR  name,
ULONG64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 323 of file dbghelp.c.

324{
325 WCHAR tmp[MAX_PATH];
327
329 lstrcpynW(tmp, name, ARRAY_SIZE(tmp));
330
331 SymLoadModuleExW(hProcess, 0, tmp, name, base, size, NULL, 0);
332 return TRUE;
333}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:33
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:922
#define MAX_PATH
Definition: compat.h:34
DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64, DWORD, PMODLOAD_DATA, DWORD)
Definition: module.c:800
#define lstrcpynW
Definition: compat.h:738

Referenced by SymInitializeW().

◆ reg_cb64to32()

static BOOL CALLBACK reg_cb64to32 ( HANDLE  hProcess,
ULONG  action,
ULONG64  data,
ULONG64  user 
)
static

Definition at line 687 of file dbghelp.c.

688{
690 void* data32;
693
694 if (!pcs) return FALSE;
695 switch (action)
696 {
697 case CBA_DEBUG_INFO:
699 case CBA_SET_OPTIONS:
701 data32 = (void*)(DWORD_PTR)data;
702 break;
708 if (!validate_addr64(idsl64->BaseOfImage))
709 return FALSE;
710 idsl.SizeOfStruct = sizeof(idsl);
711 idsl.BaseOfImage = (DWORD)idsl64->BaseOfImage;
712 idsl.CheckSum = idsl64->CheckSum;
713 idsl.TimeDateStamp = idsl64->TimeDateStamp;
714 memcpy(idsl.FileName, idsl64->FileName, sizeof(idsl.FileName));
715 idsl.Reparse = idsl64->Reparse;
716 data32 = &idsl;
717 break;
719 case CBA_EVENT:
720 case CBA_READ_MEMORY:
721 default:
722 FIXME("No mapping for action %u\n", action);
723 return FALSE;
724 }
726}
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:112
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static BYTE data32[]
Definition: misc.c:535
#define DWORD
Definition: nt_native.h:44
PSYMBOL_REGISTERED_CALLBACK reg_cb32

Referenced by SymRegisterCallback().

◆ sym_register_cb()

static BOOL sym_register_cb ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  cb,
PSYMBOL_REGISTERED_CALLBACK  cb32,
DWORD64  user,
BOOL  unicode 
)
static

Definition at line 779 of file dbghelp.c.

783{
785
786 if (!pcs) return FALSE;
787 pcs->reg_cb = cb;
788 pcs->reg_cb32 = cb32;
789 pcs->reg_is_unicode = unicode;
790 pcs->reg_user = user;
791
792 return TRUE;
793}
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

Referenced by SymRegisterCallback(), SymRegisterCallback64(), and SymRegisterCallbackW64().

◆ SymCleanup()

BOOL WINAPI SymCleanup ( HANDLE  hProcess)

Definition at line 557 of file dbghelp.c.

558{
559 struct process** ppcs;
560 struct process* next;
561
562 for (ppcs = &process_first; *ppcs; ppcs = &(*ppcs)->next)
563 {
564 if ((*ppcs)->handle == hProcess)
565 {
566 while ((*ppcs)->lmodules) module_remove(*ppcs, (*ppcs)->lmodules);
567
568 HeapFree(GetProcessHeap(), 0, (*ppcs)->search_path);
569 free((*ppcs)->environment);
570 next = (*ppcs)->next;
571 HeapFree(GetProcessHeap(), 0, *ppcs);
572 *ppcs = next;
573 return TRUE;
574 }
575 }
576
577 ERR("this process has not had SymInitialize() called for it!\n");
578 return FALSE;
579}
#define ERR(fmt,...)
Definition: debug.h:110
BOOL module_remove(struct process *pcs, struct module *module) DECLSPEC_HIDDEN
Definition: module.c:889
#define HeapFree(x, y, z)
Definition: compat.h:735
static unsigned __int64 next
Definition: rand_nt.c:6
struct process * next

Referenced by deinit_sym(), EndStackBacktrace(), main(), MiniDumpWriteDump(), START_TEST(), and SymInitializeW().

◆ SymGetExtendedOption()

BOOL WINAPI SymGetExtendedOption ( IMAGEHLP_EXTENDED_OPTIONS  option)

Definition at line 630 of file dbghelp.c.

631{
632 switch(option)
633 {
635 return dbghelp_opt_native;
636 default:
637 FIXME("Unsupported option %d\n", option);
638 }
639
640 return FALSE;
641}
@ SYMOPT_EX_WINE_NATIVE_MODULES
Definition: compat.h:1106
BOOL dbghelp_opt_native
Definition: dbghelp.c:74
Definition: getopt.h:109

◆ SymGetOptions()

DWORD WINAPI SymGetOptions ( void  )

Definition at line 600 of file dbghelp.c.

601{
602 return dbghelp_options;
603}
unsigned dbghelp_options
Definition: dbghelp.c:73

Referenced by BeginStackBacktrace(), InitDbgHelp(), and START_TEST().

◆ SymGetSearchPath()

BOOL WINAPI SymGetSearchPath ( HANDLE  hProcess,
PSTR  szSearchPath,
DWORD  SearchPathLength 
)

Definition at line 299 of file dbghelp.c.

301{
302 WCHAR* buffer = HeapAlloc(GetProcessHeap(), 0, SearchPathLength * sizeof(WCHAR));
303 BOOL ret = FALSE;
304
305 if (buffer)
306 {
307 ret = SymGetSearchPathW(hProcess, buffer, SearchPathLength);
308 if (ret)
309 WideCharToMultiByte(CP_ACP, 0, buffer, SearchPathLength,
310 szSearchPath, SearchPathLength, NULL, NULL);
312 }
313 return ret;
314}
BOOL WINAPI SymGetSearchPathW(HANDLE hProcess, PWSTR szSearchPath, DWORD SearchPathLength)
Definition: dbghelp.c:286
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret

Referenced by test_search_path().

◆ SymGetSearchPathW()

BOOL WINAPI SymGetSearchPathW ( HANDLE  hProcess,
PWSTR  szSearchPath,
DWORD  SearchPathLength 
)

Definition at line 286 of file dbghelp.c.

288{
290 if (!pcs) return FALSE;
291
292 lstrcpynW(szSearchPath, pcs->search_path, SearchPathLength);
293 return TRUE;
294}
WCHAR * search_path

Referenced by SymGetSearchPath().

◆ SymInitialize()

BOOL WINAPI SymInitialize ( HANDLE  hProcess,
PCSTR  UserSearchPath,
BOOL  fInvadeProcess 
)

Definition at line 534 of file dbghelp.c.

535{
536 WCHAR* sp = NULL;
537 BOOL ret;
538
539 if (UserSearchPath)
540 {
541 unsigned len;
542
543 len = MultiByteToWideChar(CP_ACP, 0, UserSearchPath, -1, NULL, 0);
544 sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
545 MultiByteToWideChar(CP_ACP, 0, UserSearchPath, -1, sp, len);
546 }
547
548 ret = SymInitializeW(hProcess, sp, fInvadeProcess);
550 return ret;
551}
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess)
Definition: dbghelp.c:464
static const WCHAR sp[]
Definition: suminfo.c:287

Referenced by BeginStackBacktrace(), init_sym_imp(), InitDbgHelp(), main(), and START_TEST().

◆ SymInitializeW()

BOOL WINAPI SymInitializeW ( HANDLE  hProcess,
PCWSTR  UserSearchPath,
BOOL  fInvadeProcess 
)

Definition at line 464 of file dbghelp.c.

465{
466 struct process* pcs;
467 BOOL wow64, child_wow64;
468
469 TRACE("(%p %s %u)\n", hProcess, debugstr_w(UserSearchPath), fInvadeProcess);
470
472 {
473 WARN("the symbols for this process have already been initialized!\n");
474
475 /* MSDN says to only call this function once unless SymCleanup() has been called since the last call.
476 It also says to call SymRefreshModuleList() instead if you just want the module list refreshed.
477 Native still returns TRUE even if the process has already been initialized. */
478 return TRUE;
479 }
480
482
483 if (GetProcessId(hProcess) && !IsWow64Process(hProcess, &child_wow64))
484 return FALSE;
485
486 pcs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pcs));
487 if (!pcs) return FALSE;
488
489 pcs->handle = hProcess;
490 pcs->is_64bit = (sizeof(void *) == 8 || wow64) && !child_wow64;
491 pcs->loader = &no_loader_ops; /* platform-specific initialization will override it if loader debug info can be found */
492
493 if (UserSearchPath)
494 {
496 (lstrlenW(UserSearchPath) + 1) * sizeof(WCHAR)),
497 UserSearchPath);
498 }
499 else
500 {
502 }
503
504 pcs->lmodules = NULL;
505 pcs->dbg_hdr_addr = 0;
506 pcs->next = process_first;
507 process_first = pcs;
508
509#ifndef DBGHELP_STATIC_LIB
510 if (check_live_target(pcs))
511 {
512 if (fInvadeProcess)
514 if (pcs->loader) pcs->loader->synchronize_module_list(pcs);
515 }
516 else if (fInvadeProcess)
517#else
518 if (fInvadeProcess)
519#endif
520 {
523 return FALSE;
524 }
525
526 return TRUE;
527}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
#define lstrcpyW
Definition: compat.h:749
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI SymCleanup(HANDLE hProcess)
Definition: dbghelp.c:557
static WCHAR * make_default_search_path(void)
Definition: dbghelp.c:194
static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG size, PVOID user)
Definition: dbghelp.c:323
static BOOL check_live_target(struct process *pcs)
Definition: dbghelp.c:356
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:1112
const struct loader_ops no_loader_ops
Definition: module.c:1409
#define debugstr_w
Definition: kernel32.h:32
static BOOL wow64
Definition: psapi_main.c:44
const struct loader_ops * loader
struct module * lmodules
ULONG_PTR dbg_hdr_addr

Referenced by MiniDumpWriteDump(), and SymInitialize().

◆ SymRegisterCallback()

BOOL WINAPI SymRegisterCallback ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK  CallbackFunction,
PVOID  UserContext 
)

Definition at line 798 of file dbghelp.c.

801{
802 TRACE("(%p, %p, %p)\n",
803 hProcess, CallbackFunction, UserContext);
805}
static BOOL CALLBACK reg_cb64to32(HANDLE hProcess, ULONG action, ULONG64 data, ULONG64 user)
Definition: dbghelp.c:687
static BOOL sym_register_cb(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
Definition: dbghelp.c:779
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034

◆ SymRegisterCallback64()

BOOL WINAPI SymRegisterCallback64 ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  CallbackFunction,
ULONG64  UserContext 
)

Definition at line 810 of file dbghelp.c.

813{
814 TRACE("(%p, %p, %s)\n",
816 return sym_register_cb(hProcess, CallbackFunction, NULL, UserContext, FALSE);
817}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

Referenced by test_SymRegCallback().

◆ SymRegisterCallbackW64()

BOOL WINAPI SymRegisterCallbackW64 ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  CallbackFunction,
ULONG64  UserContext 
)

Definition at line 822 of file dbghelp.c.

825{
826 TRACE("(%p, %p, %s)\n",
828 return sym_register_cb(hProcess, CallbackFunction, NULL, UserContext, TRUE);
829}

Referenced by test_SymRegCallback().

◆ SymSetContext()

BOOL WINAPI SymSetContext ( HANDLE  hProcess,
PIMAGEHLP_STACK_FRAME  StackFrame,
PIMAGEHLP_CONTEXT  Context 
)

Definition at line 658 of file dbghelp.c.

660{
662 if (!pcs) return FALSE;
663
664 if (pcs->ctx_frame.ReturnOffset == StackFrame->ReturnOffset &&
665 pcs->ctx_frame.FrameOffset == StackFrame->FrameOffset &&
666 pcs->ctx_frame.StackOffset == StackFrame->StackOffset)
667 {
668 TRACE("Setting same frame {rtn=%s frm=%s stk=%s}\n",
673 SetLastError(ERROR_ACCESS_DENIED); /* latest MSDN says ERROR_SUCCESS */
674 return FALSE;
675 }
676
677 pcs->ctx_frame = *StackFrame;
678 /* MSDN states that Context is not (no longer?) used */
679 return TRUE;
680}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
ULONG64 InstructionOffset
Definition: compat.h:1376
ULONG64 ReturnOffset
Definition: compat.h:1377
IMAGEHLP_STACK_FRAME ctx_frame

Referenced by DumpParams(), and ParseImageSymbols().

◆ SymSetExtendedOption()

BOOL WINAPI SymSetExtendedOption ( IMAGEHLP_EXTENDED_OPTIONS  option,
BOOL  value 
)

Definition at line 609 of file dbghelp.c.

610{
611 BOOL old = FALSE;
612
613 switch(option)
614 {
616 old = dbghelp_opt_native;
618 break;
619 default:
620 FIXME("Unsupported option %d with value %d\n", option, value);
621 }
622
623 return old;
624}
Definition: pdh_main.c:94

Referenced by main().

◆ SymSetOptions()

DWORD WINAPI SymSetOptions ( DWORD  opts)

Definition at line 585 of file dbghelp.c.

586{
587 struct process* pcs;
588
589 for (pcs = process_first; pcs; pcs = pcs->next)
590 {
591 pcs_callback(pcs, CBA_SET_OPTIONS, &opts);
592 }
593 return dbghelp_options = opts;
594}
BOOL pcs_callback(const struct process *pcs, ULONG action, void *data)
Definition: dbghelp.c:731

Referenced by BeginStackBacktrace(), InitDbgHelp(), main(), and START_TEST().

◆ SymSetParentWindow()

BOOL WINAPI SymSetParentWindow ( HWND  hwnd)

Definition at line 647 of file dbghelp.c.

648{
649 /* Save hwnd so it can be used as parent window */
650 FIXME("(%p): stub\n", hwnd);
651 return TRUE;
652}
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ SymSetSearchPath()

BOOL WINAPI SymSetSearchPath ( HANDLE  hProcess,
PCSTR  searchPath 
)

Definition at line 263 of file dbghelp.c.

264{
265 BOOL ret = FALSE;
266 unsigned len;
267 WCHAR* sp = NULL;
268
269 if (searchPath)
270 {
271 len = MultiByteToWideChar(CP_ACP, 0, searchPath, -1, NULL, 0);
272 sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
273 if (!sp) return FALSE;
274 MultiByteToWideChar(CP_ACP, 0, searchPath, -1, sp, len);
275 }
276
278
280 return ret;
281}
BOOL WINAPI SymSetSearchPathW(HANDLE hProcess, PCWSTR searchPath)
Definition: dbghelp.c:235

Referenced by InitDbgHelp(), and test_search_path().

◆ SymSetSearchPathW()

BOOL WINAPI SymSetSearchPathW ( HANDLE  hProcess,
PCWSTR  searchPath 
)

Definition at line 235 of file dbghelp.c.

236{
238 WCHAR* search_path_buffer;
239
240 if (!pcs) return FALSE;
241
242 if (searchPath)
243 {
244 search_path_buffer = HeapAlloc(GetProcessHeap(), 0,
245 (lstrlenW(searchPath) + 1) * sizeof(WCHAR));
246 if (!search_path_buffer) return FALSE;
247 lstrcpyW(search_path_buffer, searchPath);
248 }
249 else
250 {
251 search_path_buffer = make_default_search_path();
252 if (!search_path_buffer) return FALSE;
253 }
255 pcs->search_path = search_path_buffer;
256 return TRUE;
257}

Referenced by SymSetSearchPath().

◆ validate_addr64()

BOOL validate_addr64 ( DWORD64  addr)

Definition at line 112 of file dbghelp.c.

113{
114 if (sizeof(void*) == sizeof(int) && (addr >> 32))
115 {
116 FIXME("Unsupported address %s\n", wine_dbgstr_longlong(addr));
118 return FALSE;
119 }
120 return TRUE;
121}
GLenum const GLvoid * addr
Definition: glext.h:9621

Referenced by fetch_pe_module_info_cb(), reg_cb64to32(), SymGetModuleBase(), SymLoadModuleExW(), and SymUnloadModule64().

◆ WinDbgExtensionDllInit()

void WINAPI WinDbgExtensionDllInit ( PWINDBG_EXTENSION_APIS  lpExtensionApis,
unsigned short  major,
unsigned short  minor 
)

Definition at line 869 of file dbghelp.c.

871{
872}

◆ wine_dbgstr_addr()

const char * wine_dbgstr_addr ( const ADDRESS64 addr)

Definition at line 142 of file dbghelp.c.

143{
144 if (!addr) return "(null)";
145 switch (addr->Mode)
146 {
147 case AddrModeFlat:
148 return wine_dbg_sprintf("flat<%s>", wine_dbgstr_longlong(addr->Offset));
149 case AddrMode1616:
150 return wine_dbg_sprintf("1616<%04x:%04x>", addr->Segment, (DWORD)addr->Offset);
151 case AddrMode1632:
152 return wine_dbg_sprintf("1632<%04x:%08x>", addr->Segment, (DWORD)addr->Offset);
153 case AddrModeReal:
154 return wine_dbg_sprintf("real<%04x:%04x>", addr->Segment, (DWORD)addr->Offset);
155 default:
156 return "unknown";
157 }
158}
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
@ AddrModeReal
Definition: compat.h:1158
@ AddrModeFlat
Definition: compat.h:1159
@ AddrMode1616
Definition: compat.h:1156
@ AddrMode1632
Definition: compat.h:1157

Referenced by i386_stack_walk().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp  )

Variable Documentation

◆ api_version

API_VERSION api_version = { 4, 0, 2, 0 }
static

Definition at line 832 of file dbghelp.c.

Referenced by ImagehlpApiVersion(), and ImagehlpApiVersionEx().

◆ cpu_arm64

struct cpu cpu_i386 cpu_x86_64 cpu_arm cpu_arm64
extern

Definition at line 283 of file cpu_arm64.c.

◆ dbghelp_cpus

struct cpu* dbghelp_cpus[] = {&cpu_i386, &cpu_x86_64, &cpu_arm, &cpu_arm64, NULL}
static

Definition at line 164 of file dbghelp.c.

Referenced by cpu_find().

◆ dbghelp_current_cpu

◆ dbghelp_opt_native

◆ dbghelp_options

◆ process_first

struct process* process_first
static

Definition at line 79 of file dbghelp.c.

Referenced by process_find_by_handle(), SymCleanup(), SymInitializeW(), and SymSetOptions().

◆ sysinfo