Skip to content

Commit

Permalink
show bytes as hexstring
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Dec 17, 2024
1 parent fad1bca commit 915faa1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/patcherex2/components/assemblers/bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def _assemble(self, code: str, base=0, **kwargs) -> bytes:
if base != 0:
f.seek(base)
binary = f.read()
logger.debug(f"Assembled bytes: {bytes(binary)}")
logger.debug(f"Assembled bytes: {bytes(binary).hex()}")
return bytes(binary)
2 changes: 1 addition & 1 deletion src/patcherex2/components/assemblers/keystone.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, p, arch: int, mode: int) -> None:
def _assemble(self, code: str, base=0, **kwargs) -> bytes:
try:
binary, _ = self.ks.asm(code, base)
logger.debug(f"Assembled bytes: {bytes(binary)}")
logger.debug(f"Assembled bytes: {bytes(binary).hex()}")
return bytes(binary)
except Exception as e:
raise Exception(
Expand Down
2 changes: 1 addition & 1 deletion src/patcherex2/components/assemblers/keystone_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _assemble(self, code: str, base=0, is_thumb=False) -> bytes:
try:
ks = self.ks_thumb if is_thumb else self.ks_arm
binary, _ = ks.asm(code, base)
logger.debug(f"Assembled bytes: {bytes(binary)}")
logger.debug(f"Assembled bytes: {bytes(binary).hex()}")
return bytes(binary)
except Exception as e:
raise Exception(
Expand Down
2 changes: 1 addition & 1 deletion src/patcherex2/components/assemblers/ppc_vle.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ def _assemble(self, code: str, base=0, **kwargs) -> bytes:
if base != 0:
f.seek(base)
binary = f.read()
logger.debug(f"Assembled bytes: {bytes(binary)}")
logger.debug(f"Assembled bytes: {bytes(binary).hex()}")
return bytes(binary)
2 changes: 1 addition & 1 deletion src/patcherex2/components/binfmt_tools/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def save_binary(self, filename: str | None = None) -> None:

def update_binary_content(self, offset: int, new_content: bytes) -> None:
logger.debug(
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content}"
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content.hex()}"
)
for update in self.file_updates:
if offset >= update["offset"] and offset < update["offset"] + len(
Expand Down
2 changes: 1 addition & 1 deletion src/patcherex2/components/binfmt_tools/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def save_binary(self, filename: str | None = None) -> None:

def update_binary_content(self, offset: int, new_content: bytes) -> None:
logger.debug(
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content}"
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content.hex()}"
)
for update in self.file_updates:
if offset >= update["offset"] and offset < update["offset"] + len(
Expand Down
2 changes: 1 addition & 1 deletion src/patcherex2/components/binfmt_tools/ihex.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def save_binary(self, filename: str | None = None) -> None:

def update_binary_content(self, offset: int, new_content: bytes) -> None:
logger.debug(
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content}"
f"Updating offset {hex(offset)} with content ({len(new_content)} bytes) {new_content.hex()}"
)
for update in self.file_updates:
if offset >= update["offset"] and offset < update["offset"] + len(
Expand Down

0 comments on commit 915faa1

Please sign in to comment.