Changeset 9971 for trunk/src


Ignore:
Timestamp:
Apr 2, 2003, 1:03:33 PM (22 years ago)
Author:
sandervl
Message:

PF: Corrected HFILE definition as it is in Wine and in Win2k

Location:
trunk/src/kernel32
Files:
9 edited

Legend:

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

    r9938 r9971  
    1 /* $Id: HandleManager.cpp,v 1.96 2003-03-26 16:02:33 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.97 2003-04-02 11:03:30 sandervl Exp $ */
    22
    33/*
     
    981981 *****************************************************************************/
    982982
    983 HFILE HMCreateFile(LPCSTR lpFileName,
     983HANDLE HMCreateFile(LPCSTR lpFileName,
    984984                   DWORD  dwDesiredAccess,
    985985                   DWORD  dwShareMode,
     
    19041904 *****************************************************************************/
    19051905
    1906 BOOL HMUnlockFile (HFILE         hFile,
     1906BOOL HMUnlockFile (HANDLE        hFile,
    19071907                   DWORD         arg2,
    19081908                   DWORD         arg3,
  • trunk/src/kernel32/hmmmap.cpp

    r9948 r9971  
    1 /* $Id: hmmmap.cpp,v 1.23 2003-03-27 14:19:23 sandervl Exp $ */
     1/* $Id: hmmmap.cpp,v 1.24 2003-04-02 11:03:31 sandervl Exp $ */
    22
    33/*
     
    5151//******************************************************************************
    5252DWORD HMDeviceMemMapClass::CreateFileMapping(PHMHANDLEDATA         pHMHandleData,
    53                                              HFILE hFile,
     53                                             HANDLE hFile,
    5454                                             SECURITY_ATTRIBUTES *sa, /* [in] Optional security attributes*/
    5555                                             DWORD protect,   /* [in] Protection for mapping object */
  • trunk/src/kernel32/mmap.cpp

    r9946 r9971  
    1 /* $Id: mmap.cpp,v 1.64 2003-03-27 14:13:10 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.65 2003-04-02 11:03:31 sandervl Exp $ */
    22
    33/*
     
    7373//******************************************************************************
    7474//******************************************************************************
    75 Win32MemMap::Win32MemMap(HFILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName)
     75Win32MemMap::Win32MemMap(HANDLE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName)
    7676               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0),
    7777                 image(0), pWriteBitmap(NULL)
     
    307307  if(image) {
    308308      return image->commitPage(pageAddr, fWriteAccess);
     309  }
     310
     311  if(fWriteAccess && (mProtFlags & PAGE_WRITECOPY))
     312  {//this is a COW map, call commitGuardPage to handle write faults
     313      return commitGuardPage(ulFaultAddr, offset, fWriteAccess);
    309314  }
    310315
     
    407412                dprintf(("Mark %d page(s) starting at %x as dirty", nrPages, pageAddr));
    408413                markDirtyPages(startPage, nrPages);
     414
     415                //Write access means that the next time the corresponding COW page
     416                //is touched, we need to reload it. So set the GUARD flags.
     417                updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_GUARD);
    409418            }
    410419        }
     
    429438            //Now change all the aliased pages according to their view protection flags
    430439            updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_VIEW);
     440
     441            //Write access means that the next time the corresponding COW page
     442            //is touched, we need to reload it. So set the GUARD flags.
     443            updateViewPages(offset, memInfo.RegionSize, PAGEVIEW_GUARD);
    431444        }
    432445        faultsize -= memInfo.RegionSize;
     
    443456// Win32MemMap::commitGuardPage
    444457//
    445 // Handle a guard page exception
     458// Handle a guard page exception for a copy-on-write view (one page only)
    446459//
    447460// Parameters:
     
    468481   //align at page boundary
    469482   ulOffset &= ~0xFFF;
     483
     484   //commit a single page in the original mapping (pretend read access)
     485   ret = commitPage(ulFaultAddr, ulOffset, FALSE, 1);
     486   if(ret == FALSE) {
     487       DebugInt3();
     488       goto fail;
     489   }
     490   //clear PAGE_GUARD flag, since this page must now be made accessible
     491   dwNewProt = mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY);
     492   if(dwNewProt & PAGE_WRITECOPY) {
     493       dwNewProt |= PAGE_GUARD;
     494   }
     495   dwNewProt &= ~PAGE_GUARD;
     496   if(VirtualProtect((LPVOID)pageAddr, PAGE_SIZE, dwNewProt, &dwOldProt) == FALSE) {
     497       dprintf(("Win32MemMap::commitGuardPage: VirtualProtect %x 0x1000 %x failed!!", pageAddr, dwNewProt));
     498       goto fail;
     499   }
     500   //copy the data from the original mapping to the COW page
     501   memcpy((LPVOID)pageAddr, (char *)pMapping+ulOffset, PAGE_SIZE);
     502
     503   if(fWriteAccess)
     504   {//copy on write; mark pages as private
     505        DWORD startpage = (ulOffset) >> PAGE_SHIFT;
     506
     507        dprintf(("Win32MemMap::commitGuardPage: write access -> mark page as private"));
     508
     509        Win32MemMapView *view = Win32MemMapView::findView(ulFaultAddr);
     510        if(view)
     511        {
     512            view->markCOWPages(startpage, 1);
     513        }
     514        else DebugInt3(); //oh, oh
     515   }
     516   else
     517   {//read access; must set the map + all views to READONLY to track write access
     518
     519       dprintf(("Win32MemMap::commitGuardPage: read access -> set page as READONLY in map + all views"));
     520
     521       //first the memory map page
     522       if(VirtualProtect((LPVOID)pageAddr, PAGE_SIZE, PAGE_READONLY, &dwOldProt) == FALSE) {
     523           dprintf(("Win32MemMap::commitGuardPage: VirtualProtect %x 0x1000 %x failed!!", pageAddr, dwNewProt));
     524           goto fail;
     525       }
     526       //now for any views that exist
     527       updateViewPages(ulOffset, PAGE_SIZE, PAGEVIEW_READONLY);
     528   }
    470529
    471530   return TRUE;
     
    485544//       PAGEVIEW_READONLY      -> set page flags to readonly
    486545//       PAGEVIEW_VIEW          -> set page flags to view default
     546//       PAGEVIEW_GUARD         -> set page flags of COW view to GUARD
    487547//
    488548// Returns:
     
    535595        dprintf(("ERROR: Win32MemMap::invalidatePages: VirtualFree failed!!"));
    536596    }
    537     return TRUE;
     597    //invalidate all shared COW pages too by setting the GUARD flag
     598    //(which forces a resync the next time the app touches them)
     599    return updateViewPages(offset, size, PAGEVIEW_GUARD);
    538600}
    539601//******************************************************************************
  • trunk/src/kernel32/mmap.h

    r9946 r9971  
    1 /* $Id: mmap.h,v 1.27 2003-03-27 14:13:11 sandervl Exp $ */
     1/* $Id: mmap.h,v 1.28 2003-04-02 11:03:32 sandervl Exp $ */
    22
    33/*
     
    5454{
    5555public:
    56    Win32MemMap(HFILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
     56   Win32MemMap(HANDLE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
    5757   //Use by PE loader image class only:
    5858   Win32MemMap(Win32PeLdrImage *pImage, ULONG lpImageMem, ULONG size);
     
    6767        BOOL   allocateMap();
    6868
    69    HFILE getFileHandle()                { return hMemFile; };
     69   HANDLE getFileHandle()                { return hMemFile; };
    7070   LPSTR  getMemName()                   { return lpszMapName; };
    7171   DWORD  getMapSize()                   { return mSize; };
     
    122122
    123123protected:
    124    HFILE hMemFile;
    125    HFILE hOrgMemFile;
     124   HANDLE hMemFile;
     125   HANDLE hOrgMemFile;
    126126   ULONG  mSize;
    127127   ULONG  mProtFlags;
     
    154154{
    155155public:
    156             Win32MemMapDup(Win32MemMap *parent, HFILE hFile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
     156            Win32MemMapDup(Win32MemMap *parent, HANDLE hFile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
    157157   virtual ~Win32MemMapDup();
    158158
  • trunk/src/kernel32/mmapdup.cpp

    r9946 r9971  
    1 /* $Id: mmapdup.cpp,v 1.1 2003-03-27 14:13:11 sandervl Exp $ */
     1/* $Id: mmapdup.cpp,v 1.2 2003-04-02 11:03:32 sandervl Exp $ */
    22
    33/*
     
    4848//
    4949//******************************************************************************
    50 Win32MemMapDup::Win32MemMapDup(Win32MemMap *parent, HFILE hFile, ULONG size,
     50Win32MemMapDup::Win32MemMapDup(Win32MemMap *parent, HANDLE hFile, ULONG size,
    5151                               ULONG fdwProtect, LPSTR lpszName) :
    5252          Win32MemMap(hFile, size, fdwProtect, lpszName)
     
    221221BOOL Win32MemMapDup::commitPage(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess, int nrpages)
    222222{
     223    if(mProtFlags & PAGE_WRITECOPY)
     224    {//this is a COW map, call commitGuardPage
     225        return commitGuardPage(ulFaultAddr, offset, fWriteAccess);
     226    }
    223227    return parent->commitPage(ulFaultAddr, offset, fWriteAccess, nrpages);
    224228}
     
    226230// Win32MemMapDup::commitGuardPage
    227231//
    228 // Handle a guard page exception
     232// Handle a guard page exception for a copy-on-write view
    229233//
    230234// Parameters:
  • trunk/src/kernel32/virtual.cpp

    r9911 r9971  
    1 /* $Id: virtual.cpp,v 1.54 2003-03-06 10:44:34 sandervl Exp $ */
     1/* $Id: virtual.cpp,v 1.55 2003-04-02 11:03:32 sandervl Exp $ */
    22
    33/*
     
    4747 */
    4848HANDLE WINAPI CreateFileMappingA(
    49                 HFILE hFile,   /* [in] Handle of file to map */
     49                HANDLE hFile,   /* [in] Handle of file to map */
    5050                SECURITY_ATTRIBUTES *sa, /* [in] Optional security attributes*/
    5151                DWORD protect,   /* [in] Protection for mapping object */
     
    6767 * See CreateFileMapping32A
    6868 */
    69 HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES attr,
     69HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES attr,
    7070                                      DWORD protect, DWORD size_high,
    7171                                      DWORD size_low, LPCWSTR name )
  • trunk/src/kernel32/winexedummy.cpp

    r8887 r9971  
    1 /* $Id: winexedummy.cpp,v 1.3 2002-07-18 12:01:33 achimha Exp $ */
     1/* $Id: winexedummy.cpp,v 1.4 2003-04-02 11:03:32 sandervl Exp $ */
    22
    33/*
     
    138138    poh->MajorSubsystemVersion       = ODINNT_MAJOR_VERSION;
    139139    poh->MinorSubsystemVersion       = ODINNT_MINOR_VERSION;
    140     poh->Reserved1                   = 0;
     140    poh->Win32VersionValue           = 0;
    141141    poh->SizeOfImage                 = 0;
    142142    poh->SizeOfHeaders               = 1024;
  • trunk/src/kernel32/winimagelx.cpp

    r9413 r9971  
    1 /* $Id: winimagelx.cpp,v 1.19 2002-11-18 14:03:56 sandervl Exp $ */
     1/* $Id: winimagelx.cpp,v 1.20 2003-04-02 11:03:33 sandervl Exp $ */
    22
    33/*
     
    202202    poh->MajorSubsystemVersion       = ODINNT_MAJOR_VERSION;
    203203    poh->MinorSubsystemVersion       = ODINNT_MINOR_VERSION;
    204     poh->Reserved1                   = 0;
     204    poh->Win32VersionValue           = 0;
    205205    poh->SizeOfImage                 = 0;
    206206    poh->SizeOfHeaders               = 1024;
  • trunk/src/kernel32/wprocess.cpp

    r9890 r9971  
    1 /* $Id: wprocess.cpp,v 1.185 2003-03-03 16:38:20 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.186 2003-04-02 11:03:33 sandervl Exp $ */
    22
    33/*
     
    855855 * @remark    Forwards to LoadLibraryExA.
    856856 */
    857 HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, HANDLE hFile, DWORD dwFlags)
     857HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, HFILE hFile, DWORD dwFlags)
    858858{
    859859    HINSTANCE       hDll;
     
    12651265 * @remark    Forwards to LoadLibraryExA.
    12661266 */
    1267 HINSTANCE WIN32API LoadLibraryExW(LPCWSTR lpszLibFile, HANDLE hFile, DWORD dwFlags)
     1267HINSTANCE WIN32API LoadLibraryExW(LPCWSTR lpszLibFile, HFILE hFile, DWORD dwFlags)
    12681268{
    12691269    char *      pszAsciiLibFile;
Note: See TracChangeset for help on using the changeset viewer.