3 * Copyright 2011 Alistair Leslie-Hughes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
36 #include "wine/list.h"
37 #include "mscoree_private.h"
38 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL( mscoree
);
43 static inline CorDebug
*impl_from_ICorDebug( ICorDebug
*iface
)
45 return CONTAINING_RECORD(iface
, CorDebug
, ICorDebug_iface
);
48 /*** IUnknown methods ***/
49 static HRESULT WINAPI
CorDebug_QueryInterface(ICorDebug
*iface
, REFIID riid
, void **ppvObject
)
51 CorDebug
*This
= impl_from_ICorDebug( iface
);
53 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
55 if ( IsEqualGUID( riid
, &IID_ICorDebug
) ||
56 IsEqualGUID( riid
, &IID_IUnknown
) )
58 *ppvObject
= &This
->ICorDebug_iface
;
62 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
66 ICorDebug_AddRef( iface
);
71 static ULONG WINAPI
CorDebug_AddRef(ICorDebug
*iface
)
73 CorDebug
*This
= impl_from_ICorDebug( iface
);
74 ULONG ref
= InterlockedIncrement(&This
->ref
);
76 TRACE("%p ref=%u\n", This
, ref
);
81 static ULONG WINAPI
CorDebug_Release(ICorDebug
*iface
)
83 CorDebug
*This
= impl_from_ICorDebug( iface
);
84 ULONG ref
= InterlockedDecrement(&This
->ref
);
86 TRACE("%p ref=%u\n", This
, ref
);
91 ICLRRuntimeHost_Release(This
->runtimehost
);
94 ICorDebugManagedCallback2_Release(This
->pCallback2
);
97 ICorDebugManagedCallback_Release(This
->pCallback
);
99 HeapFree(GetProcessHeap(), 0, This
);
105 /*** ICorDebug methods ***/
106 static HRESULT WINAPI
CorDebug_Initialize(ICorDebug
*iface
)
108 CorDebug
*This
= impl_from_ICorDebug( iface
);
109 FIXME("stub %p\n", This
);
113 static HRESULT WINAPI
CorDebug_Terminate(ICorDebug
*iface
)
115 CorDebug
*This
= impl_from_ICorDebug( iface
);
116 FIXME("stub %p\n", This
);
120 static HRESULT WINAPI
CorDebug_SetManagedHandler(ICorDebug
*iface
, ICorDebugManagedCallback
*pCallback
)
122 CorDebug
*This
= impl_from_ICorDebug( iface
);
124 ICorDebugManagedCallback2
*pCallback2
;
126 TRACE("%p (%p)\n", This
, pCallback
);
131 hr
= ICorDebugManagedCallback_QueryInterface(pCallback
, &IID_ICorDebugManagedCallback2
, (void**)&pCallback2
);
135 ICorDebugManagedCallback2_Release(This
->pCallback2
);
138 ICorDebugManagedCallback_Release(This
->pCallback
);
140 This
->pCallback
= pCallback
;
141 This
->pCallback2
= pCallback2
;
143 ICorDebugManagedCallback_AddRef(This
->pCallback
);
147 WARN("Debugging without interface ICorDebugManagedCallback2 is currently not supported.\n");
153 static HRESULT WINAPI
CorDebug_SetUnmanagedHandler(ICorDebug
*iface
, ICorDebugUnmanagedCallback
*pCallback
)
155 CorDebug
*This
= impl_from_ICorDebug( iface
);
156 FIXME("stub %p %p\n", This
, pCallback
);
160 static HRESULT WINAPI
CorDebug_CreateProcess(ICorDebug
*iface
, LPCWSTR lpApplicationName
,
161 LPWSTR lpCommandLine
, LPSECURITY_ATTRIBUTES lpProcessAttributes
,
162 LPSECURITY_ATTRIBUTES lpThreadAttributes
, BOOL bInheritHandles
,
163 DWORD dwCreationFlags
, PVOID lpEnvironment
,LPCWSTR lpCurrentDirectory
,
164 LPSTARTUPINFOW lpStartupInfo
, LPPROCESS_INFORMATION lpProcessInformation
,
165 CorDebugCreateProcessFlags debuggingFlags
, ICorDebugProcess
**ppProcess
)
167 CorDebug
*This
= impl_from_ICorDebug( iface
);
168 FIXME("stub %p %s %s %p %p %d %d %p %s %p %p %d %p\n", This
, debugstr_w(lpApplicationName
),
169 debugstr_w(lpCommandLine
), lpProcessAttributes
, lpThreadAttributes
,
170 bInheritHandles
, dwCreationFlags
, lpEnvironment
, debugstr_w(lpCurrentDirectory
),
171 lpStartupInfo
, lpProcessInformation
, debuggingFlags
, ppProcess
);
175 static HRESULT WINAPI
CorDebug_DebugActiveProcess(ICorDebug
*iface
, DWORD id
, BOOL win32Attach
,
176 ICorDebugProcess
**ppProcess
)
178 CorDebug
*This
= impl_from_ICorDebug( iface
);
179 FIXME("stub %p %d %d %p\n", This
, id
, win32Attach
, ppProcess
);
183 static HRESULT WINAPI
CorDebug_EnumerateProcesses( ICorDebug
*iface
, ICorDebugProcessEnum
**ppProcess
)
185 CorDebug
*This
= impl_from_ICorDebug( iface
);
186 FIXME("stub %p %p\n", This
, ppProcess
);
190 static HRESULT WINAPI
CorDebug_GetProcess(ICorDebug
*iface
, DWORD dwProcessId
, ICorDebugProcess
**ppProcess
)
192 CorDebug
*This
= impl_from_ICorDebug( iface
);
193 FIXME("stub %p %d %p\n", This
, dwProcessId
, ppProcess
);
197 static HRESULT WINAPI
CorDebug_CanLaunchOrAttach(ICorDebug
*iface
, DWORD dwProcessId
,
198 BOOL win32DebuggingEnabled
)
200 CorDebug
*This
= impl_from_ICorDebug( iface
);
201 FIXME("stub %p %d %d\n", This
, dwProcessId
, win32DebuggingEnabled
);
205 static const struct ICorDebugVtbl cordebug_vtbl
=
207 CorDebug_QueryInterface
,
212 CorDebug_SetManagedHandler
,
213 CorDebug_SetUnmanagedHandler
,
214 CorDebug_CreateProcess
,
215 CorDebug_DebugActiveProcess
,
216 CorDebug_EnumerateProcesses
,
218 CorDebug_CanLaunchOrAttach
221 HRESULT
CorDebug_Create(ICLRRuntimeHost
*runtimehost
, IUnknown
** ppUnk
)
225 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
227 return E_OUTOFMEMORY
;
229 This
->ICorDebug_iface
.lpVtbl
= &cordebug_vtbl
;
231 This
->pCallback
= NULL
;
232 This
->pCallback2
= NULL
;
233 This
->runtimehost
= runtimehost
;
235 if(This
->runtimehost
)
236 ICLRRuntimeHost_AddRef(This
->runtimehost
);
238 *ppUnk
= (IUnknown
*)This
;