diff --git a/src/main.cpp b/src/main.cpp index b4f8d77..3bf0236 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -180,18 +180,27 @@ uint64_t estimandoFreq(){ * And this is why I'm reading the reg instead */ - uint64_t getFreqFromReg(){ + int64_t getFreqFromReg(){ //https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluew + const WORD STRING_SIZE = 4; + const WCHAR COMPARE_TARGET[STRING_SIZE + 1] = L"~MHz"; + DWORD longestDataSize; + LSTATUS status; HKEY key; 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"); + + LPBYTE dataContent = nullptr; + DWORD dataLen; + // DOESN'T WORK MS WHY const WORD NULL_ENDING_STRING = -1; + status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &key); - + if(status != ERROR_SUCCESS) return -1; + status = RegQueryInfoKey( key, // key handle NULL, // buffer for class name @@ -202,51 +211,67 @@ uint64_t estimandoFreq(){ NULL, // longest class string &numValues, // number of values for this key NULL, // longest value name - NULL, // longest value data + &longestDataSize, // 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++){ + if(status != ERROR_SUCCESS) return -2; + + dataLen = sizeof(REG_QWORD) * (longestDataSize); + dataContent = (LPBYTE)malloc(dataLen); + for (DWORD i = 0; i < numValues; i++){ + valLen = MAX_VALUE_NAME; + //data NULL + len NON_NULL to get dataBufLen; + //data allocated (NON-NULL) + len NON-NULL with previous value for dataLen + //JFC MS WHY. that why we defaultin to biggis. cos not worky. ewe + dataLen = sizeof(REG_QWORD) * (longestDataSize); status = RegEnumValueW(key, - /* [in] DWORD dwIndex */i, + i, valName, &valLen, NULL, - NULL, NULL, NULL + NULL, + dataContent, + &dataLen ); - tast = CompareStringEx( - LOCALE_NAME_USER_DEFAULT, + + if(status != ERROR_SUCCESS) return -3; + + if (CSTR_EQUAL == CompareStringEx( + LOCALE_NAME_INVARIANT, NORM_LINGUISTIC_CASING, valName, - NULL_ENDING_STRING, + valLen, COMPARE_TARGET, - wcslen(COMPARE_TARGET), + STRING_SIZE, NULL, NULL, 0 - ); + ) + ) { + //dataLen = dataLen * 2lu; + /* BROS YO ES QUE ME VOY A CAGAR EN SUS PUTOS MUERTOS + * ASí QUE PIDES DOS VECES, UNA TAMAńO, OTRA A TOPE PRESISO, EH + * PUTA BASURA DE API + * status = RegEnumValueW(key, + * i, + * valName, + * &valLen, + * NULL, + * NULL, + * dataContent, + * &dataLen + * ); + */ + LPDWORD PMHz = (LPDWORD)dataContent; + DWORD MHz = *PMHz; + free(dataContent); + return MHz * 1000000; + //break; + } - /* - * 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; - return retval; + return -4; } #endif @@ -261,8 +286,8 @@ int main(int argc, char** argv){ log_debugcpp("ayo we found " << isItActually32GHz << " flash knuckle"); } - uint64_t juas = getFreqFromReg(); - + int64_t juas = getFreqFromReg(); + log_debugcpp("JODER " << juas); //Cordura int16_t result; uint64_t tf = 0;