Ignore:
Timestamp:
Mar 6, 2003, 11:44:34 AM (22 years ago)
Author:
sandervl
Message:

cleanup/resync

File:
1 edited

Legend:

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

    r9292 r9911  
    1 /* $Id: oslibmem.cpp,v 1.5 2002-09-24 15:15:27 sandervl Exp $ */
     1/* $Id: oslibmem.cpp,v 1.6 2003-03-06 10:44:34 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    4343
    4444//******************************************************************************
    45 //TODO: Assumes entire memory range has the same protection flags!
    4645//TODO: Check if this works for code aliases...
    4746//******************************************************************************
     
    5554    cb+= PAGE_SIZE;
    5655
    57     rc = DosQueryMem(pb, &size, &attr);
    58     if(rc) {
    59         dprintf(("!ERROR!: OSLibDosAliasMem: DosQueryMem %x %x return %d", pb, size, rc));
    60         return rc;
    61     }
    62     size = (size-1) & ~0xfff;
    63     size+= PAGE_SIZE;
    64     if(size != cb) {
    65         dprintf(("!WARNING!: OSLibDosAliasMem: size != cb (%x!=%x)!!!!!!!!", size, cb));
    66         //ignore this and continue return 5;
    67         attr = fl; //just use original protection flags (NOT CORRECT)
    68     }
    69     attr &= (PAG_READ|PAG_WRITE|PAG_EXECUTE|PAG_GUARD|PAG_DEFAULT);
    70     if(attr != fl) {
    71         rc = DosSetMem(pb, size, fl);
    72         if(rc) {
    73                 dprintf(("!ERROR!: OSLibDosAliasMem: DosSetMem %x %x return %d", pb, size, rc));
    74                 attr = fl;
    75                 //just continue for now
    76                 //return rc;
    77         }
    78     }
    7956    rc = DosAliasMem(pb, cb, ppbAlias, 2);
    8057    if(rc) {
     
    8259        return rc;
    8360    }
    84     if(attr != fl) {
    85         rc = DosSetMem(pb, size, attr);
    86         if(rc) {
    87             dprintf(("!ERROR!: OSLibDosAliasMem: DosSetMem (2) %x %x return %d", pb, size, rc));
     61    //Now try to change the protection flags of all pages in the aliased range
     62    DWORD pAlias = (DWORD)*ppbAlias;
     63
     64    while(pAlias < (DWORD)*ppbAlias + cb)
     65    {
     66        rc = DosQueryMem((PVOID)pAlias, &size, &attr);
     67        if(rc != NO_ERROR) {
     68            dprintf(("!ERROR!: OSLibDosAliasMem: DosQueryMem %x returned %d", pAlias, rc));
     69            DebugInt3();
    8870            return rc;
    8971        }
     72        //Don't bother if the pages are not committed. DosSetMem will return
     73        //ERROR_ACCESS_DENIED.
     74        if(attr & PAG_COMMIT) {
     75            rc = DosSetMem((PVOID)pAlias, size, fl);
     76            if(rc) {
     77                dprintf(("!ERROR!: OSLibDosAliasMem: DosSetMem %x %x return %d", *ppbAlias, size, rc));
     78                DebugInt3();
     79                return rc;
     80            }
     81        }
     82        pAlias += size;
    9083    }
    9184    return 0;
Note: See TracChangeset for help on using the changeset viewer.