diff --git a/pykd/cpureg.cpp b/pykd/cpureg.cpp new file mode 100644 index 0000000..ce5d80a --- /dev/null +++ b/pykd/cpureg.cpp @@ -0,0 +1,68 @@ +#include "stdafx.h" + +#include "cpureg.h" +#include "dbgclient.h" + +namespace pykd { + +/////////////////////////////////////////////////////////////////////////////////// + +python::object DebugClient::getRegByIndex( ULONG index ) +{ + HRESULT hres; + + DEBUG_VALUE debugValue; + hres = m_registers->GetValue( index, &debugValue ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugRegister::GetValue failed" ); + + switch( debugValue.Type ) + { + case DEBUG_VALUE_INT8: + return boost::python::long_( debugValue.I8 ); + break; + + case DEBUG_VALUE_INT16: + return boost::python::long_( debugValue.I16 ); + break; + + case DEBUG_VALUE_INT32: + return boost::python::long_( debugValue.I32 ); + break; + + case DEBUG_VALUE_INT64: + return boost::python::long_(debugValue.I64 ); + break; + } + + throw DbgException( "Invalid register value" ); +} + +python::object getRegByIndex( ULONG index ) +{ + return g_dbgClient->getRegByIndex( index ); +} + +/////////////////////////////////////////////////////////////////////////////////// + + +python::object DebugClient::getRegByName( const std::wstring ®Name ) +{ + ULONG registerIndex = 0; + HRESULT hres; + + hres = m_registers->GetIndexByNameWide( regName.c_str(), ®isterIndex ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugRegister2::GetIndexByNameWide failed" ); + + return getRegByIndex( registerIndex ); +} + +python::object getRegByName( const std::wstring ®Name ) +{ + return g_dbgClient->getRegByName( regName ); +} + +/////////////////////////////////////////////////////////////////////////////////// + +} // end namespace pykd \ No newline at end of file diff --git a/pykd/cpureg.h b/pykd/cpureg.h new file mode 100644 index 0000000..99f6c9e --- /dev/null +++ b/pykd/cpureg.h @@ -0,0 +1,17 @@ +#pragma once + +#include "intbase.h" +#include "dbgobj.h" + +namespace pykd { + +/////////////////////////////////////////////////////////////////////////////////// + +python::object getRegByName( const std::wstring ®Name ); + +python::object getRegByIndex( ULONG index ); + +/////////////////////////////////////////////////////////////////////////////////// + +}; // end pykd namespace + diff --git a/pykd/dbgclient.cpp b/pykd/dbgclient.cpp index 5c8c3bc..ff3baf2 100644 --- a/pykd/dbgclient.cpp +++ b/pykd/dbgclient.cpp @@ -88,6 +88,26 @@ ULONG getExecutionStatus() return g_dbgClient->getExecutionStatus(); } +/////////////////////////////////////////////////////////////////////////////////// + +bool DebugClient::is64bitSystem() +{ + HRESULT hres; + + hres = m_control->IsPointer64Bit(); + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::IsPointer64Bit failed" ); + + return hres == S_OK; +} + +bool +is64bitSystem() +{ + return g_dbgClient->is64bitSystem(); +} + + /////////////////////////////////////////////////////////////////////////////////// bool DebugClient::isDumpAnalyzing() diff --git a/pykd/dbgclient.h b/pykd/dbgclient.h index 1bebaa7..20136cb 100644 --- a/pykd/dbgclient.h +++ b/pykd/dbgclient.h @@ -86,6 +86,8 @@ public: template void changeDebuggerStatus(); + bool is64bitSystem(); + bool isKernelDebugging(); bool isDumpAnalyzing(); @@ -213,6 +215,8 @@ python::tuple getDebuggeeType(); ULONG getExecutionStatus(); +bool is64bitSystem(); + bool isKernelDebugging(); bool isDumpAnalyzing(); diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 19805d3..bbb87cb 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -145,14 +145,16 @@ BOOST_PYTHON_MODULE( pykd ) "Attach debugger to a exsisting process" ) .def( "attachKernel", &DebugClient::attachKernel, "Attach debugger to a target's kernel" ) - .def( "expr", &pykd::DebugClient::evaluate, + .def( "expr", &DebugClient::evaluate, "Evaluate windbg expression" ) - .def( "getDebuggeeType", &pykd::DebugClient::getDebuggeeType, + .def( "getDebuggeeType", &DebugClient::getDebuggeeType, "Return type of the debuggee" ) - .def( "getExecutionStatus", &pykd::DebugClient::getExecutionStatus, + .def( "getExecutionStatus", &DebugClient::getExecutionStatus, "Return information about the execution status of the debugger" ) - .def( "go", &pykd::DebugClient::changeDebuggerStatus, + .def( "go", &DebugClient::changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_GO" ) + .def( "is64bitSystem", &DebugClient::is64bitSystem, + "Check if target system has 64 address space" ) .def( "isDumpAnalyzing", &pykd::DebugClient::isDumpAnalyzing, "Check if it is a dump analyzing ( not living debuggee )" ) .def( "isKernelDebugging", &pykd::DebugClient::isKernelDebugging, @@ -252,6 +254,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return information about the execution status of the debugger" ); python::def( "go", &changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_GO" ); + python::def( "is64bitSystem", &is64bitSystem, + "Check if target system has 64 address space" ); python::def( "isDumpAnalyzing", &isDumpAnalyzing, "Check if it is a dump analyzing ( not living debuggee )" ); python::def( "isKernelDebugging", &isKernelDebugging,