Skip to content

Commit d898fff

Browse files
committed
feat(PE)!: explicit base address
1 parent 4609f94 commit d898fff

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎mz/pe/pe.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ static bool pe_load(RDLoader* ldr, RDContext* ctx) {
114114
rd_kb_load(ctx, "pe/types");
115115

116116
PEFormat* pe = (PEFormat*)ldr;
117+
rd_set_base_address(ctx, pe->imagebase);
118+
117119
pe_set_bits(pe);
118120
pe_parse_richheader(ctx, pe);
119121

@@ -136,8 +138,6 @@ static bool pe_load(RDLoader* ldr, RDContext* ctx) {
136138
char section_name[PE_SIZE_OF_SHORT_NAME + 1] = {0};
137139
memcpy(section_name, s->Name, PE_SIZE_OF_SHORT_NAME);
138140

139-
RDAddress addr = pe->imagebase + s->VirtualAddress;
140-
141141
u32 vsize = s->VirtualSize;
142142
if(!vsize) vsize = s->SizeOfRawData;
143143

@@ -146,10 +146,10 @@ static bool pe_load(RDLoader* ldr, RDContext* ctx) {
146146
if(diff) vsize += pe->section_align - diff;
147147
}
148148

149-
rd_map_segment_n(ctx, section_name, addr, vsize, perm);
149+
rd_map_segment_n(ctx, section_name, s->VirtualAddress, vsize, perm);
150150

151151
if(s->PointerToRawData) {
152-
rd_map_input_n(ctx, s->PointerToRawData, addr,
152+
rd_map_input_n(ctx, s->PointerToRawData, s->VirtualAddress,
153153
s->VirtualSize < s->SizeOfRawData
154154
? s->VirtualSize
155155
: s->SizeOfRawData);

0 commit comments

Comments
 (0)