-
Notifications
You must be signed in to change notification settings - Fork 3
/
analyse_impl.py
55 lines (39 loc) · 1.36 KB
/
analyse_impl.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import os.path
import sys
from pykd import loadDump
from pykd import loadExt
from pykd import setSymbolPath
import context
import callstack
def main():
init_debugging()
print("------------> Context <------------")
show_context()
print("")
print("-----------> Call Stack <----------")
show_call_stack()
def init_debugging():
loadDump(sys.argv[1])
load_extensions()
init_symbols()
def load_extensions():
windbg_path = os.environ['WIN_DEBUGGING_TOOLS_PATH']
exts_dll_path = os.path.normpath(os.path.join(windbg_path,
'winxp/exts.dll'))
loadExt(exts_dll_path)
def init_symbols():
cache_path = r'C:\DebugSymbolCache'
symbol_server = 'http://msdl.microsoft.com/download/symbols'
setSymbolPath('srv*{}*{}'.format(cache_path, symbol_server))
def show_context():
print("User ID: {}".format(context.get_user()))
print("Data Area ID: {}".format(context.get_data_area()))
print("Client: {}".format(context.get_client()))
def show_call_stack():
for frame in callstack.get_native_frames_until_first_xpp_frame():
print(" Native | {} @{}".format(frame.symbol, hex(frame.ip)))
for frame in callstack.get_xpp_frames():
print(" X++ | {}::{}".format(frame.element_name, frame.method_name))
if __name__ == '__main__':
main()