From 06b37367103280fc57d454089aacd442644cf480 Mon Sep 17 00:00:00 2001 From: yeggor Date: Thu, 13 Jun 2024 04:10:45 +0100 Subject: [PATCH] retype CHAR16 to const CHAR16 for NVRAM variables names (to improve pseudocode quality) --- efiXplorer/efiAnalyzerX86.cpp | 4 ++++ efiXplorer/efiUtils.cpp | 10 ++++++++++ efiXplorer/efiUtils.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/efiXplorer/efiAnalyzerX86.cpp b/efiXplorer/efiAnalyzerX86.cpp index f69e9599..b37f34d5 100644 --- a/efiXplorer/efiAnalyzerX86.cpp +++ b/efiXplorer/efiAnalyzerX86.cpp @@ -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; diff --git a/efiXplorer/efiUtils.cpp b/efiXplorer/efiUtils.cpp index f2512f26..8449b28e 100644 --- a/efiXplorer/efiUtils.cpp +++ b/efiXplorer/efiUtils.cpp @@ -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() { diff --git a/efiXplorer/efiUtils.h b/efiXplorer/efiUtils.h index a3c60778..b7543456 100644 --- a/efiXplorer/efiUtils.h +++ b/efiXplorer/efiUtils.h @@ -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);