Skip to content

Commit

Permalink
Forget commit files.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Aug 24, 2020
1 parent 91dc4ed commit d534b35
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/OpenArkDrv/common/c-assist.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "c-assist.h"

VOID MmEnableWP()
{
SIZE_T cr0 = (SIZE_T)__readcr0();
cr0 |= 0x10000;
__writecr0(cr0);
}

VOID MmDisableWP()
{
SIZE_T cr0 = (SIZE_T)__readcr0();
cr0 &= ~((SIZE_T)1 << 16);
__writecr0(cr0);
}

VOID MmWriteProtectOn(IN KIRQL Irql)
{
SIZE_T cr0 = (SIZE_T)__readcr0();
cr0 |= 0x10000;
#ifdef _AMD64_
_enable();
#else
__asm cli
#endif
__writecr0(cr0);
KeLowerIrql(Irql);
}

KIRQL MmWriteProtectOff()
{
KIRQL irql = KeRaiseIrqlToDpcLevel();
SIZE_T cr0 = (SIZE_T)__readcr0();
cr0 &= ~((SIZE_T)1 << 16);
__writecr0(cr0);
#ifdef _AMD64_
_disable();
#else
__asm sti
#endif
return irql;
}
7 changes: 7 additions & 0 deletions src/OpenArkDrv/common/c-assist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include <ntifs.h>

EXTERN_C VOID MmEnableWP();
EXTERN_C VOID MmDisableWP();
EXTERN_C VOID MmWriteProtectOn(IN KIRQL Irql);
EXTERN_C KIRQL MmWriteProtectOff();

0 comments on commit d534b35

Please sign in to comment.