Changeset 9948 for trunk/src/kernel32/hmmmap.cpp
- Timestamp:
- Mar 27, 2003, 3:19:23 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmmmap.cpp
r9826 r9948 1 /* $Id: hmmmap.cpp,v 1.2 2 2003-02-18 18:58:47sandervl Exp $ */1 /* $Id: hmmmap.cpp,v 1.23 2003-03-27 14:19:23 sandervl Exp $ */ 2 2 3 3 /* … … 58 58 LPCSTR name) /* [in] Name of file-mapping object */ 59 59 { 60 Win32MemMap *map;60 Win32MemMap *map; 61 61 62 62 if((hFile == -1 && size_low == 0) || size_high || … … 70 70 dprintf(("Parameters: %x %x %x %x %s", hFile, protect, size_high, size_low, name)); 71 71 return ERROR_INVALID_PARAMETER; 72 } 73 74 //It's not allowed to map a file of length 0 according to MSDN. This time 75 //the docs are correct. (verified in NT4 SP6) 76 //TODO: also need to verify access rights of the file handle (write maps need 77 // write access obviously) 78 if(hFile != -1) { 79 DWORD dwFileSizeLow = 0, dwFileSizeHigh = 0; 80 81 dwFileSizeLow = ::GetFileSize(hFile, &dwFileSizeHigh); 82 if(dwFileSizeHigh == 0 && dwFileSizeLow == 0) { 83 dprintf(("CreateFileMappingA: not allowed to map a file with length 0!!")); 84 return ERROR_FILE_INVALID; 85 } 72 86 } 73 87 … … 105 119 return ERROR_ALREADY_EXISTS; 106 120 } 107 #if 0 121 108 122 //We reuse the original memory map object if another one is created for 109 123 //the same file handle … … 111 125 map = Win32MemMap::findMapByFile(hFile); 112 126 if(map) { 113 dprintf(("CreateFileMappingA: duplicating map with file %x!", hFile)); 114 115 //if map already exists, we must create a new handle to the existing 116 //map object 117 pHMHandleData->dwUserData = (ULONG)map; 118 pHMHandleData->dwInternalType = HMTYPE_MEMMAP; 119 120 //findMap already incremented the reference count, so we simply don't 121 //release it here 122 return ERROR_SUCCESS; 123 } 124 #endif 127 Win32MemMapDup *dupmap; 128 129 dprintf(("CreateFileMappingA: duplicating map with file %x!", hFile)); 130 131 dupmap = new Win32MemMapDup(map, hFile, size_low, protect, (LPSTR)name); 132 133 if(dupmap == NULL) { 134 dprintf(("CreateFileMappingA: can't create Win32MemMap object!")); 135 return ERROR_OUTOFMEMORY; 136 } 137 map->Release(); //findMapByFile increases the refcount, so decrease it here 138 map = dupmap; 139 } 125 140 else { 126 map = new Win32MemMap(hFile, size_low, protect, (LPSTR)name); 127 128 if(map == NULL) { 129 dprintf(("CreateFileMappingA: can't create Win32MemMap object!")); 130 return ERROR_OUTOFMEMORY; 131 } 132 133 if(map->Init(size_low) == FALSE) { 134 dprintf(("CreateFileMappingA: init failed!")); 135 delete map; 136 return ERROR_GEN_FAILURE; 137 } 141 map = new Win32MemMap(hFile, size_low, protect, (LPSTR)name); 142 143 if(map == NULL) { 144 dprintf(("CreateFileMappingA: can't create Win32MemMap object!")); 145 return ERROR_OUTOFMEMORY; 146 } 147 } 148 if(map->Init(size_low) == FALSE) { 149 dprintf(("CreateFileMappingA: init failed!")); 150 delete map; 151 return ERROR_GEN_FAILURE; 138 152 } 139 153 pHMHandleData->dwUserData = (ULONG)map;
Note:
See TracChangeset
for help on using the changeset viewer.