diff --git a/pykd/cpureg.h b/pykd/cpureg.h index fa62bfb..2269a46 100644 --- a/pykd/cpureg.h +++ b/pykd/cpureg.h @@ -38,14 +38,6 @@ CpuReg getRegByName( const std::string ®Name ); CpuReg getRegByIndex( ULONG index ); -ULONG64 loadMSR( ULONG msr ); - -void setMSR( ULONG msr, ULONG64 value); - -std::string getProcessorMode(); - -std::string getProcessorType(); - /////////////////////////////////////////////////////////////////////////////////// }; // end pykd namespace diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 8ac16ae..535ce71 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -52,6 +52,12 @@ std::string getRegNameByIndex( ULONG index ); BaseTypeVariant getRegVariantValue( ULONG index ); ULONG64 getRegInstructionPointer(); +ULONG64 loadMSR( ULONG msr ); +void setMSR( ULONG msr, ULONG64 value); +std::string getProcessorMode(); +std::string getProcessorType(); +void setProcessorMode( const std::string &mode ); + // Stack and local variables struct STACK_FRAME_DESC { ULONG number; diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 1bcb720..bc14370 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -240,6 +240,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return current processor mode as string: X86, ARM, IA64 or X64" ); python::def( "getProcessorType", &getProcessorType, "Return type of physical processor: X86, ARM, IA64 or X64" ); + python::def( "setProcessorMode", &setProcessorMode, + "Set current processor mode by string (X86, ARM, IA64 or X64)" ); // stack and local variables python::def( "getCurrentStack", &getCurrentStack, diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 87b8716..b4381e5 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -787,6 +787,29 @@ std::string getProcessorMode() /////////////////////////////////////////////////////////////////////////////// +void setProcessorMode( const std::string &mode ) +{ + HRESULT hres; + ULONG processorMode; + + if ( mode == "X86" ) + processorMode = IMAGE_FILE_MACHINE_I386; + else if ( mode == "ARM" ) + processorMode = IMAGE_FILE_MACHINE_ARM; + else if ( mode == "IA64" ) + processorMode = IMAGE_FILE_MACHINE_IA64; + else if ( mode == "X64" ) + processorMode = IMAGE_FILE_MACHINE_AMD64; + else + throw DbgException( "Unknown processor type" ); + + hres = g_dbgEng->control->SetEffectiveProcessorType( processorMode ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::SetEffectiveProcessorType failed" ); +} + +/////////////////////////////////////////////////////////////////////////////// + std::string getProcessorType() { PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );