* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
#include "dbghelp_private.h"
+#ifndef DBGHELP_STATIC_LIB
+#include "psapi.h"
+#include "winternl.h"
+#include "wine/debug.h"
+#endif
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
-#define DLLPREFIX ""
-
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'};
void module_set_module(struct module* module, const WCHAR* name)
{
- module_fill_module(name, module->module.ModuleName, sizeof(module->module.ModuleName));
+ module_fill_module(name, module->module.ModuleName,
+ sizeof(module->module.ModuleName) / sizeof(module->module.ModuleName[0]));
+ module_fill_module(name, module->modulename, sizeof(module->modulename) / sizeof(module->modulename[0]));
}
const WCHAR *get_wine_loader_name(void)
module->sources_used = 0;
module->sources_alloc = 0;
module->sources = 0;
- wine_rb_init(&module->sources_offsets_tree, &source_rb_functions);
+ wine_rb_init(&module->sources_offsets_tree, source_rb_compare);
return module;
}
break;
#ifndef DBGHELP_STATIC_LIB
case DMT_MACHO:
- ret = macho_load_debug_info(pair->effective, NULL);
+ ret = macho_load_debug_info(pair->effective);
break;
#endif
default:
return module;
}
}
- SetLastError(ERROR_INVALID_ADDRESS);
+ SetLastError(ERROR_MOD_NOT_FOUND);
return module;
}
size_t len;
struct module* module;
PCWSTR filename, modname;
- static WCHAR* dll_prefix;
- static int dll_prefix_len;
-
- if (!dll_prefix)
- {
- dll_prefix_len = MultiByteToWideChar( CP_UNIXCP, 0, DLLPREFIX, -1, NULL, 0 );
- dll_prefix = HeapAlloc( GetProcessHeap(), 0, dll_prefix_len * sizeof(WCHAR) );
- MultiByteToWideChar( CP_UNIXCP, 0, DLLPREFIX, -1, dll_prefix, dll_prefix_len );
- dll_prefix_len--;
- }
if (!base) return FALSE;
filename = get_filename(ImageName, NULL);
base < module->module.BaseOfImage + module->module.ImageSize)
{
modname = get_filename(module->module.LoadedImageName, NULL);
- if (dll_prefix_len && !strncmpW( modname, dll_prefix, dll_prefix_len )) modname += dll_prefix_len;
if (!strncmpiW(modname, filename, len) &&
!memcmp(modname + len, S_DotSoW, 3 * sizeof(WCHAR)))
{
{
int i = len;
- while (i && isdigit(name[i - 1])) i--;
+ while (i && name[i - 1] >= '0' && name[i - 1] <= '9') i--;
if (i && name[i - 1] == '.')
len = i - 1;
}
hash_table_destroy(&module->ht_symbols);
hash_table_destroy(&module->ht_types);
- wine_rb_destroy(&module->sources_offsets_tree, NULL, NULL);
HeapFree(GetProcessHeap(), 0, module->sources);
HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
pool_destroy(&module->pool);
if (!(dbghelp_options & SYMOPT_WINE_WITH_NATIVE_MODULES) &&
(module->type == DMT_ELF || module->type == DMT_MACHO))
continue;
- if (!EnumModulesCallback(module->module.ModuleName,
+ if (!EnumModulesCallback(module->modulename,
module->module.BaseOfImage, UserContext))
break;
}
if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
!GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR)))
continue;
- module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR));
+ module_fill_module(baseW, modW, sizeof(modW) / sizeof(modW[0]));
EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
UserContext);
}
return sz != 0 && i == sz;
}
+
#endif /* DBGHELP_STATIC_LIB */
+static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
+{
+ WideCharToMultiByte(CP_ACP, 0, src, -1, dst, dst_len - 1, NULL, NULL);
+ dst[dst_len - 1] = 0;
+}
+
/******************************************************************
* SymGetModuleInfo (DBGHELP.@)
*
miw64.SizeOfStruct = sizeof(miw64);
if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
- mi.SizeOfStruct = miw64.SizeOfStruct;
+ mi.SizeOfStruct = ModuleInfo->SizeOfStruct;
mi.BaseOfImage = miw64.BaseOfImage;
mi.ImageSize = miw64.ImageSize;
mi.TimeDateStamp = miw64.TimeDateStamp;
mi.CheckSum = miw64.CheckSum;
mi.NumSyms = miw64.NumSyms;
mi.SymType = miw64.SymType;
- WideCharToMultiByte(CP_ACP, 0, miw64.ModuleName, -1,
- mi.ModuleName, sizeof(mi.ModuleName), NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, miw64.ImageName, -1,
- mi.ImageName, sizeof(mi.ImageName), NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, miw64.LoadedImageName, -1,
- mi.LoadedImageName, sizeof(mi.LoadedImageName), NULL, NULL);
+ dbghelp_str_WtoA(miw64.ModuleName, mi.ModuleName, sizeof(mi.ModuleName));
+ dbghelp_str_WtoA(miw64.ImageName, mi.ImageName, sizeof(mi.ImageName));
+ dbghelp_str_WtoA(miw64.LoadedImageName, mi.LoadedImageName, sizeof(mi.LoadedImageName));
memcpy(ModuleInfo, &mi, ModuleInfo->SizeOfStruct);
miw64.SizeOfStruct = sizeof(miw64);
if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
- miw.SizeOfStruct = miw64.SizeOfStruct;
+ miw.SizeOfStruct = ModuleInfo->SizeOfStruct;
miw.BaseOfImage = miw64.BaseOfImage;
miw.ImageSize = miw64.ImageSize;
miw.TimeDateStamp = miw64.TimeDateStamp;
miw64.SizeOfStruct = sizeof(miw64);
if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
- mi64.SizeOfStruct = miw64.SizeOfStruct;
+ mi64.SizeOfStruct = ModuleInfo->SizeOfStruct;
mi64.BaseOfImage = miw64.BaseOfImage;
mi64.ImageSize = miw64.ImageSize;
mi64.TimeDateStamp = miw64.TimeDateStamp;
mi64.CheckSum = miw64.CheckSum;
mi64.NumSyms = miw64.NumSyms;
mi64.SymType = miw64.SymType;
- WideCharToMultiByte(CP_ACP, 0, miw64.ModuleName, -1,
- mi64.ModuleName, sizeof(mi64.ModuleName), NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, miw64.ImageName, -1,
- mi64.ImageName, sizeof(mi64.ImageName), NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, miw64.LoadedImageName, -1,
- mi64.LoadedImageName, sizeof(mi64.LoadedImageName), NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, miw64.LoadedPdbName, -1,
- mi64.LoadedPdbName, sizeof(mi64.LoadedPdbName), NULL, NULL);
+ dbghelp_str_WtoA(miw64.ModuleName, mi64.ModuleName, sizeof(mi64.ModuleName));
+ dbghelp_str_WtoA(miw64.ImageName, mi64.ImageName, sizeof(mi64.ImageName));
+ dbghelp_str_WtoA(miw64.LoadedImageName, mi64.LoadedImageName, sizeof(mi64.LoadedImageName));
+ dbghelp_str_WtoA(miw64.LoadedPdbName, mi64.LoadedPdbName, sizeof(mi64.LoadedPdbName));
mi64.CVSig = miw64.CVSig;
- WideCharToMultiByte(CP_ACP, 0, miw64.CVData, -1,
- mi64.CVData, sizeof(mi64.CVData), NULL, NULL);
+ dbghelp_str_WtoA(miw64.CVData, mi64.CVData, sizeof(mi64.CVData));
mi64.PdbSig = miw64.PdbSig;
mi64.PdbSig70 = miw64.PdbSig70;
mi64.PdbAge = miw64.PdbAge;