Skip to content

Commit 8d3d84f

Browse files
committed
Formatting, fixed check in SymbolParser (now releases dependencies properly)
1 parent ec80ed4 commit 8d3d84f

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

GH Injector Library/Import Handler.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ DWORD ResolveImports(ERROR_DATA & error_data)
2929

3030
WIN32_FUNC_INIT(LoadLibraryExW, hK32);
3131
WIN32_FUNC_INIT(GetLastError, hK32);
32-
if (!NATIVE::pLoadLibraryExW || !NATIVE::pGetLastError) return INJ_ERR_GET_PROC_ADDRESS_FAIL;
33-
32+
if (!NATIVE::pLoadLibraryExW || !NATIVE::pGetLastError)
33+
{
34+
return INJ_ERR_GET_PROC_ADDRESS_FAIL;
35+
}
36+
3437
if (sym_ntdll_native_ret.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready)
3538
{
3639
INIT_ERROR_DATA(error_data, INJ_ERR_ADVANCED_NOT_DEFINED);

GH Injector Library/Injection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ DWORD HijackHandle(INJECTIONDATAW * pData, ERROR_DATA & error_data)
395395

396396
DWORD LastErrCode = INJ_ERR_SUCCESS;
397397
HANDLE hHijackProc = nullptr;
398-
for (auto i : handles)
398+
for (const auto & i : handles)
399399
{
400400
hHijackProc = OpenProcess(access_mask | PROCESS_CREATE_THREAD, FALSE, i.OwnerPID);
401401
if (!hHijackProc)

GH Injector Library/Symbol Parser.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ DWORD SYMBOL_PARSER::Initialize(const std::string szModulePath, const std::strin
146146
return SYMBOL_ERR_ALREADY_INITIALIZED;
147147
}
148148

149+
m_bInterruptEvent = false;
150+
149151
std::ifstream File(szModulePath, std::ios::binary | std::ios::ate);
150152
if (!File.good())
151153
{
@@ -343,7 +345,7 @@ DWORD SYMBOL_PARSER::Initialize(const std::string szModulePath, const std::strin
343345
{
344346
while (InternetCheckConnectionA("https://msdl.microsoft.com", FLAG_ICC_FORCE_CONNECTION, NULL) == FALSE)
345347
{
346-
Sleep(50);
348+
Sleep(25);
347349

348350
if (m_bInterruptEvent)
349351
{
@@ -415,6 +417,8 @@ DWORD SYMBOL_PARSER::Initialize(const std::string szModulePath, const std::strin
415417
return SYMBOL_ERR_SYM_INIT_FAIL;
416418
}
417419

420+
m_Initialized = true;
421+
418422
SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_AUTO_PUBLICS);
419423

420424
m_SymbolTable = SymLoadModuleEx(m_hProcess, nullptr, m_szPdbPath.c_str(), nullptr, 0x10000000, Filesize, nullptr, NULL);
@@ -464,6 +468,8 @@ DWORD SYMBOL_PARSER::GetSymbolAddress(const char * szSymbolName, DWORD & RvaOut)
464468

465469
void SYMBOL_PARSER::Interrupt()
466470
{
471+
m_bInterruptEvent = true;
472+
467473
if (m_hInterruptEvent)
468474
{
469475
SetEvent(m_hInterruptEvent);
@@ -496,6 +502,5 @@ void SYMBOL_PARSER::Interrupt()
496502
m_hPdbFile = nullptr;
497503
m_hProcess = nullptr;
498504

499-
m_bInterruptEvent = false;
500505
m_hInterruptEvent = nullptr;
501506
}

GH Injector Library/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,22 @@ BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, void * pReserved)
8484
{
8585
LOG("GH Injector V%ls detaching\n", GH_INJ_VERSION);
8686

87-
if (sym_ntdll_native_ret.wait_for(std::chrono::microseconds(0)) != std::future_status::ready)
87+
if (sym_ntdll_native_ret.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready)
8888
{
89+
LOG("Attempting to interrupt native ntdll.pdb donwload thread\n");
8990
sym_ntdll_native.Interrupt();
90-
if (sym_ntdll_native_ret.wait_for(std::chrono::microseconds(25)) != std::future_status::timeout)
91+
if (sym_ntdll_native_ret.wait_for(std::chrono::milliseconds(100)) != std::future_status::ready)
9192
{
9293
LOG("Native ntdll pdb download thread didn't exit properly.\n");
9394
}
9495
}
9596

9697
#ifdef _WIN64
97-
if (sym_ntdll_wow64_ret.wait_for(std::chrono::microseconds(0)) != std::future_status::ready)
98+
if (sym_ntdll_wow64_ret.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready)
9899
{
100+
LOG("Attempting to interrupt wow64 ntdll.pdb donwload thread\n");
99101
sym_ntdll_wow64.Interrupt();
100-
if (sym_ntdll_wow64_ret.wait_for(std::chrono::microseconds(25)) != std::future_status::timeout)
102+
if (sym_ntdll_wow64_ret.wait_for(std::chrono::milliseconds(100)) != std::future_status::ready)
101103
{
102104
LOG("Wow64 ntdll pdb download thread didn't exit properly.\n");
103105
}

0 commit comments

Comments
 (0)