Skip to content

Commit

Permalink
Avoid using of decompiler APIs if the decompiler is not present (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeggor committed Dec 16, 2022
1 parent 5d3753c commit 2f016df
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
35 changes: 33 additions & 2 deletions efiXplorer/efiHexRays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ const char *Expr2String(cexpr_t *e, qstring *out) {
return out->c_str();
}

void applyAllTypesForInterfacesBootServices(std::vector<json> protocols) {
bool applyAllTypesForInterfacesBootServices(std::vector<json> protocols) {
if (!init_hexrays_plugin()) {
return false;
}

// Descriptors for EFI_BOOT_SERVICES functions
struct TargetFunctionPointer BootServicesFunctions[5]{
{"InstallProtocolInterface", 0x80, 4, 1, 3},
Expand Down Expand Up @@ -221,9 +225,15 @@ void applyAllTypesForInterfacesBootServices(std::vector<json> protocols) {

retyperBs.apply_to(&cfunc->body, nullptr);
}

return true;
}

void applyAllTypesForInterfacesSmmServices(std::vector<json> protocols) {
bool applyAllTypesForInterfacesSmmServices(std::vector<json> protocols) {
if (!init_hexrays_plugin()) {
return false;
}

// Descriptors for _EFI_SMM_SYSTEM_TABLE2 functions
struct TargetFunctionPointer SmmServicesFunctions[2]{
{"SmmHandleProtocol", 0xb8, 3, 1, 2},
Expand Down Expand Up @@ -263,9 +273,15 @@ void applyAllTypesForInterfacesSmmServices(std::vector<json> protocols) {

retyperSmm.apply_to(&cfunc->body, nullptr);
}

return true;
}

uint8_t VariablesInfoExtractAll(func_t *f, ea_t code_addr) {
if (!init_hexrays_plugin()) {
return 0xff;
}

// check func
if (f == nullptr) {
return 0xff;
Expand All @@ -283,6 +299,10 @@ uint8_t VariablesInfoExtractAll(func_t *f, ea_t code_addr) {
}

bool TrackEntryParams(func_t *f, uint8_t depth) {
if (!init_hexrays_plugin()) {
return false;
}

if (depth == 2) {
return true;
}
Expand All @@ -301,11 +321,17 @@ bool TrackEntryParams(func_t *f, uint8_t depth) {
TrackEntryParams(get_func(addr), ++depth);
}
delete pf;

return true;
}

json DetectVars(func_t *f) {
json res;

if (!init_hexrays_plugin()) {
return res;
}

// check func
if (f == nullptr) {
return res;
Expand All @@ -331,6 +357,11 @@ json DetectVars(func_t *f) {
std::vector<json> DetectServices(func_t *f) {
// check func
std::vector<json> res;

if (!init_hexrays_plugin()) {
return res;
}

if (f == nullptr) {
return res;
}
Expand Down
4 changes: 2 additions & 2 deletions efiXplorer/efiHexRays.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ bool TrackEntryParams(func_t *f, uint8_t depth);
json DetectVars(func_t *f);
std::vector<json> DetectServices(func_t *f);
bool setLvarName(qstring name, lvar_t lvar, ea_t func_addr);
void applyAllTypesForInterfacesBootServices(std::vector<json> guids);
void applyAllTypesForInterfacesSmmServices(std::vector<json> guids); // unused
bool applyAllTypesForInterfacesBootServices(std::vector<json> guids);
bool applyAllTypesForInterfacesSmmServices(std::vector<json> guids); // unused
bool setHexRaysVariableInfo(ea_t funcEa, lvar_t &ll, tinfo_t tif, std::string name);
bool setHexRaysVariableInfoAndHandleInterfaces(ea_t funcEa, lvar_t &ll, tinfo_t tif,
std::string name);
Expand Down

0 comments on commit 2f016df

Please sign in to comment.