Skip to content

Commit

Permalink
[FEATURE] Print scantimes in different units
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Feb 24, 2024
1 parent 4b4c93b commit 3f696a8
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions scanners/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace pesieve::util;

namespace pesieve {

bool validate_param_str(PARAM_STRING &strparam)
bool validate_param_str(PARAM_STRING& strparam)
{
if (!strparam.buffer || strparam.length == 0) {
return false;
Expand All @@ -38,6 +38,32 @@ namespace pesieve {
}
return true;
}

namespace util {

void print_scantime(std::stringstream& stream, size_t timeInMs)
{
float seconds = ((float)timeInMs / 1000);
float minutes = ((float)timeInMs / 60000);
stream << std::dec << timeInMs << " ms.";
if (seconds > 0.5) {
stream << " = " << seconds << " sec.";
}
if (minutes > 0.5) {
stream << " = " << minutes << " min.";
}
}

}; // namespace util

void print_scan_time(const char* scanned_element, size_t total_time)
{
std::stringstream ss;
ss << "[*] "<< scanned_element << " scanned in ";
util::print_scantime(ss, total_time);
std::cout << ss.str() << std::endl;
}

};

pesieve::ProcessScanner::ProcessScanner(HANDLE procHndl, bool is_reflection, pesieve::t_params _args)
Expand Down Expand Up @@ -292,8 +318,8 @@ size_t pesieve::ProcessScanner::scanWorkingSet(ProcessScanReport &pReport) //thr
pReport.appendReport(my_report);
}
if (!args.quiet) {
DWORD total_time = GetTickCount() - start_tick;
std::cout << "[*] Workingset scanned in " << std::dec << total_time << " ms" << std::endl;
const DWORD total_time = GetTickCount() - start_tick;
print_scan_time("Workingset", total_time);
}
return counter;
}
Expand Down Expand Up @@ -435,8 +461,8 @@ size_t pesieve::ProcessScanner::scanModulesIATs(ProcessScanReport &pReport) //th
scanForIATHooks(processHandle, modData, remoteModData, pReport, this->args.iat);
}
if (!args.quiet) {
DWORD total_time = GetTickCount() - start_tick;
std::cout << "[*] IATs scanned in " << std::dec << total_time << " ms" << std::endl;
const DWORD total_time = GetTickCount() - start_tick;
print_scan_time("IATs", total_time);
}
return counter;
}
Expand Down Expand Up @@ -480,8 +506,8 @@ size_t pesieve::ProcessScanner::scanThreads(ProcessScanReport& pReport) //throws
ThreadScanner::FreeSymbols(this->processHandle);

if (!args.quiet) {
DWORD total_time = GetTickCount() - start_tick;
std::cout << "[*] Threads scanned in " << std::dec << total_time << " ms" << std::endl;
const DWORD total_time = GetTickCount() - start_tick;
print_scan_time("Threads", total_time);
}
return 0;
}

0 comments on commit 3f696a8

Please sign in to comment.