The Use of PAGE_WRITECOPYLast reviewed: November 2, 1995Article ID: Q105532 |
The information in this article applies to:
The documentation to CreateFileMapping(), VirtualAlloc(), and VirtualProtect() indicates that the PAGE_WRITECOPY protection gives copy-on-write access to the committed region of pages. As it is, PAGE_WRITECOPY makes sense only in the context of file mapping, where you want to map something from the disk into your view and then modify the view without causing the data to go on the disk. The only case where VirtualAlloc() should succeed with PAGE_WRITECOPY is the case where CreateFileMapping() is called with -1 and allocates memory with the SEC_RESERVE flag and later on, VirtualAlloc() is used to change this into MEM_COMMIT with a PAGE_WRITECOPY protection. There is a bug in Windows NT 3.1 such that the following call to VirtualAlloc() will succeed:
lpCommit = VirtualAlloc(lpvAddr, cbSize, MEM_COMMIT, PAGE_WRITECOPY);This call will fail under Windows NT 3.5. NOTE: lpvAddr is a pointer to memory that was allocated with MEM_RESERVE and PAGE_NOACCESS. One case where this might be useful is when emulating the UNIX fork command. Emulating fork behavior would involve creating instance data and using threads or multiple processes.
|
Additional reference words: 3.10 3.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |