ReactOS  0.4.15-dev-3440-g915569a
module.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "dbghelp_private.h"
#include "image_private.h"
#include "psapi.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for module.c:

Go to the source code of this file.

Classes

struct  enum_modW64_32
 
struct  enum_modW64_64
 
struct  enum_load_modW64_64
 
struct  enum_load_modW64_32
 

Macros

#define NOTE_GNU_BUILD_ID   3
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp)
 
static int match_ext (const WCHAR *ptr, size_t len)
 
static const WCHARget_filename (const WCHAR *name, const WCHAR *endptr)
 
static BOOL is_wine_loader (const WCHAR *module)
 
static void module_fill_module (const WCHAR *in, WCHAR *out, size_t size)
 
void module_set_module (struct module *module, const WCHAR *name)
 
WCHARget_wine_loader_name (struct process *pcs)
 
static const charget_module_type (enum module_type type, BOOL virtual)
 
struct modulemodule_new (struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum)
 
struct modulemodule_find_by_nameW (const struct process *pcs, const WCHAR *name)
 
struct modulemodule_find_by_nameA (const struct process *pcs, const char *name)
 
struct modulemodule_is_already_loaded (const struct process *pcs, const WCHAR *name)
 
static struct modulemodule_get_container (const struct process *pcs, const struct module *inner)
 
struct modulemodule_get_containee (const struct process *pcs, const struct module *outer)
 
BOOL module_get_debug (struct module_pair *pair)
 
struct modulemodule_find_by_addr (const struct process *pcs, DWORD64 addr, enum module_type type)
 
static BOOL module_is_container_loaded (const struct process *pcs, const WCHAR *ImageName, DWORD64 base)
 
static BOOL image_check_debug_link (const WCHAR *file, struct image_file_map *fmap, DWORD link_crc)
 
static BOOL image_locate_debug_link (const struct module *module, struct image_file_map *fmap, const char *filename, DWORD crc)
 
static BOOL image_locate_build_id_target (struct image_file_map *fmap, const BYTE *id, unsigned idlen)
 
BOOL image_check_alternate (struct image_file_map *fmap, const struct module *module)
 
DWORD WINAPI SymLoadModule (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD BaseOfDll, DWORD SizeOfDll)
 
DWORD64 WINAPI SymLoadModuleEx (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
 
DWORD64 WINAPI SymLoadModuleExW (HANDLE hProcess, HANDLE hFile, PCWSTR wImageName, PCWSTR wModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll, PMODLOAD_DATA Data, DWORD Flags)
 
DWORD64 WINAPI SymLoadModule64 (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
 
BOOL module_remove (struct process *pcs, struct module *module)
 
BOOL WINAPI SymUnloadModule (HANDLE hProcess, DWORD BaseOfDll)
 
BOOL WINAPI SymUnloadModule64 (HANDLE hProcess, DWORD64 BaseOfDll)
 
static BOOL CALLBACK enum_modW64_32 (PCWSTR name, DWORD64 base, PVOID user)
 
BOOL WINAPI SymEnumerateModules (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_modW64_64 (PCWSTR name, DWORD64 base, PVOID user)
 
BOOL WINAPI SymEnumerateModules64 (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, PVOID UserContext)
 
BOOL WINAPI SymEnumerateModulesW64 (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_load_modW64_64 (PCWSTR name, DWORD64 base, ULONG size, PVOID user)
 
BOOL WINAPI EnumerateLoadedModules64 (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_load_modW64_32 (PCWSTR name, DWORD64 base, ULONG size, PVOID user)
 
BOOL WINAPI EnumerateLoadedModules (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, PVOID UserContext)
 
BOOL WINAPI EnumerateLoadedModulesW64 (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
 
static void dbghelp_str_WtoA (const WCHAR *src, char *dst, int dst_len)
 
BOOL WINAPI SymGetModuleInfo (HANDLE hProcess, DWORD dwAddr, PIMAGEHLP_MODULE ModuleInfo)
 
BOOL WINAPI SymGetModuleInfoW (HANDLE hProcess, DWORD dwAddr, PIMAGEHLP_MODULEW ModuleInfo)
 
BOOL WINAPI SymGetModuleInfo64 (HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
 
BOOL WINAPI SymGetModuleInfoW64 (HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
 
DWORD WINAPI SymGetModuleBase (HANDLE hProcess, DWORD dwAddr)
 
DWORD64 WINAPI SymGetModuleBase64 (HANDLE hProcess, DWORD64 dwAddr)
 
void module_reset_debug_info (struct module *module)
 
BOOL WINAPI SymRefreshModuleList (HANDLE hProcess)
 
PVOID WINAPI SymFunctionTableAccess (HANDLE hProcess, DWORD AddrBase)
 
PVOID WINAPI SymFunctionTableAccess64 (HANDLE hProcess, DWORD64 AddrBase)
 
static BOOL native_synchronize_module_list (struct process *pcs)
 
static struct modulenative_load_module (struct process *pcs, const WCHAR *name, ULONG_PTR addr)
 
static BOOL native_load_debug_info (struct process *process, struct module *module)
 
static BOOL native_enum_modules (struct process *process, enum_modules_cb cb, void *user)
 
static BOOL native_fetch_file_info (struct process *process, const WCHAR *name, ULONG_PTR load_addr, DWORD_PTR *base, DWORD *size, DWORD *checksum)
 

Variables

const WCHAR S_ElfW [] = {'<','e','l','f','>','\0'}
 
const WCHAR S_WineLoaderW [] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}
 
static const WCHAR S_DotSoW [] = {'.','s','o','\0'}
 
const WCHAR S_SlashW [] = {'/','\0'}
 
static const WCHAR S_AcmW [] = {'.','a','c','m','\0'}
 
static const WCHAR S_DllW [] = {'.','d','l','l','\0'}
 
static const WCHAR S_DrvW [] = {'.','d','r','v','\0'}
 
static const WCHAR S_ExeW [] = {'.','e','x','e','\0'}
 
static const WCHAR S_OcxW [] = {'.','o','c','x','\0'}
 
static const WCHAR S_VxdW [] = {'.','v','x','d','\0'}
 
static const WCHAR *const ext [] = {S_AcmW, S_DllW, S_DrvW, S_ExeW, S_OcxW, S_VxdW, NULL}
 
const struct loader_ops no_loader_ops
 

Macro Definition Documentation

◆ NOTE_GNU_BUILD_ID

#define NOTE_GNU_BUILD_ID   3

Definition at line 38 of file module.c.

Function Documentation

◆ dbghelp_str_WtoA()

static void dbghelp_str_WtoA ( const WCHAR src,
char dst,
int  dst_len 
)
static

Definition at line 1148 of file module.c.

1149 {
1150  WideCharToMultiByte(CP_ACP, 0, src, -1, dst, dst_len - 1, NULL, NULL);
1151  dst[dst_len - 1] = 0;
1152 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define NULL
Definition: types.h:112

Referenced by SymGetModuleInfo(), and SymGetModuleInfo64().

◆ enum_load_modW64_32()

static BOOL CALLBACK enum_load_modW64_32 ( PCWSTR  name,
DWORD64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 1088 of file module.c.

1090 {
1091  struct enum_load_modW64_32* x = user;
1092  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
1093  return x->cb(x->module, (DWORD)base, size, x->user);
1094 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
Definition: name.c:38
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_load_modW64_64()

static BOOL CALLBACK enum_load_modW64_64 ( PCWSTR  name,
DWORD64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 1056 of file module.c.

1058 {
1059  struct enum_load_modW64_64* x = user;
1060 
1061  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
1062  return x->cb(x->module, base, size, x->user);
1063 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
#define NULL
Definition: types.h:112
Definition: name.c:38
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_modW64_32()

static BOOL CALLBACK enum_modW64_32 ( PCWSTR  name,
DWORD64  base,
PVOID  user 
)
static

Definition at line 968 of file module.c.

969 {
970  struct enum_modW64_32* x = user;
971 
972  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
973  return x->cb(x->module, (DWORD)base, x->user);
974 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
Definition: name.c:38
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_modW64_64()

static BOOL CALLBACK enum_modW64_64 ( PCWSTR  name,
DWORD64  base,
PVOID  user 
)
static

Definition at line 999 of file module.c.

1000 {
1001  struct enum_modW64_64* x = user;
1002 
1003  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
1004  return x->cb(x->module, base, x->user);
1005 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define NULL
Definition: types.h:112
Definition: name.c:38
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ EnumerateLoadedModules()

BOOL WINAPI EnumerateLoadedModules ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACK  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 1096 of file module.c.

1099 {
1100  struct enum_load_modW64_32 x;
1101 
1102  x.cb = EnumLoadedModulesCallback;
1103  x.user = UserContext;
1104 
1106 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:1112
PENUMLOADED_MODULES_CALLBACK cb
Definition: module.c:1083

◆ EnumerateLoadedModules64()

BOOL WINAPI EnumerateLoadedModules64 ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACK64  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 1065 of file module.c.

1068 {
1069  struct enum_load_modW64_64 x;
1070 
1071  x.cb = EnumLoadedModulesCallback;
1072  x.user = UserContext;
1073 
1075 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
PENUMLOADED_MODULES_CALLBACK64 cb
Definition: module.c:1051
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:1112

◆ EnumerateLoadedModulesW64()

BOOL WINAPI EnumerateLoadedModulesW64 ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACKW64  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 1112 of file module.c.

1115 {
1116  HMODULE* hMods;
1117  WCHAR baseW[256], modW[256];
1118  DWORD i, sz;
1119  MODULEINFO mi;
1120 
1121  hMods = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods[0]));
1122  if (!hMods) return FALSE;
1123 
1124  if (!EnumProcessModules(hProcess, hMods, 256 * sizeof(hMods[0]), &sz))
1125  {
1126  /* hProcess should also be a valid process handle !! */
1127  FIXME("If this happens, bump the number in mod\n");
1128  HeapFree(GetProcessHeap(), 0, hMods);
1129  return FALSE;
1130  }
1131  sz /= sizeof(HMODULE);
1132  for (i = 0; i < sz; i++)
1133  {
1134  if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
1136  continue;
1138  EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
1139  UserContext);
1140  }
1141  HeapFree(GetProcessHeap(), 0, hMods);
1142 
1143  return sz != 0 && i == sz;
1144 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static MONITORINFO mi
Definition: win.c:7338
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:914
BOOL WINAPI EnumProcessModules(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded)
Definition: psapi.c:526
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:65
static const WCHAR modW[]
Definition: lex.c:66
HANDLE HMODULE
Definition: typedefs.h:77
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
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL WINAPI GetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb)
Definition: psapi.c:1064
static void module_fill_module(const WCHAR *in, WCHAR *out, size_t size)
Definition: module.c:118
static WCHAR baseW[MAX_PATH]
Definition: FindFiles.c:24
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by EnumerateLoadedModules(), EnumerateLoadedModules64(), fetch_modules_info(), and SymInitializeW().

◆ get_filename()

static const WCHAR* get_filename ( const WCHAR name,
const WCHAR endptr 
)
static

Definition at line 70 of file module.c.

71 {
72  const WCHAR* ptr;
73 
74  if (!endptr) endptr = name + lstrlenW(name);
75  for (ptr = endptr - 1; ptr >= name; ptr--)
76  {
77  if (*ptr == '/' || *ptr == '\\') break;
78  }
79  return ++ptr;
80 }
#define lstrlenW
Definition: compat.h:609
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: name.c:38
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by basic_tests(), is_wine_loader(), module_fill_module(), module_is_already_loaded(), and module_is_container_loaded().

◆ get_module_type()

static const char* get_module_type ( enum module_type  type,
BOOL  virtual 
)
static

Definition at line 184 of file module.c.

185 {
186  switch (type)
187  {
188  case DMT_ELF: return virtual ? "Virtual ELF" : "ELF";
189  case DMT_PE: return virtual ? "Virtual PE" : "PE";
190  case DMT_MACHO: return virtual ? "Virtual Mach-O" : "Mach-O";
191  default: return "---";
192  }
193 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by module_new().

◆ get_wine_loader_name()

WCHAR* get_wine_loader_name ( struct process pcs)

Definition at line 150 of file module.c.

151 {
152  static const WCHAR wineW[] = {'w','i','n','e',0};
153  static const WCHAR suffixW[] = {'6','4',0};
154  WCHAR *buffer, *p;
155  const char *env;
156 
157  /* All binaries are loaded with WINELOADER (if run from tree) or by the
158  * main executable
159  */
160  if ((env = getenv("WINELOADER")))
161  {
162  DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, env, -1, NULL, 0 );
163  buffer = heap_alloc( len * sizeof(WCHAR) );
165  }
166  else
167  {
168  buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
169  lstrcpyW( buffer, wineW );
170  }
171 
172  p = buffer + lstrlenW( buffer ) - lstrlenW( suffixW );
173  if (p > buffer && !wcscmp( p, suffixW ))
174  *p = 0;
175 
176  if (pcs->is_64bit)
177  lstrcatW(buffer, suffixW);
178 
179  TRACE( "returning %s\n", debugstr_w(buffer) );
180  return buffer;
181 }
GLuint buffer
Definition: glext.h:5915
#define lstrlenW
Definition: compat.h:609
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR wineW[]
Definition: localmon.c:128
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define MultiByteToWideChar
Definition: compat.h:110
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by elf_read_wine_loader_dbg_info(), and macho_search_loader().

◆ image_check_alternate()

BOOL image_check_alternate ( struct image_file_map fmap,
const struct module module 
)

Definition at line 701 of file module.c.

702 {
703  BOOL ret = FALSE;
704  BOOL found = FALSE;
705  struct image_section_map buildid_sect, debuglink_sect;
706 
707  /* if present, add the .gnu_debuglink file as an alternate to current one */
708  if (image_find_section(fmap, ".note.gnu.build-id", &buildid_sect))
709  {
710  const UINT32* note;
711 
712  found = TRUE;
713  note = (const UINT32*)image_map_section(&buildid_sect);
714  if (note != IMAGE_NO_MAP)
715  {
716  /* the usual ELF note structure: name-size desc-size type <name> <desc> */
717  if (note[2] == NOTE_GNU_BUILD_ID)
718  {
719  ret = image_locate_build_id_target(fmap, (const BYTE*)(note + 3 + ((note[0] + 3) >> 2)), note[1]);
720  }
721  }
722  image_unmap_section(&buildid_sect);
723  }
724  /* if present, add the .gnu_debuglink file as an alternate to current one */
725  if (!ret && image_find_section(fmap, ".gnu_debuglink", &debuglink_sect))
726  {
727  const char* dbg_link;
728 
729  found = TRUE;
730  dbg_link = (const char*)image_map_section(&debuglink_sect);
731  if (dbg_link != IMAGE_NO_MAP)
732  {
733  /* The content of a debug link section is:
734  * 1/ a NULL terminated string, containing the file name for the
735  * debug info
736  * 2/ padding on 4 byte boundary
737  * 3/ CRC of the linked file
738  */
739  DWORD crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3));
740  ret = image_locate_debug_link(module, fmap, dbg_link, crc);
741  if (!ret)
742  WARN("Couldn't load linked debug file for %s\n",
744  }
745  image_unmap_section(&debuglink_sect);
746  }
747  return found ? ret : TRUE;
748 }
WCHAR ModuleName[32]
Definition: compat.h:935
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
struct image_file_map * fmap
#define NOTE_GNU_BUILD_ID
Definition: module.c:38
static BOOL image_locate_build_id_target(struct image_file_map *fmap, const BYTE *id, unsigned idlen)
Definition: module.c:621
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define FALSE
Definition: types.h:117
unsigned int UINT32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
int note(char *format,...)
Definition: util.c:12
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static void image_unmap_section(struct image_section_map *ism)
static BOOL image_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
uint32_t DWORD_PTR
Definition: typedefs.h:65
static const char * image_map_section(struct image_section_map *ism)
unsigned char BYTE
Definition: xxhash.c:193
IMAGEHLP_MODULEW64 module
static BOOL image_locate_debug_link(const struct module *module, struct image_file_map *fmap, const char *filename, DWORD crc)
Definition: module.c:543

Referenced by elf_load_debug_info_from_map(), and pe_load_debug_info().

◆ image_check_debug_link()

static BOOL image_check_debug_link ( const WCHAR file,
struct image_file_map fmap,
DWORD  link_crc 
)
static

Definition at line 481 of file module.c.

482 {
484  HANDLE handle;
485 #ifndef DBGHELP_STATIC_LIB
486  WCHAR *path;
487 #endif
488  WORD magic;
489  BOOL ret;
490 
491 #ifndef DBGHELP_STATIC_LIB
494  heap_free(path);
495 #else
497 #endif
498  if (handle == INVALID_HANDLE_VALUE) return FALSE;
499 
500  if (link_crc)
501  {
502  DWORD crc = calc_crc32(handle);
503  if (crc != link_crc)
504  {
505  WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc);
507  return FALSE;
508  }
509  }
510 
514  else
515 #ifndef __REACTOS__
517 #else
518  ret = FALSE;
519 #endif
521  return ret;
522 }
#define CloseHandle
Definition: compat.h:598
GLsizei const GLchar ** path
Definition: glext.h:7234
#define WARN(fmt,...)
Definition: debug.h:112
struct image_file_map * fmap
u32_t magic(void)
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:168
#define FILE_BEGIN
Definition: compat.h:620
#define FILE_SHARE_READ
Definition: compat.h:136
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define OPEN_EXISTING
Definition: compat.h:634
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL elf_map_handle(HANDLE handle, struct image_file_map *fmap)
Definition: elf_module.c:582
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define GENERIC_READ
Definition: compat.h:135
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt) DECLSPEC_HIDDEN
Definition: pe_module.c:241
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
DWORD calc_crc32(HANDLE handle)
Definition: dbghelp.c:874
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
WCHAR * get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN
Definition: path.c:671
#define SetFilePointer
Definition: compat.h:602
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: fci.c:126

Referenced by image_locate_build_id_target(), and image_locate_debug_link().

◆ image_locate_build_id_target()

static BOOL image_locate_build_id_target ( struct image_file_map fmap,
const BYTE id,
unsigned  idlen 
)
static

Definition at line 621 of file module.c.

622 {
623  static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
624  static const WCHAR buildidW[] = {'.','b','u','i','l','d','-','i','d','/'};
625  static const WCHAR dotDebug0W[] = {'.','d','e','b','u','g',0};
626  struct image_file_map* fmap_link = NULL;
627  WCHAR* p;
628  WCHAR* z;
629  const BYTE* idend = id + idlen;
630 
631  fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link));
632  if (!fmap_link) return FALSE;
633 
634  p = HeapAlloc(GetProcessHeap(), 0,
635  sizeof(globalDebugDirW) + sizeof(buildidW) +
636  (idlen * 2 + 1) * sizeof(WCHAR) + sizeof(dotDebug0W));
637  z = p;
638  memcpy(z, globalDebugDirW, sizeof(globalDebugDirW));
639  z += ARRAY_SIZE(globalDebugDirW);
640  memcpy(z, buildidW, sizeof(buildidW));
641  z += ARRAY_SIZE(buildidW);
642 
643  if (id < idend)
644  {
645  *z++ = "0123456789abcdef"[*id >> 4 ];
646  *z++ = "0123456789abcdef"[*id & 0x0F];
647  id++;
648  }
649  if (id < idend)
650  *z++ = '/';
651  while (id < idend)
652  {
653  *z++ = "0123456789abcdef"[*id >> 4 ];
654  *z++ = "0123456789abcdef"[*id & 0x0F];
655  id++;
656  }
657  memcpy(z, dotDebug0W, sizeof(dotDebug0W));
658  TRACE("checking %s\n", wine_dbgstr_w(p));
659 
660  if (image_check_debug_link(p, fmap_link, 0))
661  {
662  struct image_section_map buildid_sect;
663  if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect))
664  {
665  const UINT32* note;
666 
667  note = (const UINT32*)image_map_section(&buildid_sect);
668  if (note != IMAGE_NO_MAP)
669  {
670  /* the usual ELF note structure: name-size desc-size type <name> <desc> */
671  if (note[2] == NOTE_GNU_BUILD_ID)
672  {
673  if (note[1] == idlen &&
674  !memcmp(note + 3 + ((note[0] + 3) >> 2), idend - idlen, idlen))
675  {
676  TRACE("Located debug information file at %s\n", debugstr_w(p));
677  HeapFree(GetProcessHeap(), 0, p);
678  fmap->alternate = fmap_link;
679  return TRUE;
680  }
681  WARN("mismatch in buildid information for %s\n", wine_dbgstr_w(p));
682  }
683  }
684  image_unmap_section(&buildid_sect);
685  }
686  image_unmap_file(fmap_link);
687  }
688 
689  TRACE("not found\n");
690  HeapFree(GetProcessHeap(), 0, p);
691  HeapFree(GetProcessHeap(), 0, fmap_link);
692  return FALSE;
693 }
static BOOL image_check_debug_link(const WCHAR *file, struct image_file_map *fmap, DWORD link_crc)
Definition: module.c:481
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define WARN(fmt,...)
Definition: debug.h:112
struct image_file_map * fmap
#define NOTE_GNU_BUILD_ID
Definition: module.c:38
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define FALSE
Definition: types.h:117
unsigned int UINT32
#define debugstr_w
Definition: kernel32.h:32
GLdouble GLdouble z
Definition: glext.h:5874
int note(char *format,...)
Definition: util.c:12
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void image_unmap_file(struct image_file_map *fmap)
static void image_unmap_section(struct image_section_map *ism)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static BOOL image_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
unsigned char BYTE
Definition: xxhash.c:193
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
GLfloat GLfloat p
Definition: glext.h:8902
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by image_check_alternate().

◆ image_locate_debug_link()

static BOOL image_locate_debug_link ( const struct module module,
struct image_file_map fmap,
const char filename,
DWORD  crc 
)
static

Definition at line 543 of file module.c.

544 {
545 #ifndef __REACTOS__
546  static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
547 #else
548  static const WCHAR globalDebugDirW[] = {'\0'};
549 #endif
550  static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'};
551  const size_t globalDebugDirLen = ARRAY_SIZE(globalDebugDirW);
552  size_t filename_len, path_len;
553  WCHAR* p = NULL;
554  WCHAR* slash;
555  WCHAR* slash2;
556  struct image_file_map* fmap_link = NULL;
557 
558  fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link));
559  if (!fmap_link) return FALSE;
560 
561  filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);
564  p = HeapAlloc(GetProcessHeap(), 0,
565  (globalDebugDirLen + path_len + 6 + 1 + filename_len + 1) * sizeof(WCHAR));
566  if (!p) goto found;
567 
568  /* we prebuild the string with "execdir" */
570  slash = p;
571  if ((slash2 = wcsrchr(slash, '/'))) slash = slash2 + 1;
572  if ((slash2 = wcsrchr(slash, '\\'))) slash = slash2 + 1;
573 
574  /* testing execdir/filename */
575  MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len);
576  if (image_check_debug_link(p, fmap_link, crc)) goto found;
577 
578  /* testing execdir/.debug/filename */
579  memcpy(slash, dotDebugW, sizeof(dotDebugW));
580  MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + ARRAY_SIZE(dotDebugW), filename_len);
581  if (image_check_debug_link(p, fmap_link, crc)) goto found;
582 
583  if (module->real_path)
584  {
586  slash = p;
587  if ((slash2 = wcsrchr(slash, '/'))) slash = slash2 + 1;
588  if ((slash2 = wcsrchr(slash, '\\'))) slash = slash2 + 1;
589  MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len);
590  if (image_check_debug_link(p, fmap_link, crc)) goto found;
591  }
592 
593  /* testing globaldebugdir/execdir/filename */
594  memmove(p + globalDebugDirLen, p, (slash - p) * sizeof(WCHAR));
595  memcpy(p, globalDebugDirW, globalDebugDirLen * sizeof(WCHAR));
596  slash += globalDebugDirLen;
597  MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len);
598  if (image_check_debug_link(p, fmap_link, crc)) goto found;
599 
600  /* finally testing filename */
601  if (image_check_debug_link(slash, fmap_link, crc)) goto found;
602 
603 
604  WARN("Couldn't locate or map %s\n", filename);
605  HeapFree(GetProcessHeap(), 0, p);
606  HeapFree(GetProcessHeap(), 0, fmap_link);
607  return FALSE;
608 
609 found:
610  TRACE("Located debug information file %s at %s\n", filename, debugstr_w(p));
611  HeapFree(GetProcessHeap(), 0, p);
612  fmap->alternate = fmap_link;
613  return TRUE;
614 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define max(a, b)
Definition: svc.c:63
static BOOL image_check_debug_link(const WCHAR *file, struct image_file_map *fmap, DWORD link_crc)
Definition: module.c:481
WCHAR * real_path
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
const char * filename
Definition: ioapi.h:135
#define lstrlenW
Definition: compat.h:609
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
struct image_file_map * alternate
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define wcsrchr
Definition: compat.h:16
static DWORD path_len
Definition: batch.c:31
#define lstrcpyW
Definition: compat.h:608
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLfloat GLfloat p
Definition: glext.h:8902
IMAGEHLP_MODULEW64 module
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by image_check_alternate().

◆ is_wine_loader()

static BOOL is_wine_loader ( const WCHAR module)
static

Definition at line 83 of file module.c.

84 {
85  static const WCHAR wineW[] = {'w','i','n','e',0};
86  static const WCHAR suffixW[] = {'6','4',0};
88  const char *ptr;
89  BOOL ret = FALSE;
90  WCHAR *buffer;
91  DWORD len;
92 
93  if ((ptr = getenv("WINELOADER")))
94  {
95  ptr = file_nameA(ptr);
96  len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, NULL, 0 );
97  buffer = heap_alloc( len * sizeof(WCHAR) );
99  }
100  else
101  {
102  buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
103  lstrcpyW( buffer, wineW );
104  }
105 
106  if (!wcscmp( filename, buffer ))
107  ret = TRUE;
108 
109  lstrcatW( buffer, suffixW );
110  if (!wcscmp( filename, buffer ))
111  ret = TRUE;
112 
113  heap_free( buffer );
114  return ret;
115 }
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR wineW[]
Definition: localmon.c:128
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
const char * file_nameA(const char *str) DECLSPEC_HIDDEN
Definition: path.c:37
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:70
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by module_fill_module().

◆ match_ext()

static int match_ext ( const WCHAR ptr,
size_t  len 
)
static

Definition at line 55 of file module.c.

56 {
57  const WCHAR* const *e;
58  size_t l;
59 
60  for (e = ext; *e; e++)
61  {
62  l = lstrlenW(*e);
63  if (l >= len) return 0;
64  if (wcsnicmp(&ptr[len - l], *e, l)) continue;
65  return l;
66  }
67  return 0;
68 }
#define lstrlenW
Definition: compat.h:609
#define e
Definition: ke_i.h:82
static PVOID ptr
Definition: dispmode.c:27
r l[0]
Definition: byte_order.h:167
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define wcsnicmp
Definition: compat.h:14
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by module_fill_module().

◆ module_fill_module()

static void module_fill_module ( const WCHAR in,
WCHAR out,
size_t  size 
)
static

Definition at line 118 of file module.c.

119 {
120  const WCHAR *ptr, *endptr;
121  size_t len, l;
122 
123  ptr = get_filename(in, endptr = in + lstrlenW(in));
124  len = min(endptr - ptr, size - 1);
125  memcpy(out, ptr, len * sizeof(WCHAR));
126  out[len] = '\0';
127  if (len > 4 && (l = match_ext(out, len)))
128  out[len - l] = '\0';
129 #ifndef __REACTOS__
130  else if (is_wine_loader(out))
132 #endif
133  else
134  {
135  if (len > 3 && !wcsicmp(&out[len - 3], S_DotSoW) &&
136  (l = match_ext(out, len - 3)))
137  lstrcpyW(&out[len - l - 3], S_ElfW);
138  }
139  while ((*out = towlower(*out))) out++;
140 }
static int match_ext(const WCHAR *ptr, size_t len)
Definition: module.c:55
#define lstrlenW
Definition: compat.h:609
#define lstrcpynW
Definition: compat.h:597
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:70
static BOOL is_wine_loader(const WCHAR *module)
Definition: module.c:83
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR S_ElfW[]
Definition: module.c:40
static FILE * out
Definition: regtests2xml.c:44
#define wcsicmp
Definition: compat.h:15
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR S_DotSoW[]
Definition: module.c:44
#define lstrcpyW
Definition: compat.h:608
GLuint in
Definition: glext.h:9616
const WCHAR S_WineLoaderW[]
Definition: module.c:42
#define min(a, b)
Definition: monoChain.cc:55
#define towlower(c)
Definition: wctype.h:97

Referenced by EnumerateLoadedModulesW64(), and module_set_module().

◆ module_find_by_addr()

struct module* module_find_by_addr ( const struct process pcs,
DWORD64  addr,
enum module_type  type 
)

Definition at line 420 of file module.c.

422 {
423  struct module* module;
424 
425  if (type == DMT_UNKNOWN)
426  {
427  if ((module = module_find_by_addr(pcs, addr, DMT_PE)) ||
428  (module = module_find_by_addr(pcs, addr, DMT_ELF)) ||
430  return module;
431  }
432  else
433  {
434  for (module = pcs->lmodules; module; module = module->next)
435  {
436  if (type == module->type && addr >= module->module.BaseOfImage &&
438  return module;
439  }
440  }
442  return module;
443 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
DWORD64 BaseOfImage
Definition: compat.h:929
static HMODULE module
Definition: module.c:32
enum module_type type
struct module * lmodules
#define SetLastError(x)
Definition: compat.h:611
GLenum const GLvoid * addr
Definition: glext.h:9621
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by dwarf2_virtual_unwind(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymFunctionTableAccess64(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetModuleBase64(), SymGetModuleInfoW64(), SymGetTypeFromName(), SymGetTypeInfo(), symt_enum_locals(), SymUnloadModule(), SymUnloadModule64(), and x86_64_fetch_minidump_module().

◆ module_find_by_nameA()

struct module* module_find_by_nameA ( const struct process pcs,
const char name 
)

Definition at line 291 of file module.c.

292 {
293  WCHAR wname[MAX_PATH];
294 
295  MultiByteToWideChar(CP_ACP, 0, name, -1, wname, ARRAY_SIZE(wname));
296  return module_find_by_nameW(pcs, wname);
297 }
struct module * module_find_by_nameW(const struct process *pcs, const WCHAR *name)
Definition: module.c:279
#define CP_ACP
Definition: compat.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:110
Definition: name.c:38

Referenced by SymFromName().

◆ module_find_by_nameW()

struct module* module_find_by_nameW ( const struct process pcs,
const WCHAR name 
)

Definition at line 279 of file module.c.

280 {
281  struct module* module;
282 
283  for (module = pcs->lmodules; module; module = module->next)
284  {
285  if (!wcsicmp(name, module->module.ModuleName)) return module;
286  }
288  return NULL;
289 }
WCHAR ModuleName[32]
Definition: compat.h:935
static HMODULE module
Definition: module.c:32
struct module * lmodules
#define SetLastError(x)
Definition: compat.h:611
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
Definition: name.c:38
#define ERROR_INVALID_NAME
Definition: compat.h:103
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by module_find_by_nameA(), and SymEnumSourceFilesW().

◆ module_get_containee()

struct module* module_get_containee ( const struct process pcs,
const struct module outer 
)

Definition at line 349 of file module.c.

350 {
351  struct module* module;
352 
353  for (module = pcs->lmodules; module; module = module->next)
354  {
355  if (module != outer &&
357  outer->module.BaseOfImage + outer->module.ImageSize >=
359  return module;
360  }
361  return NULL;
362 }
DWORD64 BaseOfImage
Definition: compat.h:929
static HMODULE module
Definition: module.c:32
struct module * lmodules
#define NULL
Definition: types.h:112
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by sym_enum(), and SymFromName().

◆ module_get_container()

static struct module* module_get_container ( const struct process pcs,
const struct module inner 
)
static

Definition at line 329 of file module.c.

331 {
332  struct module* module;
333 
334  for (module = pcs->lmodules; module; module = module->next)
335  {
336  if (module != inner &&
339  inner->module.BaseOfImage + inner->module.ImageSize)
340  return module;
341  }
342  return NULL;
343 }
DWORD64 BaseOfImage
Definition: compat.h:929
static HMODULE module
Definition: module.c:32
struct module * lmodules
#define NULL
Definition: types.h:112
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by module_get_debug(), and SymGetModuleInfoW64().

◆ module_get_debug()

BOOL module_get_debug ( struct module_pair pair)

Definition at line 374 of file module.c.

375 {
377 
378  if (!pair->requested) return FALSE;
379  /* for a PE builtin, always get info from container */
380  if (!(pair->effective = module_get_container(pair->pcs, pair->requested)))
381  pair->effective = pair->requested;
382  /* if deferred, force loading */
383  if (pair->effective->module.SymType == SymDeferred)
384  {
385  BOOL ret;
386 
387  if (pair->effective->is_virtual) ret = FALSE;
388  else if (pair->effective->type == DMT_PE)
389  {
390  idslW64.SizeOfStruct = sizeof(idslW64);
391  idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
392  idslW64.CheckSum = pair->effective->module.CheckSum;
393  idslW64.TimeDateStamp = pair->effective->module.TimeDateStamp;
394  memcpy(idslW64.FileName, pair->effective->module.ImageName,
395  sizeof(pair->effective->module.ImageName));
396  idslW64.Reparse = FALSE;
397  idslW64.hFile = INVALID_HANDLE_VALUE;
398 
400  ret = pe_load_debug_info(pair->pcs, pair->effective);
401  pcs_callback(pair->pcs,
403  &idslW64);
404  }
405  else ret = pair->pcs->loader->load_debug_info(pair->pcs, pair->effective);
406 
407  if (!ret) pair->effective->module.SymType = SymNone;
408  assert(pair->effective->module.SymType != SymDeferred);
409  pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts;
410  }
411  return pair->effective->module.SymType != SymNone;
412 }
BOOL pcs_callback(const struct process *pcs, ULONG action, void *data)
Definition: dbghelp.c:731
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:836
static struct module * module_get_container(const struct process *pcs, const struct module *inner)
Definition: module.c:329
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define assert(x)
Definition: debug.h:53
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:1026
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL pe_load_debug_info(const struct process *pcs, struct module *module) DECLSPEC_HIDDEN
Definition: pe_module.c:747
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:837
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:835
Definition: _pair.h:47

Referenced by dwarf2_virtual_unwind(), find_name(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetTypeFromName(), SymGetTypeInfo(), and symt_enum_locals().

◆ module_is_already_loaded()

struct module* module_is_already_loaded ( const struct process pcs,
const WCHAR name 
)

Definition at line 303 of file module.c.

304 {
305  struct module* module;
306  const WCHAR* filename;
307 
308  /* first compare the loaded image name... */
309  for (module = pcs->lmodules; module; module = module->next)
310  {
312  return module;
313  }
314  /* then compare the standard filenames (without the path) ... */
316  for (module = pcs->lmodules; module; module = module->next)
317  {
319  return module;
320  }
322  return NULL;
323 }
static HMODULE module
Definition: module.c:32
const char * filename
Definition: ioapi.h:135
WCHAR LoadedImageName[256]
Definition: compat.h:937
struct module * lmodules
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112
Definition: name.c:38
#define ERROR_INVALID_NAME
Definition: compat.h:103
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by elf_load_cb(), elf_search_and_load_file(), macho_search_and_load_file(), and SymLoadModuleExW().

◆ module_is_container_loaded()

static BOOL module_is_container_loaded ( const struct process pcs,
const WCHAR ImageName,
DWORD64  base 
)
static

Definition at line 451 of file module.c.

453 {
454  size_t len;
455  struct module* module;
456  PCWSTR filename, modname;
457 
458  if (!base) return FALSE;
460  len = lstrlenW(filename);
461 
462  for (module = pcs->lmodules; module; module = module->next)
463  {
464  if ((module->type == DMT_ELF || module->type == DMT_MACHO) &&
467  {
469  if (!wcsnicmp(modname, filename, len) &&
470  !memcmp(modname + len, S_DotSoW, 3 * sizeof(WCHAR)))
471  {
472  return TRUE;
473  }
474  }
475  }
476  /* likely a native PE module */
477  WARN("Couldn't find container for %s\n", debugstr_w(ImageName));
478  return FALSE;
479 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
#define WARN(fmt,...)
Definition: debug.h:112
static HMODULE module
Definition: module.c:32
const char * filename
Definition: ioapi.h:135
#define lstrlenW
Definition: compat.h:609
enum module_type type
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const char * ImageName
Definition: image.c:34
#define wcsnicmp
Definition: compat.h:14
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR S_DotSoW[]
Definition: module.c:44
#define NULL
Definition: types.h:112
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by SymLoadModuleExW().

◆ module_new()

struct module* module_new ( struct process pcs,
const WCHAR name,
enum module_type  type,
BOOL  virtual,
DWORD64  mod_addr,
DWORD64  size,
ULONG_PTR  stamp,
ULONG_PTR  checksum 
)

Definition at line 198 of file module.c.

202 {
203  struct module* module;
204  unsigned i;
205 
206  assert(type == DMT_ELF || type == DMT_PE || type == DMT_MACHO);
207  if (!(module = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*module))))
208  return NULL;
209 
210  module->next = pcs->lmodules;
211  pcs->lmodules = module;
212 
213  TRACE("=> %s %s-%s %s\n",
214  get_module_type(type, virtual),
215  wine_dbgstr_longlong(mod_addr), wine_dbgstr_longlong(mod_addr + size),
216  debugstr_w(name));
217 
218  pool_init(&module->pool, 65536);
219 
220  module->process = pcs;
221  module->module.SizeOfStruct = sizeof(module->module);
222  module->module.BaseOfImage = mod_addr;
225  module->module.ImageName[0] = '\0';
228  module->module.NumSyms = 0;
229  module->module.TimeDateStamp = stamp;
231 
233  module->module.CVSig = 0;
234  memset(module->module.CVData, 0, sizeof(module->module.CVData));
235  module->module.PdbSig = 0;
237  module->module.PdbAge = 0;
245 
246  module->reloc_delta = 0;
247  module->type = type;
248  module->is_virtual = virtual;
249  for (i = 0; i < DFI_LAST; i++) module->format_info[i] = NULL;
251  module->sorttab_size = 0;
253  module->num_sorttab = 0;
254  module->num_symbols = 0;
255 
256  vector_init(&module->vsymt, sizeof(struct symt*), 128);
257  /* FIXME: this seems a bit too high (on a per module basis)
258  * need some statistics about this
259  */
262 #ifdef __x86_64__
263  hash_table_init(&module->pool, &module->ht_symaddr, 4096);
264 #endif
265  vector_init(&module->vtypes, sizeof(struct symt*), 32);
266 
267  module->sources_used = 0;
268  module->sources_alloc = 0;
269  module->sources = 0;
271 
272  return module;
273 }
unsigned sources_alloc
DWORD64 BaseOfImage
Definition: compat.h:929
unsigned sources_used
struct hash_table ht_symbols
struct vector vsymt
static HMODULE module
Definition: module.c:32
#define assert(x)
Definition: debug.h:53
struct wine_rb_tree sources_offsets_tree
unsigned num_symbols
char * sources
#define lstrcpynW
Definition: compat.h:597
enum module_type type
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
struct module * lmodules
int sortlist_valid
int source_rb_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN
Definition: source.c:40
#define debugstr_w
Definition: kernel32.h:32
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:133
unsigned num_sorttab
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct vector vtypes
WCHAR ImageName[256]
Definition: compat.h:936
void module_set_module(struct module *module, const WCHAR *name)
Definition: module.c:142
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:43
static const char * get_module_type(enum module_type type, BOOL virtual)
Definition: module.c:184
DWORD SizeOfStruct
Definition: compat.h:928
SYM_TYPE SymType
Definition: compat.h:934
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
struct pool pool
struct process * process
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
#define ARRAY_SIZE(a)
Definition: main.h:24
unsigned short is_virtual
DWORD TimeDateStamp
Definition: compat.h:931
struct hash_table ht_types
WCHAR CVData[MAX_PATH *3]
Definition: compat.h:940
#define NULL
Definition: types.h:112
unsigned sorttab_size
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
WCHAR LoadedPdbName[256]
Definition: compat.h:938
void hash_table_init(struct pool *pool, struct hash_table *ht, unsigned num_buckets) DECLSPEC_HIDDEN
Definition: storage.c:334
Definition: name.c:38
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
struct symt_ht ** addr_sorttab
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by elf_load_file_from_fmap(), macho_load_file(), pe_load_builtin_module(), pe_load_native_module(), and SymLoadModuleExW().

◆ module_remove()

BOOL module_remove ( struct process pcs,
struct module module 
)

Definition at line 889 of file module.c.

890 {
891  struct module_format*modfmt;
892  struct module** p;
893  unsigned i;
894 
895  TRACE("%s (%p)\n", debugstr_w(module->module.ModuleName), module);
896 
897  for (i = 0; i < DFI_LAST; i++)
898  {
899  if ((modfmt = module->format_info[i]) && modfmt->remove)
900  modfmt->remove(pcs, module->format_info[i]);
901  }
908  /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
909  * so do we
910  */
911  for (p = &pcs->lmodules; *p; p = &(*p)->next)
912  {
913  if (*p == module)
914  {
915  *p = module->next;
917  return TRUE;
918  }
919  }
920  FIXME("This shouldn't happen\n");
921  return FALSE;
922 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
WCHAR * real_path
WCHAR ModuleName[32]
Definition: compat.h:935
#define TRUE
Definition: types.h:120
struct hash_table ht_symbols
char * sources
#define FALSE
Definition: types.h:117
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
struct pool pool
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:342
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:50
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
struct hash_table ht_types
struct symt_ht ** addr_sorttab
GLfloat GLfloat p
Definition: glext.h:8902
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by elf_synchronize_module_list(), macho_synchronize_module_list(), SymCleanup(), SymUnloadModule(), and SymUnloadModule64().

◆ module_reset_debug_info()

void module_reset_debug_info ( struct module module)

Definition at line 1328 of file module.c.

1329 {
1331  module->sorttab_size = 0;
1335  module->ht_symbols.num_buckets = 0;
1336  module->ht_symbols.buckets = NULL;
1338  module->ht_types.num_buckets = 0;
1339  module->ht_types.buckets = NULL;
1340  module->vtypes.num_elts = 0;
1343  module->sources = NULL;
1344 }
unsigned sources_alloc
#define TRUE
Definition: types.h:120
unsigned sources_used
struct hash_table ht_symbols
unsigned num_symbols
char * sources
int sortlist_valid
unsigned num_sorttab
struct vector vtypes
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:342
struct hash_table ht_types
#define NULL
Definition: types.h:112
unsigned sorttab_size
struct symt_ht ** addr_sorttab

Referenced by stabs_parse().

◆ module_set_module()

void module_set_module ( struct module module,
const WCHAR name 
)

Definition at line 142 of file module.c.

143 {
146 }
WCHAR ModuleName[32]
Definition: compat.h:935
WCHAR modulename[64]
#define ARRAY_SIZE(a)
Definition: main.h:24
static void module_fill_module(const WCHAR *in, WCHAR *out, size_t size)
Definition: module.c:118
Definition: name.c:38
IMAGEHLP_MODULEW64 module

Referenced by elf_read_wine_loader_dbg_info(), macho_read_wine_loader_dbg_info(), module_new(), and SymLoadModuleExW().

◆ native_enum_modules()

static BOOL native_enum_modules ( struct process process,
enum_modules_cb  cb,
void user 
)
static

Definition at line 1398 of file module.c.

1399 {
1400  return FALSE;
1401 }
#define FALSE
Definition: types.h:117

◆ native_fetch_file_info()

static BOOL native_fetch_file_info ( struct process process,
const WCHAR name,
ULONG_PTR  load_addr,
DWORD_PTR base,
DWORD size,
DWORD checksum 
)
static

Definition at line 1403 of file module.c.

1405 {
1406  return FALSE;
1407 }
#define FALSE
Definition: types.h:117

◆ native_load_debug_info()

static BOOL native_load_debug_info ( struct process process,
struct module module 
)
static

Definition at line 1393 of file module.c.

1394 {
1395  return FALSE;
1396 }
#define FALSE
Definition: types.h:117

◆ native_load_module()

static struct module* native_load_module ( struct process pcs,
const WCHAR name,
ULONG_PTR  addr 
)
static

Definition at line 1388 of file module.c.

1389 {
1390  return NULL;
1391 }
#define NULL
Definition: types.h:112

◆ native_synchronize_module_list()

static BOOL native_synchronize_module_list ( struct process pcs)
static

Definition at line 1383 of file module.c.

1384 {
1385  return FALSE;
1386 }
#define FALSE
Definition: types.h:117

◆ SymEnumerateModules()

BOOL WINAPI SymEnumerateModules ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACK  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 976 of file module.c.

979 {
980  struct enum_modW64_32 x;
981 
982  x.cb = EnumModulesCallback;
983  x.user = UserContext;
984 
986 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
Definition: module.c:1023
PSYM_ENUMMODULES_CALLBACK cb
Definition: module.c:963

◆ SymEnumerateModules64()

BOOL WINAPI SymEnumerateModules64 ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACK64  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 1007 of file module.c.

1010 {
1011  struct enum_modW64_64 x;
1012 
1013  x.cb = EnumModulesCallback;
1014  x.user = UserContext;
1015 
1017 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
Definition: module.c:1023
PSYM_ENUMMODULES_CALLBACK64 cb
Definition: module.c:994

◆ SymEnumerateModulesW64()

BOOL WINAPI SymEnumerateModulesW64 ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACKW64  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 1023 of file module.c.

1026 {
1027  struct process* pcs = process_find_by_handle(hProcess);
1028  struct module* module;
1029 
1030  if (!pcs) return FALSE;
1031 
1032  for (module = pcs->lmodules; module; module = module->next)
1033  {
1034  if (!dbghelp_opt_native &&
1035  (module->type == DMT_ELF || module->type == DMT_MACHO))
1036  continue;
1037  if (!EnumModulesCallback(module->modulename,
1038  module->module.BaseOfImage, UserContext))
1039  break;
1040  }
1041  return TRUE;
1042 }
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
BOOL dbghelp_opt_native
Definition: dbghelp.c:74
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
enum module_type type
#define FALSE
Definition: types.h:117
struct module * lmodules
WCHAR modulename[64]
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by SymEnumerateModules(), and SymEnumerateModules64().

◆ SymFunctionTableAccess()

PVOID WINAPI SymFunctionTableAccess ( HANDLE  hProcess,
DWORD  AddrBase 
)

Definition at line 1363 of file module.c.

1364 {
1365  return SymFunctionTableAccess64(hProcess, AddrBase);
1366 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase)
Definition: module.c:1371

Referenced by StackWalk().

◆ SymFunctionTableAccess64()

PVOID WINAPI SymFunctionTableAccess64 ( HANDLE  hProcess,
DWORD64  AddrBase 
)

Definition at line 1371 of file module.c.

1372 {
1373  struct process* pcs = process_find_by_handle(hProcess);
1374  struct module* module;
1375 
1376  if (!pcs || !dbghelp_current_cpu->find_runtime_function) return NULL;
1377  module = module_find_by_addr(pcs, AddrBase, DMT_UNKNOWN);
1378  if (!module) return NULL;
1379 
1380  return dbghelp_current_cpu->find_runtime_function(module, AddrBase);
1381 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define NULL
Definition: types.h:112
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:169

Referenced by PrintStackBacktrace(), StackWalk64(), and SymFunctionTableAccess().

◆ SymGetModuleBase()

DWORD WINAPI SymGetModuleBase ( HANDLE  hProcess,
DWORD  dwAddr 
)

Definition at line 1302 of file module.c.

1303 {
1304  DWORD64 ret;
1305 
1306  ret = SymGetModuleBase64(hProcess, dwAddr);
1307  return validate_addr64(ret) ? ret : 0;
1308 }
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:112
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD64 WINAPI SymGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr)
Definition: module.c:1313
int ret
uint64_t DWORD64
Definition: typedefs.h:67

Referenced by StackWalk().

◆ SymGetModuleBase64()

DWORD64 WINAPI SymGetModuleBase64 ( HANDLE  hProcess,
DWORD64  dwAddr 
)

Definition at line 1313 of file module.c.

1314 {
1315  struct process* pcs = process_find_by_handle(hProcess);
1316  struct module* module;
1317 
1318  if (!pcs) return 0;
1319  module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
1320  if (!module) return 0;
1321  return module->module.BaseOfImage;
1322 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
DWORD64 BaseOfImage
Definition: compat.h:929
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
IMAGEHLP_MODULEW64 module

Referenced by PrintStackBacktrace(), StackWalk64(), and SymGetModuleBase().

◆ SymGetModuleInfo()

BOOL WINAPI SymGetModuleInfo ( HANDLE  hProcess,
DWORD  dwAddr,
PIMAGEHLP_MODULE  ModuleInfo 
)

Definition at line 1158 of file module.c.

1160 {
1162  IMAGEHLP_MODULEW64 miw64;
1163 
1164  if (sizeof(mi) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
1165 
1166  miw64.SizeOfStruct = sizeof(miw64);
1167  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
1168 
1169  mi.SizeOfStruct = ModuleInfo->SizeOfStruct;
1170  mi.BaseOfImage = miw64.BaseOfImage;
1171  mi.ImageSize = miw64.ImageSize;
1172  mi.TimeDateStamp = miw64.TimeDateStamp;
1173  mi.CheckSum = miw64.CheckSum;
1174  mi.NumSyms = miw64.NumSyms;
1175  mi.SymType = miw64.SymType;
1176  dbghelp_str_WtoA(miw64.ModuleName, mi.ModuleName, sizeof(mi.ModuleName));
1177  dbghelp_str_WtoA(miw64.ImageName, mi.ImageName, sizeof(mi.ImageName));
1178  dbghelp_str_WtoA(miw64.LoadedImageName, mi.LoadedImageName, sizeof(mi.LoadedImageName));
1179 
1180  memcpy(ModuleInfo, &mi, ModuleInfo->SizeOfStruct);
1181 
1182  return TRUE;
1183 }
static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
Definition: module.c:1148
WCHAR ModuleName[32]
Definition: compat.h:935
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static MONITORINFO mi
Definition: win.c:7338
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
WCHAR ImageName[256]
Definition: compat.h:936
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1269
DWORD SizeOfStruct
Definition: compat.h:928
SYM_TYPE SymType
Definition: compat.h:934
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD TimeDateStamp
Definition: compat.h:931

◆ SymGetModuleInfo64()

BOOL WINAPI SymGetModuleInfo64 ( HANDLE  hProcess,
DWORD64  dwAddr,
PIMAGEHLP_MODULE64  ModuleInfo 
)

Definition at line 1219 of file module.c.

1221 {
1222  IMAGEHLP_MODULE64 mi64;
1223  IMAGEHLP_MODULEW64 miw64;
1224 
1225  if (sizeof(mi64) < ModuleInfo->SizeOfStruct)
1226  {
1227  SetLastError(ERROR_MOD_NOT_FOUND); /* NOTE: native returns this error */
1228  WARN("Wrong size %u\n", ModuleInfo->SizeOfStruct);
1229  return FALSE;
1230  }
1231 
1232  miw64.SizeOfStruct = sizeof(miw64);
1233  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
1234 
1235  mi64.SizeOfStruct = ModuleInfo->SizeOfStruct;
1236  mi64.BaseOfImage = miw64.BaseOfImage;
1237  mi64.ImageSize = miw64.ImageSize;
1238  mi64.TimeDateStamp = miw64.TimeDateStamp;
1239  mi64.CheckSum = miw64.CheckSum;
1240  mi64.NumSyms = miw64.NumSyms;
1241  mi64.SymType = miw64.SymType;
1242  dbghelp_str_WtoA(miw64.ModuleName, mi64.ModuleName, sizeof(mi64.ModuleName));
1243  dbghelp_str_WtoA(miw64.ImageName, mi64.ImageName, sizeof(mi64.ImageName));
1245  dbghelp_str_WtoA(miw64.LoadedPdbName, mi64.LoadedPdbName, sizeof(mi64.LoadedPdbName));
1246 
1247  mi64.CVSig = miw64.CVSig;
1248  dbghelp_str_WtoA(miw64.CVData, mi64.CVData, sizeof(mi64.CVData));
1249  mi64.PdbSig = miw64.PdbSig;
1250  mi64.PdbSig70 = miw64.PdbSig70;
1251  mi64.PdbAge = miw64.PdbAge;
1252  mi64.PdbUnmatched = miw64.PdbUnmatched;
1253  mi64.DbgUnmatched = miw64.DbgUnmatched;
1254  mi64.LineNumbers = miw64.LineNumbers;
1255  mi64.GlobalSymbols = miw64.GlobalSymbols;
1256  mi64.TypeInfo = miw64.TypeInfo;
1257  mi64.SourceIndexed = miw64.SourceIndexed;
1258  mi64.Publics = miw64.Publics;
1259 
1260  memcpy(ModuleInfo, &mi64, ModuleInfo->SizeOfStruct);
1261 
1262  return TRUE;
1263 }
SYM_TYPE SymType
Definition: compat.h:1103
static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
Definition: module.c:1148
WCHAR ModuleName[32]
Definition: compat.h:935
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
CHAR LoadedPdbName[256]
Definition: compat.h:1107
#define WARN(fmt,...)
Definition: debug.h:112
CHAR ModuleName[32]
Definition: compat.h:1104
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD TimeDateStamp
Definition: compat.h:1100
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
DWORD SizeOfStruct
Definition: compat.h:1097
DWORD64 BaseOfImage
Definition: compat.h:1098
WCHAR ImageName[256]
Definition: compat.h:936
#define SetLastError(x)
Definition: compat.h:611
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1269
DWORD SizeOfStruct
Definition: compat.h:928
SYM_TYPE SymType
Definition: compat.h:934
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CHAR CVData[MAX_PATH *3]
Definition: compat.h:1109
DWORD TimeDateStamp
Definition: compat.h:931
WCHAR CVData[MAX_PATH *3]
Definition: compat.h:940
WCHAR LoadedPdbName[256]
Definition: compat.h:938
CHAR ImageName[256]
Definition: compat.h:1105
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
CHAR LoadedImageName[256]
Definition: compat.h:1106

Referenced by PrintStackBacktrace(), supports_pdb(), and supports_rsym().

◆ SymGetModuleInfoW()

BOOL WINAPI SymGetModuleInfoW ( HANDLE  hProcess,
DWORD  dwAddr,
PIMAGEHLP_MODULEW  ModuleInfo 
)

Definition at line 1189 of file module.c.

1191 {
1192  IMAGEHLP_MODULEW64 miw64;
1193  IMAGEHLP_MODULEW miw;
1194 
1195  if (sizeof(miw) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
1196 
1197  miw64.SizeOfStruct = sizeof(miw64);
1198  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
1199 
1200  miw.SizeOfStruct = ModuleInfo->SizeOfStruct;
1201  miw.BaseOfImage = miw64.BaseOfImage;
1202  miw.ImageSize = miw64.ImageSize;
1203  miw.TimeDateStamp = miw64.TimeDateStamp;
1204  miw.CheckSum = miw64.CheckSum;
1205  miw.NumSyms = miw64.NumSyms;
1206  miw.SymType = miw64.SymType;
1207  lstrcpyW(miw.ModuleName, miw64.ModuleName);
1208  lstrcpyW(miw.ImageName, miw64.ImageName);
1210  memcpy(ModuleInfo, &miw, ModuleInfo->SizeOfStruct);
1211 
1212  return TRUE;
1213 }
WCHAR ModuleName[32]
Definition: compat.h:935
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
DWORD BaseOfImage
Definition: compat.h:1075
WCHAR ImageName[256]
Definition: compat.h:1082
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
WCHAR LoadedImageName[256]
Definition: compat.h:937
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
WCHAR LoadedImageName[256]
Definition: compat.h:1083
WCHAR ImageName[256]
Definition: compat.h:936
DWORD SizeOfStruct
Definition: compat.h:1074
SYM_TYPE SymType
Definition: compat.h:1080
WCHAR ModuleName[32]
Definition: compat.h:1081
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1269
DWORD SizeOfStruct
Definition: compat.h:928
SYM_TYPE SymType
Definition: compat.h:934
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define lstrcpyW
Definition: compat.h:608
DWORD TimeDateStamp
Definition: compat.h:931
DWORD TimeDateStamp
Definition: compat.h:1077

◆ SymGetModuleInfoW64()

BOOL WINAPI SymGetModuleInfoW64 ( HANDLE  hProcess,
DWORD64  dwAddr,
PIMAGEHLP_MODULEW64  ModuleInfo 
)

Definition at line 1269 of file module.c.

1271 {
1272  struct process* pcs = process_find_by_handle(hProcess);
1273  struct module* module;
1274  IMAGEHLP_MODULEW64 miw64;
1275 
1276  TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo);
1277 
1278  if (!pcs) return FALSE;
1279  if (ModuleInfo->SizeOfStruct > sizeof(*ModuleInfo)) return FALSE;
1280  module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
1281  if (!module) return FALSE;
1282 
1283  miw64 = module->module;
1284 
1285  /* update debug information from container if any */
1286  if (module->module.SymType == SymNone)
1287  {
1289  if (module && module->module.SymType != SymNone)
1290  {
1291  miw64.SymType = module->module.SymType;
1292  miw64.NumSyms = module->module.NumSyms;
1293  }
1294  }
1295  memcpy(ModuleInfo, &miw64, ModuleInfo->SizeOfStruct);
1296  return TRUE;
1297 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
#define TRUE
Definition: types.h:120
static struct module * module_get_container(const struct process *pcs, const struct module *inner)
Definition: module.c:329
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define FALSE
Definition: types.h:117
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
#define TRACE(s)
Definition: solgame.cpp:4
SYM_TYPE SymType
Definition: compat.h:934
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
IMAGEHLP_MODULEW64 module

Referenced by SymGetModuleInfo(), SymGetModuleInfo64(), and SymGetModuleInfoW().

◆ SymLoadModule()

DWORD WINAPI SymLoadModule ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD  BaseOfDll,
DWORD  SizeOfDll 
)

Definition at line 753 of file module.c.

755 {
756  return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll,
757  SizeOfDll, NULL, 0);
758 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1274
static const char * ImageName
Definition: image.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
#define NULL
Definition: types.h:112
DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:763

Referenced by main().

◆ SymLoadModule64()

DWORD64 WINAPI SymLoadModule64 ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD64  BaseOfDll,
DWORD  SizeOfDll 
)

Definition at line 878 of file module.c.

880 {
881  return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, SizeOfDll,
882  NULL, 0);
883 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1274
static const char * ImageName
Definition: image.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
#define NULL
Definition: types.h:112
DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:763

Referenced by LoadModuleWithSymbolsFullPath(), main(), START_TEST(), and test_SymRegCallback().

◆ SymLoadModuleEx()

DWORD64 WINAPI SymLoadModuleEx ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD64  BaseOfDll,
DWORD  DllSize,
PMODLOAD_DATA  Data,
DWORD  Flags 
)

Definition at line 763 of file module.c.

766 {
767  PWSTR wImageName, wModuleName;
768  unsigned len;
769  DWORD64 ret;
770 
771  TRACE("(%p %p %s %s %s %08x %p %08x)\n",
773  wine_dbgstr_longlong(BaseOfDll), DllSize, Data, Flags);
774 
775  if (ImageName)
776  {
778  wImageName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
779  MultiByteToWideChar(CP_ACP, 0, ImageName, -1, wImageName, len);
780  }
781  else wImageName = NULL;
782  if (ModuleName)
783  {
785  wModuleName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
786  MultiByteToWideChar(CP_ACP, 0, ModuleName, -1, wModuleName, len);
787  }
788  else wModuleName = NULL;
789 
790  ret = SymLoadModuleExW(hProcess, hFile, wImageName, wModuleName,
791  BaseOfDll, DllSize, Data, Flags);
792  HeapFree(GetProcessHeap(), 0, wImageName);
793  HeapFree(GetProcessHeap(), 0, wModuleName);
794  return ret;
795 }
uint16_t * PWSTR
Definition: typedefs.h:56
#define CP_ACP
Definition: compat.h:109
DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageName, PCWSTR wModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:800
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1274
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
int ret
static const char * ImageName
Definition: image.c:34
GLenum GLsizei len
Definition: glext.h:6722
_In_ HANDLE hFile
Definition: mswsock.h:90
uint64_t DWORD64
Definition: typedefs.h:67
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by SymLoadModule(), and SymLoadModule64().

◆ SymLoadModuleExW()

DWORD64 WINAPI SymLoadModuleExW ( HANDLE  hProcess,
HANDLE  hFile,
PCWSTR  wImageName,
PCWSTR  wModuleName,
DWORD64  BaseOfDll,
DWORD  SizeOfDll,
PMODLOAD_DATA  Data,
DWORD  Flags 
)

Definition at line 800 of file module.c.

803 {
804  struct process* pcs;
805  struct module* module = NULL;
806 
807  TRACE("(%p %p %s %s %s %08x %p %08x)\n",
808  hProcess, hFile, debugstr_w(wImageName), debugstr_w(wModuleName),
809  wine_dbgstr_longlong(BaseOfDll), SizeOfDll, Data, Flags);
810 
811  if (Data)
812  FIXME("Unsupported load data parameter %p for %s\n",
813  Data, debugstr_w(wImageName));
814  if (!validate_addr64(BaseOfDll)) return FALSE;
815 
816  if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
817 
818  if (Flags & SLMFLAG_VIRTUAL)
819  {
820  if (!wImageName) return FALSE;
821  module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0);
822  if (!module) return FALSE;
823  if (wModuleName) module_set_module(module, wModuleName);
825 
826  return TRUE;
827  }
828  if (Flags & ~(SLMFLAG_VIRTUAL))
829  FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
830 
831  pcs->loader->synchronize_module_list(pcs);
832 
833  /* this is a Wine extension to the API just to redo the synchronisation */
834  if (!wImageName && !hFile) return 0;
835 
836  /* check if the module is already loaded, or if it's a builtin PE module with
837  * an containing ELF module
838  */
839  if (wImageName)
840  {
841  module = module_is_already_loaded(pcs, wImageName);
842  if (!module && module_is_container_loaded(pcs, wImageName, BaseOfDll))
843  {
844  /* force the loading of DLL as builtin */
845  module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll);
846  }
847  }
848  if (!module)
849  {
850  /* otherwise, try a regular PE module */
851  if (!(module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)) &&
852  wImageName)
853  {
854  /* and finally an ELF or Mach-O module */
855  module = pcs->loader->load_module(pcs, wImageName, BaseOfDll);
856  }
857  }
858  if (!module)
859  {
860  WARN("Couldn't locate %s\n", debugstr_w(wImageName));
861  return 0;
862  }
863  module->module.NumSyms = module->ht_symbols.num_elts;
864  /* by default module_new fills module.ModuleName from a derivation
865  * of LoadedImageName. Overwrite it, if we have better information
866  */
867  if (wModuleName)
868  module_set_module(module, wModuleName);
869  if (wImageName)
871 
872  return module->module.BaseOfImage;
873 }
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
struct hash_table ht_symbols
#define WARN(fmt,...)
Definition: debug.h:112
struct module * module_is_already_loaded(const struct process *pcs, const WCHAR *name)
Definition: module.c:303
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:112
#define SLMFLAG_VIRTUAL
Definition: compat.h:885
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrcpynW
Definition: compat.h:597
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
struct module * pe_load_native_module(struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size) DECLSPEC_HIDDEN
Definition: pe_module.c:799
static BOOL module_is_container_loaded(const struct process *pcs, const WCHAR *ImageName, DWORD64 base)
Definition: module.c:451
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
const struct loader_ops * loader
WCHAR ImageName[256]
Definition: compat.h:936
struct module * pe_load_builtin_module(struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size) DECLSPEC_HIDDEN
Definition: pe_module.c:892
void module_set_module(struct module *module, const WCHAR *name)
Definition: module.c:142
SYM_TYPE SymType
Definition: compat.h:934
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum)
Definition: module.c:198
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
IMAGEHLP_MODULEW64 module

Referenced by process_invade_cb(), and SymLoadModuleEx().

◆ SymRefreshModuleList()

BOOL WINAPI SymRefreshModuleList ( HANDLE  hProcess)

Definition at line 1349 of file module.c.

1350 {
1351  struct process* pcs;
1352 
1353  TRACE("(%p)\n", hProcess);
1354 
1355  if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
1356 
1357  return pcs->loader->synchronize_module_list(pcs);
1358 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
const struct loader_ops * loader

◆ SymUnloadModule()

BOOL WINAPI SymUnloadModule ( HANDLE  hProcess,
DWORD  BaseOfDll 
)

Definition at line 928 of file module.c.

929 {
930  struct process* pcs;
931  struct module* module;
932 
934  if (!pcs) return FALSE;
935  module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
936  if (!module) return FALSE;
937  return module_remove(pcs, module);
938 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define FALSE
Definition: types.h:117
BOOL module_remove(struct process *pcs, struct module *module)
Definition: module.c:889

Referenced by main().

◆ SymUnloadModule64()

BOOL WINAPI SymUnloadModule64 ( HANDLE  hProcess,
DWORD64  BaseOfDll 
)

Definition at line 944 of file module.c.

945 {
946  struct process* pcs;
947  struct module* module;
948 
950  if (!pcs) return FALSE;
951  if (!validate_addr64(BaseOfDll)) return FALSE;
952  module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
953  if (!module) return FALSE;
954  return module_remove(pcs, module);
955 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:420
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
static HMODULE module
Definition: module.c:32
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:112
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define FALSE
Definition: types.h:117
BOOL module_remove(struct process *pcs, struct module *module)
Definition: module.c:889

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp  )

Variable Documentation

◆ ext

Definition at line 53 of file module.c.

Referenced by match_ext().

◆ no_loader_ops

const struct loader_ops no_loader_ops
Initial value:
=
{
}
static struct module * native_load_module(struct process *pcs, const WCHAR *name, ULONG_PTR addr)
Definition: module.c:1388
static BOOL native_load_debug_info(struct process *process, struct module *module)
Definition: module.c:1393
static BOOL native_enum_modules(struct process *process, enum_modules_cb cb, void *user)
Definition: module.c:1398
static BOOL native_fetch_file_info(struct process *process, const WCHAR *name, ULONG_PTR load_addr, DWORD_PTR *base, DWORD *size, DWORD *checksum)
Definition: module.c:1403
static BOOL native_synchronize_module_list(struct process *pcs)
Definition: module.c:1383

Definition at line 1409 of file module.c.

Referenced by SymInitializeW().

◆ S_AcmW

const WCHAR S_AcmW[] = {'.','a','c','m','\0'}
static

Definition at line 47 of file module.c.

◆ S_DllW

const WCHAR S_DllW[] = {'.','d','l','l','\0'}
static

Definition at line 48 of file module.c.

◆ S_DotSoW

const WCHAR S_DotSoW[] = {'.','s','o','\0'}
static

Definition at line 44 of file module.c.

Referenced by module_fill_module(), and module_is_container_loaded().

◆ S_DrvW

const WCHAR S_DrvW[] = {'.','d','r','v','\0'}
static

Definition at line 49 of file module.c.

◆ S_ElfW

const WCHAR S_ElfW = {'<','e','l','f','>','\0'}

Definition at line 40 of file module.c.

Referenced by elf_load_debug_info_from_map(), and module_fill_module().

◆ S_ExeW

const WCHAR S_ExeW[] = {'.','e','x','e','\0'}
static

Definition at line 50 of file module.c.

◆ S_OcxW

const WCHAR S_OcxW[] = {'.','o','c','x','\0'}
static

Definition at line 51 of file module.c.

◆ S_SlashW

const WCHAR S_SlashW = {'/','\0'}

Definition at line 45 of file module.c.

◆ S_VxdW

const WCHAR S_VxdW[] = {'.','v','x','d','\0'}
static

Definition at line 52 of file module.c.

◆ S_WineLoaderW

const WCHAR S_WineLoaderW = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}