[0.2.x] added : getProcessorMode routine

git-svn-id: https://pykd.svn.codeplex.com/svn@78889 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-08-16 15:59:02 +00:00 committed by Mikhail I. Izmestev
parent 2decf9abc7
commit b91bb8ca38
3 changed files with 63 additions and 0 deletions

View File

@ -42,6 +42,10 @@ ULONG64 loadMSR( ULONG msr );
void setMSR( ULONG msr, ULONG64 value); void setMSR( ULONG msr, ULONG64 value);
std::string getProcessorMode();
std::string getProcessorType();
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
}; // end pykd namespace }; // end pykd namespace

View File

@ -192,6 +192,11 @@ BOOST_PYTHON_MODULE( pykd )
"Return MSR value" ); "Return MSR value" );
python::def( "wrmsr", &setMSR, python::def( "wrmsr", &setMSR,
"Set MSR value" ); "Set MSR value" );
python::def( "getProcessorMode", &getProcessorMode,
"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" );
// stack and local variables // stack and local variables
python::def( "getCurrentStack", &getCurrentStack, python::def( "getCurrentStack", &getCurrentStack,

View File

@ -645,6 +645,60 @@ void getStackTrace( STACK_FRAME_DESC* frames, ULONG frameCount, ULONG* frameRetu
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
std::string processorToStr(ULONG processorMode)
{
switch( processorMode )
{
case IMAGE_FILE_MACHINE_I386:
return "X86";
case IMAGE_FILE_MACHINE_ARM:
return "ARM";
case IMAGE_FILE_MACHINE_IA64:
return "IA64";
case IMAGE_FILE_MACHINE_AMD64:
return "X64";
}
throw DbgException( "Unknown CPU type" );
}
///////////////////////////////////////////////////////////////////////////////
std::string getProcessorMode()
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
ULONG processorMode;
hres = g_dbgEng->control->GetEffectiveProcessorType( &processorMode );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
return processorToStr(processorMode);
}
///////////////////////////////////////////////////////////////////////////////
std::string getProcessorType()
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
ULONG processorMode;
hres = g_dbgEng->control->GetActualProcessorType( &processorMode );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetActualProcessorType failed" );
return processorToStr(processorMode);
}
///////////////////////////////////////////////////////////////////////////////
} // end pykd namespace } // end pykd namespace