Windows specifies that some virtual memory can be swapped into a file, which is known as paged memory
Some virtual memory is never exchanged to a file, which is called non-paged memory
#define Pagedcode code_seg ("page");//Paging memory
#define Lockedcode code_seg ();//Non-paged
#define Initcode code_seg ("INIT");
#define PAGEDDATA data_seg ("page");
#define Lockeddata data_seg ();
#define InitData data_seg ("INIT");
Cases:
If you load a function into paged memory, the following functions are available
#pragma pagedcode
VOID Fun ()
{
Paged_code (); Do something
}
Note: Paged_code () is a macro provided by DDK that only takes effect in the check version, and it checks if the function is running at an interrupt request below dispatch_leval, if it is equal to or higher than the interrupt request level, An assertion is generated. When the program is running on top of dispatch_level (including this layer), the program can only use non-paged memory, otherwise it will cause blue screen to panic
If you load a function into non-paged memory, the following functions are available
#pragma lockedcode
VOID Fun ()
{
}
A routine needs to be loaded into memory at initialization time, and then unloaded from memory, such as DriverEntry case, DriverEntry will be large, occupy a lot of space, in order to save memory, need to unload the memory in a timely manner
#pragma initcode
NTSTATUS DriverEntry (
In Pdriver_object Pdriverobject,
In Punicode_string Registerpath)
{//do something}
Paging memory vs. non-paged memory