Skip to content

Commit

Permalink
Merge pull request #67 from binarly-io/arm
Browse files Browse the repository at this point in the history
Improve interface names reconstruction
  • Loading branch information
yeggor committed Sep 30, 2022
2 parents 41cd1b8 + 016d41f commit 1bdc939
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions efiXplorer/efiAnalyzerX86.cpp
Expand Up @@ -1371,8 +1371,8 @@ bool EfiAnalysis::EfiAnalyzer::AddProtocol(std::string serviceName, ea_t guidAdd
std::string name = it->second;
protocol["prot_name"] = name;
} else {
protocol["prot_name"] = "UNKNOWN_PROTOCOL";
setTypeAndName(guidAddress, "UNKNOWN_PROTOCOL", "EFI_GUID");
protocol["prot_name"] = "UNKNOWN_PROTOCOL_GUID";
setTypeAndName(guidAddress, "UNKNOWN_PROTOCOL_GUID", "EFI_GUID");
}
if (!jsonInVec(allProtocols, protocol)) {
allProtocols.push_back(protocol);
Expand Down
26 changes: 26 additions & 0 deletions efiXplorer/efiHexRays.h
Expand Up @@ -511,6 +511,11 @@ class GUIDRetyper : public GUIDRelatedVisitorBase {
tinfo_t tif;
import_type(get_idati(), -1, interfaceTypeName.c_str());
if (!tif.get_named_type(get_idati(), interfaceTypeName.c_str())) {
// Get the referent for the interface argument.
cexpr_t *outArgReferent = GetReferent(mOutArg, "ptr", true);
if (outArgReferent == nullptr)
return 0;
ApplyName(outArgReferent, interfaceTypeName);
return 0;
}

Expand Down Expand Up @@ -569,12 +574,33 @@ class GUIDRetyper : public GUIDRelatedVisitorBase {
lvar_t &destVar = varRef.mba->vars[varRef.idx];
// Set the Hex-Rays variable type
auto name = typeToName(static_cast<std::string>(tStr.c_str()));
setLvarName(static_cast<qstring>(name.c_str()), destVar, mFuncEa);
if (setHexRaysVariableInfoAndHandleInterfaces(mFuncEa, destVar, ptrTif,
name)) {
++mNumApplied;
}
}
}

void ApplyName(cexpr_t *outArg, std::string type_name) {
ea_t dest_ea = outArg->obj_ea;

// For global variables
if (outArg->op == cot_obj) {
// Rename global variable
auto name = "g" + typeToName(type_name);
set_name(dest_ea, name.c_str(), SN_FORCE);
}

// For local variables
else if (outArg->op == cot_var) {
var_ref_t varRef = outArg->v;
lvar_t &destVar = varRef.mba->vars[varRef.idx];
// Set the Hex-Rays variable type
auto name = typeToName(type_name);
setLvarName(static_cast<qstring>(name.c_str()), destVar, mFuncEa);
}
}
};

class VariablesInfoExtractor : public ctree_visitor_t {
Expand Down

0 comments on commit 1bdc939

Please sign in to comment.