Changeset 3609 for trunk/src


Ignore:
Timestamp:
May 26, 2000, 8:42:57 PM (25 years ago)
Author:
sandervl
Message:

memory map bugfixes + added method for querying image size

Location:
trunk/src/kernel32
Files:
7 edited

Legend:

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

    r3599 r3609  
    1 /* $Id: hmmmap.cpp,v 1.12 2000-05-24 01:56:08 phaller Exp $ */
     1/* $Id: hmmmap.cpp,v 1.13 2000-05-26 18:42:55 sandervl Exp $ */
    22
    33/*
     
    213213        return ERROR_INVALID_HANDLE;
    214214  }
     215  //Although an application may close the file handle used to create a file
     216  //mapping object, the system holds the corresponding file open until the last
     217  //view of the file is unmapped.
    215218  map = (Win32MemMap *)pHMHandleData->dwUserData;
    216   map->Release();
     219  map->close();
    217220
    218221  return NO_ERROR;
  • trunk/src/kernel32/mmap.cpp

    r3602 r3609  
    1 /* $Id: mmap.cpp,v 1.40 2000-05-24 19:28:26 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.41 2000-05-26 18:42:55 sandervl Exp $ */
    22
    33/*
     
    1717 * TODO: Sharing memory mapped files between multiple processes
    1818 * TODO: Memory mapped files with views that extend the file (not 100% correct now)
     19 * TODO: Suspend all threads when a page is committed (possible that another thread
     20 *       accesses the same memory before the page is read from disk
    1921 *
    2022 * Project Odin Software License can be found in LICENSE.TXT
     
    5254//******************************************************************************
    5355Win32MemMap::Win32MemMap(HFILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName)
    54                : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0)
     56               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0),
     57                 fClosed(FALSE)
    5558{
    5659  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
     
    7578//******************************************************************************
    7679Win32MemMap::Win32MemMap(Win32PeLdrImage *pImage, ULONG baseAddress, ULONG size)
    77                : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0)
     80               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0),
     81                 fClosed(FALSE)
    7882{
    7983  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
     
    292296  }
    293297  mapMutex.leave();
     298 
     299  //if there are no more mappings left and the memory map's handle has been
     300  //closed, then delete the object
     301  if(nrMappings == 0 && fClosed) {
     302        delete this;
     303  }
    294304  return TRUE;
    295305fail:
     
    526536                        delete map;
    527537                }
    528                 else    CloseHandle(memmaps->hMemMap);
     538                else {
     539                        if(!map->isClosed())
     540                                CloseHandle(memmaps->hMemMap);
     541                        delete map;
     542                }
    529543        }
    530544        else {
  • trunk/src/kernel32/mmap.h

    r2658 r3609  
    1 /* $Id: mmap.h,v 1.15 2000-02-05 14:09:32 sandervl Exp $ */
     1/* $Id: mmap.h,v 1.16 2000-05-26 18:42:56 sandervl Exp $ */
    22
    33/*
     
    6161   void   Release()                      { if(--referenced == 0) delete this; };
    6262
     63   void   close()                        { fClosed = TRUE; };
     64   BOOL   isClosed()                     { return fClosed; };
     65
    6366   BOOL   commitPage(ULONG offset, BOOL fWriteAccess, int nrpages = NRPAGES_TOCOMMIT);
    6467
     
    97100   LPSTR  lpszMapName;
    98101   void  *pMapping;
     102   BOOL   fClosed;  //handle is removed by CloseHandle
    99103
    100104   ULONG  nrMappings;
  • trunk/src/kernel32/winimagebase.cpp

    r3483 r3609  
    1 /* $Id: winimagebase.cpp,v 1.19 2000-05-02 20:53:14 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.20 2000-05-26 18:42:56 sandervl Exp $ */
    22
    33/*
     
    145145  //dummy
    146146  return FALSE;
     147}
     148//******************************************************************************
     149//******************************************************************************
     150ULONG Win32ImageBase::getImageSize()
     151{
     152  //dummy
     153  return 0;
    147154}
    148155//******************************************************************************
  • trunk/src/kernel32/winimagebase.h

    r3588 r3609  
    1 /* $Id: winimagebase.h,v 1.8 2000-05-22 19:08:00 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.9 2000-05-26 18:42:56 sandervl Exp $ */
    22
    33/*
     
    105105virtual ULONG getApi(int ordinal) = 0;
    106106
     107virtual ULONG getImageSize();
     108
    107109virtual BOOL  isDll() = 0;
    108110
  • trunk/src/kernel32/winimagepeldr.cpp

    r3483 r3609  
    1 /* $Id: winimagepeldr.cpp,v 1.42 2000-05-02 20:53:15 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.43 2000-05-26 18:42:56 sandervl Exp $ */
    22
    33/*
     
    14961496//******************************************************************************
    14971497//******************************************************************************
     1498ULONG Win32PeLdrImage::getImageSize()
     1499{
     1500  return imageSize;
     1501}
     1502//******************************************************************************
     1503//******************************************************************************
    14981504ULONG Win32PeLdrImage::getApi(char *name)
    14991505{
  • trunk/src/kernel32/winimagepeldr.h

    r3483 r3609  
    1 /* $Id: winimagepeldr.h,v 1.2 2000-05-02 20:53:15 sandervl Exp $ */
     1/* $Id: winimagepeldr.h,v 1.3 2000-05-26 18:42:57 sandervl Exp $ */
    22
    33/*
     
    8181        //any dlls are loaded, so that exes without fixups can be loaded at a low
    8282        //address)
    83 virtual BOOL  init(ULONG reservedMem);
     83    virtual BOOL  init(ULONG reservedMem);
    8484
    8585    virtual BOOL  insideModule(ULONG address);
     
    8888    virtual ULONG getApi(char *name);
    8989    virtual ULONG getApi(int ordinal);
     90
     91    virtual ULONG getImageSize();
    9092
    9193    //Returns required OS version for this image
Note: See TracChangeset for help on using the changeset viewer.