@@ -30,8 +30,6 @@ BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, void * pReserved)
3030
3131 LOG (" GH Injector V%ls attached at %p\n " , GH_INJ_VERSION, hDll);
3232
33- DisableThreadLibraryCalls (hDll);
34-
3533 g_hInjMod = hDll;
3634
3735 char szRootPathA[MAX_PATH]{ 0 };
@@ -68,26 +66,42 @@ BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, void * pReserved)
6866
6967 LOG (" Rootpath is %s\n " , szRootPathA);
7068
69+ std::string szNtDllNative = szWindowsDir;
70+ szNtDllNative += " \\ System32\\ ntdll.dll" ;
71+
72+ sym_ntdll_native_ret = std::async (std::launch::async, &SYMBOL_PARSER::Initialize, &sym_ntdll_native, szNtDllNative, g_RootPathA, nullptr , false , true );
73+
7174#ifdef _WIN64
7275 std::string szNtDllWOW64 = szWindowsDir;
7376 szNtDllWOW64 += " \\ SysWOW64\\ ntdll.dll" ;
7477
75- sym_ntdll_wow64_ret = std::async (std::launch::async, &SYMBOL_PARSER::Initialize, &sym_ntdll_wow64, szNtDllWOW64, g_RootPathA, nullptr , false , true );
78+ sym_ntdll_wow64_ret = std::async (std::launch::async, &SYMBOL_PARSER::Initialize, &sym_ntdll_wow64, szNtDllWOW64, g_RootPathA, nullptr , false , true );
7679#endif
7780
78- std::string szNtDllNative = szWindowsDir;
79- szNtDllNative += " \\ System32\\ ntdll.dll" ;
80-
81- sym_ntdll_native_ret = std::async (std::launch::async, &SYMBOL_PARSER::Initialize, &sym_ntdll_native, szNtDllNative, g_RootPathA, nullptr , false , true );
82-
8381 delete[] szWindowsDir;
8482 }
8583 else if (dwReason == DLL_PROCESS_DETACH)
8684 {
87- sym_ntdll_native.InterruptCleanup ();
85+ LOG (" GH Injector V%ls detaching\n " , GH_INJ_VERSION);
86+
87+ if (sym_ntdll_native_ret.wait_for (std::chrono::microseconds (0 )) != std::future_status::ready)
88+ {
89+ sym_ntdll_native.Interrupt ();
90+ if (sym_ntdll_native_ret.wait_for (std::chrono::microseconds (25 )) != std::future_status::timeout)
91+ {
92+ LOG (" Native ntdll pdb download thread didn't exit properly.\n " );
93+ }
94+ }
8895
8996#ifdef _WIN64
90- sym_ntdll_wow64.InterruptCleanup ();
97+ if (sym_ntdll_wow64_ret.wait_for (std::chrono::microseconds (0 )) != std::future_status::ready)
98+ {
99+ sym_ntdll_wow64.Interrupt ();
100+ if (sym_ntdll_wow64_ret.wait_for (std::chrono::microseconds (25 )) != std::future_status::timeout)
101+ {
102+ LOG (" Wow64 ntdll pdb download thread didn't exit properly.\n " );
103+ }
104+ }
91105#endif
92106
93107 LOG (" GH Injector V%ls detached\n " , GH_INJ_VERSION);
0 commit comments