Section property Page Properties

Source: Internet
Author: User

1. Define also an attribute array

1     //Protection flags for Memory pages (executable, readable, writeable)2     Static intprotectionflags[2][2][2] = {3         {4             //Not executable5 {page_noaccess, page_writecopy},6 {page_readonly, page_readwrite},7         }, {8             //executable9 {page_execute, page_execute_writecopy},Ten {page_execute_read, page_execute_readwrite}, One         }, A};

2. Parsing section properties, converting to page properties

1     //Loop through all sections and change access flags2      for(i=0; I < module->headers->fileheader.numberofsections; i++, section++) {3 DWORD Protect, oldprotect, size;4         intExecutable = (Section->characteristics & image_scn_mem_execute)! =0;5         intreadable = (Section->characteristics & image_scn_mem_read)! =0;6         intwriteable = (Section->characteristics & image_scn_mem_write)! =0;7 8         //determine protection flags based on characteristics9protect =protectionflags[executable][readable][writeable];Ten         if(Section->characteristics &image_scn_mem_not_cached) { OneProtect |=Page_nocache; A         } -  -         //determine size of region theSize = section->Sizeofrawdata; -         if(Size >0) { -             //Change Memory Access flags -VirtualProtect ((LPVOID) ((pointer_type) section->misc.physicaladdress | imageoffset), size, protect, &oldprotect); +         } -}

Section property Page Properties

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.