-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_excr.py
26 lines (23 loc) · 1.04 KB
/
extract_excr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from minidump import *
if __name__ == '__main__':
import sys
md = MINIDUMP_HEADER.parse_stream(open(sys.argv[1], 'rb'))
excr = None
threads = None
for stream in range(0, md.NumberOfStreams-1):
if md.MINIDUMP_DIRECTORY[stream].StreamType == 'ExceptionStream':
excr = md.MINIDUMP_DIRECTORY[stream]
if threads is not None:
break
if md.MINIDUMP_DIRECTORY[stream].StreamType == 'ThreadListStream':
threads = md.MINIDUMP_DIRECTORY[stream]
if excr is not None:
break
if excr is not None:
ethid = excr.DirectoryData.ThreadId
print 'Exception in thread %ld' % ethid
for thread in range(0, threads.DirectoryData.NumberOfThreads-1):
if threads.DirectoryData.MINIDUMP_THREAD[thread].ThreadId == ethid:
ethread = threads.DirectoryData.MINIDUMP_THREAD[thread]
print 'Exception context: RVA(%ld), Size(%ld)' % \
(ethread.ThreadContext.RVA, ethread.ThreadContext.DataSize)