From 4add408d1049c3cf947f33cc0b836aab70340b5e Mon Sep 17 00:00:00 2001 From: Jason Green Date: Tue, 20 Nov 2007 15:28:55 -0500 Subject: [PATCH] Add a number of TRACEs to the Module functions --- dlls/dbghelp/module.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 43 insertions(+), 5 deletions(-) diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index f3c5e15..8c373cb 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -526,21 +526,29 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam */ if (wImageName) { + TRACE("loading the module %s\n", debugstr_w(wImageName)); module = module_is_already_loaded(pcs, wImageName); + + TRACE("checking if the module's elf container is already loaded\n"); if (!module && module_is_elf_container_loaded(pcs, wImageName, BaseOfDll)) { /* force the loading of DLL as builtin */ + TRACE("loading the module %s as builtin {base = 0x%08llx, size = %d}\n", debugstr_w(wImageName), BaseOfDll, SizeOfDll); module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll); } } if (!module) { + TRACE("module %s not loaded yet. Trying as a native PE module\n", debugstr_w(wImageName)); /* otherwise, try a regular PE module */ if (!(module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll))) { + TRACE("PE load failed... Getting the dbg typename from filename '%s'\n", debugstr_w(wImageName)); /* and finally and ELF module */ - if (module_get_type_by_name(wImageName) == DMT_ELF) + if (module_get_type_by_name(wImageName) == DMT_ELF){ + TRACE("found an ELF file. Loading\n"); module = elf_load_module(pcs, wImageName, BaseOfDll); + } } } if (!module) @@ -552,6 +560,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam /* by default module_new fills module.ModuleName from a derivation * of LoadedImageName. Overwrite it, if we have better information */ + TRACE("setting the module name\n"); if (wModuleName) module_set_module(module, wModuleName); lstrcpynW(module->module.ImageName, wImageName, @@ -799,6 +808,8 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, hMods = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods[0])); if (!hMods) return FALSE; + + TRACE("retrieving the module list for process %p\n", hProcess); if (!EnumProcessModules(hProcess, hMods, 256 * sizeof(hMods[0]), &sz)) { /* hProcess should also be a valid process handle !! */ @@ -806,12 +817,19 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, HeapFree(GetProcessHeap(), 0, hMods); return FALSE; } + + sz /= sizeof(HMODULE); + for (i = 0; i < sz; i++) { + TRACE("getting info for the module %p\n", hMods[i]); if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) || - !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR))) + !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR))){ + ERR("couldn't get info for %p\n", hMods[i]); continue; + } + module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR)); EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage, UserContext); @@ -977,9 +995,23 @@ DWORD WINAPI SymGetModuleBase(HANDLE hProcess, DWORD dwAddr) struct process* pcs = process_find_by_handle(hProcess); struct module* module; - if (!pcs) return 0; + + TRACE("(hProcess = %p, dwAddr = 0x%08x)\n", hProcess, dwAddr); + + if (!pcs){ + ERR("no process with the handle %p has been initialized\n", hProcess); + return 0; + } + + module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); - if (!module) return 0; + + if (!module){ + ERR("no module containing the address 0x%08x was found\n", dwAddr); + return 0; + } + + TRACE("returning base address of 0x%016llx\n", module->module.BaseOfImage); return module->module.BaseOfImage; } @@ -988,7 +1020,13 @@ DWORD WINAPI SymGetModuleBase(HANDLE hProcess, DWORD dwAddr) */ DWORD64 WINAPI SymGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr) { - if (!validate_addr64(dwAddr)) return 0; + TRACE("(hProcess = %p, dwAddr = 0x%016llx)\n", + hProcess, dwAddr); + + if (!validate_addr64(dwAddr)){ + return 0; + } + return SymGetModuleBase(hProcess, (DWORD)dwAddr); } -- 1.4.4.2