Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically apply const type to NVRAM variable names #89

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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