Ignore:
Timestamp:
May 6, 2003, 2:06:11 PM (22 years ago)
Author:
sandervl
Message:

Fixed closing of parent file handle by duplicate memory map; Compare file names instead of handles when checking for duplicate file maps

File:
1 edited

Legend:

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

    r9971 r10073  
    1 /* $Id: mmap.cpp,v 1.65 2003-04-02 11:03:31 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.66 2003-05-06 12:06:10 sandervl Exp $ */
    22
    33/*
     
    7575Win32MemMap::Win32MemMap(HANDLE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName)
    7676               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0),
    77                  image(0), pWriteBitmap(NULL)
     77                 image(0), pWriteBitmap(NULL), lpszFileName(NULL)
    7878{
    7979    DosEnterCriticalSection(&globalmapcritsect);
     
    101101Win32MemMap::Win32MemMap(Win32PeLdrImage *pImage, ULONG baseAddress, ULONG size)
    102102               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0),
    103                  image(0), pWriteBitmap(NULL)
     103                 image(0), pWriteBitmap(NULL), lpszFileName(NULL)
    104104{
    105105    DosEnterCriticalSection(&globalmapcritsect);
     
    127127    if(hMemFile != -1)
    128128    {
     129        lpszFileName = (char *)_smalloc(MMAP_MAX_FILENAME_LENGTH);
     130        if(HMGetFileNameFromHandle(hMemFile, lpszFileName, MMAP_MAX_FILENAME_LENGTH) == FALSE) {
     131            return FALSE;
     132        }
    129133#if 0
    130134        if(DuplicateHandle(GetCurrentProcess(), hMemFile, GetCurrentProcess(),
     
    181185    if(lpszMapName) {
    182186        free(lpszMapName);
     187    }
     188    if(lpszFileName) {
     189        free(lpszFileName);
    183190    }
    184191    if(pMapping && !image) {
     
    917924Win32MemMap *Win32MemMap::findMapByFile(HANDLE hFile)
    918925{
     926  DWORD processId = GetCurrentProcessId();
     927  char  szFileName[260];
     928
    919929  if(hFile == -1)
     930    return NULL;
     931
     932  if(HMGetFileNameFromHandle(hFile, szFileName, sizeof(szFileName)) == FALSE)
    920933    return NULL;
    921934
     
    926939  {
    927940    while(map) {
    928         if(map->hOrgMemFile == hFile)
    929             break;
     941        //TODO: we currently don't support sharing file maps between processes
     942        if(map->mProcessId == processId && map->lpszFileName)
     943        {
     944            if(!strcmp(map->lpszFileName, szFileName))
     945                break;
     946        }
    930947        map = map->next;
    931948    }
Note: See TracChangeset for help on using the changeset viewer.