Ignore:
Timestamp:
Jul 26, 2002, 12:46:56 PM (23 years ago)
Author:
sandervl
Message:

protect larger part of on demand page handler (DosEnterCritSec)

File:
1 edited

Legend:

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

    r8914 r8918  
    1 /* $Id: winimagepeldr.cpp,v 1.100 2002-07-24 11:29:23 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.101 2002-07-26 10:46:56 sandervl Exp $ */
    22
    33/*
     
    743743 ULONG    ulNewPos, ulRead, orgVirtAddress = virtAddress;
    744744 APIRET   rc;
     745 BOOL     fCriticalSection = FALSE;
    745746
    746747    dprintf((LOG, "Win32PeLdrImage::commitPage %x %d %d", virtAddress, fWriteAccess, fPageCmd));
     
    796797        return TRUE;
    797798    }
     799    rc = DosEnterCritSec();
     800    if(rc) {
     801        dprintf((LOG, "DosEnterCritSec failed with rc %d", rc));
     802        goto fail;
     803    }
     804    //tell fail handler to call DosExitCritSec
     805    fCriticalSection = TRUE;
     806
    798807    //Check range of pages with the same attributes starting at virtAddress
    799808    //(some pages might already have been loaded)
     
    802811    if(rc) {
    803812        dprintf((LOG, "Win32PeLdrImage::commitPage: DosQueryMem for %x returned %d", virtAddress, rc));
    804         return FALSE;
     813        goto fail;
    805814    }
    806815    if(attr & PAG_COMMIT) {
    807816        dprintf((LOG, "Win32PeLdrImage::commitPage: Memory at 0x%x already committed!", virtAddress));
    808         return FALSE;
     817        goto fail;
    809818    }
    810819
     
    824833
    825834    if(size && fileoffset != -1) {
    826         rc = DosEnterCritSec();
    827         if(rc) {
    828             dprintf((LOG, "DosEnterCritSec failed with rc %d", rc));
    829             goto fail;
    830         }
    831835        rc = DosSetMem((PVOID)virtAddress, sectionsize, PAG_READ|PAG_WRITE|PAG_COMMIT);
    832836        if(rc) {
    833             DosExitCritSec();
    834837            dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetMem failed (%d)!", rc));
    835838            goto fail;
     
    837840
    838841        if(DosSetFilePtr(hFile, ulPEOffset+fileoffset, FILE_BEGIN, &ulNewPos) == -1) {
    839             DosExitCritSec();
    840842            dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetFilePtr failed for 0x%x!", fileoffset));
    841843            goto fail;
     
    850852#endif
    851853        if(rc) {
    852             DosExitCritSec();
    853854            dprintf((LOG, "Win32PeLdrImage::commitPage: DosRead failed for 0x%x %x %x %x (rc=%d)!", virtAddress, size, ulRead, fileoffset, rc));
    854855            goto fail;
    855856        }
    856857        if(ulRead != size) {
    857             DosExitCritSec();
    858858            dprintf((LOG, "Win32PeLdrImage::commitPage: DosRead failed to read %x (%x) bytes at %x for 0x%x!", size, ulRead, fileoffset, virtAddress));
    859859            goto fail;
     
    862862
    863863        rc = DosSetMem((PVOID)virtAddress, sectionsize, protflags);
    864         DosExitCritSec();
    865864        if(rc) {
    866865            dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetMem failed (%d)!", rc));
     
    869868    }
    870869    else {
    871         rc = DosEnterCritSec();
    872         if(rc) {
    873             dprintf((LOG, "DosEnterCritSec failed with rc %d", rc));
    874             goto fail;
    875         }
    876 
    877870        rc = DosSetMem((PVOID)virtAddress, sectionsize, PAG_READ|PAG_WRITE|PAG_COMMIT);
    878         if(rc) {
    879             DosExitCritSec();
    880             dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetMem failed (%d)!", rc));
    881             goto fail;
    882         }
    883         setFixups(virtAddress, sectionsize);
    884 
    885         rc = DosSetMem((PVOID)virtAddress, sectionsize, protflags);
    886         DosExitCritSec();
    887871        if(rc) {
    888872            dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetMem failed (%d)!", rc));
    889873            goto fail;
    890874        }
    891     }
     875        setFixups(virtAddress, sectionsize);
     876
     877        rc = DosSetMem((PVOID)virtAddress, sectionsize, protflags);
     878        if(rc) {
     879            dprintf((LOG, "Win32PeLdrImage::commitPage: DosSetMem failed (%d)!", rc));
     880            goto fail;
     881        }
     882    }
     883    DosExitCritSec();
    892884    return TRUE;
    893885
    894886fail:
     887    if(fCriticalSection) DosExitCritSec();
    895888    return FALSE;
    896889}
Note: See TracChangeset for help on using the changeset viewer.