Skip to content

Commit 4e0a7b3

Browse files
committed
feat(handler): clean up msi handler
Requires this PR to (almost) work properly: nightlark/pymsi#81
1 parent 297d798 commit 4e0a7b3

File tree

1 file changed

+6
-14
lines changed
  • python/unblob/handlers/archive

1 file changed

+6
-14
lines changed

python/unblob/handlers/archive/msi.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""MSI Handler
22
3-
Extracts uses 7z for now. Could migrate to fully implementation:
3+
Extracts uses 7z for now. Could migrate to a fully Python-based implementation:
44
55
https://github.com/nightlark/pymsi
66
"""
@@ -51,21 +51,13 @@ class MsiHandler(Handler):
5151
def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]:
5252
file.seek(start_offset, io.SEEK_SET)
5353

54-
try:
55-
# TODO: pymsi wants a path or BytesIO
56-
buf = io.BytesIO()
57-
buf.write(file[:])
58-
buf.seek(0)
59-
60-
package = pymsi.Package(buf)
61-
msi = pymsi.Msi(package, True)
62-
except Exception:
63-
return None
54+
package = pymsi.Package(file)
55+
msi = pymsi.Msi(package, False)
6456

6557
# MSI moves the file pointer
66-
msi_end_offset = buf.tell()
58+
msi_end_offset = file.tell()
6759

6860
return ValidChunk(
69-
start_offset = start_offset,
70-
end_offset = msi_end_offset,
61+
start_offset = start_offset,
62+
end_offset = msi_end_offset,
7163
)

0 commit comments

Comments
 (0)