AddRef();
return S_OK;
}
+ if (InterfaceId == IID_ICorDebugDataTarget4)
+ {
+ *Interface = (ICorDebugDataTarget4*)this;
+ AddRef();
+ return S_OK;
+ }
else
{
*Interface = NULL;
{
return E_NOTIMPL;
}
+
+HRESULT STDMETHODCALLTYPE
+DataTarget::GetPid(
+ /* [out] */ DWORD *pdwProcessId)
+{
+ return g_ExtSystem->GetCurrentProcessId(pdwProcessId);
+}
\ No newline at end of file
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-class DataTarget : public ICLRDataTarget
+class DataTarget : public ICLRDataTarget, ICorDebugDataTarget4
{
private:
LONG m_ref; // Reference count.
/* [size_is][in] */ BYTE *inBuffer,
/* [in] */ ULONG32 outBufferSize,
/* [size_is][out] */ BYTE *outBuffer);
+
+ // ICorDebugDataTarget4
+
+ virtual HRESULT STDMETHODCALLTYPE GetPid(
+ /* [out] */ DWORD *pdwProcessId);
};
\ No newline at end of file
//----------------------------------------------------------------------------
HRESULT
+DebugClient::GetCurrentProcessId(
+ PULONG id)
+{
+ if (id == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
+ lldb::SBProcess process = GetCurrentProcess();
+ if (!process.IsValid())
+ {
+ *id = 0;
+ return E_FAIL;
+ }
+
+ *id = process.GetProcessID();
+ return S_OK;
+}
+
+HRESULT
DebugClient::GetCurrentThreadId(
PULONG id)
{
+ if (id == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
lldb::SBThread thread = GetCurrentThread();
if (!thread.IsValid())
{
DebugClient::GetCurrentThreadSystemId(
PULONG sysId)
{
+ if (sysId == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
lldb::SBThread thread = GetCurrentThread();
if (!thread.IsValid())
{
lldb::SBProcess process;
lldb::SBThread thread;
+ if (threadId == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
process = GetCurrentProcess();
if (!process.IsValid())
{
DT_CONTEXT *dtcontext;
HRESULT hr = E_FAIL;
- if (contextSize < sizeof(DT_CONTEXT))
+ if (context == NULL || contextSize < sizeof(DT_CONTEXT))
{
goto exit;
}
// IDebugSystemObjects
//----------------------------------------------------------------------------
+ HRESULT GetCurrentProcessId(
+ PULONG id);
+
HRESULT GetCurrentThreadId(
PULONG id);
class IDebugSystemObjects
{
public:
+ virtual HRESULT GetCurrentProcessId(
+ PULONG id) = 0;
+
// Controls implicit thread used by the
// debug engine. The debuggers current
// thread is just a piece of data held
#define S_FALSE (HRESULT)0x00000001
#define E_NOTIMPL (HRESULT)0x80004001
#define E_FAIL (HRESULT)0x80004005
+#define E_INVALIDARG (HRESULT)0x80070057
#define MAX_PATH 260
// Standard impl of IUnknown::QueryInterface
HRESULT STDMETHODCALLTYPE
DataTargetAdapter::QueryInterface(
- REFIID InterfaceId,
+ REFIID interfaceId,
PVOID* pInterface)
{
- if (InterfaceId == IID_IUnknown)
+ if (interfaceId == IID_IUnknown)
{
*pInterface = static_cast<IUnknown *>(static_cast<ICorDebugDataTarget *>(this));
}
- else if (InterfaceId == IID_ICorDebugDataTarget)
+ else if (interfaceId == IID_ICorDebugDataTarget)
{
*pInterface = static_cast<ICorDebugDataTarget *>(this);
}
- else if (InterfaceId == IID_ICorDebugMutableDataTarget)
+ else if (interfaceId == IID_ICorDebugMutableDataTarget)
{
// Note that we always implement the mutable interface, even though our underlying target
// may return E_NOTIMPL for all the functions on this interface. There is no reliable way
}
else
{
- *pInterface = NULL;
- return E_NOINTERFACE;
+ // For ICorDebugDataTarget4 and other interfaces directly implemented by the legacy data target.
+ return m_pLegacyTarget->QueryInterface(interfaceId, pInterface);
}
AddRef();
* for dbgeng (watson, windbg, etc.) and for any other 3rd parties since
* it is a documented API for dump generation.
*/
-class DataTargetAdapter : public ICorDebugMutableDataTarget
+class DataTargetAdapter : public ICorDebugMutableDataTarget
{
public:
// Create an adapter over the supplied legacy data target interface
#define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL)
#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL)
#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)
-#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)
#define E_POINTER _HRESULT_TYPEDEF_(0x80004003L)
#define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L)
#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L)