diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2025-01-20 18:44:25 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2025-01-20 18:44:25 -0500 |
| commit | e78cae77103b5396ce42d9e33593ea55f9135be0 (patch) | |
| tree | b44cb4bf7732c1e2e77ae39335eb4e2f02d9af84 /python/examples | |
| parent | cbd4d7f12d54ddc4b6d3d90a8d7b49591f468a94 (diff) | |
Revert "Add line formatter API and a generic line formatter plugin"
This reverts commit 1699c71999d29d32aba5c9f8fea193a661a4b02b.
Diffstat (limited to 'python/examples')
| -rw-r--r-- | python/examples/pseudo_python.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/python/examples/pseudo_python.py b/python/examples/pseudo_python.py index 655039fe..6a9e401b 100644 --- a/python/examples/pseudo_python.py +++ b/python/examples/pseudo_python.py @@ -316,7 +316,16 @@ class PseudoPythonFunction(LanguageRepresentationFunction): tokens.append(InstructionTextToken(InstructionTextTokenType.TextToken, ": ")) tokens.append(instr.var.type.get_tokens()) elif instr.operation == HighLevelILOperation.HLIL_FLOAT_CONST: - tokens.append(InstructionTextToken(InstructionTextTokenType.FloatingPointToken, f"{instr.constant:g}")) + # The constant value in the instruction contains the raw bits of the floating point value. Convert + # this to a floating point value and display it. + if instr.size == 4: + value = struct.unpack("<f", struct.pack("<I", instr.constant))[0] + tokens.append(InstructionTextToken(InstructionTextTokenType.FloatToken, f"{value:g}")) + elif instr.size == 8: + value = struct.unpack("<d", struct.pack("<Q", instr.constant))[0] + tokens.append(InstructionTextToken(InstructionTextTokenType.FloatToken, f"{value:g}")) + else: + tokens.append_integer_text_token(instr, instr.constant, instr.size) elif instr.operation == HighLevelILOperation.HLIL_CONST: # Check for bool type. Display these as True or False. The default handling will use C style # booleans instead of Python style. @@ -1066,7 +1075,7 @@ class PseudoPythonFunctionType(LanguageRepresentationFunctionType): language_name = "Pseudo Python" def create(self, arch: Architecture, owner: Function, hlil: HighLevelILFunction): - return PseudoPythonFunction(self, arch, owner, hlil) + return PseudoPythonFunction(arch, owner, hlil) def function_type_tokens(self, func: Function, settings: DisassemblySettings) -> DisassemblyTextLine: tokens = [] |
