From f0fc6f3f86bc98ed588888996fcd01daeea317fb Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 16 Oct 2012 08:15:20 +0000 Subject: [PATCH] [0.2.x] added : sample um.critsec.py git-svn-id: https://pykd.svn.codeplex.com/svn@80243 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/pykdver.h | 2 +- pykd/typeinfo.cpp | 14 ++++++++++++-- samples/km/ssdt.py | 12 +++++++----- samples/samples.py | 2 ++ test/scripts/moduletest.py | 2 +- test/targetapp/targetapp.cpp | 4 +++- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/pykd/pykdver.h b/pykd/pykdver.h index 064c343..0963004 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 2 #define PYKD_VERSION_SUBVERSION 0 -#define PYKD_VERSION_BUILDNO 1 +#define PYKD_VERSION_BUILDNO 2 #define __VER_STR2__(x) #x diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 73bb42a..19dd6b5 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -76,9 +76,19 @@ ULONG64 TypeInfo::getSymbolSize( const std::string &fullName ) std::string TypeInfo::findSymbol( ULONG64 offset ) { - ModulePtr module = Module::loadModuleByOffset( offset ); + try { - return module->getName() + '!' + module->getSymbolNameByVa( offset ); + ModulePtr module = Module::loadModuleByOffset( offset ); + + return module->getName() + '!' + module->getSymbolNameByVa( offset ); + + } + catch( DbgException& ) + { + std::stringstream sstr; + sstr << std::hex << offset; + return sstr.str(); + } } ///////////////////////////////////////////////////////////////////////////////////// diff --git a/samples/km/ssdt.py b/samples/km/ssdt.py index 7ac0b40..32edd97 100644 --- a/samples/km/ssdt.py +++ b/samples/km/ssdt.py @@ -44,10 +44,6 @@ def checkSSDT(): dprintln( "[%u] " % i + findSymbol( serviceTable[i] ) ) def run(): - checkSSDT() - - -if __name__ == "__main__": while True: @@ -60,6 +56,12 @@ if __name__ == "__main__": dprintln( "not a kernel debugging" ) break - run() + checkSSDT() break + + + +if __name__ == "__main__": + + run() diff --git a/samples/samples.py b/samples/samples.py index 9a87d6c..59a9d08 100644 --- a/samples/samples.py +++ b/samples/samples.py @@ -6,6 +6,8 @@ from pykd import dprintln from pykd import dprint def printAllSamples(): + dprintln( "User mode", True) + dprintln( "Get critical sections list Run Source", True) dprintln( "Kernel mode", True ) dprintln( "Get process list Run Source", True) dprintln( "Get kernel service list Run Source", True) diff --git a/test/scripts/moduletest.py b/test/scripts/moduletest.py index 701d578..cd65e71 100644 --- a/test/scripts/moduletest.py +++ b/test/scripts/moduletest.py @@ -66,6 +66,6 @@ class ModuleTest( unittest.TestCase ): self.assertTrue( re.search('targetapp\\.cpp', fileName ) ) self.assertEqual( 2, displacement ) fileName, lineNo, displacement = pykd.getSourceLine() - self.assertEqual( 622, lineNo ) + self.assertEqual( 624, lineNo ) diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index 7c38a9c..00b0f0d 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -459,6 +459,8 @@ void FuncWithName1(int a) std::cout << g_arrOfPtrToFunc[1]; } +#pragma optimize("g", off) + static void _FuncWithName2(int a) { @@ -466,7 +468,7 @@ void _FuncWithName2(int a) } //////////////////////////////////////////////////////////////////////////////// -#pragma optimize("g", off) + VOID functionCalledFromEnumWindowsProc1(DWORD dwProcessId) { DWORD dwCurrentProcessId = GetCurrentProcessId();