From be9c033e9fae24b9207616c0dd6b3a1f4ba71191 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 28 Oct 2010 09:06:43 +0000 Subject: [PATCH] [+] added: windbg snippet displaying CR0 register git-svn-id: https://pykd.svn.codeplex.com/svn@56579 9b283d60-5439-405e-af05-b73fd8c4d996 --- snippets/cr0.py | 32 ++++++++++++++++++++++++++++++++ snippets/cr4.py | 1 + 2 files changed, 33 insertions(+) create mode 100644 snippets/cr0.py diff --git a/snippets/cr0.py b/snippets/cr0.py new file mode 100644 index 0000000..f352cf0 --- /dev/null +++ b/snippets/cr0.py @@ -0,0 +1,32 @@ +# +# +# + +import sys +from pykd import * + +def cr0( value = 0 ): + + if value == 0: + value = reg( "cr0" ) + + dprintln( "CR0: %x (" % value + "".join( [ ( value & ( 1 << ( 31 - i ) ) ) and "1" or "0" for i in range(0,31) ] ) + ")" ) + + for i in range (0, 31): + bits = { 0 : "PE", 1 : "MP", 2 : "EM", 3 : "TS", 4 : "ET", 5 : "NE", 16 : "WP", 18 : "AM", 29 : "NW", 30 : "CD", 31 : "PG" } + if ( ( 1 << ( 31 -i ) ) & value ) and 31-i in bits: + dprint( " " + bits[31-i] ) + + dprintln("") + + +if __name__ == "__main__": + + if not isSessionStart(): + print "script is launch out of windbg" + quit( 0 ) + + if (sys.argv[0] != "" ): + cr0( int( sys.argv[0], 16 ) ) + else: + cr0() diff --git a/snippets/cr4.py b/snippets/cr4.py index b29e1d3..a4437d8 100644 --- a/snippets/cr4.py +++ b/snippets/cr4.py @@ -2,6 +2,7 @@ # # +import sys from pykd import * def cr4( value = 0 ):