Changeset 8882 for trunk/src


Ignore:
Timestamp:
Jul 16, 2002, 10:16:48 AM (23 years ago)
Author:
sandervl
Message:

Fix for loading PE images in low memory (introduced yesterday)

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

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

    r8877 r8882  
    1 /* $Id: oslibmem.cpp,v 1.3 2002-07-15 14:28:52 sandervl Exp $ */
     1/* $Id: oslibmem.cpp,v 1.4 2002-07-16 08:16:47 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    9494//Allocate memory aligned at 64kb boundary
    9595//******************************************************************************
    96 DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD cbSize, DWORD flFlags)
     96DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD cbSize, DWORD flFlags, BOOL fLowMemory)
    9797{
    9898    PVOID   pvMemAddr;
    9999    DWORD   offset;
    100100    APIRET  rc;
    101 
     101    BOOL    fMemFlags = flAllocMem;
     102
     103    //Override low/high memory flag if necessary
     104    if(fLowMemory) {
     105        fMemFlags = 0;
     106    }
    102107    /*
    103108     * Let's try use the extended DosAllocMem API of Win32k.sys.
     
    105110    if (libWin32kInstalled())
    106111    {
    107         rc = DosAllocMemEx(lplpMemAddr, cbSize, flFlags | flAllocMem | OBJ_ALIGN64K);
     112        rc = DosAllocMemEx(lplpMemAddr, cbSize, flFlags | fMemFlags | OBJ_ALIGN64K);
    108113        if (rc != ERROR_NOT_SUPPORTED)  /* This call was stubbed until recently. */
    109114            return rc;
     
    114119     */
    115120
    116     rc = DosAllocMem(&pvMemAddr, cbSize, flFlags | flAllocMem);
     121    rc = DosAllocMem(&pvMemAddr, cbSize, flFlags | fMemFlags);
    117122    if(rc) {
    118123        dprintf(("!ERROR!: DosAllocMem failed with rc %d", rc));
     
    128133
    129134        //Allocate 64kb more so we can round the address to a 64kb aligned value
    130         rc = DosAllocMem((PPVOID)&addr64kb, cbSize + 64*1024,  (flFlags & ~PAG_COMMIT) | flAllocMem);
     135        rc = DosAllocMem((PPVOID)&addr64kb, cbSize + 64*1024,  (flFlags & ~PAG_COMMIT) | fMemFlags);
    131136        if(rc) {
    132137            dprintf(("!ERROR!: DosAllocMem failed with rc %d", rc));
  • trunk/src/kernel32/oslibmem.h

    r8877 r8882  
    1 /* $Id: oslibmem.h,v 1.1 2002-07-15 14:28:52 sandervl Exp $ */
     1/* $Id: oslibmem.h,v 1.2 2002-07-16 08:16:48 sandervl Exp $ */
    22/*
    33 * OS/2 Memory management procedures
     
    4242               
    4343DWORD OSLibDosAliasMem(LPVOID pb, ULONG cb, LPVOID *ppbAlias, ULONG fl);
    44 DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD size, DWORD flags);
     44DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD size, DWORD flags, BOOL fLowMemory = FALSE);
    4545DWORD OSLibDosFreeMem(LPVOID lpMemAddr);
    4646DWORD OSLibDosQueryMem(LPVOID lpMemAddr, DWORD *lpRangeSize, DWORD *lpAttr);
  • trunk/src/kernel32/winimagepeldr.cpp

    r8877 r8882  
    1 /* $Id: winimagepeldr.cpp,v 1.96 2002-07-15 14:28:53 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.97 2002-07-16 08:16:48 sandervl Exp $ */
    22
    33/*
     
    431431    }
    432432
    433     dprintf((LOG, "OS/2 base address %x", realBaseAddress ));
     433    dprintf((LOG, "OS/2 base address   %x", realBaseAddress ));
    434434    if(oh.AddressOfEntryPoint) {
    435435        entryPoint = realBaseAddress + oh.AddressOfEntryPoint;
     
    999999 ULONG  diff, i, baseAddress;
    10001000 APIRET rc;
    1001  BOOL   allocFlags = flAllocMem;
     1001 BOOL   fLowMemory = FALSE;
    10021002
    10031003    //Reserve enough space to store 4096 pointers to 1MB memory chunks
     
    10091009
    10101010    if(oh.ImageBase < 512*1024*1024) {
    1011         allocFlags = 0;
     1011        fLowMemory = TRUE;
    10121012    }
    10131013    while(TRUE) {
    1014         rc = OSLibDosAllocMem((PPVOID)&address, FALLOC_SIZE, PAG_READ | allocFlags);
     1014        rc = OSLibDosAllocMem((PPVOID)&address, FALLOC_SIZE, PAG_READ, fLowMemory);
    10151015        if(rc) break;
    10161016
     
    10261026            diff = oh.ImageBase - address;
    10271027            if(diff) {
    1028                 rc = OSLibDosAllocMem((PPVOID)&address, diff, PAG_READ | allocFlags);
     1028                rc = OSLibDosAllocMem((PPVOID)&address, diff, PAG_READ, fLowMemory);
    10291029                if(rc) break;
    10301030            }
    1031             rc = OSLibDosAllocMem((PPVOID)&baseAddress, imageSize, PAG_READ | PAG_WRITE | allocFlags);
     1031            rc = OSLibDosAllocMem((PPVOID)&baseAddress, imageSize, PAG_READ | PAG_WRITE, fLowMemory);
    10321032            if(rc) break;
    10331033
Note: See TracChangeset for help on using the changeset viewer.