From 7dc14791e3e1e0e7cac4b3c2cbb6ea25b5fa2fa5 Mon Sep 17 00:00:00 2001 From: Harry Fei Date: Sun, 30 Sep 2018 17:53:14 +0800 Subject: init commit --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/lib.rs (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..678735d --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,20 @@ +#![no_std] + +mod alloc_sys; + +use self::alloc_sys::*; +use core::alloc::{GlobalAlloc, Layout}; + +const KMRS_TAG: u32 = 0x4B4D5253; // 'KMRS' + +pub struct KernelAlloc; + +unsafe impl GlobalAlloc for KernelAlloc { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + ExAllocatePoolWithTag(POOL_TYPE::PagedPool, layout.size(), KMRS_TAG) + } + + unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { + ExFreePoolWithTag(ptr, KMRS_TAG); + } +} -- cgit v1.2.3