Skip to content

Commit e044459

Browse files
committed
feat(PE): sync to core changes
1 parent 0eba02f commit e044459

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

mz/pe/pe.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "pe/dirs/exports.h"
77
#include "pe/dirs/imports.h"
88
#include "pe/dirs/resources.h"
9+
#include "pe/vb/decompiler.h"
910
#include <string.h>
1011

1112
static bool pe_parse(RDLoader* ldr, const RDLoaderRequest* req) {
@@ -176,6 +177,16 @@ static bool pe_load(RDLoader* ldr, RDContext* ctx) {
176177
rd_set_entry_point(ctx, pe_norm(ctx, pe, ep), NULL);
177178

178179
pe->classification = pe_classify(pe, ctx);
180+
181+
switch(pe->classification) {
182+
case PE_CLASS_VISUAL_BASIC_5:
183+
case PE_CLASS_VISUAL_BASIC_6:
184+
rd_analyzer_enable(ctx, PE_VB_DECOMPILER_ID);
185+
break;
186+
187+
default: break;
188+
}
189+
179190
pe_classify_print(pe->classification);
180191
return true;
181192
}

mz/pe/vb/decompiler.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "decompiler.h"
2-
#include "pe/format.h"
32
#include "pe/vb/components.h"
43
#include "pe/vb/format.h"
54
#include <string.h>
@@ -163,19 +162,6 @@ static bool _pe_vb_decompiler_obj(RDAddress address, RDReader* r,
163162
return !rd_reader_has_error(r);
164163
}
165164

166-
static bool pe_vb_decompiler_is_enabled(RDContext* ctx,
167-
const struct RDAnalyzerPlugin* plugin) {
168-
RD_UNUSED(plugin);
169-
170-
const RDLoaderPlugin* lplugin = rd_get_loader_plugin(ctx);
171-
if(strcmp(lplugin->id, PE_PLUGIN_ID) != 0) return false;
172-
173-
PEFormat* pe = (PEFormat*)rd_get_loader(ctx);
174-
175-
return pe && (pe->classification == PE_CLASS_VISUAL_BASIC_5 ||
176-
pe->classification == PE_CLASS_VISUAL_BASIC_6);
177-
}
178-
179165
static void pe_vb_decompiler_execute(RDContext* ctx) {
180166
RDAddress ep;
181167
if(!rd_get_entry_point(ctx, &ep)) return;
@@ -260,10 +246,9 @@ static void pe_vb_decompiler_execute(RDContext* ctx) {
260246

261247
const RDAnalyzerPlugin PE_VB_DECOMPILER = {
262248
.level = RD_API_LEVEL,
263-
.id = "win_pe_vb",
249+
.id = PE_VB_DECOMPILER_ID,
264250
.name = "Decompile VB5/6",
265251
.flags = RD_AF_SELECTED | RD_AF_RUNONCE,
266252
.order = 1000,
267-
.is_enabled = pe_vb_decompiler_is_enabled,
268253
.execute = pe_vb_decompiler_execute,
269254
};

mz/pe/vb/decompiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
#include <redasm/redasm.h>
44

5+
#define PE_VB_DECOMPILER_ID "win_pe_vb"
6+
57
extern const RDAnalyzerPlugin PE_VB_DECOMPILER;

0 commit comments

Comments
 (0)