Uses [`ExAllocatePool2`] on Microsoft Windows 10.0.19041 and later, and [`ExAllocatePoolWithTag`] on older versions of Microsoft Windows to allocate memory.
(&self, layout: Layout)
| 46 | /// Uses [`ExAllocatePool2`] on Microsoft Windows 10.0.19041 and later, and |
| 47 | /// [`ExAllocatePoolWithTag`] on older versions of Microsoft Windows to allocate memory. |
| 48 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { |
| 49 | let use_ex_allocate_pool2 = |
| 50 | VERSION_INFO.major() > 10 || |
| 51 | (VERSION_INFO.major() == 10 && VERSION_INFO.build_number() == 19041); |
| 52 | |
| 53 | let ptr = if use_ex_allocate_pool2 { |
| 54 | ExAllocatePool2( |
| 55 | POOL_TYPE::NonPagedPool as _, |
| 56 | layout.size() as u64, |
| 57 | self.tag, |
| 58 | ) |
| 59 | } else { |
| 60 | ExAllocatePoolWithTag( |
| 61 | POOL_TYPE::NonPagedPool, |
| 62 | layout.size() as u64, |
| 63 | self.tag, |
| 64 | ) |
| 65 | }; |
| 66 | |
| 67 | if ptr.is_null() { |
| 68 | panic!("[kernel-alloc] failed to allocate pool."); |
| 69 | } |
| 70 | |
| 71 | ptr as _ |
| 72 | } |
| 73 | |
| 74 | /// Uses [`ExFreePool`] to free allocated memory. |
| 75 | unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { |
nothing calls this directly
no test coverage detected