Meaning of preprocessing in Windows drivers

Source: Internet
Author: User

 

# Pragma code_seg ("page ")
This part of code is put into the paging memory for running.

# Pragma code_seg ()
Set the code segment as the default code segment

# Pragma code_seg ("init ")
Loaded to the init memory area. After loading, you can exit the memory.

From: http://blog.csdn.net/whatday/article/details/7100855

 

Windows requires that some virtual memory can be exchanged to files. Such memory is calledPaging memory

Some virtual memory will never be switched to files.Non-Paging memory

# Define pagedcode code_seg ("page"); // paging memory

# Define lockedcode code_seg (); // non-Paging

# Define initcode code_seg ("init ");

 

# Define pageddata data_seg ("page ");

# Define lockeddata data_seg ();

# Define initdata data_seg ("init ");

 

Example:

If you load a function into the paging memory, the following functions are available:

# Pragma pagedcode

Void fun ()

{

Paged_code (); // do something

}

Note:Paged_code () is a macro provided by DDK and takes effect only in the check version. It checks this function.
Indicates whether the number of interrupted requests is lower than dispatch_leval. If the number is equal to or higher than the level of the interrupted request, an asserted is generated. When the program runs on the dispatch_level (including the current layer), the program can only use non-Paging memory; otherwise, the blue screen will crash.

 

If you load a function into non-Paging memory, the following functions are available:

# Pragma lockedcode

Void fun ()

{

}

A routine needs to load the memory during initialization and can be detached from the memory. For example, in DriverEntry mode, DriverEntry will be large and occupy a large amount of space. In order to save memory, need to detach from memory in time

# Pragma initcode

Ntstatus DriverEntry (

In pdriver_object pdriverobject,

In punicode_string registerpath)

{// Do something}

From: http://blog.chinaunix.net/uid-24504987-id-161192.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.