From 10640607e1b135d87a1dbf6a94db5855b053d1ab Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 10 Sep 2013 06:17:22 +0000 Subject: [PATCH] [0.3.x] branch : cr0.py cr4.py git-svn-id: https://pykd.svn.codeplex.com/svn@85138 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd-0.3-2010.sln | 18 ++++++++++++++++++ snippets/cr0.py | 32 ++++++++++++++++++++++++++++++++ snippets/cr4.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 snippets/cr0.py create mode 100644 snippets/cr4.py diff --git a/pykd-0.3-2010.sln b/pykd-0.3-2010.sln index 8fb6c8d..f415845 100644 --- a/pykd-0.3-2010.sln +++ b/pykd-0.3-2010.sln @@ -40,6 +40,23 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{FE24 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "kdlibcpp\tests\targetapp\targetapp.vcxproj", "{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{A7AF87D2-983B-4B3A-823F-5A2C6989672E}" + ProjectSection(SolutionItems) = preProject + samples\samples.py = samples\samples.py + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{AAB21DD2-B0EE-493E-8415-5195F18879EB}" + ProjectSection(SolutionItems) = preProject + snippets\cr0.py = snippets\cr0.py + snippets\cr4.py = snippets\cr4.py + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "um", "um", "{EEFC9510-DFA7-439E-801E-48FCE72766AD}" + ProjectSection(SolutionItems) = preProject + samples\um\critlist.py = samples\um\critlist.py + samples\um\ldr.py = samples\um\ldr.py + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_2.7|Win32 = Debug_2.7|Win32 @@ -93,5 +110,6 @@ Global GlobalSection(NestedProjects) = preSolution {FE246107-1CB8-404F-97BD-E901E4B5E972} = {5A3C2DA6-AE91-4025-AC03-A58BD03CEBCD} {0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF} = {5A3C2DA6-AE91-4025-AC03-A58BD03CEBCD} + {EEFC9510-DFA7-439E-801E-48FCE72766AD} = {A7AF87D2-983B-4B3A-823F-5A2C6989672E} EndGlobalSection EndGlobal diff --git a/snippets/cr0.py b/snippets/cr0.py new file mode 100644 index 0000000..82d6f1b --- /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" ) & 0xFFFFFFFF + + dprintln( "CR0: %x (" % value + "".join( [ ( value & ( 1 << ( 31 - i ) ) ) and "1" or "0" for i in range(0,32) ] ) + ")" ) + + for i in range (0, 32): + 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 isWindbgExt(): + print "script is launch out of windbg" + quit( 0 ) + + if ( len( sys.argv ) > 1 ): + cr0( int( sys.argv[1], 16 ) ) + else: + cr0() diff --git a/snippets/cr4.py b/snippets/cr4.py new file mode 100644 index 0000000..5f66727 --- /dev/null +++ b/snippets/cr4.py @@ -0,0 +1,35 @@ +# +# +# + +import sys +from pykd import * + +def cr4( value = 0 ): + + if value == 0: + value = reg( "cr4" ) & 0xFFFFFFFF + + dprintln( "CR4: %x (" % value + "".join( [ ( value & ( 1 << ( 31 - i ) ) ) and "1" or "0" for i in range(0,32) ] ) + ")" ) + + for i in range (0, 32): + bits = { 0 : "VME", 1 : "PVI", 2 : "TSD", 3 : "DE", 4 : "PSE", 5 : "PAE", 6 : "MCE", 7 : "PGE", 8 : "PCE", 9 : "OSFXSR", 10 : "OSXMMEXCPT", 13 : "VMXE", 14 : "SMXE", 17 : "PCIDE", 18 : "OSXSAVE" } + if ( ( 1 << ( 31 -i ) ) & value ) and 31-i in bits: + dprint( " " + bits[31-i] ) + + dprintln("") + + +if __name__ == "__main__": + + if not isWindbgExt(): + print "script is launch out of windbg" + quit( 0 ) + + if len(sys.argv) > 1: + cr4( int( sys.argv[1], 16 ) ) + else: + cr4() + + +