Skip to content

Commit 74c3f20

Browse files
committed
Improve PhSipQueryProcessorLogicalInformationEx buffer caching
1 parent d3a78c6 commit 74c3f20

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

ProcessHacker/syssccpu.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,12 +1495,26 @@ NTSTATUS PhSipQueryProcessorLogicalInformationEx(
14951495
_Out_ PULONG BufferLength
14961496
)
14971497
{
1498+
static ULONG initialBufferSize[2] = { 0x200, 0x80 };
14981499
NTSTATUS status;
1500+
ULONG classIndex;
14991501
PVOID buffer;
15001502
ULONG bufferSize;
15011503
ULONG attempts;
15021504

1503-
bufferSize = 0x100;
1505+
switch (RelationshipType)
1506+
{
1507+
case RelationProcessorCore:
1508+
classIndex = 0;
1509+
break;
1510+
case RelationProcessorPackage:
1511+
classIndex = 1;
1512+
break;
1513+
default:
1514+
return STATUS_INVALID_INFO_CLASS;
1515+
}
1516+
1517+
bufferSize = initialBufferSize[classIndex];
15041518
buffer = PhAllocate(bufferSize);
15051519

15061520
status = NtQuerySystemInformationEx(
@@ -1529,13 +1543,15 @@ NTSTATUS PhSipQueryProcessorLogicalInformationEx(
15291543
attempts++;
15301544
}
15311545

1532-
if (NT_SUCCESS(status))
1546+
if (!NT_SUCCESS(status))
15331547
{
1534-
*Buffer = buffer;
1535-
*BufferLength = bufferSize;
1536-
}
1537-
else
15381548
PhFree(buffer);
1549+
return status;
1550+
}
1551+
1552+
if (bufferSize <= 0x100000) initialBufferSize[classIndex] = bufferSize;
1553+
*Buffer = buffer;
1554+
*BufferLength = bufferSize;
15391555

15401556
return status;
15411557
}

0 commit comments

Comments
 (0)