mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[0.1.x] added : getCurrentProcess routine
[0.1.x] added : getImplicitThread routine git-svn-id: https://pykd.svn.codeplex.com/svn@72141 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
adfad183f2
commit
7ec136e150
@ -83,8 +83,12 @@ public:
|
|||||||
|
|
||||||
std::string findSymbol( ULONG64 offset );
|
std::string findSymbol( ULONG64 offset );
|
||||||
|
|
||||||
|
ULONG64 getCurrentProcess();
|
||||||
|
|
||||||
python::tuple getDebuggeeType();
|
python::tuple getDebuggeeType();
|
||||||
|
|
||||||
|
ULONG64 getImplicitThread();
|
||||||
|
|
||||||
ULONG getExecutionStatus();
|
ULONG getExecutionStatus();
|
||||||
|
|
||||||
template<ULONG status>
|
template<ULONG status>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "typedvar.h"
|
#include "typedvar.h"
|
||||||
#include "dbgmem.h"
|
#include "dbgmem.h"
|
||||||
#include "intbase.h"
|
#include "intbase.h"
|
||||||
|
#include "process.h"
|
||||||
|
|
||||||
using namespace pykd;
|
using namespace pykd;
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def( "__long__", &intBase::long_ )
|
.def( "__long__", &intBase::long_ )
|
||||||
.def( "__int__", &intBase::int_ );
|
.def( "__int__", &intBase::int_ );
|
||||||
|
|
||||||
python::class_<pykd::DebugClient, pykd::DebugClientPtr>("dbgClient", "Class representing a debugging session", python::no_init )
|
python::class_<DebugClient, DebugClientPtr>("dbgClient", "Class representing a debugging session", python::no_init )
|
||||||
.def( "addr64", &DebugClient::addr64,
|
.def( "addr64", &DebugClient::addr64,
|
||||||
"Extend address to 64 bits formats" )
|
"Extend address to 64 bits formats" )
|
||||||
.def( "breakin", &DebugClient::breakin,
|
.def( "breakin", &DebugClient::breakin,
|
||||||
@ -151,8 +152,12 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Evaluate windbg expression" )
|
"Evaluate windbg expression" )
|
||||||
.def( "findSymbol", &DebugClient::findSymbol,
|
.def( "findSymbol", &DebugClient::findSymbol,
|
||||||
"Find symbol by the target virtual memory offset" )
|
"Find symbol by the target virtual memory offset" )
|
||||||
|
.def( "getCurrentProcess", &DebugClient::getCurrentProcess,
|
||||||
|
"Return pointer to current process's block" )
|
||||||
.def( "getDebuggeeType", &DebugClient::getDebuggeeType,
|
.def( "getDebuggeeType", &DebugClient::getDebuggeeType,
|
||||||
"Return type of the debuggee" )
|
"Return type of the debuggee" )
|
||||||
|
.def( "getImplicitThread", &getImplicitThread,
|
||||||
|
"Return implicit thread for current process" )
|
||||||
.def( "getExecutionStatus", &DebugClient::getExecutionStatus,
|
.def( "getExecutionStatus", &DebugClient::getExecutionStatus,
|
||||||
"Return information about the execution status of the debugger" )
|
"Return information about the execution status of the debugger" )
|
||||||
.def( "go", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>,
|
.def( "go", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>,
|
||||||
@ -264,8 +269,12 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Evaluate windbg expression" );
|
"Evaluate windbg expression" );
|
||||||
python::def( "findSymbol", &findSymbol,
|
python::def( "findSymbol", &findSymbol,
|
||||||
"Find symbol by the target virtual memory offset" );
|
"Find symbol by the target virtual memory offset" );
|
||||||
|
python::def( "getCurrentProcess", &getCurrentProcess,
|
||||||
|
"Return pointer to current process's block" );
|
||||||
python::def( "getDebuggeeType", &getDebuggeeType,
|
python::def( "getDebuggeeType", &getDebuggeeType,
|
||||||
"Return type of the debuggee" );
|
"Return type of the debuggee" );
|
||||||
|
python::def( "getImplicitThread", &getImplicitThread,
|
||||||
|
"Return implicit thread for current process" );
|
||||||
python::def( "debuggerPath", &getDebuggerImage,
|
python::def( "debuggerPath", &getDebuggerImage,
|
||||||
"Return full path to the process image that uses pykd" );
|
"Return full path to the process image that uses pykd" );
|
||||||
python::def( "getExecutionStatus", &getExecutionStatus,
|
python::def( "getExecutionStatus", &getExecutionStatus,
|
||||||
|
@ -41,17 +41,22 @@ protected:
|
|||||||
hres = client->QueryInterface( __uuidof(IDebugRegisters2), (void**)&m_registers );
|
hres = client->QueryInterface( __uuidof(IDebugRegisters2), (void**)&m_registers );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
throw DbgException("QueryInterface IDebugDataSpaces failed");
|
||||||
|
|
||||||
|
hres = client->QueryInterface( __uuidof(IDebugSystemObjects), (void**)&m_system );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException("QueryInterface IDebugSystem2 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DbgObject() {};
|
virtual ~DbgObject() {};
|
||||||
|
|
||||||
CComPtr<IDebugClient5> m_client5;
|
CComPtr<IDebugClient5> m_client5;
|
||||||
CComPtr<IDebugClient4> m_client;
|
CComPtr<IDebugClient4> m_client;
|
||||||
CComPtr<IDebugControl4> m_control;
|
CComPtr<IDebugControl4> m_control;
|
||||||
CComPtr<IDebugSymbols3> m_symbols;
|
CComPtr<IDebugSymbols3> m_symbols;
|
||||||
CComPtr<IDebugAdvanced2> m_advanced;
|
CComPtr<IDebugAdvanced2> m_advanced;
|
||||||
CComPtr<IDebugDataSpaces4> m_dataSpaces;
|
CComPtr<IDebugDataSpaces4> m_dataSpaces;
|
||||||
CComPtr<IDebugRegisters2> m_registers;
|
CComPtr<IDebugRegisters2> m_registers;
|
||||||
|
CComPtr<IDebugSystemObjects2> m_system;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
49
pykd/process.cpp
Normal file
49
pykd/process.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "dbgclient.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
DebugClient::getCurrentProcess()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 processAddr = 0;
|
||||||
|
|
||||||
|
hres = m_system->GetImplicitProcessDataOffset( &processAddr );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSystemObjects2::GetImplicitProcessDataOffset failed" );
|
||||||
|
|
||||||
|
return processAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
getCurrentProcess()
|
||||||
|
{
|
||||||
|
return g_dbgClient->getCurrentProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
DebugClient::getImplicitThread()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 threadOffset = -1;
|
||||||
|
|
||||||
|
hres = m_system->GetImplicitThreadDataOffset( &threadOffset );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSystemObjects2::GetImplicitThreadDataOffset failed" );
|
||||||
|
|
||||||
|
return threadOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
getImplicitThread() {
|
||||||
|
return g_dbgClient->getImplicitThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
13
pykd/process.h
Normal file
13
pykd/process.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64 getCurrentProcess();
|
||||||
|
|
||||||
|
ULONG64 getImplicitThread();
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="windows-1251"?>
|
<?xml version="1.0" encoding="windows-1251"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="pykd"
|
Name="pykd"
|
||||||
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
|
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
|
||||||
RootNamespace="pykd"
|
RootNamespace="pykd"
|
||||||
@ -409,6 +409,10 @@
|
|||||||
RelativePath=".\module.cpp"
|
RelativePath=".\module.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\process.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\pykd.def"
|
RelativePath=".\pykd.def"
|
||||||
>
|
>
|
||||||
@ -531,6 +535,10 @@
|
|||||||
RelativePath=".\module.h"
|
RelativePath=".\module.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\process.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\pyaux.h"
|
RelativePath=".\pyaux.h"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user