Module: wine
Branch: master
Commit: 32bc569520d2761a40a88d65d9a943d7292bcdf6
URL: https://gitlab.winehq.org/wine/wine/-/commit/32bc569520d2761a40a88d65d9a943…
Author: Eric Pouech <eric.pouech(a)gmail.com>
Date: Thu Feb 16 10:49:01 2023 +0100
dbghelp: Unload overlapping modules in SymLoadModule*().
Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com>
---
dlls/dbghelp/module.c | 20 +++++++-------------
dlls/dbghelp/tests/dbghelp.c | 4 ----
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index b6f36b1f28a..ad8ec22fe32 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -992,17 +992,10 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
}
if (altmodule)
{
- /* we have a conflict as the new module cannot be found by its base address
- * we need to get rid of one on the two modules
+ /* We have a conflict as the new module cannot be found by its base address
+ * (it's hidden by altmodule).
+ * We need to decide which one the two modules we need to get rid of.
*/
- if (lstrcmpW(module->modulename, altmodule->modulename) != 0)
- {
- /* module overlaps an existing but different module... unload new module and return error */
- WARN("%ls overlaps %ls\n", module->modulename, altmodule->modulename);
- module_remove(pcs, module);
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
/* loading same module at same address... don't change anything */
if (module->module.BaseOfImage == altmodule->module.BaseOfImage)
{
@@ -1010,9 +1003,10 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
SetLastError(ERROR_SUCCESS);
return 0;
}
- /* replace old module with new one, which will look like a shift of base address */
- WARN("Shift module %ls from %I64x to %I64x\n",
- module->modulename, altmodule->module.BaseOfImage, module->module.BaseOfImage);
+ /* replace old module with new one */
+ WARN("Replace module %ls at %I64x by module %ls at %I64x\n",
+ altmodule->module.ImageName, altmodule->module.BaseOfImage,
+ module->module.ImageName, module->module.BaseOfImage);
module_remove(pcs, altmodule);
}
diff --git a/dlls/dbghelp/tests/dbghelp.c b/dlls/dbghelp/tests/dbghelp.c
index 6b7c6b8d5b8..83805f3ed10 100644
--- a/dlls/dbghelp/tests/dbghelp.c
+++ b/dlls/dbghelp/tests/dbghelp.c
@@ -456,7 +456,6 @@ static void test_modules_overlap(void)
}
else
{
- todo_wine_if(i == 6 || i == 7)
ok(base == tests[i].input.base, "SymLoadModuleEx failed: %lu\n", GetLastError());
}
for (j = 0; j < ARRAY_SIZE(tests[i].outputs); j++)
@@ -471,13 +470,10 @@ static void test_modules_overlap(void)
break;
}
ok(nth.index == -1, "Expecting more modules\n");
- 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)
ok(nth.module.ImageSize == tests[i].outputs[j].size, "Wrong size\n");
- todo_wine_if(i == 6 || i == 7)
ok(!strcasecmp(nth.module.ModuleName, tests[i].outputs[j].name), "Wrong name\n");
}
}