Ignore:
Timestamp:
Nov 22, 1999, 9:35:52 PM (26 years ago)
Author:
sandervl
Message:

Rewrite of PE loader code, EB's fixes + VirtualProtect bugfix

File:
1 edited

Legend:

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

    r1710 r1811  
    1 /* $Id: oslibdos.cpp,v 1.8 1999-11-12 11:38:40 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.9 1999-11-22 20:35:50 sandervl Exp $ */
    22
    33/*
     
    2626
    2727//******************************************************************************
     28//TODO: Assumes entire memory range has the same protection flags!
     29//TODO: Check if this works for code aliases...
    2830//******************************************************************************
    2931DWORD OSLibDosAliasMem(LPVOID pb, ULONG cb, LPVOID *ppbAlias, ULONG fl)
    3032{
    31   return DosAliasMem(pb, cb, ppbAlias, fl);
     33 DWORD rc;
     34 DWORD attr;
     35 DWORD size = cb;
     36
     37  cb = (cb-1) & ~0xfff;
     38  cb+= PAGE_SIZE;
     39
     40  rc = DosQueryMem(pb, &size, &attr);
     41  if(rc) {
     42        dprintf(("OSLibDosAliasMem: DosQueryMem %x %x return %d", pb, size, rc));
     43        return rc;
     44  }
     45  size = (size-1) & ~0xfff;
     46  size+= PAGE_SIZE;
     47  if(size != cb) {
     48        dprintf(("ERROR: OSLibDosAliasMem: size != cb (%x!=%x)!!!!!!!!", size, cb));
     49        return 5;
     50  }
     51  attr &= (PAG_READ|PAG_WRITE|PAG_EXECUTE|PAG_GUARD|PAG_DEFAULT);
     52  if(attr != fl) {
     53        rc = DosSetMem(pb, size, fl);
     54        if(rc) {
     55                dprintf(("OSLibDosAliasMem: DosSetMem %x %x return %d", pb, size, rc));
     56                attr = fl;
     57                //just continue for now
     58                //return rc;
     59        }
     60  }
     61  rc = DosAliasMem(pb, cb, ppbAlias, 2);
     62  if(rc) {
     63        dprintf(("OSLibDosAliasMem: DosAliasMem %x %x return %d", pb, cb, rc));
     64        return rc;
     65  }
     66  if(attr != fl) {
     67        rc = DosSetMem(pb, size, attr);
     68        if(rc) {
     69                dprintf(("OSLibDosAliasMem: DosSetMem (2) %x %x return %d", pb, size, rc));
     70                return rc;
     71        }
     72  }
     73  return 0;
    3274}
    3375//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.