[0.2.x] added : setProcessorMode routine

git-svn-id: https://pykd.svn.codeplex.com/svn@81227 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-11-20 05:36:48 +00:00 committed by Mikhail I. Izmestev
parent 67e1ce1e63
commit 44fd2e17cb
4 changed files with 31 additions and 8 deletions

View File

@ -38,14 +38,6 @@ CpuReg getRegByName( const std::string &regName );
CpuReg getRegByIndex( ULONG index ); CpuReg getRegByIndex( ULONG index );
ULONG64 loadMSR( ULONG msr );
void setMSR( ULONG msr, ULONG64 value);
std::string getProcessorMode();
std::string getProcessorType();
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
}; // end pykd namespace }; // end pykd namespace

View File

@ -52,6 +52,12 @@ std::string getRegNameByIndex( ULONG index );
BaseTypeVariant getRegVariantValue( ULONG index ); BaseTypeVariant getRegVariantValue( ULONG index );
ULONG64 getRegInstructionPointer(); 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 // Stack and local variables
struct STACK_FRAME_DESC { struct STACK_FRAME_DESC {
ULONG number; ULONG number;

View File

@ -240,6 +240,8 @@ BOOST_PYTHON_MODULE( pykd )
"Return current processor mode as string: X86, ARM, IA64 or X64" ); "Return current processor mode as string: X86, ARM, IA64 or X64" );
python::def( "getProcessorType", &getProcessorType, python::def( "getProcessorType", &getProcessorType,
"Return type of physical processor: X86, ARM, IA64 or X64" ); "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 // stack and local variables
python::def( "getCurrentStack", &getCurrentStack, python::def( "getCurrentStack", &getCurrentStack,

View File

@ -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() std::string getProcessorType()
{ {
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );