Ignore:
Timestamp:
Aug 25, 1999, 5:27:20 PM (26 years ago)
Author:
sandervl
Message:

Readonly memory mapped files work now + PE loader uses those apis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/mmap.cpp

    r690 r695  
    1 /* $Id: mmap.cpp,v 1.11 1999-08-25 14:27:07 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.12 1999-08-25 15:27:19 sandervl Exp $ */
    22
    33/*
     
    150150
    151151  dprintf(("Win32MemMap::commitPage %x (faultaddr %x), nr of pages %d", pageAddr, lpPageFaultAddr, nrpages));
    152   if(VirtualAlloc((LPVOID)pageAddr, nrpages*PAGE_SIZE, MEM_COMMIT, newProt) == FALSE) {
    153         goto fail;
    154   }
    155152  if(hMemFile != -1) {
     153        if(VirtualAlloc((LPVOID)pageAddr, nrpages*PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE) == FALSE) {
     154                goto fail;
     155        }
    156156        offset = pageAddr - (ULONG)pMapping;
    157157        size   = nrpages*PAGE_SIZE;
     
    171171                goto fail;
    172172        }
     173        if(mProtFlags & PAGE_READONLY) {
     174//DosSetMem returns flags with EXECUTE bit set, even though the initial allocation is without this bit set!
     175//Also returns access denied when trying to set it back to READONLY
     176                VirtualProtect((LPVOID)pageAddr, nrpages*PAGE_SIZE, newProt, &oldProt);
     177//              if(VirtualProtect((LPVOID)pageAddr, nrpages*PAGE_SIZE, newProt, &oldProt) == FALSE) {
     178//                      goto fail;
     179//              }
     180        }
     181  }
     182  else {
     183        if(VirtualAlloc((LPVOID)pageAddr, nrpages*PAGE_SIZE, MEM_COMMIT, newProt) == FALSE) {
     184                goto fail;
     185        }
    173186  }
    174187
     
    224237
    225238  if(fMapped == FALSE) {//if not mapped, reserve/commit entire view
    226         pMapping = VirtualAlloc(0, mSize, fAlloc, mProtFlags);
     239        pMapping = VirtualAlloc(0, mSize, fAlloc, memFlags);
    227240        if(pMapping == NULL) {
    228241                dprintf(("Win32MemMap::mapFileView: VirtualAlloc %x %x %x failed!", mSize, fAlloc, memFlags));
     
    255268
    256269//  mapMutex.enter();
     270  dprintf(("Win32MemMap::flushView: %x %x", lpvBase, cbFlush));
    257271  if(fMapped == FALSE)
    258272        goto parmfail;
Note: See TracChangeset for help on using the changeset viewer.