@@ -936,6 +936,19 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
936936 if (Flags & ~(SLMFLAG_VIRTUAL ))
937937 FIXME ("Unsupported Flags %08lx for %s\n" , Flags , debugstr_w (wImageName ));
938938
939+ /* Trying to load a new module at the same address of an existing one,
940+ * native simply keeps the old one in place.
941+ */
942+ if (BaseOfDll )
943+ for (altmodule = pcs -> lmodules ; altmodule ; altmodule = altmodule -> next )
944+ {
945+ if (altmodule -> type == DMT_PE && BaseOfDll == altmodule -> module .BaseOfImage )
946+ {
947+ SetLastError (ERROR_SUCCESS );
948+ return 0 ;
949+ }
950+ }
951+
939952 pcs -> loader -> synchronize_module_list (pcs );
940953
941954 /* this is a Wine extension to the API just to redo the synchronisation */
@@ -967,6 +980,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
967980 if (!module )
968981 {
969982 WARN ("Couldn't locate %s\n" , debugstr_w (wImageName ));
983+ SetLastError (ERROR_NO_MORE_FILES );
970984 return 0 ;
971985 }
972986 /* by default module_new fills module.ModuleName from a derivation
@@ -997,11 +1011,11 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
9971011 SetLastError (ERROR_INVALID_PARAMETER );
9981012 return 0 ;
9991013 }
1000- /* loading same module at same address... don't change anything */
1014+ /* loading same module at same address... we can only get here when BaseOfDll is 0 */
10011015 if (module -> module .BaseOfImage == altmodule -> module .BaseOfImage )
10021016 {
10031017 module_remove (pcs , module );
1004- SetLastError (ERROR_SUCCESS );
1018+ SetLastError (ERROR_INVALID_ADDRESS );
10051019 return 0 ;
10061020 }
10071021 /* replace old module with new one, which will look like a shift of base address */
0 commit comments