-
Notifications
You must be signed in to change notification settings - Fork 0
/
irp_flags.py
49 lines (36 loc) · 1.31 KB
/
irp_flags.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
"""
Description: This program is used for print IRP Flags
Developer: [email protected]
"""
import sys,string
base = [str(x) for x in range(10)] + [ chr(x) for x in range(ord('A'),ord('A')+6)]
flags = ["IRP_NOCACHE", "IRP_PAGING_IO\\IRP_MOUNT_COMPLETION", "IRP_SYNCHRONOUS_API", "IRP_ASSOCIATED_IRP", "IRP_BUFFERED_IO", "IRP_DEALLOCATE_BUFFER", "IRP_SYNCHRONOUS_PAGING_IO\\IRP_INPUT_OPERATION", "IRP_CREATE_OPERATION", "IRP_READ_OPERATION", "IRP_WRITE_OPERATION", "IRP_CLOSE_OPERATION", "IRP_DEFER_IO_COMPLETION"]
def main():
if len(sys.argv) < 2:
print "Usage: python irp_flags.py param(hexadecimal)"
print "Example: python irp_flags.py 0xa00"
return
# flag = string.atoi(sys.argv[1])
flag_dec = int( sys.argv[1], 16 )
print 'Decimal: ' + str(flag_dec)
flag_str_bin = dec2bin(flag_dec)
length = len(flag_str_bin)
if length > len(flags):
length = len(flags)
flag_str_bin = flag_str_bin[len(flag_str_bin)-length:]
print 'Binary: ' + flag_str_bin
print 'IrpFlags:'
for i in range(length):
if flag_str_bin[length-i-1] == '1':
print '\t' + flags[i]
def hex2dec(string_num):
return str(int(string_num.upper(), 16))
def dec2bin(string_num):
num = int(string_num)
mid = []
while True:
if num == 0: break
num,rem = divmod(num, 2)
mid.append(base[rem])
return ''.join([str(x) for x in mid[::-1]])
main()