Skip to content

Instantly share code, notes, and snippets.

@JustasMasiulis
Created April 3, 2019 10:28
Show Gist options
  • Save JustasMasiulis/1cfb6275d98572fec6457c063c8f01ea to your computer and use it in GitHub Desktop.
Save JustasMasiulis/1cfb6275d98572fec6457c063c8f01ea to your computer and use it in GitHub Desktop.
uint64_t MiLockPageInline(_MMPFN *pfn)
{
auto oldIrql = KeRaiseIrqlToDpcLevel();
uint32_t spinCount = 0;
while(_interlockedbittestandset64(&pfn->u2.Lock, 63ui64)) // set pfn->u2.LockBit
{
do
KeYieldProcessorEx(&spinCount);
while(pfn->u2.LockBit);
}
return oldIrql;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment