Changeset 21302 for trunk/src/kernel32/hmmmap.cpp
- Timestamp:
- Jun 18, 2009, 11:53:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmmmap.cpp
r9971 r21302 74 74 //It's not allowed to map a file of length 0 according to MSDN. This time 75 75 //the docs are correct. (verified in NT4 SP6) 76 //bird: It's not allowed to create a non-file based mapping with size 0. 76 77 //TODO: also need to verify access rights of the file handle (write maps need 77 78 // write access obviously) … … 81 82 dwFileSizeLow = ::GetFileSize(hFile, &dwFileSizeHigh); 82 83 if(dwFileSizeHigh == 0 && dwFileSizeLow == 0) { 84 /* 85 * Two actions, if we can grow the file we should if not fail. 86 */ 87 if (!(protect & PAGE_READWRITE)) /* TODO: check this and verify flags */ 88 { 83 89 dprintf(("CreateFileMappingA: not allowed to map a file with length 0!!")); 84 return ERROR_FILE_INVALID; 90 return ERROR_NOT_ENOUGH_MEMORY; /* XP returns this if the mapping is readonly, odd.. */ 91 } 92 /* 93 * Try extend the file. 94 * (Not sure if we need to preserve the filepointer, but it doesn't hurt I think.) 95 */ 96 LONG lFilePosHigh = 0; 97 DWORD dwFilePosLow = ::SetFilePointer(hFile, 0, &lFilePosHigh, FILE_CURRENT); 98 LONG lFileSizeHigh = size_high; 99 if ( ::SetFilePointer(hFile, size_low, &lFileSizeHigh, FILE_BEGIN) == INVALID_SET_FILE_POINTER 100 || !::SetEndOfFile(hFile)) 101 { 102 ::SetFilePointer(hFile, dwFilePosLow, &lFilePosHigh, FILE_BEGIN); 103 dprintf(("CreateFileMappingA: unable to grow file to 0x%#08x%08x bytes.\n", size_high, size_low)); 104 return ERROR_DISK_FULL; 105 } 106 ::SetFilePointer(hFile, dwFilePosLow, &lFilePosHigh, FILE_BEGIN); 85 107 } 86 108 }
Note:
See TracChangeset
for help on using the changeset viewer.