Skip to content

Commit

Permalink
[REFACT] Refactored checking if the thread is running
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Sep 7, 2024
1 parent 186c7b7 commit cab8f52
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions scanners/thread_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ typedef struct _t_stack_enum_params {

//---

namespace pesieve {

bool is_thread_running(HANDLE hThread)
{
DWORD exit_code = 0;
if (GetExitCodeThread(hThread, &exit_code)) {
if (exit_code != STILL_ACTIVE) {
#ifdef _DEBUG
std::cout << " Thread ExitCode: " << std::dec << exit_code << "\n";
#endif
return false;
}
}
return true;
}
};

DWORD WINAPI enum_stack_thread(LPVOID lpParam)
{
t_stack_enum_params* args = static_cast<t_stack_enum_params*>(lpParam);
Expand Down Expand Up @@ -418,13 +435,7 @@ bool pesieve::ThreadScanner::scanRemoteThreadCtx(HANDLE hThread, ThreadScanRepor
ctx_details cDetails = { 0 };
const bool is_ok = fetchThreadCtxDetails(processHandle, hThread, cDetails);

DWORD exit_code = 0;
GetExitCodeThread(hThread, &exit_code);

if (exit_code != STILL_ACTIVE) {
#ifdef _DEBUG
std::cout << " ExitCode: " << std::dec << exit_code << "\n";
#endif
if (!pesieve::is_thread_running(hThread)) {
my_report->status = SCAN_NOT_SUSPICIOUS;
return false;
}
Expand Down

0 comments on commit cab8f52

Please sign in to comment.