Original link: http://blog.chinaunix.net/uid-24504987-id-161192.html
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 takes effect only in the check version, and it checks to see if the function is running below the dispatch_leval interrupt request. If it is equal to or higher than this 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}
Windows kernel Programming: Paging memory and nonpaged memory #define PAGEDCODE code_seg ("page") (RPM)