mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] added : findMemoryRegion ( Return address of begining valid memory region nearest to offset )
[0.3.x] added : getVaProtect ( Return memory attributes ) git-svn-id: https://pykd.svn.codeplex.com/svn@87282 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
5396e876e3
commit
32d2fe9962
@ -10,6 +10,19 @@ namespace python = boost::python;
|
|||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
|
|
||||||
|
inline kdlib::MEMOFFSET_64 addr64( kdlib::MEMOFFSET_64 offset )
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return kdlib::addr64(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isVaValid( kdlib::MEMOFFSET_64 offset )
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return kdlib::isVaValid(offset);
|
||||||
|
}
|
||||||
|
|
||||||
inline unsigned char ptrByte( kdlib::MEMOFFSET_64 offset )
|
inline unsigned char ptrByte( kdlib::MEMOFFSET_64 offset )
|
||||||
{
|
{
|
||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
@ -139,102 +152,24 @@ inline bool compareMemory( kdlib::MEMOFFSET_64 addr1, kdlib::MEMOFFSET_64 addr2,
|
|||||||
return kdlib::compareMemory(addr1, addr2, length, phyAddr);
|
return kdlib::compareMemory(addr1, addr2, length, phyAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline python::tuple findMemoryRegion( kdlib::MEMOFFSET_64 offset )
|
||||||
|
{
|
||||||
|
|
||||||
|
kdlib::MEMOFFSET_64 regionOffset;
|
||||||
|
size_t regionLength;
|
||||||
|
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
|
||||||
|
kdlib::findMemoryRegion( offset, regionOffset, regionLength );
|
||||||
|
|
||||||
//inline int ptrSignByte( kdlib::MEMOFFSET_64 offset )
|
return python::make_tuple( regionOffset, regionLength );
|
||||||
//{
|
}
|
||||||
// AutoRestorePyState pystate;
|
|
||||||
// return kdlib::ptrSignByte(offset);
|
inline kdlib::MemoryProtect getVaProtect( kdlib::MEMOFFSET_64 offset )
|
||||||
//}
|
{
|
||||||
//
|
AutoRestorePyState pystate;
|
||||||
//inline python::list loadBytes( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
return kdlib::getVaProtect(offset);
|
||||||
//{
|
}
|
||||||
//
|
|
||||||
// do
|
|
||||||
// AutoRestorePyState pystate;
|
|
||||||
// kdlib::loadBytes( offset, count, phyAddr )
|
|
||||||
// return vectorToList( );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadDWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadDWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadQWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// AutoRestorePyState pystate;
|
|
||||||
// return vectorToList( kdlib::loadQWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadSignBytes( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// AutoRestorePyState pystate;
|
|
||||||
// return vectorToList( kdlib::loadSignBytes( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadSignWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadSignWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadSignDWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadSignDWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadSignQWords( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadSignQWords( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadFloats( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadFloats( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadDoubles( kdlib::MEMOFFSET_64 offset, unsigned long count, bool phyAddr = false )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadDoubles( offset, count, phyAddr ) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//inline kdlib::MEMOFFSET_64 ptrPtr( kdlib::MEMOFFSET_64 offset )
|
|
||||||
//{
|
|
||||||
// return kdlib::ptrPtr( offset );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadPtrList( kdlib::MEMOFFSET_64 offset )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadPtrList(offset) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline python::list loadPtrArray( kdlib::MEMOFFSET_64 offset, unsigned long count )
|
|
||||||
//{
|
|
||||||
// return vectorToList( kdlib::loadPtrs(offset, count) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//std::wstring loadUnicodeStr(kdlib::MEMOFFSET_64 offset);
|
|
||||||
//
|
|
||||||
//std::string loadAnsiStr(kdlib::MEMOFFSET_64 offset);
|
|
||||||
//
|
|
||||||
//inline kdlib::MEMOFFSET_64 searchMemoryLst( kdlib::MEMOFFSET_64 beginOffset, unsigned long length, const python::list &pattern )
|
|
||||||
//{
|
|
||||||
// return kdlib::searchMemory( beginOffset, length, listToVector<char>(pattern) );
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//inline kdlib::MEMOFFSET_64 searchMemoryStr( kdlib::MEMOFFSET_64 beginOffset, unsigned long length, const std::string &pattern )
|
|
||||||
//{
|
|
||||||
// const char* p = pattern.c_str();
|
|
||||||
// return kdlib::searchMemory( beginOffset, length, std::vector<char>( p, p + pattern.length() ) );
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace pykd
|
} // end namespace pykd
|
||||||
|
@ -187,20 +187,20 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return systemVersion");
|
"Return systemVersion");
|
||||||
|
|
||||||
// Manage target memory access
|
// Manage target memory access
|
||||||
python::def( "addr64", &kdlib::addr64,
|
python::def( "addr64", pykd::addr64,
|
||||||
"Extend address to 64 bits formats" );
|
"Extend address to 64 bits formats" );
|
||||||
python::def( "isValid", &kdlib::isVaValid,
|
python::def( "isValid", pykd::isVaValid,
|
||||||
"Check if the virtual address is valid" );
|
"Check if the virtual address is valid" );
|
||||||
python::def( "compareMemory", &kdlib::compareMemory, compareMemory_( python::args( "offset1", "offset2", "length", "phyAddr" ),
|
python::def( "compareMemory", pykd::compareMemory, compareMemory_( python::args( "offset1", "offset2", "length", "phyAddr" ),
|
||||||
"Compare two memory buffers by virtual or physical addresses" ) );
|
"Compare two memory buffers by virtual or physical addresses" ) );
|
||||||
python::def( "searchMemory", &pykd::searchMemoryLst,
|
python::def( "searchMemory", pykd::searchMemoryLst,
|
||||||
"Search in virtual memory" );
|
"Search in virtual memory" );
|
||||||
python::def( "searchMemory", &pykd::searchMemoryStr,
|
python::def( "searchMemory", pykd::searchMemoryStr,
|
||||||
"Search in virtual memory" );
|
"Search in virtual memory" );
|
||||||
//python::def( "findMemoryRegion", &kdlib::findMemoryRegion,
|
python::def( "findMemoryRegion", pykd::findMemoryRegion,
|
||||||
// "Return address of begining valid memory region nearest to offset" );
|
"Return address of begining valid memory region nearest to offset" );
|
||||||
//python::def( "getVaProtect", &kdlib::getVaProtect,
|
python::def( "getVaProtect", pykd::getVaProtect,
|
||||||
// "Return memory attributes" );
|
"Return memory attributes" );
|
||||||
|
|
||||||
python::def( "ptrByte", pykd::ptrByte,
|
python::def( "ptrByte", pykd::ptrByte,
|
||||||
"Read an unsigned 1-byte integer from the target memory" );
|
"Read an unsigned 1-byte integer from the target memory" );
|
||||||
@ -820,6 +820,17 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.value("AMD64", kdlib::CPU_AMD64 )
|
.value("AMD64", kdlib::CPU_AMD64 )
|
||||||
.export_values();
|
.export_values();
|
||||||
|
|
||||||
|
python::enum_<kdlib::MemoryProtect>("memoryProtect", "Memory protection attribiuties")
|
||||||
|
.value("PageNoAccess", kdlib::PageNoAccess)
|
||||||
|
.value("PageReadOnly", kdlib::PageReadOnly)
|
||||||
|
.value("PageReadWrite", kdlib::PageReadWrite)
|
||||||
|
.value("PageWriteCopy", kdlib::PageReadOnly)
|
||||||
|
.value("PageExecute", kdlib::PageExecute)
|
||||||
|
.value("PageExecuteRead", kdlib::PageExecuteRead)
|
||||||
|
.value("PageExecuteReadWrite", kdlib::PageExecuteReadWrite)
|
||||||
|
.value("PageExecuteWriteCopy", kdlib::PageExecuteWriteCopy)
|
||||||
|
.export_values();
|
||||||
|
|
||||||
python::class_<EventHandler, EventHandlerPtr, boost::noncopyable>(
|
python::class_<EventHandler, EventHandlerPtr, boost::noncopyable>(
|
||||||
"eventHandler", "Base class for overriding and handling debug notifications" )
|
"eventHandler", "Base class for overriding and handling debug notifications" )
|
||||||
.def( "onBreakpoint", &EventHandler::onBreakpoint,
|
.def( "onBreakpoint", &EventHandler::onBreakpoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user