Skip to content

Commit

Permalink
improve tid_t initialisation for MACRO_ types (enums);
Browse files Browse the repository at this point in the history
annotate Attributes argument for SetVariable() when possible
  • Loading branch information
yeggor committed Dec 7, 2024
1 parent 96fa03d commit c439679
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
22 changes: 6 additions & 16 deletions efiXplorer/efi_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class efi_analyser_t {
ea_list_t m_double_get_variable;

tid_t m_macro_efi_tid;
tid_t m_macro_var_attr_tid;

// mask and masked value for MACRO_EFI enum value detection
uint64_t m_mask = 0;
Expand Down Expand Up @@ -373,14 +374,8 @@ class efi_analyser_x86_t : public efi_analyser_t {
import_type(idati, -1, "EFI_PEI_SERVICES");
import_type(idati, -1, "EFI_PEI_READ_ONLY_VARIABLE2_PPI");
import_type(idati, -1, "EFI_SMM_VARIABLE_PROTOCOL");
import_type(idati, -1, "MACRO_VARIABLE_ATTRIBUTE");

#if IDA_SDK_VERSION >= 900
tinfo_t tinfo;
if (tinfo.get_named_type(idati, "MACRO_EFI")) {
m_macro_efi_tid = tinfo.force_tid();
}
#endif
m_macro_efi_tid = import_type(idati, -1, "MACRO_EFI");
m_macro_var_attr_tid = import_type(idati, -1, "MACRO_VARIABLE_ATTRIBUTE");

#ifdef HEX_RAYS
for (auto idx = 0; idx < get_entry_qty(); idx++) {
Expand Down Expand Up @@ -436,14 +431,8 @@ class efi_analyser_arm_t : public efi_analyser_t {
import_type(idati, -1, "EFI_HANDLE");
import_type(idati, -1, "EFI_RUNTIME_SERVICES");
import_type(idati, -1, "EFI_SYSTEM_TABLE");
import_type(idati, -1, "MACRO_VARIABLE_ATTRIBUTE");

#if IDA_SDK_VERSION >= 900
tinfo_t tinfo;
if (tinfo.get_named_type(idati, "MACRO_EFI")) {
m_macro_efi_tid = tinfo.force_tid();
}
#endif
m_macro_efi_tid = import_type(idati, -1, "MACRO_EFI");
m_macro_var_attr_tid = import_type(idati, -1, "MACRO_VARIABLE_ATTRIBUTE");
}

~efi_analyser_arm_t() {
Expand All @@ -469,6 +458,7 @@ class efi_analyser_arm_t : public efi_analyser_t {
ea_list_t m_rt_list_arm;

tid_t m_macro_efi_tid;
tid_t m_macro_var_attr_tid;

bool get_protocol(ea_t address, uint32_t p_reg, std::string service_name);
bool set_enums_repr(ea_t ea, insn_t insn);
Expand Down
5 changes: 4 additions & 1 deletion efiXplorer/efi_analysis_x86.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2372,9 +2372,12 @@ bool efi_analysis::efi_analyser_t::analyse_variable_service(
{0x00000008, "HARDWARE_ERROR_RECORD"},
{0x00000010, "AUTHENTICATED_WRITE_ACCESS"}};

addr = args[2]; // attributes argument
addr = args[2]; // Attributes argument
decode_insn(&insn, addr);

// attempt to annotate Attributes argument
op_enum(addr, 1, m_macro_var_attr_tid, 0);

if (insn.itype == NN_xor && insn.ops[0].type == o_reg &&
insn.ops[1].type == o_reg && insn.ops[0].reg == insn.ops[1].reg &&
insn.ops[0].reg == R_R8) {
Expand Down

0 comments on commit c439679

Please sign in to comment.