Changeset 3259 for trunk/src


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

openfile, virtualquery + import name fixes

Location:
trunk/src/kernel32
Files:
6 edited

Legend:

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

    r3105 r3259  
    1 /* $Id: Fileio.cpp,v 1.25 2000-03-13 20:39:09 sandervl Exp $ */
     1/* $Id: Fileio.cpp,v 1.26 2000-03-28 17:11:48 sandervl Exp $ */
    22
    33/*
     
    617617
    618618ODINFUNCTION3(HFILE, OpenFile,
    619               LPCSTR, arg1,
    620               OFSTRUCT *, arg2,
    621               UINT, arg3)
     619              LPCSTR, lpszFile,
     620              OFSTRUCT *, lpOpenBuff,
     621              UINT, fuMode)
    622622{
    623623  HFILE hFile;
    624624
    625625  dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
    626            arg1,
    627            arg2,
    628            arg3));
    629 
    630   hFile = HMOpenFile(arg1,                                      /* call open32 */
    631                      arg2,
    632                      arg3);
     626           lpszFile,
     627           lpOpenBuff,
     628           fuMode));
     629
     630  hFile = HMOpenFile(lpszFile,                                      /* call open32 */
     631                     lpOpenBuff,
     632                     fuMode);
    633633
    634634  return (hFile);
  • trunk/src/kernel32/hmopen32.cpp

    r3228 r3259  
    1 /* $Id: hmopen32.cpp,v 1.19 2000-03-24 19:25:32 sandervl Exp $ */
     1/* $Id: hmopen32.cpp,v 1.20 2000-03-28 17:11:49 sandervl Exp $ */
    22
    33/*
     
    700700                                     PHMHANDLEDATA pHMHandleData,
    701701                                     OFSTRUCT      *pOFStruct,
    702                                      UINT          arg3)
     702                                     UINT          fuMode)
    703703{
    704704  HFILE hFile;
    705705  FILETIME filetime;
    706706  WORD filedatetime[2];
     707  char filepath[260];
    707708
    708709  dprintfl(("KERNEL32: HandleManager::Open32::OpenFile %s(%s,%08x,%08x,%08x) - stub?\n",
     
    711712           pHMHandleData,
    712713           pOFStruct,
    713            arg3));
    714 
    715   if (strcmp(lpFileName,       // "support" for local unc names
     714           fuMode));
     715
     716  if(strcmp(lpFileName,       // "support" for local unc names
    716717             "\\\\.\\") == 0)
     718  {
    717719    lpFileName+=4;
    718 
     720  }
     721  else
     722  if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\'))
     723  {
     724        //filename only; search for file in following order
     725        //1: dir from which the app loaded
     726        //2: current dir
     727        //3: windows system dir
     728        //4: windows dir
     729        //5: dirs in path path environment variable
     730        //SearchPath does exactly that
     731        LPSTR filenameinpath;
     732
     733        if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
     734           && !(fuMode & OF_CREATE) ) {
     735                SetLastError(ERROR_FILE_NOT_FOUND);
     736                return HFILE_ERROR;
     737        }
     738        lpFileName = filepath;
     739  }
    719740  // filling OFSTRUCT
    720741  memset(pOFStruct, 0, sizeof(OFSTRUCT));
     
    725746  hFile = O32_OpenFile(lpFileName,
    726747                       pOFStruct,
    727                        arg3);
     748                       fuMode);
    728749  if (hFile != INVALID_HANDLE_ERROR)
    729750  {
  • trunk/src/kernel32/kobjects.cpp

    r3128 r3259  
    1 /* $Id: kobjects.cpp,v 1.10 2000-03-16 19:20:39 sandervl Exp $ */
     1/* $Id: kobjects.cpp,v 1.11 2000-03-28 17:11:49 sandervl Exp $ */
    22
    33/*
     
    322322              UINT, cHandles)
    323323{
    324   return(HMSetHandleCount(cHandles));
     324  //SvL: Has no effect in NT; also ignore it
     325  return cHandles;
    325326}
    326327
  • trunk/src/kernel32/mmap.cpp

    r3206 r3259  
    1 /* $Id: mmap.cpp,v 1.37 2000-03-23 19:23:47 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.38 2000-03-28 17:11:49 sandervl Exp $ */
    22
    33/*
     
    195195  if(hMemFile != -1) {
    196196//      for(i=0;i<nrpages;i++) {
    197                 if(VirtualQuery((LPSTR)pageAddr, &memInfo, nrpages*PAGE_SIZE) == 0) {
     197                if(VirtualQuery((LPSTR)pageAddr, &memInfo, sizeof(MEMORY_BASIC_INFORMATION)) == 0) {
    198198                        dprintf(("Win32MemMap::commitPage: VirtualQuery (%x,%x) failed for %x", pageAddr, nrpages*PAGE_SIZE));
    199199                        goto fail;
    200200                }
     201                memInfo.RegionSize = min(memInfo.RegionSize, nrpages*PAGE_SIZE);
    201202                //Only changes the state of the pages with the same attribute flags
    202203                //(returned in memInfo.RegionSize)
     
    250251        ULONG sizeleft = nrpages*PAGE_SIZE;
    251252        while(sizeleft) {
    252                 if(VirtualQuery((LPSTR)pageAddr, &memInfo, sizeleft) == 0) {
     253
     254                if(VirtualQuery((LPSTR)pageAddr, &memInfo, sizeof(MEMORY_BASIC_INFORMATION)) == 0) {
    253255                        dprintf(("Win32MemMap::commitPage: VirtualQuery (%x,%x) failed", pageAddr, sizeleft));
    254256                        goto fail;
    255257                }
     258                memInfo.RegionSize = min(memInfo.RegionSize, sizeleft);
     259
    256260                if(!(memInfo.State & MEM_COMMIT))
    257261                {//if it's already committed, then the app tried to write to it
  • 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);
  • trunk/src/kernel32/winimagepeldr.cpp

    r3228 r3259  
    1 /* $Id: winimagepeldr.cpp,v 1.37 2000-03-24 19:25:32 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.38 2000-03-28 17:11:50 sandervl Exp $ */
    22
    33/*
     
    11781178 ULONG nsize;
    11791179
    1180   if(!strcmp(apiname, "At"))
    1181         DebugInt3();
    11821180  if(nameexports == NULL) {
    11831181        nameExportSize= 4096;
     
    15281526  {
    15291527    if(apilen == curexport->nlength &&
    1530        *(ULONG *)curexport->name == *(ULONG *)name)
     1528       *(ULONG *)curexport->name == *(ULONG *)apiname)
    15311529    {
    1532         if(strcmp(curexport->name, name) == 0)
     1530        if(strcmp(curexport->name, apiname) == 0)
    15331531                return(curexport->virtaddr);
    15341532    }
Note: See TracChangeset for help on using the changeset viewer.