mirror of
https://github.com/mandiant/capa.git
synced 2026-01-03 08:18:26 -08:00
insn.py: Update extract_insn_api_features() to optimize by means of viv rather than function attributes
This commit is contained in:
@@ -123,7 +123,7 @@ def extract_insn_api_features(fh: FunctionHandle, bb, ih: InsnHandle) -> Iterato
|
||||
return
|
||||
|
||||
if f.vw.metadata["Format"] == "elf":
|
||||
if not hasattr(extract_insn_api_features, "symtab"):
|
||||
if "SymbolTable" not in f.vw.metadata:
|
||||
# the symbol table gets stored as a function's attribute in order to avoid running
|
||||
# this code everytime the call is made, thus preventing the computational overhead.
|
||||
elf = f.vw.parsedbin
|
||||
@@ -138,9 +138,9 @@ def extract_insn_api_features(fh: FunctionHandle, bb, ih: InsnHandle) -> Iterato
|
||||
sh_strtab = Shdr.from_viv(strtab, elf.getSectionBytes(strtab.name))
|
||||
|
||||
symtab = SymTab(endian, bitness, sh_symtab, sh_strtab)
|
||||
extract_insn_api_features.symtab = symtab
|
||||
f.vw.metadata["SymbolTable"] = symtab
|
||||
|
||||
symtab = extract_insn_api_features.symtab
|
||||
symtab = f.vw.metadata["SymbolTable"]
|
||||
for symbol in symtab.get_symbols():
|
||||
sym_name = symtab.get_name(symbol)
|
||||
sym_value = symbol.value
|
||||
|
||||
Reference in New Issue
Block a user