[pykd] added : typedVar::data method ( Return raw string object with data stream )

git-svn-id: https://pykd.svn.codeplex.com/svn@66398 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-06-07 16:39:05 +00:00
parent 80eaf476cd
commit 2f4f925b4b
3 changed files with 36 additions and 3 deletions

View File

@ -21,7 +21,6 @@
#include "dbgdump.h" #include "dbgdump.h"
#include "dbgexcept.h" #include "dbgexcept.h"
#include "dbgeventcb.h" #include "dbgeventcb.h"
#include "dbgcallback.h"
#include "dbgpath.h" #include "dbgpath.h"
#include "dbgprocess.h" #include "dbgprocess.h"
#include "dbgsynsym.h" #include "dbgsynsym.h"
@ -253,8 +252,10 @@ BOOST_PYTHON_MODULE( pykd )
"constructor" ) ) "constructor" ) )
.def("getAddress", &TypedVar::getAddress, .def("getAddress", &TypedVar::getAddress,
"Return virtual address" ) "Return virtual address" )
.def("sizeof", &TypedVar::getSize, .def("sizeof", &TypedVar::getSize,
"Return size of a variable in the target memory" ) "Return size of a variable in the target memory" )
.def("data", &TypedVar::data,
"Return raw string object with data stream" )
.def("__getattr__", &TypedVar::getFieldWrap, .def("__getattr__", &TypedVar::getFieldWrap,
"Return field of structure as a object attribute" ) "Return field of structure as a object attribute" )
.def("__str__", &TypedVar::print, .def("__str__", &TypedVar::print,
@ -827,6 +828,21 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
char str[100]; char str[100];
ULONG inputSize; ULONG inputSize;
bool stopInput = false; bool stopInput = false;
boost::python::import( "pykd" );
boost::python::object main = boost::python::import("__main__");
boost::python::object global(main.attr("__dict__"));
// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
boost::python::object sys = boost::python::import("sys");
dbgOut dout;
sys.attr("stdout") = boost::python::object( dout );
dbgIn din;
sys.attr("stdin") = boost::python::object( din );
do { do {

View File

@ -867,6 +867,21 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
std::string
TypedVar::data()
{
if ( m_buffer.size() == 0 )
{
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
return std::string( &m_buffer[0], m_buffer.size() );
}
/////////////////////////////////////////////////////////////////////////////////////
std::string std::string
TypedVar::print() TypedVar::print()
{ {

View File

@ -216,7 +216,7 @@ public:
getAddress() const { getAddress() const {
return m_targetOffset; return m_targetOffset;
} }
ULONG ULONG
getSize() const { getSize() const {
return m_typeInfo.fullSize(); return m_typeInfo.fullSize();
@ -233,6 +233,8 @@ public:
return m_targetOffset; return m_targetOffset;
} }
std::string data();
std::string print(); std::string print();
private: private: