Last active
August 22, 2024 09:27
-
-
Save FelixK15/63b3666233a30db439629cb9be240d9d to your computer and use it in GitHub Desktop.
Read microcode version using win32 registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <stdint.h> | |
#pragma comment(lib, "Advapi32.lib") | |
bool tryToFindMicrocodeVersionInRegistry(uint32_t* pOutMicrocodeVersion) | |
{ | |
bool success = false; | |
HKEY pProcessorRegistryKey = nullptr; | |
DWORD bufferLength = MAX_PATH; | |
const char* pEntryName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; | |
if(ERROR_SUCCESS != RegOpenKeyA(HKEY_LOCAL_MACHINE, pEntryName, &pProcessorRegistryKey)) | |
{ | |
goto cleanup_and_exit; | |
} | |
uint64_t updateRevision = 0u; | |
DWORD entryLengthInBytes = sizeof(updateRevision); | |
if(ERROR_SUCCESS != RegGetValueA(pProcessorRegistryKey, nullptr, "Update Revision", RRF_RT_REG_BINARY, nullptr, (PVOID)&updateRevision, &entryLengthInBytes)) | |
{ | |
goto cleanup_and_exit; | |
} | |
*pOutMicrocodeVersion = (updateRevision >> 32u); | |
success = true; | |
cleanup_and_exit: | |
if(pProcessorRegistryKey != nullptr) | |
{ | |
RegCloseKey(pProcessorRegistryKey); | |
} | |
return success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment