diff --git a/decompiler/backend/cexpressiongenerator.py b/decompiler/backend/cexpressiongenerator.py index 77cfbe77e..892f52212 100644 --- a/decompiler/backend/cexpressiongenerator.py +++ b/decompiler/backend/cexpressiongenerator.py @@ -199,6 +199,9 @@ def visit_constant_composition(self, expr: expressions.ConstantComposition): case CustomType(text="wchar16") | CustomType(text="wchar32"): val = "".join([x.value for x in expr.value]) return f'L"{val}"' if len(val) <= MAX_GLOBAL_INIT_LENGTH else f'L"{val[:MAX_GLOBAL_INIT_LENGTH]}..."' + case Integer(size=8, signed=False): + val = "".join([f"\\x{x.value:02X}" for x in expr.value][:MAX_GLOBAL_INIT_LENGTH]) + return f'"{val}"' if len(val) <= MAX_GLOBAL_INIT_LENGTH else f'"{val[:MAX_GLOBAL_INIT_LENGTH]}..."' case Integer(8): val = "".join([x.value for x in expr.value][:MAX_GLOBAL_INIT_LENGTH]) return f'"{val}"' if len(val) <= MAX_GLOBAL_INIT_LENGTH else f'"{val[:MAX_GLOBAL_INIT_LENGTH]}..."' diff --git a/decompiler/backend/variabledeclarations.py b/decompiler/backend/variabledeclarations.py index 27e2152cd..55639f48b 100644 --- a/decompiler/backend/variabledeclarations.py +++ b/decompiler/backend/variabledeclarations.py @@ -63,7 +63,7 @@ def _generate_definitions(global_variables: set[GlobalVariable]) -> Iterator[str match variable.type: case ArrayType(): br, bl = "", "" - if not variable.type.type in [Integer.char(), CustomType.wchar16(), CustomType.wchar32()]: + if not variable.type.type in [Integer.char(), Integer.uint8_t(), CustomType.wchar16(), CustomType.wchar32()]: br, bl = "{", "}" yield f"{base}{variable.type.type} {variable.name}[{hex(variable.type.elements)}] = {br}{CExpressionGenerator().visit(variable.initial_value)}{bl};" case _: diff --git a/decompiler/frontend/binaryninja/handlers/constants.py b/decompiler/frontend/binaryninja/handlers/constants.py index d351a2a2e..e7e5dffdd 100644 --- a/decompiler/frontend/binaryninja/handlers/constants.py +++ b/decompiler/frontend/binaryninja/handlers/constants.py @@ -72,9 +72,6 @@ def lift_constant_pointer(self, pointer: mediumlevelil.MediumLevelILConstPtr, ** if isinstance(res, Constant): # BNinja Error case handling return res - if isinstance(res.type, Pointer) and res.type.type == CustomType.void(): - return res - if isinstance(pointer, mediumlevelil.MediumLevelILImport): # Temp fix for '&' return res diff --git a/decompiler/frontend/binaryninja/handlers/globals.py b/decompiler/frontend/binaryninja/handlers/globals.py index 388cc061e..076610109 100644 --- a/decompiler/frontend/binaryninja/handlers/globals.py +++ b/decompiler/frontend/binaryninja/handlers/globals.py @@ -247,7 +247,9 @@ def _get_unknown_value(self, variable: DataVariable): type = PseudoArrayType(self._lifter.lift(data[1]), len(data[0])) data = ConstantComposition([Constant(x, type.type) for x in data[0]], type) else: - data, type = get_raw_bytes(variable.address, self._view), Pointer(CustomType.void(), self._view.address_size * BYTE_SIZE) + rbytes = get_raw_bytes(variable.address, self._view) + type = PseudoArrayType(Integer.uint8_t(), len(rbytes)) + data = ConstantComposition([Constant(b, type.type) for b in rbytes], type) return data, type def _get_unknown_pointer_value(self, variable: DataVariable, callers: list[int] = None):