From 3f696a8610512db20a3854c988f9823c98b7edaa Mon Sep 17 00:00:00 2001 From: hasherezade Date: Sat, 24 Feb 2024 12:50:15 -0800 Subject: [PATCH] [FEATURE] Print scantimes in different units --- scanners/scanner.cpp | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/scanners/scanner.cpp b/scanners/scanner.cpp index 4595c21ad..9f2971483 100644 --- a/scanners/scanner.cpp +++ b/scanners/scanner.cpp @@ -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; @@ -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) @@ -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; } @@ -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; } @@ -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; }