Skip to content

Commit

Permalink
[BUGFIX] Protect against scanning your own current thread
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Sep 12, 2024
1 parent b02469d commit e2cad93
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scanners/thread_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ bool pesieve::ThreadScanner::scanRemoteThreadCtx(HANDLE hThread, ThreadScanRepor
return true;
}
}

// other indicators of stack being corrupt:

bool isStackCorrupt = false;
Expand Down Expand Up @@ -574,9 +573,13 @@ bool pesieve::ThreadScanner::scanRemoteThreadCtx(HANDLE hThread, ThreadScanRepor

ThreadScanReport* pesieve::ThreadScanner::scanRemote()
{
ThreadScanReport* my_report = new ThreadScanReport(info.tid);
if (!my_report) return nullptr;

if (GetCurrentThreadId() == info.tid) {
return nullptr; // do not scan your own thread
}
ThreadScanReport* my_report = new (std::nothrow) ThreadScanReport(info.tid);
if (!my_report) {
return nullptr;
}
#ifdef _SHOW_THREAD_INFO
printThreadInfo(info);
#endif // _SHOW_THREAD_INFO
Expand Down

0 comments on commit e2cad93

Please sign in to comment.