30 typedef struct _PERFPAGE_CONTEXT
45 static GUID CLSID_CorpubPublish_I = { 0x047a9a40, 0x657e, 0x11d3, { 0x8d, 0x5b, 0x00, 0x10, 0x4b, 0x35, 0xe7, 0xef } };
46 static GUID IID_ICorPublish_I = { 0x9613a0e7, 0x5a68, 0x11d3, { 0x8f, 0x84, 0x00, 0xa0, 0xc9, 0xb4, 0xd5, 0x0c } };
50 static ULONG DotNetObjectTypeInfoCount = 0;
51 static PVOID PerfInfoTextData = NULL;
58 PropContext->PropContext,
65 _Out_ ICorPublish **Publish
86 static HMODULE mscordbiDllBase;
94 LoadLibrary(L
"mscoree.dll");
98 PhInitializeStringRef(&mscordbiPathString, L
"\\Microsoft.NET\\Framework64\\v4.0.30319\\mscordbi.dll");
104 mscordbiDllBase = LoadLibrary(mscordbiFileName->
Buffer);
112 HRESULT (__stdcall *dllGetClassObject)(REFCLSID, REFIID, LPVOID *);
114 dllGetClassObject = (PVOID)GetProcAddress(mscordbiDllBase,
"DllGetClassObjectInternal");
116 if (dllGetClassObject)
118 IClassFactory *factory;
120 if (SUCCEEDED(dllGetClassObject(&CLSID_CorpubPublish_I, &IID_IClassFactory, &factory)))
122 result = IClassFactory_CreateInstance(factory, NULL, &IID_ICorPublish_I, Publish);
123 IClassFactory_Release(factory);
131 return CoCreateInstance(&CLSID_CorpubPublish_I, NULL, CLSCTX_INPROC_SERVER, &IID_ICorPublish_I, Publish);
136 _Out_ ICorPublishProcess **PublishProcess
140 ICorPublish *publish;
144 result = ICorPublish_GetProcess(publish, HandleToUlong(ProcessId), PublishProcess);
145 ICorPublish_Release(publish);
163 L
".NET CLR Exceptions;"
167 L
".NET CLR LocksAndThreads;"
169 L
".NET CLR Remoting;"
184 ICorPublishProcess *publishProcess;
185 ICorPublishAppDomainEnum *publishAppDomainEnum;
186 ICorPublishAppDomain *publishAppDomain;
188 ULONG appDomainNameCount;
189 WCHAR appDomainName[256];
193 SendMessage(appDomainsLv, WM_SETREDRAW,
FALSE, 0);
194 ListView_DeleteAllItems(appDomainsLv);
198 if (SUCCEEDED(ICorPublishProcess_EnumAppDomains(publishProcess, &publishAppDomainEnum)))
202 if (!SUCCEEDED(ICorPublishAppDomainEnum_Next(publishAppDomainEnum, 1, &publishAppDomain, &returnCount)))
204 if (returnCount == 0)
207 if (SUCCEEDED(ICorPublishAppDomain_GetName(publishAppDomain, 256, &appDomainNameCount, appDomainName)))
212 ICorPublishAppDomain_Release(publishAppDomain);
215 ICorPublishAppDomainEnum_Release(publishAppDomainEnum);
218 ICorPublishProcess_Release(publishProcess);
221 SendMessage(appDomainsLv, WM_SETREDRAW,
TRUE, 0);
234 for (i = 0; i < DotNetObjectTypeInfoCount; i++)
238 return &DotNetObjectTypeInfo[i];
248 _In_ BOOLEAN RefreshCategory
256 PPERF_DATA_BLOCK block;
258 PPERF_OBJECT_TYPE objectType;
260 PPERF_COUNTER_DEFINITION counter;
261 PPERF_INSTANCE_DEFINITION instance;
266 ListView_DeleteAllItems(countersLv);
273 if (PerfInfoTextData)
275 textData = PerfInfoTextData;
292 objectType = (PPERF_OBJECT_TYPE)((PCHAR)block + block->HeaderLength);
294 for (i = 0; i < block->NumObjectTypes; i++)
296 if (objectType->ObjectNameTitleIndex == typeInfo->
NameIndex && objectType->NumInstances != PERF_NO_INSTANCES)
298 PPERF_COUNTER_BLOCK counterBlock = NULL;
299 BOOLEAN instanceFound =
FALSE;
303 instance = (PPERF_INSTANCE_DEFINITION)((PCHAR)objectType + objectType->DefinitionLength);
305 for (j = 0; j < (ULONG)objectType->NumInstances; j++)
309 if (instance->NameLength != 0)
311 instanceName.
Buffer = (PWSTR)((PCHAR)instance + instance->NameOffset);
312 instanceName.
Length = instance->NameLength -
sizeof(WCHAR);
314 counterBlock = (PPERF_COUNTER_BLOCK)((PCHAR)instance + instance->ByteLength);
318 instanceFound =
TRUE;
323 instance = (PPERF_INSTANCE_DEFINITION)((PCHAR)counterBlock + counterBlock->ByteLength);
328 counter = (PPERF_COUNTER_DEFINITION)((PCHAR)objectType + objectType->HeaderLength);
330 for (j = 0; j < objectType->NumCounters; j++)
332 INT lvItemIndex = -1;
335 counter->CounterType != PERF_COUNTER_RAWCOUNT &&
336 counter->CounterType != PERF_COUNTER_LARGE_RAWCOUNT &&
337 counter->CounterType != PERF_RAW_FRACTION
350 lvItemIndex =
PhAddListViewItem(countersLv, MAXINT, counterName, (PVOID)counter->CounterNameTitleIndex);
357 if (lvItemIndex != -1 && instanceFound)
359 switch (counter->CounterType)
361 case PERF_COUNTER_RAWCOUNT:
363 PULONG value = (PULONG)((PCHAR)counterBlock + counter->CounterOffset);
368 case PERF_COUNTER_LARGE_RAWCOUNT:
370 PULONG64 value = (PULONG64)((PCHAR)counterBlock + counter->CounterOffset);
375 case PERF_RAW_FRACTION:
377 PULONG value = (PULONG)((PCHAR)counterBlock + counter->CounterOffset);
378 PPERF_COUNTER_DEFINITION denomCounter = (PPERF_COUNTER_DEFINITION)((PCHAR)counter + counter->ByteLength);
379 PULONG denomValue = (PULONG)((PCHAR)counterBlock + denomCounter->CounterOffset);
381 WCHAR formatBuffer[10];
383 if (*denomValue != 0)
385 PhInitFormatF(&format, (FLOAT)*value * 100 / (FLOAT)*denomValue, 2);
400 counter = (PPERF_COUNTER_DEFINITION)((PCHAR)counter + counter->ByteLength);
404 objectType = (PPERF_OBJECT_TYPE)((PCHAR)objectType + objectType->TotalByteLength);
409 if (textData != PerfInfoTextData)
420 LPPROPSHEETPAGE propSheetPage;
427 context = propPageContext->
Context;
438 ULONG_PTR indexOfLastDot;
441 HWND categoriesHandle;
446 propPageContext->
Context = context;
447 context->WindowHandle = hwndDlg;
448 context->ProcessItem = processItem;
449 context->Enabled =
TRUE;
456 if (indexOfLastDot != -1)
457 context->InstanceName =
PhSubstring(context->ProcessItem->ProcessName, 0, indexOfLastDot);
459 PhSetReference(&context->InstanceName, context->ProcessItem->ProcessName);
477 for (i = 0; i < DotNetObjectTypeInfoCount; i++)
484 ComboBox_SelectString(categoriesHandle, -1, L
".NET CLR Memory");
486 SetTimer(hwndDlg, 1, 1000, NULL);
491 if (context->InstanceName)
514 switch (LOWORD(wParam))
517 if (HIWORD(wParam) == CBN_SELCHANGE)
527 LPNMHDR header = (LPNMHDR)lParam;
529 switch (header->code)
532 context->Enabled =
TRUE;
535 context->Enabled =
FALSE;
545 if (wParam == 1 && context->Enabled)