From c9b63b1bdbce0137deb6004007327bc04fc19fb9 Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Mon, 3 Oct 2011 19:47:03 +0000 Subject: [PATCH] [+] getProcessorType: type of physical processor git-svn-id: https://pykd.svn.codeplex.com/svn@70185 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgext.cpp | 2 ++ pykd/dbgprocess.cpp | 46 +++++++++++++++++++++++++++++++++------------ pykd/dbgprocess.h | 7 +++++-- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index c6c2b6a..1958efb 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -213,6 +213,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return current processor mode as string: X86, ARM, IA64 or X64" ); boost::python::def( "setProcessorMode", &setProcessorMode, "Set current processor mode by string (X86, ARM, IA64 or X64)" ); + boost::python::def( "getProcessorType", &getProcessorType, + "Returns physical processor type as string: X86, ARM, IA64 or X64"); boost::python::def( "addSynSymbol", &addSyntheticSymbol, "Add new synthetic symbol for virtual address" ); boost::python::def( "delAllSynSymbols", &delAllSyntheticSymbols, diff --git a/pykd/dbgprocess.cpp b/pykd/dbgprocess.cpp index 78284fe..ec58d82 100644 --- a/pykd/dbgprocess.cpp +++ b/pykd/dbgprocess.cpp @@ -119,17 +119,10 @@ getCurrentStack() } ///////////////////////////////////////////////////////////////////////////////// - -std::string -getProcessorMode() +// Processor type to string +///////////////////////////////////////////////////////////////////////////////// +static std::string processorToStr(ULONG processorMode) { - HRESULT hres; - - ULONG processorMode; - hres = dbgExt->control->GetEffectiveProcessorType( &processorMode ); - if ( FAILED( hres ) ) - throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" ); - switch( processorMode ) { case IMAGE_FILE_MACHINE_I386: @@ -146,7 +139,36 @@ getProcessorMode() } throw DbgException( "Unknown CPU type" ); +} +///////////////////////////////////////////////////////////////////////////////// + +std::string +getProcessorMode() +{ + HRESULT hres; + + ULONG processorMode; + hres = dbgExt->control->GetEffectiveProcessorType( &processorMode ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" ); + + return processorToStr(processorMode); +} + +///////////////////////////////////////////////////////////////////////////////// + +std::string +getProcessorType() +{ + HRESULT hres; + + ULONG processorMode; + hres = dbgExt->control->GetActualProcessorType( &processorMode ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" ); + + return processorToStr(processorMode); } ///////////////////////////////////////////////////////////////////////////////// @@ -167,13 +189,13 @@ setProcessorMode( else if ( mode == "X64" ) processorMode = IMAGE_FILE_MACHINE_AMD64; else - throw DbgException( "Unknown processor type" ); + throw DbgException( "Unknown processor type" ); hres = dbgExt->control->SetEffectiveProcessorType( processorMode ); if ( FAILED( hres ) ) throw DbgException( "IDebugControl::SetEffectiveProcessorType failed" ); -} +} ///////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/dbgprocess.h b/pykd/dbgprocess.h index 1425c7b..88ccc6b 100644 --- a/pykd/dbgprocess.h +++ b/pykd/dbgprocess.h @@ -40,11 +40,14 @@ public: std::string getProcessorMode(); +std::string +getProcessorType(); + void setProcessorMode( const std::string &mode ); - -ULONG64 + +ULONG64 getCurrentProcess(); VOID