Skip to content

Commit 8676c26

Browse files
committed
ExtendedTools: Remove unused code, Tidy up checks
1 parent e5bb757 commit 8676c26

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

plugins/ExtendedTools/PresentMon/TraceSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ void CALLBACK EventRecordCallback(EVENT_RECORD* pEventRecord)
203203

204204
if (hdr.ProviderId == Microsoft_Windows_DxgKrnl::GUID)
205205
HandleDXGKEvent(pEventRecord);
206+
else if (hdr.ProviderId == Microsoft_Windows_DXGI::GUID)
207+
HandleDXGIEvent(pEventRecord);
206208
else if (hdr.ProviderId == Microsoft_Windows_Win32k::GUID)
207209
HandleWin32kEvent(pEventRecord);
208210
else if (hdr.ProviderId == Microsoft_Windows_Dwm_Core::GUID)
209211
HandleDWMEvent(pEventRecord);
210-
else if (hdr.ProviderId == Microsoft_Windows_DXGI::GUID)
211-
HandleDXGIEvent(pEventRecord);
212212
else if (hdr.ProviderId == Microsoft_Windows_D3D9::GUID)
213213
HandleD3D9Event(pEventRecord);
214214
else if (hdr.ProviderId == Microsoft_Windows_Dwm_Core::Win7::GUID)

plugins/ExtendedTools/counters.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,6 @@ BOOLEAN EtPerfCounterParseGpuAdapterDedicatedPerfCounterInstance(
492492
PH_STRINGREF remainingPart;
493493
LONG64 engineLuidLow;
494494

495-
if (!EtGpuAdapterDedicatedHashTable)
496-
return FALSE;
497-
498495
// luid_0x00000000_0x0000C4CF_phys_0
499496
PhInitializeStringRefLongHint(&remainingPart, InstanceName);
500497
PhSkipStringRef(&remainingPart, 5 * sizeof(WCHAR));
@@ -522,6 +519,9 @@ PET_GPU_ENGINE_PERFCOUNTER EtPerfCounterAddOrUpdateGpuEngineCounters(
522519
ET_GPU_ENGINE_PERFCOUNTER lookupEntry;
523520
PET_GPU_ENGINE_PERFCOUNTER entry;
524521

522+
if (!EtPerfCounterEngineInstanceHashTable)
523+
return NULL;
524+
525525
lookupEntry.InstanceId = CounterInstance.InstanceId;
526526

527527
if (entry = PhFindEntryHashtable(EtPerfCounterEngineInstanceHashTable, &lookupEntry))
@@ -589,6 +589,9 @@ PET_GPU_PROCESS_PERFCOUNTER EtPerfCounterAddOrUpdateGpuProcessCounters(
589589
ET_GPU_PROCESS_PERFCOUNTER lookupEntry;
590590
PET_GPU_PROCESS_PERFCOUNTER entry;
591591

592+
if (!EtPerfCounterProcessInstanceHashTable)
593+
return NULL;
594+
592595
lookupEntry.InstanceId = CounterInstance.InstanceId;
593596

594597
if (entry = PhFindEntryHashtable(EtPerfCounterProcessInstanceHashTable, &lookupEntry))
@@ -633,6 +636,9 @@ PET_GPU_ADAPTER_PERFCOUNTER EtPerfCounterAddOrUpdateGpuAdapterCounters(
633636
ET_GPU_ADAPTER_PERFCOUNTER lookupEntry;
634637
PET_GPU_ADAPTER_PERFCOUNTER entry;
635638

639+
if (!EtPerfCounterAdapterInstanceHashTable)
640+
return NULL;
641+
636642
lookupEntry.InstanceId = CounterInstance.InstanceId;
637643

638644
if (entry = PhFindEntryHashtable(EtPerfCounterAdapterInstanceHashTable, &lookupEntry))
@@ -1041,6 +1047,21 @@ BOOLEAN EtPerfCounterGetCounterData(
10411047
ULONG bufferSize;
10421048
PPERF_DATA_HEADER buffer;
10431049

1050+
{
1051+
static ULONG64 lastTickCount = 0;
1052+
ULONG64 tickCount = NtGetTickCount64();
1053+
1054+
if (lastTickCount == 0)
1055+
lastTickCount = tickCount;
1056+
1057+
if (tickCount - lastTickCount >= 600 * 1000)
1058+
{
1059+
lastTickCount = tickCount;
1060+
// Reset initial buffer size.
1061+
initialBufferSize = 0x4000;
1062+
}
1063+
}
1064+
10441065
bufferSize = initialBufferSize;
10451066
buffer = PhAllocate(bufferSize);
10461067

@@ -1197,18 +1218,11 @@ VOID EtPerfCounterInitialization(
11971218
VOID
11981219
)
11991220
{
1200-
static PH_INITONCE initOnce = PH_INITONCE_INIT;
1201-
1202-
if (PhBeginInitOnce(&initOnce))
1203-
{
1204-
EtGpuCreatePerfCounterHashTables();
1205-
EtGpuCreatePerfCounterHashTable();
1206-
//PhCreateThread2(EtPerfCounterQueryThread, NULL);
1207-
1208-
PhEndInitOnce(&initOnce);
1209-
}
1221+
EtGpuCreatePerfCounterHashTables();
1222+
EtGpuCreatePerfCounterHashTable();
12101223
}
12111224

1225+
_Success_(return)
12121226
BOOLEAN EtPerfCounterOpenHandle(
12131227
_Out_ PHANDLE PerfQueryHandle
12141228
)

plugins/ExtendedTools/etwmon.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ VOID EtStartEtwSession(
141141
EtpTraceProperties->Wnode.ClientContext = 1;
142142
EtpTraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
143143
EtpTraceProperties->MinimumBuffers = 1;
144-
EtpTraceProperties->BufferSize = 64;
145144
EtpTraceProperties->LogFileMode = EVENT_TRACE_REAL_TIME_MODE;
146145
EtpTraceProperties->FlushTimer = 1;
147146
EtpTraceProperties->EnableFlags = EVENT_TRACE_FLAG_DISK_IO | EVENT_TRACE_FLAG_DISK_FILE_IO | EVENT_TRACE_FLAG_NETWORK_TCPIP | EVENT_TRACE_FLAG_NO_SYSCONFIG;
@@ -317,8 +316,6 @@ VOID NTAPI EtpEtwEventCallback(
317316
case 35: // FileDelete
318317
fileEvent.Type = EtEtwFileDeleteType;
319318
break;
320-
default:
321-
break;
322319
}
323320

324321
if (fileEvent.Type != ULONG_MAX)
@@ -497,7 +494,6 @@ ULONG EtStartEtwRundown(
497494
EtpRundownTraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
498495
EtpRundownTraceProperties->MinimumBuffers = 1;
499496
EtpRundownTraceProperties->LogFileMode = EVENT_TRACE_REAL_TIME_MODE;
500-
EtpRundownTraceProperties->BufferSize = 1024; // 1MB session buffer (dmex)
501497
EtpRundownTraceProperties->FlushTimer = 1;
502498
EtpRundownTraceProperties->EnableFlags = EVENT_TRACE_FLAG_NO_SYSCONFIG;
503499
EtpRundownTraceProperties->LogFileNameOffset = 0;
@@ -579,8 +575,6 @@ VOID NTAPI EtpRundownEtwEventCallback(
579575
case 36: // FileRundown
580576
fileEvent.Type = EtEtwFileRundownType;
581577
break;
582-
default:
583-
break;
584578
}
585579

586580
if (fileEvent.Type != ULONG_MAX)

0 commit comments

Comments
 (0)