Process Hacker
clrsup.h
Go to the documentation of this file.
1 #ifndef CLRSUP_H
2 #define CLRSUP_H
3 
4 #define CINTERFACE
5 #define COBJMACROS
6 #include <clrdata.h>
7 #undef CINTERFACE
8 #undef COBJMACROS
9 
10 // General interfaces
11 
12 typedef struct _CLR_PROCESS_SUPPORT
13 {
16 
17 PCLR_PROCESS_SUPPORT CreateClrProcessSupport(
18  _In_ HANDLE ProcessId
19  );
20 
22  _In_ PCLR_PROCESS_SUPPORT Support
23  );
24 
26  _In_ PCLR_PROCESS_SUPPORT Support,
27  _In_ ULONG64 Address,
28  _Out_opt_ PULONG64 Displacement
29  );
30 
32  _In_ PVOID AppDomain
33  );
34 
35 PVOID LoadMscordacwks(
36  _In_ BOOLEAN IsClrV4
37  );
38 
39 HRESULT CreateXCLRDataProcess(
40  _In_ HANDLE ProcessId,
41  _In_ ICLRDataTarget *Target,
42  _Out_ struct IXCLRDataProcess **DataProcess
43  );
44 
45 // xclrdata
46 
47 typedef ULONG64 CLRDATA_ENUM;
48 
54 
55 typedef struct IXCLRDataProcessVtbl
56 {
57  HRESULT (STDMETHODCALLTYPE *QueryInterface)(
58  _In_ IXCLRDataProcess *This,
59  _In_ REFIID riid,
60  _Outptr_ void **ppvObject
61  );
62 
63  ULONG (STDMETHODCALLTYPE *AddRef)(
64  _In_ IXCLRDataProcess *This
65  );
66 
67  ULONG (STDMETHODCALLTYPE *Release)(
68  _In_ IXCLRDataProcess *This
69  );
70 
71  HRESULT (STDMETHODCALLTYPE *Flush)(
72  _In_ IXCLRDataProcess *This
73  );
74 
75  HRESULT (STDMETHODCALLTYPE *StartEnumTasks)(
76  _In_ IXCLRDataProcess *This,
77  _Out_ CLRDATA_ENUM *handle
78  );
79 
80  HRESULT (STDMETHODCALLTYPE *EnumTask)(
81  _In_ IXCLRDataProcess *This,
82  _Inout_ CLRDATA_ENUM *handle,
83  _Out_ IXCLRDataTask **task
84  );
85 
86  HRESULT (STDMETHODCALLTYPE *EndEnumTasks)(
87  _In_ IXCLRDataProcess *This,
88  _In_ CLRDATA_ENUM handle
89  );
90 
91  HRESULT (STDMETHODCALLTYPE *GetTaskByOSThreadID)(
92  _In_ IXCLRDataProcess *This,
93  _In_ ULONG32 osThreadID,
94  _Out_ IXCLRDataTask **task
95  );
96 
98  PVOID GetFlags;
99  PVOID IsSameObject;
104 
105  HRESULT (STDMETHODCALLTYPE *GetRuntimeNameByAddress)(
106  _In_ IXCLRDataProcess *This,
107  _In_ CLRDATA_ADDRESS address,
108  _In_ ULONG32 flags,
109  _In_ ULONG32 bufLen,
110  _Out_ ULONG32 *nameLen,
111  _Out_ WCHAR *nameBuf,
112  _Out_ CLRDATA_ADDRESS *displacement
113  );
114 
115  // ...
117 
118 typedef struct IXCLRDataProcess
119 {
122 
123 #define IXCLRDataProcess_QueryInterface(This, riid, ppvObject) \
124  ((This)->lpVtbl->QueryInterface(This, riid, ppvObject))
125 
126 #define IXCLRDataProcess_AddRef(This) \
127  ((This)->lpVtbl->AddRef(This))
128 
129 #define IXCLRDataProcess_Release(This) \
130  ((This)->lpVtbl->Release(This))
131 
132 #define IXCLRDataProcess_GetRuntimeNameByAddress(This, address, flags, bufLen, nameLen, nameBuf, displacement) \
133  ((This)->lpVtbl->GetRuntimeNameByAddress(This, address, flags, bufLen, nameLen, nameBuf, displacement))
134 
135 #define IXCLRDataProcess_Flush(This) \
136  ((This)->lpVtbl->Flush(This))
137 
138 #define IXCLRDataProcess_StartEnumTasks(This, handle) \
139  ((This)->lpVtbl->StartEnumTasks(This, handle))
140 
141 #define IXCLRDataProcess_EnumTask(This, handle, task) \
142  ((This)->lpVtbl->EnumTask(This, handle, task))
143 
144 #define IXCLRDataProcess_EndEnumTasks(This, handle) \
145  ((This)->lpVtbl->EndEnumTasks(This, handle))
146 
147 #define IXCLRDataProcess_GetTaskByOSThreadID(This, osThreadID, task) \
148  ((This)->lpVtbl->GetTaskByOSThreadID(This, osThreadID, task))
149 
151 {
152  HRESULT (STDMETHODCALLTYPE *QueryInterface)(
153  _In_ IXCLRDataAppDomain *This,
154  _In_ REFIID riid,
155  _Outptr_ void **ppvObject
156  );
157 
158  ULONG (STDMETHODCALLTYPE *AddRef)(
159  _In_ IXCLRDataAppDomain *This
160  );
161 
162  ULONG (STDMETHODCALLTYPE *Release)(
163  _In_ IXCLRDataAppDomain *This
164  );
165 
166  HRESULT (STDMETHODCALLTYPE *GetProcess)(
167  _In_ IXCLRDataAppDomain *This,
168  _Out_ IXCLRDataProcess **process
169  );
170 
171  HRESULT (STDMETHODCALLTYPE *GetName)(
172  _In_ IXCLRDataAppDomain *This,
173  _In_ ULONG32 bufLen,
174  _Out_ ULONG32 *nameLen,
175  _Out_ WCHAR *name
176  );
177 
178  HRESULT (STDMETHODCALLTYPE *GetUniqueID)(
179  _In_ IXCLRDataAppDomain *This,
180  _Out_ ULONG64 *id
181  );
182 
183  // ...
185 
186 typedef struct IXCLRDataAppDomain
187 {
190 
191 #define IXCLRDataAppDomain_QueryInterface(This, riid, ppvObject) \
192  ((This)->lpVtbl->QueryInterface(This, riid, ppvObject))
193 
194 #define IXCLRDataAppDomain_AddRef(This) \
195  ((This)->lpVtbl->AddRef(This))
196 
197 #define IXCLRDataAppDomain_Release(This) \
198  ((This)->lpVtbl->Release(This))
199 
200 #define IXCLRDataAppDomain_GetProcess(This, process) \
201  ((This)->lpVtbl->GetProcess(This, process))
202 
203 #define IXCLRDataAppDomain_GetName(This, bufLen, nameLen, name) \
204  ((This)->lpVtbl->GetName(This, bufLen, nameLen, name))
205 
206 #define IXCLRDataAppDomain_GetUniqueID(This, id) \
207  ((This)->lpVtbl->GetUniqueID(This, id))
208 
209 typedef struct IXCLRDataTaskVtbl
210 {
211  HRESULT (STDMETHODCALLTYPE *QueryInterface)(
212  _In_ IXCLRDataTask *This,
213  _In_ REFIID riid,
214  _Outptr_ void **ppvObject
215  );
216 
217  ULONG (STDMETHODCALLTYPE *AddRef)(
218  _In_ IXCLRDataTask *This
219  );
220 
221  ULONG (STDMETHODCALLTYPE *Release)(
222  _In_ IXCLRDataTask *This
223  );
224 
225  HRESULT (STDMETHODCALLTYPE *GetProcess)(
226  _In_ IXCLRDataTask *This,
227  _Out_ IXCLRDataProcess **process
228  );
229 
230  HRESULT (STDMETHODCALLTYPE *GetCurrentAppDomain)(
231  _In_ IXCLRDataTask *This,
233  );
234 
235  HRESULT (STDMETHODCALLTYPE *GetUniqueID)(
236  _In_ IXCLRDataTask *This,
237  _Out_ ULONG64 *id
238  );
239 
240  HRESULT (STDMETHODCALLTYPE *GetFlags)(
241  _In_ IXCLRDataTask *This,
242  _Out_ ULONG32 *flags
243  );
244 
249 
250  HRESULT (STDMETHODCALLTYPE *CreateStackWalk)(
251  _In_ IXCLRDataTask *This,
252  _In_ ULONG32 flags,
254  );
255 
256  HRESULT (STDMETHODCALLTYPE *GetOSThreadID)(
257  _In_ IXCLRDataTask *This,
258  _Out_ ULONG32 *id
259  );
260 
261  PVOID GetContext;
262  PVOID SetContext;
264  PVOID Request;
265 
266  HRESULT (STDMETHODCALLTYPE *GetName)(
267  _In_ IXCLRDataTask *This,
268  _In_ ULONG32 bufLen,
269  _Out_ ULONG32 *nameLen,
270  _Out_ WCHAR *name
271  );
272 
275 
276 typedef struct IXCLRDataTask
277 {
279 } IXCLRDataTask;
280 
281 #define IXCLRDataTask_QueryInterface(This, riid, ppvObject) \
282  ((This)->lpVtbl->QueryInterface(This, riid, ppvObject))
283 
284 #define IXCLRDataTask_AddRef(This) \
285  ((This)->lpVtbl->AddRef(This))
286 
287 #define IXCLRDataTask_Release(This) \
288  ((This)->lpVtbl->Release(This))
289 
290 #define IXCLRDataTask_GetProcess(This, process) \
291  ((This)->lpVtbl->GetProcess(This, process))
292 
293 #define IXCLRDataTask_GetCurrentAppDomain(This, appDomain) \
294  ((This)->lpVtbl->GetCurrentAppDomain(This, appDomain))
295 
296 #define IXCLRDataTask_GetUniqueID(This, id) \
297  ((This)->lpVtbl->GetUniqueID(This, id))
298 
299 #define IXCLRDataTask_GetFlags(This, flags) \
300  ((This)->lpVtbl->GetFlags(This, flags))
301 
302 #define IXCLRDataTask_CreateStackWalk(This, flags, stackWalk) \
303  ((This)->lpVtbl->CreateStackWalk(This, flags, stackWalk))
304 
305 #define IXCLRDataTask_GetOSThreadID(This, id) \
306  ((This)->lpVtbl->GetOSThreadID(This, id))
307 
308 #define IXCLRDataTask_GetName(This, bufLen, nameLen, name) \
309  ((This)->lpVtbl->GetName(This, bufLen, nameLen, name))
310 
311 typedef enum
312 {
318 
319 typedef enum
320 {
338 
339 typedef enum
340 {
344 
346 {
347  HRESULT (STDMETHODCALLTYPE *QueryInterface)(
348  _In_ IXCLRDataStackWalk *This,
349  _In_ REFIID riid,
350  _Outptr_ void **ppvObject
351  );
352 
353  ULONG (STDMETHODCALLTYPE *AddRef)(
354  _In_ IXCLRDataStackWalk *This
355  );
356 
357  ULONG (STDMETHODCALLTYPE *Release)(
358  _In_ IXCLRDataStackWalk *This
359  );
360 
361  HRESULT (STDMETHODCALLTYPE *GetContext)(
362  _In_ IXCLRDataStackWalk *This,
363  _In_ ULONG32 contextFlags,
364  _In_ ULONG32 contextBufSize,
365  _Out_ ULONG32 *contextSize,
366  _Out_ BYTE *contextBuf
367  );
368 
369  PVOID SetContext;
370 
371  HRESULT (STDMETHODCALLTYPE *Next)(
372  _In_ IXCLRDataStackWalk *This
373  );
374 
375  HRESULT (STDMETHODCALLTYPE *GetStackSizeSkipped)(
376  _In_ IXCLRDataStackWalk *This,
377  _Out_ ULONG64 *stackSizeSkipped
378  );
379 
380  HRESULT (STDMETHODCALLTYPE *GetFrameType)(
381  _In_ IXCLRDataStackWalk *This,
384  );
385 
386  HRESULT (STDMETHODCALLTYPE *GetFrame)(
387  _In_ IXCLRDataStackWalk *This,
388  _Out_ PVOID *frame
389  );
390 
391  HRESULT (STDMETHODCALLTYPE *Request)(
392  _In_ IXCLRDataStackWalk *This,
393  _In_ ULONG32 reqCode,
394  _In_ ULONG32 inBufferSize,
395  _In_ BYTE *inBuffer,
396  _In_ ULONG32 outBufferSize,
397  _Out_ BYTE *outBuffer
398  );
399 
400  HRESULT (STDMETHODCALLTYPE *SetContext2)(
401  _In_ IXCLRDataStackWalk *This,
402  _In_ ULONG32 flags,
403  _In_ ULONG32 contextSize,
404  _In_ BYTE *context
405  );
407 
408 typedef struct IXCLRDataStackWalk
409 {
412 
413 #define IXCLRDataStackWalk_QueryInterface(This, riid, ppvObject) \
414  ((This)->lpVtbl->QueryInterface(This, riid, ppvObject))
415 
416 #define IXCLRDataStackWalk_AddRef(This) \
417  ((This)->lpVtbl->AddRef(This))
418 
419 #define IXCLRDataStackWalk_Release(This) \
420  ((This)->lpVtbl->Release(This))
421 
422 #define IXCLRDataStackWalk_GetContext(This, contextFlags, contextBufSize, contextSize, contextBuf) \
423  ((This)->lpVtbl->GetContext(This, contextFlags, contextBufSize, contextSize, contextBuf))
424 
425 #define IXCLRDataStackWalk_Next(This) \
426  ((This)->lpVtbl->Next(This))
427 
428 #define IXCLRDataStackWalk_GetStackSizeSkipped(This, stackSizeSkipped) \
429  ((This)->lpVtbl->GetStackSizeSkipped(This, stackSizeSkipped))
430 
431 #define IXCLRDataStackWalk_GetFrameType(This, simpleType, detailedType) \
432  ((This)->lpVtbl->GetFrameType(This, simpleType, detailedType))
433 
434 #define IXCLRDataStackWalk_GetFrame(This, frame) \
435  ((This)->lpVtbl->GetFrame(This, frame))
436 
437 #define IXCLRDataStackWalk_Request(This, reqCode, inBufferSize, inBuffer, outBufferSize, outBuffer) \
438  ((This)->lpVtbl->SetContext2(This, reqCode, inBufferSize, inBuffer, outBufferSize, outBuffer))
439 
440 #define IXCLRDataStackWalk_SetContext2(This, flags, contextSize, context) \
441  ((This)->lpVtbl->SetContext2(This, flags, contextSize, context))
442 
443 typedef struct IXCLRDataFrameVtbl
444 {
445  HRESULT (STDMETHODCALLTYPE *QueryInterface)(
446  _In_ IXCLRDataFrame *This,
447  _In_ REFIID riid,
448  _Outptr_ void **ppvObject
449  );
450 
451  ULONG (STDMETHODCALLTYPE *AddRef)(
452  _In_ IXCLRDataFrame *This
453  );
454 
455  ULONG (STDMETHODCALLTYPE *Release)(
456  _In_ IXCLRDataFrame *This
457  );
458 
459  HRESULT (STDMETHODCALLTYPE *GetFrameType)(
460  _In_ IXCLRDataFrame *This,
463  );
464 
465  HRESULT (STDMETHODCALLTYPE *GetContext)(
466  _In_ IXCLRDataFrame *This,
467  _In_ ULONG32 contextFlags,
468  _In_ ULONG32 contextBufSize,
469  _Out_ ULONG32 *contextSize,
470  _Out_ BYTE *contextBuf
471  );
472 
478 
479  HRESULT (STDMETHODCALLTYPE *GetCodeName)(
480  _In_ IXCLRDataFrame *This,
481  _In_ ULONG32 *flags,
482  _In_ ULONG32 *bufLen,
483  _Out_ ULONG32 *nameLen,
484  _Out_ WCHAR *nameBuf
485  );
487 
488 typedef struct IXCLRDataFrame
489 {
492 
493 #define IXCLRDataFrame_QueryInterface(This, riid, ppvObject) \
494  ((This)->lpVtbl->QueryInterface(This, riid, ppvObject))
495 
496 #define IXCLRDataFrame_AddRef(This) \
497  ((This)->lpVtbl->AddRef(This))
498 
499 #define IXCLRDataFrame_Release(This) \
500  ((This)->lpVtbl->Release(This))
501 
502 #define IXCLRDataFrame_GetFrameType(This, simpleType, detailedType) \
503  ((This)->lpVtbl->GetFrameType(This, simpleType, detailedType))
504 
505 #define IXCLRDataFrame_GetContext(This, contextFlags, contextBufSize, contextSize, contextBuf) \
506  ((This)->lpVtbl->GetContext(This, contextFlags, contextBufSize, contextSize, contextBuf))
507 
508 #define IXCLRDataFrame_GetCodeName(This, flags, bufLen, nameLen, nameBuf) \
509  ((This)->lpVtbl->GetCodeName(This, flags, bufLen, nameLen, nameBuf))
510 
511 // DnCLRDataTarget
512 
513 typedef struct
514 {
515  ICLRDataTargetVtbl *VTable;
516 
517  ULONG RefCount;
518 
519  HANDLE ProcessId;
521  BOOLEAN IsWow64;
523 
524 ICLRDataTarget *DnCLRDataTarget_Create(
525  _In_ HANDLE ProcessId
526  );
527 
528 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_QueryInterface(
529  _In_ ICLRDataTarget *This,
530  _In_ REFIID Riid,
531  _Out_ PVOID *Object
532  );
533 
534 ULONG STDMETHODCALLTYPE DnCLRDataTarget_AddRef(
535  _In_ ICLRDataTarget *This
536  );
537 
538 ULONG STDMETHODCALLTYPE DnCLRDataTarget_Release(
539  _In_ ICLRDataTarget *This
540  );
541 
542 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetMachineType(
543  _In_ ICLRDataTarget *This,
544  _Out_ ULONG32 *machineType
545  );
546 
547 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetPointerSize(
548  _In_ ICLRDataTarget *This,
549  _Out_ ULONG32 *pointerSize
550  );
551 
552 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetImageBase(
553  _In_ ICLRDataTarget *This,
554  _In_ LPCWSTR imagePath,
555  _Out_ CLRDATA_ADDRESS *baseAddress
556  );
557 
558 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_ReadVirtual(
559  _In_ ICLRDataTarget *This,
560  _In_ CLRDATA_ADDRESS address,
561  _Out_ BYTE *buffer,
562  _In_ ULONG32 bytesRequested,
563  _Out_ ULONG32 *bytesRead
564  );
565 
566 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_WriteVirtual(
567  _In_ ICLRDataTarget *This,
568  _In_ CLRDATA_ADDRESS address,
569  _In_ BYTE *buffer,
570  _In_ ULONG32 bytesRequested,
571  _Out_ ULONG32 *bytesWritten
572  );
573 
574 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetTLSValue(
575  _In_ ICLRDataTarget *This,
576  _In_ ULONG32 threadID,
577  _In_ ULONG32 index,
578  _Out_ CLRDATA_ADDRESS *value
579  );
580 
581 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetTLSValue(
582  _In_ ICLRDataTarget *This,
583  _In_ ULONG32 threadID,
584  _In_ ULONG32 index,
585  _In_ CLRDATA_ADDRESS value
586  );
587 
588 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetCurrentThreadID(
589  _In_ ICLRDataTarget *This,
590  _Out_ ULONG32 *threadID
591  );
592 
593 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetThreadContext(
594  _In_ ICLRDataTarget *This,
595  _In_ ULONG32 threadID,
596  _In_ ULONG32 contextFlags,
597  _In_ ULONG32 contextSize,
598  _Out_ BYTE *context
599  );
600 
601 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetThreadContext(
602  _In_ ICLRDataTarget *This,
603  _In_ ULONG32 threadID,
604  _In_ ULONG32 contextSize,
605  _In_ BYTE *context
606  );
607 
608 HRESULT STDMETHODCALLTYPE DnCLRDataTarget_Request(
609  _In_ ICLRDataTarget *This,
610  _In_ ULONG32 reqCode,
611  _In_ ULONG32 inBufferSize,
612  _In_ BYTE *inBuffer,
613  _In_ ULONG32 outBufferSize,
614  _Out_ BYTE *outBuffer
615  );
616 
618 {
620  PVOID BaseAddress;
622 
623 #endif