Skip to content

Commit

Permalink
Implemented support for Open XML documents
Browse files Browse the repository at this point in the history
  • Loading branch information
bontchev committed Nov 20, 2016
1 parent 45189ce commit b9821b0
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pcodedmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def decode(x):

__author__ = 'Vesselin Bontchev <[email protected]>'
__license__ = 'GPL'
__VERSION__ = '1.2.1'
__VERSION__ = '1.2.2'

def hexdump(buffer, length=16):
theHex = lambda data: ' '.join('{:02X}'.format(ord(i)) for i in data)
Expand Down Expand Up @@ -1148,16 +1148,10 @@ def pcodeDump(moduleData, vbaProjectData, dirData, identifiers, is64bit, verbose
print('Error: {}.'.format(e), file=sys.stderr)
return

def processFile(fileName, verbose, disasmOnly):
# TODO:
# - Handle VBA3 documents
print('Processing file: {}'.format(fileName))
vbaParser = None
def processProject(vbaParser, verbose, disasmOnly):
try:
vbaParser = VBA_Parser(fileName)
vbaProjects = vbaParser.find_vba_projects()
if (vbaProjects is None):
vbaParser.close()
return
for vbaRoot, projectPath, dirPath in vbaProjects:
print('=' * 79)
Expand Down Expand Up @@ -1186,8 +1180,21 @@ def processFile(fileName, verbose, disasmOnly):
pcodeDump(moduleData, vbaProjectData, dirData, identifiers, is64bit, verbose, disasmOnly)
except Exception as e:
print('Error: {}.'.format(e), file=sys.stderr)
if (vbaParser):
vbaParser.close()

def processFile(fileName, verbose, disasmOnly):
# TODO:
# - Handle VBA3 documents
print('Processing file: {}'.format(fileName))
try:
vbaParser = VBA_Parser(fileName)
if (vbaParser.ole_file is None):
for subFile in vbaParser.ole_subfiles:
processProject(subFile, verbose, disasmOnly)
else:
processProject(vbaParser, verbose, disasmOnly)
except Exception as e:
print('Error: {}.'.format(e), file=sys.stderr)
vbaParser.close()

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Dumps the p-code of VBA-containing documents.')
Expand Down

0 comments on commit b9821b0

Please sign in to comment.