Last active
October 12, 2024 15:55
-
-
Save hosct/456055c0eec4e71bb504489410ed7fb6 to your computer and use it in GitHub Desktop.
ctBiosKey
This file contains 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
#include <iostream> | |
#include <Windows.h> | |
int main() | |
{ | |
DWORD firmwareTableProviderSignature = 0x41435049; // "ACPI" | |
DWORD firmwareTableMSDMID = 0x4d44534d; // "MSDM" | |
UINT structSize = EnumSystemFirmwareTables(firmwareTableProviderSignature, NULL, 0); | |
if (structSize == 0) { | |
std::cout << "EnumSystemFirmwareTables() fehlgeschlagen." << std::endl; | |
return 1; | |
} | |
char *tableBuffer = new char[structSize + 1]; | |
EnumSystemFirmwareTables(firmwareTableProviderSignature, tableBuffer, structSize); | |
tableBuffer[structSize] = '\0'; | |
BOOL found = strstr(tableBuffer, "MSDM") != NULL; | |
delete[] tableBuffer; | |
if (!found) { | |
std::cout << "Kein Product Key gefunden." << std::endl; | |
return 1; | |
} | |
structSize = GetSystemFirmwareTable(firmwareTableProviderSignature, firmwareTableMSDMID, NULL, 0); | |
if (structSize == 0) { | |
std::cout << "GetSystemFirmwareTable() fehlgeschlagen." << std::endl; | |
return 1; | |
} | |
tableBuffer = new char[structSize]; | |
GetSystemFirmwareTable(firmwareTableProviderSignature, firmwareTableMSDMID, tableBuffer, structSize); | |
char key[30]; | |
strncpy_s(key, tableBuffer + 56, 29); | |
key[29] = '\0'; | |
delete[] tableBuffer; | |
std::cout << key << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mehr zu Dokumentationszwecken als zum Nachbauen: Dies ist der komplette (!) Quelltext des Programms ctBiosKey, das im c't-Keyfinder enthalten ist und für Fehlalarme bei zahlreichen Virenscannern gesorgt hat.