Commit 5654af81 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Add new module at end of the process' modules list.

This preserves order in which modules are loaded, and enumeration is done according to this order. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent c823f9b1
......@@ -333,10 +333,8 @@ const struct cpu* process_get_cpu(const struct process* pcs)
{
const struct module* m = pcs->lmodules;
/* main module is the last one in list */
if (!m) return dbghelp_current_cpu;
while (m->next) m = m->next;
return m->cpu;
/* return cpu of main module, which is the first module in process's modules list */
return (m) ? m->cpu : dbghelp_current_cpu;
}
/******************************************************************
......
......@@ -177,14 +177,16 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
ULONG_PTR stamp, ULONG_PTR checksum, WORD machine)
{
struct module* module;
struct module** pmodule;
unsigned i;
assert(type == DMT_ELF || type == DMT_PE || type == DMT_MACHO);
if (!(module = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*module))))
return NULL;
module->next = pcs->lmodules;
pcs->lmodules = module;
for (pmodule = &pcs->lmodules; *pmodule; pmodule = &(*pmodule)->next);
module->next = NULL;
*pmodule = module;
TRACE("=> %s %I64x-%I64x %s\n",
get_module_type(type, virtual), mod_addr, mod_addr + size, debugstr_w(name));
......
......@@ -285,7 +285,6 @@ struct nth_module
unsigned int index;
BOOL will_fail;
IMAGEHLP_MODULE64 module;
BOOL with_todo_wine;
};
static BOOL CALLBACK nth_module_cb(const char* name, DWORD64 base, void* usr)
......@@ -296,8 +295,6 @@ static BOOL CALLBACK nth_module_cb(const char* name, DWORD64 base, void* usr)
if (nth->index--) return TRUE;
nth->module.SizeOfStruct = sizeof(nth->module);
ret = SymGetModuleInfo64(nth->proc, base, &nth->module);
todo_wine_if(nth->with_todo_wine)
{
if (nth->will_fail)
{
ok(!ret, "SymGetModuleInfo64 should have failed\n");
......@@ -308,7 +305,6 @@ static BOOL CALLBACK nth_module_cb(const char* name, DWORD64 base, void* usr)
ok(ret, "SymGetModuleInfo64 failed: %lu\n", GetLastError());
ok(nth->module.BaseOfImage == base, "Wrong base\n");
}
}
return FALSE;
}
......@@ -465,7 +461,7 @@ static void test_modules_overlap(void)
}
for (j = 0; j < ARRAY_SIZE(tests[i].outputs); j++)
{
struct nth_module nth = {dummy, j, !tests[i].outputs[j].name, {0}, i == 9 || i == 11};
struct nth_module nth = {dummy, j, !tests[i].outputs[j].name, {0}};
ret = SymEnumerateModules64(dummy, nth_module_cb, &nth);
ok(ret, "SymEnumerateModules64 failed: %lu\n", GetLastError());
......@@ -475,13 +471,13 @@ static void test_modules_overlap(void)
break;
}
ok(nth.index == -1, "Expecting more modules\n");
todo_wine_if(i >= 6)
todo_wine_if(i == 6 || i == 7)
ok(nth.module.BaseOfImage == tests[i].outputs[j].base, "Wrong base\n");
if (!nth.will_fail)
{
todo_wine_if(i == 7 || i == 9 || i == 11)
todo_wine_if(i == 7)
ok(nth.module.ImageSize == tests[i].outputs[j].size, "Wrong size\n");
todo_wine_if(i >= 6 && i != 8)
todo_wine_if(i == 6 || i == 7)
ok(!strcasecmp(nth.module.ModuleName, tests[i].outputs[j].name), "Wrong name\n");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment