forked from yiwiz-sai/pyInspector
/
directory_op.py
45 lines (38 loc) · 1019 Bytes
/
directory_op.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
#!/usr/bin/env python
# -*- coding: utf-8 -*
# author: SAI
import os,sys,time
import traceback
import pykd
from common import *
def crawl_object_by_directory(callback, param, dirname='\\'):
cmdline='!object '+dirname
#print cmdline
r=pykd.dbgCommand(cmdline)
r=r.splitlines()
startlist=0
for i in r:
i=i.lstrip()
if i.startswith('--'):
startlist=1
continue
if not startlist:
continue
data=i.split()
if len(data)>3:
obj=data[1]
type=data[2]
name=data[3]
else:
obj=data[0]
type=data[1]
name=data[2]
if not callback(obj, type, param):
return False
if type=='Directory':
childname=dirname+name+'\\'
if not crawl_object_by_directory(callback, param, childname):
return False
return True
if __name__=='__main__':
pass