Ignore:
Timestamp:
Mar 28, 2000, 7:11:50 PM (25 years ago)
Author:
sandervl
Message:

openfile, virtualquery + import name fixes

File:
1 edited

Legend:

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

    r2802 r3259  
    1 /* $Id: virtual.cpp,v 1.28 2000-02-16 14:22:46 sandervl Exp $ */
     1/* $Id: virtual.cpp,v 1.29 2000-03-28 17:11:50 sandervl Exp $ */
    22
    33/*
     
    553553  LPVOID lpBase;
    554554
    555   if(pmbiBuffer == NULL || cbLength == 0) // check parameters
    556   {
    557     return 0;                             // nothing to return
    558   }
     555  if(pmbiBuffer == NULL || cbLength != sizeof(MEMORY_BASIC_INFORMATION)) // check parameters
     556  {
     557        SetLastError(ERROR_INVALID_PARAMETER);
     558        return 0;                             // nothing to return
     559  }
     560  SetLastError(ERROR_SUCCESS);
    559561
    560562  // determine exact page range
    561563  lpBase = (LPVOID)((ULONG)lpvAddress & 0xFFFFF000);
    562   cbRangeSize = cbLength & ~0x00000FFF;   // assuming intel page sizes :)
    563   if(cbLength & 0x00000FFF)
    564     cbRangeSize += PAGE_SIZE;
     564  cbRangeSize = -1;
    565565
    566566  rc = OSLibDosQueryMem(lpBase,
     
    569569  if(rc)
    570570  {
    571     dprintf(("VirtualQuery - OSLibDosQueryMem %x %x returned %d\n",
    572              lpBase,
    573              cbLength,
    574              rc));
    575     return 0;
     571        dprintf(("VirtualQuery - OSLibDosQueryMem %x %x returned %d\n",
     572                  lpBase, cbLength, rc));
     573        SetLastError(ERROR_INVALID_PARAMETER);
     574        return 0;
    576575  }
    577576
     
    607606
    608607  if(!(dAttr & PAG_SHARED))
    609     pmbiBuffer->Type = MEM_PRIVATE;
     608        pmbiBuffer->Type = MEM_PRIVATE;
    610609
    611610  //TODO: This is not correct: AllocationProtect should contain the protection
    612611  //      flags used in the initial call to VirtualAlloc
    613612  pmbiBuffer->AllocationProtect = pmbiBuffer->Protect;
    614   if(dAttr & PAG_BASE)
    615     pmbiBuffer->AllocationBase = lpBase;
     613  if(dAttr & PAG_BASE) {
     614        pmbiBuffer->AllocationBase = lpBase;
     615  }
    616616  else
    617617  {
    618     while(lpBase > 0)
    619     {
    620       rc = OSLibDosQueryMem(lpBase, &cbRangeSize, &dAttr);
    621       if(rc)
    622       {
    623          dprintf(("VirtualQuery - OSLibDosQueryMem %x %x returned %d\n",
    624                   lpBase,
    625                   cbLength,
    626                   rc));
    627          break;
    628       }
    629       if(dAttr & PAG_BASE)
    630       {
    631          pmbiBuffer->AllocationBase = lpBase;
    632          break;
    633       }
    634       lpBase = (LPVOID)((ULONG)lpBase - PAGE_SIZE);
    635    }
     618        while(lpBase > 0)
     619        {
     620                rc = OSLibDosQueryMem(lpBase, &cbRangeSize, &dAttr);
     621                if(rc) {
     622                        dprintf(("VirtualQuery - OSLibDosQueryMem %x %x returned %d\n",
     623                                  lpBase, cbLength, rc));
     624                        break;
     625                }
     626                if(dAttr & PAG_BASE) {
     627                        pmbiBuffer->AllocationBase = lpBase;
     628                        break;
     629                }
     630                lpBase = (LPVOID)((ULONG)lpBase - PAGE_SIZE);
     631        }
    636632  }
    637633  return sizeof(MEMORY_BASIC_INFORMATION);
Note: See TracChangeset for help on using the changeset viewer.