Skip to content

Commit

Permalink
[REFACT] Cleanup. Pass lists and stings as constant references when p…
Browse files Browse the repository at this point in the history
…ossible
  • Loading branch information
hasherezade committed Sep 25, 2024
1 parent 216d0e2 commit 35bfd85
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion postprocessors/imp_rec/imp_reconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pesieve::ImpReconstructor::t_imprec_res pesieve::ImpReconstructor::rebuildImport
return IMP_RECOVERY_ERROR;
}

bool pesieve::ImpReconstructor::printFoundIATs(std::string reportPath)
bool pesieve::ImpReconstructor::printFoundIATs(const std::string& reportPath)
{
if (!foundIATs.size()) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion postprocessors/imp_rec/imp_reconstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace pesieve {

t_imprec_res rebuildImportTable(const IN peconv::ExportsMapper* exportsMap, IN const pesieve::t_imprec_mode &imprec_mode);

bool printFoundIATs(std::string reportPath);
bool printFoundIATs(const std::string &reportPath);

private:

Expand Down
2 changes: 1 addition & 1 deletion scanners/code_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace pesieve;
using namespace pesieve::util;

size_t pesieve::CodeScanReport::generateTags(std::string reportPath)
size_t pesieve::CodeScanReport::generateTags(const std::string& reportPath)
{
if (patchesList.size() == 0) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion scanners/code_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace pesieve {
return countSectionsWithStatus(SECTION_SCAN_ERR);
}

size_t generateTags(std::string reportPath);
size_t generateTags(const std::string &reportPath);

std::map<DWORD, t_section_status> sectionToResult;
PatchList patchesList;
Expand Down
2 changes: 1 addition & 1 deletion scanners/iat_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ std::string IATScanReport::formatHookedFuncName(IN peconv::ImportsCollection* st

}

bool IATScanReport::saveNotRecovered(IN std::string fileName,
bool IATScanReport::saveNotRecovered(IN const std::string& fileName,
IN HANDLE hProcess,
IN peconv::ImportsCollection *storedFunc,
IN peconv::ImpsNotCovered &notCovered,
Expand Down
2 changes: 1 addition & 1 deletion scanners/iat_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace pesieve {
{
public:

static bool saveNotRecovered(IN std::string fileName,
static bool saveNotRecovered(IN const std::string &fileName,
IN HANDLE hProcess,
IN peconv::ImportsCollection *storedFunc,
IN peconv::ImpsNotCovered &notCovered,
Expand Down
2 changes: 1 addition & 1 deletion scanners/thread_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool pesieve::ThreadScanner::checkReturnAddrIntegrity(IN const std::vector<ULONG
return false;
}

size_t pesieve::ThreadScanner::analyzeCallStack(IN const std::vector<ULONGLONG> call_stack, IN OUT ctx_details& cDetails)
size_t pesieve::ThreadScanner::analyzeCallStack(IN const std::vector<ULONGLONG> &call_stack, IN OUT ctx_details& cDetails)
{
size_t processedCntr = 0;

Expand Down
2 changes: 1 addition & 1 deletion scanners/thread_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace pesieve {
bool printResolvedAddr(ULONGLONG addr);
bool fetchThreadCtxDetails(IN HANDLE hProcess, IN HANDLE hThread, OUT ctx_details& c);
size_t fillCallStackInfo(IN HANDLE hProcess, IN HANDLE hThread, IN LPVOID ctx, IN OUT ctx_details& cDetails);
size_t analyzeCallStack(IN const std::vector<ULONGLONG> stack_frame, IN OUT ctx_details& cDetails);
size_t analyzeCallStack(IN const std::vector<ULONGLONG> &stack_frame, IN OUT ctx_details& cDetails);
bool checkReturnAddrIntegrity(IN const std::vector<ULONGLONG>& callStack);
bool fillAreaStats(ThreadScanReport* my_report);
bool reportSuspiciousAddr(ThreadScanReport* my_report, ULONGLONG susp_addr);
Expand Down
4 changes: 2 additions & 2 deletions stats/stats_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace pesieve {
return points;
}

size_t countFoundStrings(IN const AreaMultiStats& stats, IN std::set<std::string> neededStrings, IN size_t minOccurrence)
size_t countFoundStrings(IN const AreaMultiStats& stats, IN const std::set<std::string> &neededStrings, IN size_t minOccurrence)
{
size_t totalCount = 0;
if (!stats.currArea.foundStrings.size()) {
Expand Down Expand Up @@ -100,7 +100,7 @@ namespace pesieve {
{
size_t valsCount = 0;
for (auto itr1 = currArea.frequencies.rbegin(); itr1 != currArea.frequencies.rend(); ++itr1) {
double counter = itr1->first;
double counter = (double)itr1->first;
if (counter >= mean) {
valsCount += itr1->second.size();
}
Expand Down
7 changes: 3 additions & 4 deletions utils/path_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace pesieve {
return false;
}

std::string remap_to_drive_letter(std::string full_path)
std::string remap_to_drive_letter(const std::string &full_path)
{
size_t full_path_size = full_path.length();
if (full_path_size == 0) {
Expand Down Expand Up @@ -237,7 +237,7 @@ std::string pesieve::util::device_path_to_win32_path(const std::string &full_pat
return path;
}

bool is_device_path(std::string path)
bool is_device_path(const std::string &path)
{
const std::string device_path = "\\Device\\";
if (path.length() < device_path.length() || path[0] !='\\') {
Expand All @@ -249,7 +249,7 @@ bool is_device_path(std::string path)
return false;
}

std::string pesieve::util::expand_path(std::string path)
std::string pesieve::util::expand_path(const std::string &path)
{
std::string basic_path = pesieve::util::device_path_to_win32_path(path);
if (is_device_path(basic_path)) {
Expand All @@ -270,4 +270,3 @@ std::string pesieve::util::expand_path(std::string path)
}
return strip_prefix(filename, LONG_PATH_PREFIX);
}

2 changes: 1 addition & 1 deletion utils/path_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace pesieve {
//converts path in format i.e.: \Device\HarddiskVolume2\... to format: C:\...
std::string device_path_to_win32_path(const std::string &full_path);

std::string expand_path(std::string path);
std::string expand_path(const std::string &path);

};
};
Expand Down

0 comments on commit 35bfd85

Please sign in to comment.