Crusader_Decomp/_tmp_inspect_entity_vm_runtime_create_frame.py

55 lines
No EOL
2.6 KiB
Python

def dump_function(address):
function = helpers["get_function"](program, address)
if function is None:
raise RuntimeError("Function %s not found" % address)
frame = function.getStackFrame()
symbol_table = program.getSymbolTable()
print("FUNCTION", address)
print("SIGNATURE", function.getSignature())
print("CALLING_CONVENTION", function.getCallingConventionName())
print("CUSTOM_STORAGE", function.hasCustomVariableStorage())
print("STACK_PURGE_SIZE", function.getStackPurgeSize())
print("STACK_PURGE_VALID", function.isStackPurgeSizeValid())
print("HAS_NO_RETURN", function.hasNoReturn())
print("ENTRY", function.getEntryPoint())
print("BODY", function.getBody().getMinAddress(), function.getBody().getMaxAddress())
print("PARENT_NAMESPACE", function.getParentNamespace())
print("STACK_GROWS_NEGATIVE", frame.growsNegative())
print("LOCAL_SIZE", frame.getLocalSize())
print("PARAM_OFFSET", frame.getParameterOffset())
print("RETURN_ADDR_OFFSET", frame.getReturnAddressOffset())
print("FRAME_SIZE", frame.getFrameSize())
print("PARAM_SIZE", frame.getParameterSize())
print("SYMBOLS_AT_ENTRY")
for symbol in symbol_table.getSymbols(function.getEntryPoint()):
print(" ", symbol.getName(True), symbol.getSymbolType(), symbol.getSource())
print("PARAMETERS")
for parameter in function.getParameters():
print(" ", parameter.getName(), parameter.getDataType().getDisplayName(), parameter.getVariableStorage())
print("LOCALS")
for variable in function.getLocalVariables():
print(" ", variable.getName(), variable.getDataType().getDisplayName(), variable.getVariableStorage(), type(variable).__name__)
print("ALL_VARS")
for variable in function.getAllVariables():
print(" ", variable.getName(), variable.getDataType().getDisplayName(), variable.getVariableStorage(), type(variable).__name__)
print("STACK_REFERENCES")
listing = program.getListing()
instruction = listing.getInstructionAt(function.getEntryPoint())
while instruction is not None and function.getBody().contains(instruction.getAddress()):
operands = []
for operand_index in range(instruction.getNumOperands()):
references = instruction.getOperandReferences(operand_index)
if references:
operands.append((operand_index, [str(reference) for reference in references]))
print(instruction.getAddress(), instruction, operands)
instruction = instruction.getNext()
print()
dump_function("1420:1499")
dump_function("1430:0000")