-
Notifications
You must be signed in to change notification settings - Fork 119
bugfix(system): Prevent AMD/ATI driver crash on game launch by front loading the system dbghelp.dll #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix(system): Prevent AMD/ATI driver crash on game launch by front loading the system dbghelp.dll #1066
Conversation
|
Will this still work when the game doesn't have the rights to move the dll? I didn't look into the details of this PR, but overall this looks like overkill. Given that the retail game still works when the dll is deleted, wouldn't it make more sense to simply show an errormessage when the dll is detected and instruct the user to delete it? Maybe even just rename it automatically when the game has the rights or ask for permission from the user to do that. |
|
When the game cannot rename this file, then it will not work. The game would need to be launched with Admin privileges if the location requires that permission. In "Program Files" it typically does. If we want this to work for unelevated executables, then we would need to hook ntdll's LoadLibrary and then prevent loading that way. We can add hooking for Windows with https://github.com/TsudaKageyu/minhook. Then we would not need to rename the file. |
|
I will try rework the deactivation of dbghelp.dll so it does not require touching the physical file. |
A prompt is not possible in fullscreen. It is also not necessary for NVIDIA GPU's which are used by the majority of users.
That would mean dbghelp.dll would not work on systems that do not have dbghelp.dll in system32.
Maybe. It is currently used for some debugs though. |
|
How was this tested? Do you have an AMD system? |
|
Yes. AMD RX 590. |
|
So, if we were to remove the dependency on dbghelp.dll, but the dll would still be there, would the AMD driver still crash? |
Please don't add hooks... |
Yes. Because the driver will then load that file and try to use it.
Hooks are harmless if implemented correctly. GenTool works like that for 15 years :) We either hook, or rename file on runtime. Hooking will have the advantage of requiring no permission to write files in the game install directory. |
They are still a hack. And MS explicitely recommends against using them. So does the driver crash during DX initialization? How about we call |
|
Good suggestion. I will try that. |
|
I tested a bit yesterday with But there is another thing we can do that likely will work: We can front load the system dbghelp before calling into the driver. That way the driver will use the system's dbghelp instead of attempting to load it from the game directory. |
d8b5c04 to
c235db4
Compare
|
Ok. The logic has been simplified by front loading the system dbghelp.dll before the driver attempts to load it from the game directory. This works and gets rid of the file renaming code. The process needs no elevated permissions to avoid crashing. This only works if there actually is a dbghelp.dll in Windows, which we assume to be true in modern versions of Windows. |
|
This can be reviewed. |
|
In what situation does this occur? i have not come across an issue with it. |
|
This happens with some AMD Driver(s). |
c235db4 to
1e9d67c
Compare
|
Rebased. |
…d of file renaming
This reverts commit 00c93dd.
This reverts commit de2f8b5. # Conflicts: # Core/GameEngine/Include/Common/GameMemory.h # Core/GameEngine/Source/Common/System/GameMemoryCommon.cpp # Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp # Core/Libraries/Source/WWVegas/WWLib/MallocAllocator.h
b674a38 to
3648be6
Compare
|
Rebased. I also reverted the unnecessary changes to GameMemory. |
Reverting unification of these files to avoid conflicts with: - PR TheSuperHackers#654 (tomsons26): Cleans up inconsistencies - PR TheSuperHackers#670 (zzambers): Replacements for rest of asm code - PR TheSuperHackers#688 (tomsons26): Backports various things from ZH - PR TheSuperHackers#1066 (xezon): Prevent AMD/ATI driver crash - PR TheSuperHackers#1703 (Stubbjax): Add replay archive feature - PR TheSuperHackers#1741 (Skyaero42): Remove redundant include guards Files reverted: - BitFlagsIO.h, DataChunk.h, GameType.h, List.h - Money.h, Radar.h, Recorder.h, SpecialPowerMaskType.h, StackDump.h - NameKeyGenerator.cpp, GameCommon.cpp, StackDump.cpp
Reverting unification of these files to avoid conflicts with: - PR TheSuperHackers#654 (tomsons26): Cleans up inconsistencies - PR TheSuperHackers#670 (zzambers): Replacements for rest of asm code - PR TheSuperHackers#688 (tomsons26): Backports various things from ZH - PR TheSuperHackers#1066 (xezon): Prevent AMD/ATI driver crash - PR TheSuperHackers#1703 (Stubbjax): Add replay archive feature - PR TheSuperHackers#1741 (Skyaero42): Remove redundant include guards Files reverted: - BitFlagsIO.h, DataChunk.h, GameType.h, List.h - Money.h, Radar.h, Recorder.h, SpecialPowerMaskType.h, StackDump.h - NameKeyGenerator.cpp, GameCommon.cpp, StackDump.cpp
|
Applied a few more minor tweaks and improvements. Tested and worked. |
|
Tested Zero Hour World Builder and W3DView. Worked. |
…loading the system dbghelp.dll (TheSuperHackers#1066)
This change prevents the AMD/ATI driver crash on game launch by temporarily loading and unloading the Windows system dbghelp.dll, before the driver would try to load and use the dbghelp.dll from the game install directory - if the user did not delete this file.
The crash workaround is quite a bit more complicated and intricate and adds a few new classes. On a positive note, it does get rid of the legacy dbghelp.lib link dependency.
dbghelp.dll is now loaded dynamically in WWLib code. This allows to unload it. And skip loading it if it is not even used. By default it will now also first try to load dbghelp.dll from Windows system32 directory which does not cause this crash. It appears that the AMD/ATI drivers are only incompatible with this old dbghelp.dll, likely because of insufficient error handling.
The
DbgHelpLoaderhas a specific requirement, where it is not allowed to use new/delete, because of the timing it can be activated withMEMORYPOOL_DEBUG_STACKTRACEduring game memory initialization. That is why thestl::malloc_allocatorstl::system_allocatorwas added.TheScopedFileRenamerwas added to help safely rename and revert the dbghelp.dll on game launch.The
DbgHelpGuardwas added to front load the dbghelp DLL in RAII fashion at the 2 necessary places.Improve implementation with Hooks