diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 16d6df4..4dca1b6 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -98,6 +98,7 @@ BOOST_PYTHON_MODULE( pykd ) boost::python::def( "dprintln", &DbgPrint::dprintln, dprintln( boost::python::args( "str", "dml" ), "" ) ); boost::python::def( "loadDump", &dbgLoadDump ); boost::python::def( "dbgCommand", &dbgCommand ); + boost::python::def( "isValid", &isOffsetValid ); boost::python::def( "is64bitSystem", &is64bitSystem ); boost::python::def( "isKernelDebugging", &isKernelDebugging ); boost::python::def( "ptrSize", ptrSize ); diff --git a/pykd/dbgmem.cpp b/pykd/dbgmem.cpp index 0bb911b..dde15a7 100644 --- a/pykd/dbgmem.cpp +++ b/pykd/dbgmem.cpp @@ -4,6 +4,7 @@ #include "dbgexcept.h" #include "dbgmem.h" #include "dbgsystem.h" +#include "dbgcallback.h" using namespace std; @@ -525,4 +526,45 @@ loadLinkedList( ULONG64 address ) return objList; } +/////////////////////////////////////////////////////////////////////////////////// + +bool +isOffsetValid( ULONG64 addr ) +{ + HRESULT hres; + + try { + + // нужно подавить возможный вывод в консоль об отсутствующей странице памяти + OutputReader outputReader( dbgExt->client ); + + ULONG offsetInfo; + + hres = + dbgExt->dataSpaces4->GetOffsetInformation( + DEBUG_DATA_SPACE_VIRTUAL, + DEBUG_OFFSINFO_VIRTUAL_SOURCE, + addr, + &offsetInfo, + sizeof( offsetInfo ), + NULL ); + + if ( FAILED( hres ) ) + throw DbgException( "IDebugDataSpace4::GetOffsetInformation failed" ); + + return offsetInfo != DEBUG_VSOURCE_INVALID; + + } + catch( std::exception &e ) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() ); + } + catch(...) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); + } + + return false; +} + /////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/pykd/dbgmem.h b/pykd/dbgmem.h index 268d84f..04918ff 100644 --- a/pykd/dbgmem.h +++ b/pykd/dbgmem.h @@ -91,4 +91,7 @@ addr64( ULONG64 addr ); boost::python::object loadLinkedList( ULONG64 address ); +bool +isOffsetValid( ULONG64 addr ); + ///////////////////////////////////////////////////////////////////////////////// \ No newline at end of file