Skip to content

Commit

Permalink
Version 0.1.9.4
Browse files Browse the repository at this point in the history
bugfix : correctly read in unicode strings
  • Loading branch information
mos9527 committed Oct 30, 2022
1 parent 701a5e0 commit c582776
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion evbunpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#-*- coding: utf-8 --
__version__ = '0.1.9.3'
__version__ = '0.1.9.4'
__author__ = 'mos9527'
13 changes: 6 additions & 7 deletions evbunpack/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ def unpack(structure, buffer, *args, **extra):
def read_named_node(src):
blkFilename = bytearray()
p = src.read(2)
while p[0]!=0x00:
while (p[0]!=0 or p[1]!=0):
blkFilename.extend(p)
p = src.read(2)
src.seek(-2,1)
block = blkFilename + src.read(3)
p = src.read(2)
block = blkFilename + src.read(1)
return unpack(EVB_NODE_NAMED, block, len(blkFilename),offset=src.tell())

def read_header_node(src):
Expand Down Expand Up @@ -123,16 +122,16 @@ def pe_external_tree(fd):
while True:
try:
header_node = read_header_node(fd)
named_node = read_named_node(fd)
named_node = read_named_node(fd)
except struct.error:
return # Potential EOF exception
if named_node['type'] == NODE_TYPE_FILE:
optional_node = read_optional_file_node(fd)
optional_node['offset'] = abs_offset
abs_offset += optional_node['stored_size']
abs_offset += optional_node['stored_size']
elif named_node['type'] == NODE_TYPE_FOLDER:
optional_node = {}
fd.seek(25,1)
fd.seek(25,1)
else:
return # assuming finished
named_node['name'] = named_node['name'].decode('utf-16-le')
Expand Down
3 changes: 1 addition & 2 deletions evbunpack/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
]

EVB_NODE_NAMED = [
('%ds', 'name'), # args[0] - filename buffer length
('2s', ''),
('%ds', 'name'), # args[0] - filename buffer length
('B', 'type'),
]

Expand Down

0 comments on commit c582776

Please sign in to comment.