feet wet with the reg

This commit is contained in:
Hane 2023-07-19 17:53:14 +02:00
commit d38bd08be9

View file

@ -18,10 +18,18 @@ Intel(R) 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B
//TSC is incremented by the base multiplier once every reference clock, so on my Xeon E5-2680 (Sandy Bridge EP) this is an increment of 27 every 10 ns //TSC is incremented by the base multiplier once every reference clock, so on my Xeon E5-2680 (Sandy Bridge EP) this is an increment of 27 every 10 ns
#ifdef _WIN64 #ifdef _WIN64
//#include <Windows.h> //#include <Windows.h>
#include <synchapi.h> //#include <sysinfoapi.h>
//#include <powerbase.h>
#define UNICODE
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT _WIN32_WINNT_WIN10 //0x0A00
#include <Windows.h>
#include <winreg.h>
#include <synchapi.h>
#endif #endif
#ifdef NOMESELDELINUS #ifdef NOMESELDELINUS
//hilitos y tal //hilitos y tal
@ -153,6 +161,8 @@ uint64_t rdtscp(uint64_t* logicore = nullptr ) {
return (rdxho << 32) + raxlo; //| return (rdxho << 32) + raxlo; //|
} }
//labor encomiable, ahora muere
uint64_t estimandoFreq(){ uint64_t estimandoFreq(){
uint64_t test = rdtsc(); uint64_t test = rdtsc();
Sleep(1000); Sleep(1000);
@ -160,6 +170,25 @@ uint64_t estimandoFreq(){
return test; return test;
} }
#ifdef _WIN64
//https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo
//https://learn.microsoft.com/en-us/windows/win32/api/powerbase/nf-powerbase-callntpowerinformation?redirectedfrom=MSDN
/*
* And this is why I'm reading the reg instead
*/
uint64_t getFreqFromReg(){
LSTATUS status;
HKEY key;
status = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("System"), 0,
KEY_QUERY_VALUE, &key);
uint64_t retval = (status == ERROR_SUCCESS) ? 1 : 0;
return retval;
}
#endif
int main(int argc, char** argv){ int main(int argc, char** argv){
//AMD Momento //AMD Momento
char* opiniones = AMDMeCagoEnTusPutosMuertos(); char* opiniones = AMDMeCagoEnTusPutosMuertos();
@ -168,6 +197,9 @@ int main(int argc, char** argv){
uint64_t isItActually32GHz = estimandoFreq(); uint64_t isItActually32GHz = estimandoFreq();
log_debugcpp("ayo we found " << isItActually32GHz << " flash knuckle"); log_debugcpp("ayo we found " << isItActually32GHz << " flash knuckle");
} }
uint64_t juas = getFreqFromReg();
//Cordura //Cordura
int16_t result; int16_t result;
uint64_t tf = 0; uint64_t tf = 0;