@@ -60,8 +60,6 @@ MiniDumper::MiniDumper()
6060{
6161 m_miniDumpInitialized = false ;
6262 m_requestedDumpType = DUMP_TYPE_MINIMAL;
63- m_dbgHlp = NULL ;
64- m_pMiniDumpWriteDump = NULL ;
6563 m_dumpRequested = NULL ;
6664 m_dumpComplete = NULL ;
6765 m_quitting = NULL ;
@@ -74,7 +72,6 @@ MiniDumper::MiniDumper()
7472#endif
7573 memset (m_dumpDir, 0 , ARRAY_SIZE (m_dumpDir));
7674 memset (m_dumpFile, 0 , ARRAY_SIZE (m_dumpFile));
77- memset (m_sysDbgHelpPath, 0 , ARRAY_SIZE (m_sysDbgHelpPath));
7875 memset (m_executablePath, 0 , ARRAY_SIZE (m_executablePath));
7976};
8077
@@ -148,36 +145,12 @@ void MiniDumper::TriggerMiniDumpForException(struct _EXCEPTION_POINTERS* e_info,
148145
149146void MiniDumper::Initialize (const AsciiString& userDirPath)
150147{
151- // Find the full path to the dbghelp.dll file in the system32 dir
152- ::GetSystemDirectory (m_sysDbgHelpPath, MAX_PATH);
153- strlcat (m_sysDbgHelpPath, " \\ dbghelp.dll" , MAX_PATH);
148+ bool success = DbgHelpLoader::load ();
154149
155150 // We want to only use the dbghelp.dll from the OS installation, as the one bundled with the game does not support MiniDump functionality
156- Bool loadedDbgHelp = false ;
157- HMODULE m_dbgHlp = ::GetModuleHandle (m_sysDbgHelpPath);
158- if (m_dbgHlp == NULL )
151+ if (!(success && DbgHelpLoader::isLoadedFromSystem ()))
159152 {
160- // Load the dbghelp library from the system folder
161- m_dbgHlp = ::LoadLibrary (m_sysDbgHelpPath);
162- if (m_dbgHlp == NULL )
163- {
164- DEBUG_LOG ((" MiniDumper::Initialize: Unable to load system-provided dbghelp.dll from '%s': error=%u" , m_sysDbgHelpPath, ::GetLastError ()));
165- return ;
166- }
167-
168- loadedDbgHelp = true ;
169- }
170-
171- m_pMiniDumpWriteDump = reinterpret_cast <MiniDumpWriteDump_t>(::GetProcAddress (m_dbgHlp, " MiniDumpWriteDump" ));
172- if (m_pMiniDumpWriteDump == NULL )
173- {
174- if (loadedDbgHelp)
175- {
176- ::FreeLibrary (m_dbgHlp);
177- m_dbgHlp = NULL ;
178- }
179-
180- DEBUG_LOG ((" MiniDumper::Initialize: Could not get address of proc MiniDumpWriteDump from '%s'!" , m_sysDbgHelpPath));
153+ DEBUG_LOG ((" MiniDumper::Initialize: Unable to load system-provided dbghelp.dll, minidump functionality disabled." ));
181154 return ;
182155 }
183156
@@ -291,11 +264,7 @@ void MiniDumper::CleanupResources()
291264 m_quitting = NULL ;
292265 }
293266
294- if (m_dbgHlp != NULL )
295- {
296- ::FreeModule (m_dbgHlp);
297- m_dbgHlp = NULL ;
298- }
267+ DbgHelpLoader::unload ();
299268}
300269
301270void MiniDumper::ShutDown ()
@@ -438,7 +407,7 @@ void MiniDumper::CreateMiniDump(DumpType dumpType)
438407 }
439408
440409 MINIDUMP_TYPE miniDumpType = static_cast <MINIDUMP_TYPE>(dumpTypeFlags);
441- BOOL success = m_pMiniDumpWriteDump (
410+ BOOL success = DbgHelpLoader::miniDumpWriteDump (
442411 ::GetCurrentProcess (),
443412 currentProcessId,
444413 dumpFile,
0 commit comments