MCPcopy Create free account
hub / github.com/SamuelTulach/memhv / ThreadBench

Function ThreadBench

client/client/Source/Entry.cpp:92–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90std::mutex m;
91ULONG64 MainModule = 0;
92void ThreadBench(int id)
93{
94 while (true)
95 {
96 UINT64 totalOk = 0;
97 UINT64 totalFail = 0;
98
99 auto t1 = std::chrono::high_resolution_clock::now();
100 for (int i = 0; i < 100000; i++)
101 {
102 int offset = rand() % 20 + 1;
103 offset += 0x48;
104 volatile int readValue = HV::Read<int>(MainModule + offset);
105 volatile int readConfirm = HV::Read<int>(MainModule + offset);
106 if (readValue == readConfirm && readValue != 0)
107 totalOk++;
108 else
109 {
110 totalFail++;
111 m.lock();
112 printf("[!] Invalid read: %x %x\n", readValue, readConfirm);
113 m.unlock();
114 }
115 }
116 auto t2 = std::chrono::high_resolution_clock::now();
117 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
118 m.lock();
119 printf("[+] Ok: %llu Fail: %llu In: %llu\n", totalOk, totalFail, duration);
120 m.unlock();
121 }
122}
123
124int main()
125{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected