mirror of
https://github.com/zodiacon/WindowsInternals
synced 2026-08-09 13:18:09 +00:00
23 lines
564 B
C++
23 lines
564 B
C++
#include "stdafx.h"
|
|
#include "SystemCpuSet.h"
|
|
|
|
|
|
bool SystemCpuSet::Init() {
|
|
ULONG length;
|
|
BOOL success = ::GetSystemCpuSetInformation(nullptr, 0, &length, ::GetCurrentProcess(), 0);
|
|
ASSERT(!success);
|
|
|
|
if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
|
return false;
|
|
}
|
|
|
|
_buffer = std::make_unique<BYTE[]>(length);
|
|
_cpuSets = reinterpret_cast<SYSTEM_CPU_SET_INFORMATION*>(_buffer.get());
|
|
success = ::GetSystemCpuSetInformation(_cpuSets, length, &length, ::GetCurrentProcess(), 0);
|
|
ASSERT(success);
|
|
|
|
_count = length / _cpuSets[0].Size;
|
|
return true;
|
|
}
|
|
|