forked from BlackINT3/OpenArk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |