86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
// Public nt-lite DDK memory declarations.
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include <ntlite/status.h>
|
|
|
|
#ifndef PAGE_SIZE
|
|
#define PAGE_SIZE 4096ULL
|
|
#endif
|
|
#ifndef PAGE_MASK
|
|
#define PAGE_MASK (~(PAGE_SIZE - 1ULL))
|
|
#endif
|
|
|
|
#define NTL_DDK_PAGE_SIZE PAGE_SIZE
|
|
#define NTL_DDK_PAGE_PRESENT (1ULL << 0)
|
|
#define NTL_DDK_PAGE_WRITE (1ULL << 1)
|
|
#define NTL_DDK_PAGE_CACHE_WB 0ULL
|
|
#define NTL_DDK_PAGE_CACHE_WC (1ULL << 3)
|
|
#define NTL_DDK_PAGE_CACHE_UC (1ULL << 4)
|
|
#define NTL_DDK_PAGE_CACHE_MASK (NTL_DDK_PAGE_CACHE_WC | NTL_DDK_PAGE_CACHE_UC)
|
|
#define NTL_DDK_PAGE_NX (1ULL << 63)
|
|
|
|
#ifndef PAGE_PRESENT
|
|
#define PAGE_PRESENT (1ULL << 0)
|
|
#endif
|
|
#ifndef PAGE_WRITE
|
|
#define PAGE_WRITE (1ULL << 1)
|
|
#endif
|
|
#ifndef PAGE_USER
|
|
#define PAGE_USER (1ULL << 2)
|
|
#endif
|
|
#ifndef PAGE_CACHE_WB
|
|
#define PAGE_CACHE_WB 0ULL
|
|
#endif
|
|
#ifndef PAGE_CACHE_WC
|
|
#define PAGE_CACHE_WC (1ULL << 3)
|
|
#endif
|
|
#ifndef PAGE_CACHE_UC
|
|
#define PAGE_CACHE_UC (1ULL << 4)
|
|
#endif
|
|
#ifndef PAGE_CACHE_MASK
|
|
#define PAGE_CACHE_MASK (PAGE_CACHE_WC | PAGE_CACHE_UC)
|
|
#endif
|
|
#ifndef PAGE_ACCESSED
|
|
#define PAGE_ACCESSED (1ULL << 5)
|
|
#endif
|
|
#ifndef PAGE_DIRTY
|
|
#define PAGE_DIRTY (1ULL << 6)
|
|
#endif
|
|
#ifndef PAGE_NX
|
|
#define PAGE_NX (1ULL << 63)
|
|
#endif
|
|
|
|
#ifndef NTL_PHYSICAL_ADDRESS_DEFINED
|
|
typedef uint64_t PHYSICAL_ADDRESS;
|
|
#define NTL_PHYSICAL_ADDRESS_DEFINED 1
|
|
#endif
|
|
|
|
typedef enum NTL_DDK_MAP_MODE {
|
|
NtlDdkMapFailIfPresent = 0,
|
|
NtlDdkMapReplaceExisting = 1,
|
|
} NTL_DDK_MAP_MODE;
|
|
|
|
|
|
#define MM_POOL_TAG(a, b, c, d) \
|
|
((uint32_t)(uint8_t)(a) | ((uint32_t)(uint8_t)(b) << 8) | \
|
|
((uint32_t)(uint8_t)(c) << 16) | ((uint32_t)(uint8_t)(d) << 24))
|
|
|
|
// Allocates from kernel pool for current kernel-mode drivers.
|
|
__declspec(dllexport) void* MmAllocatePool(size_t size);
|
|
|
|
// Allocates tagged memory from kernel pool for current kernel-mode drivers.
|
|
__declspec(dllexport) void* MmAllocatePoolTag(size_t size, uint32_t tag);
|
|
|
|
// Frees kernel pool memory.
|
|
__declspec(dllexport) void MmFreePool(void* ptr);
|
|
|
|
// Reallocates kernel pool memory.
|
|
__declspec(dllexport) void* MmReallocatePool(void* ptr, size_t newSize);
|
|
|
|
__declspec(dllexport) void* MmDdkPhysToVirt(uint64_t physicalAddress);
|
|
__declspec(dllexport) KSTATUS MmDdkMapPage(uintptr_t virtualAddress, uint64_t physicalAddress, uint64_t flags, NTL_DDK_MAP_MODE mode);
|