1
0
mirror of synced 2024-11-13 17:40:47 +01:00

Fix help display and fix skipping padding bytes ('x' character).

This commit is contained in:
Jennifer Taylor 2021-04-03 05:26:48 +00:00
parent bfa7384f2b
commit 4a3068686a

View File

@ -148,10 +148,11 @@ class StructPrinter:
else: else:
size = struct.calcsize(prefix + spec) size = struct.calcsize(prefix + spec)
chunk = self.data[offset:(offset + size)] chunk = self.data[offset:(offset + size)]
if dohex: if spec != 'x':
line.append(hex(struct.unpack(prefix + spec, chunk)[0])) if dohex:
else: line.append(hex(struct.unpack(prefix + spec, chunk)[0]))
line.append(struct.unpack(prefix + spec, chunk)[0]) else:
line.append(struct.unpack(prefix + spec, chunk)[0])
offset += size offset += size
else: else:
chunk = self.data[offset:(offset + 4)] chunk = self.data[offset:(offset + 4)]
@ -201,7 +202,7 @@ def main() -> None:
"for details. Additionally, prefixing a format specifier with * allows dereferencing pointers. " "for details. Additionally, prefixing a format specifier with * allows dereferencing pointers. "
"Surround a chunk of format specifiers with parenthesis to dereference complex structures. For " "Surround a chunk of format specifiers with parenthesis to dereference complex structures. For "
"ease of unpacking C string pointers, the specifier \"z\" is recognzied to mean null-terminated " "ease of unpacking C string pointers, the specifier \"z\" is recognzied to mean null-terminated "
"string. A % preceeding a format specifier means that we should convert to hex before displaying." "string. A & preceeding a format specifier means that we should convert to hex before displaying."
), ),
type=str, type=str,
default=None, default=None,