Skip to content

Commit

Permalink
Merge pull request #89 from binarly-io/feature/const-char
Browse files Browse the repository at this point in the history
automatically apply const type to NVRAM variable names
  • Loading branch information
yeggor authored Jun 13, 2024
2 parents 1f26858 + 06b3736 commit 0f67081
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
28 changes: 15 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.py[cod]
__pycache__/

# Distribution / packaging
*.egg
*.egg-info/
.eggs/
.installed.cfg
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
MANIFEST
parts/
pip-wheel-metadata/
sdist/
share/python-wheels/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# pyenv
.python-version

# Environments
.env
.venv
env.bak/
env/
venv/
ENV/
env.bak/
venv.bak/
venv/

# custom directories
.vscode/
.vs/
.cache
.idea/
.vs/
.vscode/
test/
tests

# OSX
.DS_Store
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 0f67081

Please sign in to comment.