Eric Pouech : dbghelp: Improve collision handling in SymLoadModuleEx().

Alexandre Julliard julliard at winehq.org
Tue Nov 16 16:32:28 CST 2021


Module: wine
Branch: master
Commit: b65ef71fc0a7044557e0ba530e3b95497644867c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b65ef71fc0a7044557e0ba530e3b95497644867c

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Tue Nov 16 17:47:57 2021 +0100

dbghelp: Improve collision handling in SymLoadModuleEx().

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dbghelp/module.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 64d4e3113d5..fe65683c6e1 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -969,6 +969,14 @@ DWORD64 WINAPI  SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
         /* 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
          */
+        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)
         {
@@ -976,9 +984,10 @@ DWORD64 WINAPI  SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
             SetLastError(ERROR_SUCCESS);
             return 0;
         }
-        module_remove(pcs, module);
-        SetLastError(ERROR_INVALID_PARAMETER);
-        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);
+        module_remove(pcs, altmodule);
     }
 
     if ((dbghelp_options & SYMOPT_DEFERRED_LOADS) == 0)




More information about the wine-cvs mailing list