Commit 8e52d4b1 by devttys0

Extract module creates separate output directories; fixed bug in BlockFile.seek

parent cfedd0ff
...@@ -358,7 +358,7 @@ class BlockFile(io.FileIO): ...@@ -358,7 +358,7 @@ class BlockFile(io.FileIO):
def seek(self, n, whence=os.SEEK_SET): def seek(self, n, whence=os.SEEK_SET):
if whence == os.SEEK_SET: if whence == os.SEEK_SET:
self.total_read = n self.total_read = n - self.offset
elif whence == os.SEEK_CUR: elif whence == os.SEEK_CUR:
self.total_read += n self.total_read += n
elif whence == os.SEEK_END: elif whence == os.SEEK_END:
......
...@@ -462,14 +462,12 @@ class Modules(object): ...@@ -462,14 +462,12 @@ class Modules(object):
def load(self, module): def load(self, module):
kwargs = self.argv(module, argv=self.arguments) kwargs = self.argv(module, argv=self.arguments)
kwargs.update(self.dependencies(module)) kwargs.update(self.dependencies(module))
print "Loading", module
return module(**kwargs) return module(**kwargs)
def dependencies(self, module): def dependencies(self, module):
import binwalk.modules import binwalk.modules
kwargs = {} kwargs = {}
print "Loading dependency:", module
if hasattr(module, "DEPENDS"): if hasattr(module, "DEPENDS"):
for (kwarg, dependency) in iterator(module.DEPENDS): for (kwarg, dependency) in iterator(module.DEPENDS):
......
...@@ -112,13 +112,15 @@ class Signature(binwalk.module.Module): ...@@ -112,13 +112,15 @@ class Signature(binwalk.module.Module):
r.valid = False r.valid = False
def scan_file(self, fp): def scan_file(self, fp):
current_file_offset = 0
while True: while True:
(data, dlen) = fp.read_block() (data, dlen) = fp.read_block()
if not data: if not data:
break break
current_block_offset = 0 current_block_offset = 0
block_start = fp.total_read - dlen block_start = fp.offset + fp.total_read - dlen
self.status.completed = block_start - fp.offset self.status.completed = block_start - fp.offset
for candidate_offset in self.parser.find_signature_candidates(data, dlen): for candidate_offset in self.parser.find_signature_candidates(data, dlen):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment