in src/CodeSetSize/CodeSetSize.cpp [100:124]
void exp2(const int memSize)
{
const auto _memSize = memSize / 2;
auto buf = (char*)VirtualAlloc(nullptr, _memSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!buf)
{
cerr << "Argh 0\n";
return;
}
ErrorHistogram e;
fillBuffer<uint8_t>(buf, _memSize, 0x90);
// write "jmp rax" to the end of the buffer
buf[_memSize - 2] = 255;
buf[_memSize - 1] = 224;
_mm_mfence();
for (int i = 0; i < nRetries; i++)
{
e[exec2Trans(buf)]++;
Sleep(0);
}
cout << "Executed 2 x " << _memSize << " nops. Errors:\n" << e << "\n";
}