Changeset 8913 for trunk/src/kernel32/windllpeldr.cpp
- Timestamp:
- Jul 23, 2002, 3:51:49 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/windllpeldr.cpp
r8885 r8913 1 /* $Id: windllpeldr.cpp,v 1.1 0 2002-07-18 11:52:56 achimhaExp $ */1 /* $Id: windllpeldr.cpp,v 1.11 2002-07-23 13:51:48 sandervl Exp $ */ 2 2 3 3 /* … … 34 34 #include "dbglocal.h" 35 35 36 //******************************************************************************37 // Design information on PE DLL memory layout - AH 2002-07-1838 //39 // We are currently using (high) private memory for all PE objects, including the40 // read/execute code segments, constant data segments and global data segments.41 // Global data segments might not be implemented correctly at all as we've never42 // encountered any applictions making use of them. Therefore we are actually43 // wasting memory when running multiple processes using the same PE DLLs.44 //45 // There are several reasons for this design decisions. Both OS/2 (LX) and46 // Windows NT put all DLL segments into the shared arena. What they do for47 // instance data is map it for each process to read-only pages initially. When48 // a write attempt is made by a process, an exception will be triggered. This49 // makes the operating system to copy the data to a new page that is read/write50 // and change the page table of the process to map the linear process in the51 // shared arena to private memory (this is called "copy-on-write").52 // Even though an application is not guaranteed any virtual address for instance53 // data segments, they always end up in the shared region and the virtual addreses54 // are contiguous. An application could therefore make nasty assumptions.55 // Unfortunately, it is not possible for us from ring 3 to replicate the behavior56 // for our PE loader. While we can make the page read only and catch the57 // exception, we have no method to remap the pages to private memory.58 //59 // One solution would be to create another reagion with the private region,60 // i.e. define some address space range as reserved in Odin (configurable to61 // workaround issues with certain PE images requiring those addresses). We62 // could then load the instance data segments of PE DLLs into this private63 // memory arena and still guarantee identical virtual addresses for each64 // process.65 //66 // While the above method should work fine (assuming an application does not67 // make any nasty assumptions), there is one major problem. If we enable the68 // PE on-demand loader (i.e. the mmap loads each page from the PE file when69 // it is accesses for the first time - very much like NT), then we would have70 // nasty concurrency issues. A process could access a page for the first time71 // and the exception is triggered. We commit the page read the data in using72 // a call to DosRead. If the very same page is accessed from a different73 // process after we have committed it but before we have finished the DosRead,74 // we would run into problems. Unfortunately, there does not seem to be any75 // solution for this.76 //77 // The bottomline is that we put everything into private memory and accept the78 // drawback of wasting memory.79 //******************************************************************************80 81 36 82 37 //****************************************************************************** … … 98 53 //****************************************************************************** 99 54 //****************************************************************************** 100 BOOL Win32PeLdrDll::init(ULONG reservedMem )55 BOOL Win32PeLdrDll::init(ULONG reservedMem, ULONG ulPEOffset) 101 56 { 102 57 char modname[CCHMAXPATH];
Note:
See TracChangeset
for help on using the changeset viewer.