Ignore:
Timestamp:
Jun 27, 2011, 2:34:59 AM (14 years ago)
Author:
dmik
Message:

kernel32: Fixed: Closing a duplicate of a handle opened with FILE_FLAG_DELETE_ON_CLOSE would not perform file deletion if that duplicate was the last reference to the file (e.g. closed after the original handle).

File:
1 edited

Legend:

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

    r21564 r21655  
    384384      SetHandleInformation(pHMHandleData, HANDLE_FLAG_INHERIT, (fInherit) ? HANDLE_FLAG_INHERIT : 0);
    385385
     386      // Duplicate file information as well -- this is e.g. needed in
     387      // CloseHandle() for the FILE_FLAG_DELETE_ON_CLOSE emulation to work
     388      if (srcfileinfo) {
     389        pHMHandleData->dwUserData =
     390          (DWORD) new HMFileInfo(pHMHandleData->hHMHandle,
     391                                 srcfileinfo->lpszFileName, NULL);
     392      }
     393
    386394      SetLastError(ERROR_SUCCESS);
    387395      return TRUE;    // OK
     
    640648  DWORD curfilepos;
    641649  map = Win32MemMap::findMapByFile(pHMHandleData->hWin32Handle);
    642   if(map) {
     650  if(map && map->getFileHandle() != pHMHandleData->hWin32Handle) {
    643651      curfilepos = SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT);
    644652
Note: See TracChangeset for help on using the changeset viewer.