26 static GUID IID_ICLRDataTarget_I = { 0x3e11ccee, 0xd08b, 0x43e5, { 0xaf, 0x01, 0x32, 0x71, 0x7a, 0x64, 0xda, 0x03 } };
27 static GUID IID_IXCLRDataProcess = { 0x5c552ab6, 0xfc09, 0x4cb3, { 0x8e, 0x36, 0x22, 0xfa, 0x03, 0xc7, 0x98, 0xb7 } };
29 static ICLRDataTargetVtbl DnCLRDataTarget_VTable =
52 ICLRDataTarget *dataTarget;
62 ICLRDataTarget_Release(dataTarget);
84 _Out_opt_ PULONG64 Displacement
112 if (returnLength > bufferLength)
115 bufferLength = returnLength;
119 Support->DataProcess,
134 *Displacement = displacement;
136 buffer->
Length = (returnLength - 1) * 2;
150 appDomain = AppDomain;
164 if (returnLength > bufferLength)
167 bufferLength = returnLength;
177 buffer->
Length = (returnLength - 1) * 2;
191 LoadLibrary(L
"mscoree.dll");
198 PhInitializeStringRef(&mscordacwksPathString, L
"\\Microsoft.NET\\Framework64\\v4.0.30319\\mscordacwks.dll");
200 PhInitializeStringRef(&mscordacwksPathString, L
"\\Microsoft.NET\\Framework\\v4.0.30319\\mscordacwks.dll");
206 PhInitializeStringRef(&mscordacwksPathString, L
"\\Microsoft.NET\\Framework64\\v2.0.50727\\mscordacwks.dll");
208 PhInitializeStringRef(&mscordacwksPathString, L
"\\Microsoft.NET\\Framework\\v2.0.50727\\mscordacwks.dll");
213 dllBase = LoadLibrary(mscordacwksFileName->
Buffer);
221 _In_ ICLRDataTarget *Target,
228 HRESULT (__stdcall *clrDataCreateInstance)(REFIID, ICLRDataTarget *,
void **);
243 static HMODULE mscordacwksDllBase;
251 dllBase = mscordacwksDllBase;
256 static HMODULE mscordacwksDllBase;
264 dllBase = mscordacwksDllBase;
270 clrDataCreateInstance = (PVOID)GetProcAddress(dllBase,
"CLRDataCreateInstance");
272 if (!clrDataCreateInstance)
275 return clrDataCreateInstance(&IID_IXCLRDataProcess, Target, DataProcess);
283 HANDLE processHandle;
292 NtClose(processHandle);
300 dataTarget->
VTable = &DnCLRDataTarget_VTable;
307 return (ICLRDataTarget *)dataTarget;
311 _In_ ICLRDataTarget *This,
317 IsEqualIID(Riid, &IID_IUnknown) ||
318 IsEqualIID(Riid, &IID_ICLRDataTarget_I)
327 return E_NOINTERFACE;
331 _In_ ICLRDataTarget *This
338 return this->RefCount;
342 _In_ ICLRDataTarget *This
349 if (this->RefCount == 0)
351 NtClose(this->ProcessHandle);
358 return this->RefCount;
362 _In_ ICLRDataTarget *This,
363 _Out_ ULONG32 *machineType
370 *machineType = IMAGE_FILE_MACHINE_AMD64;
372 *machineType = IMAGE_FILE_MACHINE_I386;
374 *machineType = IMAGE_FILE_MACHINE_I386;
381 _In_ ICLRDataTarget *This,
382 _Out_ ULONG32 *pointerSize
390 *pointerSize =
sizeof(PVOID);
393 *pointerSize =
sizeof(ULONG);
400 _In_ PLDR_DATA_TABLE_ENTRY Module,
401 _In_opt_ PVOID Context
417 _In_ ICLRDataTarget *This,
418 _In_ LPCWSTR imagePath,
419 _Out_ CLRDATA_ADDRESS *baseAddress
436 *baseAddress = (CLRDATA_ADDRESS)context.
BaseAddress;
447 _In_ ICLRDataTarget *This,
448 _In_ CLRDATA_ADDRESS address,
450 _In_ ULONG32 bytesRequested,
451 _Out_ ULONG32 *bytesRead
456 SIZE_T numberOfBytesRead;
466 *bytesRead = (ULONG32)numberOfBytesRead;
476 return HRESULT_FROM_WIN32(result);
481 _In_ ICLRDataTarget *This,
482 _In_ CLRDATA_ADDRESS address,
484 _In_ ULONG32 bytesRequested,
485 _Out_ ULONG32 *bytesWritten
492 _In_ ICLRDataTarget *This,
493 _In_ ULONG32 threadID,
495 _Out_ CLRDATA_ADDRESS *value
502 _In_ ICLRDataTarget *This,
503 _In_ ULONG32 threadID,
505 _In_ CLRDATA_ADDRESS value
512 _In_ ICLRDataTarget *This,
513 _Out_ ULONG32 *threadID
520 _In_ ICLRDataTarget *This,
521 _In_ ULONG32 threadID,
522 _In_ ULONG32 contextFlags,
523 _In_ ULONG32 contextSize,
531 if (contextSize <
sizeof(CONTEXT))
534 memset(&buffer, 0,
sizeof(CONTEXT));
535 buffer.ContextFlags = contextFlags;
540 NtClose(threadHandle);
545 memcpy(context, &buffer,
sizeof(CONTEXT));
556 _In_ ICLRDataTarget *This,
557 _In_ ULONG32 threadID,
558 _In_ ULONG32 contextSize,
566 _In_ ICLRDataTarget *This,
567 _In_ ULONG32 reqCode,
568 _In_ ULONG32 inBufferSize,
570 _In_ ULONG32 outBufferSize,
571 _Out_ BYTE *outBuffer