unicode hijo de puta

This commit is contained in:
Hane 2023-07-19 21:45:21 +02:00
commit f537d92799

View file

@ -27,8 +27,11 @@ Intel(R) 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B
#define UNICODE #define UNICODE
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT _WIN32_WINNT_WIN10 //0x0A00 #define _WIN32_WINNT _WIN32_WINNT_WIN10 //0x0A00
#define MAX_KEY_LENGTH 255
#define MAX_VALUE_NAME 32768
#include <Windows.h> #include <Windows.h>
#include <winreg.h> #include <winreg.h>
#include <stringapiset.h>
#include <synchapi.h> #include <synchapi.h>
#endif #endif
#ifdef NOMESELDELINUS #ifdef NOMESELDELINUS
@ -178,10 +181,70 @@ uint64_t estimandoFreq(){
*/ */
uint64_t getFreqFromReg(){ uint64_t getFreqFromReg(){
//https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluew
LSTATUS status; LSTATUS status;
HKEY key; HKEY key;
status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("System"), 0, DWORD numValues;
WCHAR valName[MAX_VALUE_NAME]; //uint32_t wtf
DWORD valLen = MAX_VALUE_NAME;
const WORD NULL_ENDING_STRING = -1;
const WCHAR* COMPARE_TARGET = TEXT("~MHz");
status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0,
KEY_QUERY_VALUE, &key); KEY_QUERY_VALUE, &key);
status = RegQueryInfoKey(
key, // key handle
NULL, // buffer for class name
NULL, // size of class string
NULL, // reserved
NULL, // number of subkeys
NULL, // longest subkey size
NULL, // longest class string
&numValues, // number of values for this key
NULL, // longest value name
NULL, // longest value data
NULL, // security descriptor
NULL); // last write time
/*
* status = RegOpenKeyExW(key, TEXT("CentralProcessor\\0"), 0,
* KEY_QUERY_VALUE, &key2);
*/
int tast;
for (int i = 0; i < numValues; i++){
status = RegEnumValueW(key,
/* [in] DWORD dwIndex */i,
valName,
&valLen,
NULL,
NULL, NULL, NULL
);
tast = CompareStringEx(
LOCALE_NAME_USER_DEFAULT,
NORM_LINGUISTIC_CASING,
valName,
NULL_ENDING_STRING,
COMPARE_TARGET,
wcslen(COMPARE_TARGET),
NULL,
NULL,
0
);
/*
* if (CSTR_EQUAL == CompareStringEx(
* LOCALE_NAME_INVARIANT,
* 0,
* valName,
* NULL_ENDING_STRING,
* COMPARE_TARGET,
* wcslen(COMPARE_TARGET),
* NULL,
* NULL,
* 0
* )) break;
*/
}
uint64_t retval = (status == ERROR_SUCCESS) ? 1 : 0; uint64_t retval = (status == ERROR_SUCCESS) ? 1 : 0;
return retval; return retval;
} }