Ignore:
Timestamp:
Aug 4, 2000, 11:12:10 PM (25 years ago)
Author:
sandervl
Message:

mmap + share hack

File:
1 edited

Legend:

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

    r3836 r3948  
    1 /* $Id: hmfile.cpp,v 1.13 2000-07-17 00:34:05 phaller Exp $ */
     1/* $Id: hmfile.cpp,v 1.14 2000-08-04 21:12:07 sandervl Exp $ */
    22
    33/*
     
    55 *
    66 * Copyright 1999-2000 Sander van Leeuwen
     7 *
     8 * Notes: (#define SHARE_WORKAROUND)
     9 *    - Temporary workaround for differences in share mode between
     10 *      OS/2 & NT (for opening the same file multiple times):
     11 *      NT: CreateFile with FILE_SHARE_READ
     12 *          CreateFile with FILE_SHARE_READ | FILE_SHARE_WRITE
     13 *          -> 2nd CreateFile overrides share flags of first one
     14 *          -> CreateFile with GENERIC_WRITE is now allowed
     15 *      OS2: DosOpen with OPEN_SHARE_DENYWRITE
     16 *           DosOpen with OPEN_SHARE_DENYNONE
     17 *           -> sharing violation; can't change share flags while
     18 *              handle returned by 1st DosOpen isn't closed
     19 *      --> 'Solution': always open files in FILE_SHARE_DENYNONE mode
     20 *          (several installation programs depend on this behaviour)
     21 *   
     22 *    - Only for CreateFile; might also be necessary for OpenFile, but I haven't
     23 *      seen any apps that require it (yet).
    724 *
    825 * Project Odin Software License can be found in LICENSE.TXT
     
    3754#define DBG_LOCALLOG    DBG_hmfile
    3855#include "dbglocal.h"
     56
     57//SvL: Share violation workaround for CreateFile
     58#define SHARE_WORKAROUND
    3959
    4060/*****************************************************************************
     
    92112        pHMHandleData->dwShare &= ~FILE_SHARE_DELETE;
    93113  }
    94 
     114#ifdef SHARE_WORKAROUND
     115  pHMHandleData->dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE;
     116#endif
    95117  hFile = OSLibDosCreateFile((LPSTR)lpFileName,
    96118                             pHMHandleData->dwAccess,
     
    286308                                        DWORD   fdwAccess,
    287309                                        BOOL    fInherit,
    288                                         DWORD   fdwOptions)
     310                                        DWORD   fdwOptions,
     311                                        DWORD   fdwOdinOptions)
    289312{
    290313 HMFileInfo *srcfileinfo = (HMFileInfo *)pHMSrcHandle->dwUserData;
     
    309332  if(srcfileinfo)
    310333  {
    311 #if 0
    312     // @@@PH Why createfile here? Why not OSLibDupHandle() ?
    313     if(CreateFile(srcfileinfo->lpszFileName, pHMHandleData,
    314                   srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR)
     334    //SvL: Special duplicatehandle option used by memory mapped class to duplicate
     335    //     file handle
     336    //     Can't use DosDupHandle or else there can be a sharing violation
     337    //     when an app tries to access the same file again
     338    if(fdwOdinOptions)
    315339    {
    316       return TRUE;
     340        if(CreateFile(srcfileinfo->lpszFileName, pHMHandleData,
     341                      srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR)
     342        {
     343                return TRUE;
     344        }
     345        dprintf(("ERROR: DuplicateHandle; CreateFile %s failed!",
     346                  srcfileinfo->lpszFileName));
     347        return FALSE;
    317348    }
    318     dprintf(("ERROR: DuplicateHandle; CreateFile %s failed!",
    319              srcfileinfo->lpszFileName));
    320     return FALSE;
    321 #else
    322349   
    323350    if(!(fdwOptions & DUPLICATE_SAME_ACCESS) && fdwAccess != pHMSrcHandle->dwAccess) {
     
    339366      return TRUE;    // OK
    340367    }
    341 #endif
    342368  }
    343369  else
Note: See TracChangeset for help on using the changeset viewer.