diff --git a/pykd/cpucontext.h b/pykd/cpucontext.h index c74ea78..716194c 100644 --- a/pykd/cpucontext.h +++ b/pykd/cpucontext.h @@ -47,6 +47,14 @@ inline kdlib::CPUType getProcessorType() { return kdlib::loadCPUCurrentContext()->getCPUType(); } +inline void setProcessorMode( kdlib::CPUType mode ) { + kdlib::loadCPUCurrentContext()->setCPUMode(mode); +} + +inline void switchProcessorMode() { + kdlib::loadCPUCurrentContext()->switchCPUMode(); +} + inline python::list getCurrentStack() { return CPUContextAdaptor::getStack( *kdlib::loadCPUCurrentContext() ); } diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 39b21bf..d2aecdb 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -259,8 +259,10 @@ 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)" ); + python::def( "setProcessorMode", &setProcessorMode, + "Set current processor mode (X86, ARM, IA64 or X64)" ); + python::def( "switchProcessorMode", &switchProcessorMode, + "Switch processor mode ( X86 <-> X64 )" ); // stack and local variables python::def( "getStack", &getCurrentStack, @@ -560,6 +562,8 @@ BOOST_PYTHON_MODULE( pykd ) .add_property("fp", &kdlib::CPUContext::getSP ) .def("getCPUType", &kdlib::CPUContext::getCPUType ) .def("getCPUMode", &kdlib::CPUContext::getCPUMode ) + .def("setCPUMode", &kdlib::CPUContext::setCPUMode ) + .def("switchCPUMode", &kdlib::CPUContext::switchCPUMode ) .def("getStack", &CPUContextAdaptor::getStack ) .def("__getattr__", &CPUContextAdaptor::getRegisterByName ) .def("__getitem__", &CPUContextAdaptor::getRegisterByIndex ); @@ -671,7 +675,8 @@ BOOST_PYTHON_MODULE( pykd ) .def( "reset", &kdlib::Disasm::reset, "Reset current offset to begin" ) .def( "findOffset", &kdlib::Disasm::getNearInstruction, "Return the location of a processor instruction relative to a given location" ) .def( "jump", &kdlib::Disasm::jump, "Change the current instruction" ) - .def( "jumprel", &kdlib::Disasm::jumprel, "Change the current instruction" ); + .def( "jumprel", &kdlib::Disasm::jumprel, "Change the current instruction" ) + .def( "__str__", &kdlib::Disasm::instruction ); python::enum_("eventResult", "Return value of event handler")