aboutsummaryrefslogtreecommitdiff
path: root/EfiGuardDxe/util.h
diff options
context:
space:
mode:
authorMatthijs Lavrijsen <mattiwatti@gmail.com>2023-03-26 14:13:39 +0200
committerMatthijs Lavrijsen <mattiwatti@gmail.com>2023-03-26 15:11:22 +0200
commit4465715c2c3abbd554f2ee09360532bcf257d34a (patch)
tree2661684514dbcebc7f610afd2760744c142adf73 /EfiGuardDxe/util.h
parent30e8570f9a3585572f60867166ac74f8951bf804 (diff)
Add CopyWpMem and SetWpMem routines
Additionally make SetServicePointer also clear and restore CR0.WP if needed
Diffstat (limited to 'EfiGuardDxe/util.h')
-rw-r--r--EfiGuardDxe/util.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/EfiGuardDxe/util.h b/EfiGuardDxe/util.h
index d69fc89..89c13e6 100644
--- a/EfiGuardDxe/util.h
+++ b/EfiGuardDxe/util.h
@@ -6,6 +6,9 @@
#include <Zydis/Formatter.h>
#endif
+#define CR0_WP ((UINTN)0x10000) // CR0.WP
+
+
//
// Stalls CPU for N milliseconds
//
@@ -48,6 +51,28 @@ PrintKernelPatchInfo(
);
//
+// Wrapper for CopyMem() that disables write protection prior to copying if needed.
+//
+VOID*
+EFIAPI
+CopyWpMem(
+ OUT VOID *Destination,
+ IN CONST VOID *Source,
+ IN UINTN Length
+ );
+
+//
+// Wrapper for SetMem() that disables write protection prior to copying if needed.
+//
+VOID*
+EFIAPI
+SetWpMem(
+ OUT VOID *Destination,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+//
// Case-insensitive string comparison.
//
INTN