Skip to content

Commit

Permalink
retype CHAR16 to const CHAR16
Browse files Browse the repository at this point in the history
for NVRAM variables names (to improve pseudocode quality)
  • Loading branch information
yeggor committed Jun 13, 2024
1 parent 8170c66 commit 06b3736
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions efiXplorer/efiAnalyzerX86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,10 @@ bool EfiAnalysis::EfiAnalyzer::AnalyzeVariableService(ea_t ea, std::string servi
msg("[%s] VariableName address: 0x%016llX\n", plugin_name,
u64_addr(insn.ops[1].addr));
std::string var_name = getWideString(insn.ops[1].addr);

// retype CHAR16 to const CHAR16 to improve pseudocode quality
setConstChar16Type(insn.ops[1].addr);

msg("[%s] VariableName: %s\n", plugin_name, var_name.c_str());
item["VariableName"] = var_name;
name_found = true;
Expand Down
10 changes: 10 additions & 0 deletions efiXplorer/efiUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ void setTypeAndName(ea_t ea, std::string name, std::string type) {
}
}

//--------------------------------------------------------------------------
// Set const CHAR16 type
void setConstChar16Type(ea_t ea) {
tinfo_t tinfo;
if (tinfo.get_named_type(get_idati(), "CHAR16")) {
tinfo.set_const();
apply_tinfo(ea, tinfo, TINFO_DEFINITE);
}
}

//--------------------------------------------------------------------------
// Get file format name (fileformatname)
std::string getFileFormatName() {
Expand Down
3 changes: 3 additions & 0 deletions efiXplorer/efiUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ bool setRetToPeiSvc(ea_t start_ea);
// Set type and name
void setTypeAndName(ea_t ea, std::string name, std::string type);

// Set const CHAR16 type
void setConstChar16Type(ea_t ea);

// Get module name by address
qstring getModuleNameLoader(ea_t address);

Expand Down

0 comments on commit 06b3736

Please sign in to comment.