Skip to content

Commit

Permalink
[FEATURE] If rebasing requested, and the original base is not known, …
Browse files Browse the repository at this point in the history
…use a default one
  • Loading branch information
hasherezade committed Nov 6, 2024
1 parent 5271991 commit 3053ac2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions postprocessors/results_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "../scanners/code_scanner.h"

#define DIR_SEPARATOR "\\"

#define DEFAULT_BASE 0x10000000
//---
namespace pesieve {

Expand Down Expand Up @@ -227,15 +227,14 @@ pesieve::ProcessDumpReport* pesieve::ResultsDumper::dumpDetectedModules(
if (dumpReport->hasModule((ULONGLONG)mod->module, mod->moduleSize)) {
continue;
}
ULONGLONG out_base = rebase ? mod->origBase : 0;
dumpModule(processHandle,
isRefl,
process_report.modulesInfo,
mod,
process_report.exportsMap,
dump_mode,
imprec_mode,
out_base,
rebase,
*dumpReport
);
}
Expand Down Expand Up @@ -267,7 +266,7 @@ bool pesieve::ResultsDumper::dumpModule(IN HANDLE processHandle,
IN const peconv::ExportsMapper *exportsMap,
IN const pesieve::t_dump_mode dump_mode,
IN const t_imprec_mode imprec_mode,
IN ULONGLONG out_base,
IN bool rebase,
OUT ProcessDumpReport &dumpReport
)
{
Expand Down Expand Up @@ -328,8 +327,14 @@ bool pesieve::ResultsDumper::dumpModule(IN HANDLE processHandle,
ImpReconstructor::t_imprec_res imprec_res = impRec.rebuildImportTable(exportsMap, imprec_mode);
modDumpReport->impRecMode = get_imprec_res_name(imprec_res);

// Define a base the module should be rebased to:
module_buf.setRelocBase(mod->getRelocBase());
if (out_base) {
ULONGLONG out_base = 0;
if (rebase) {
out_base = mod->origBase;
if (!out_base) {
out_base = DEFAULT_BASE;
}
module_buf.setRelocBase(out_base);
}
if (imprec_mode == pesieve::PE_IMPREC_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion postprocessors/results_dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace pesieve {
IN const peconv::ExportsMapper *exportsMap,
IN const pesieve::t_dump_mode dump_mode,
IN const pesieve::t_imprec_mode imprec_mode,
IN ULONGLONG out_base,
IN bool rebase,
OUT ProcessDumpReport &dumpReport
);

Expand Down

0 comments on commit 3053ac2

Please sign in to comment.