Changeset 673 for trunk/src/kernel32/virtual.cpp
- Timestamp:
- Aug 25, 1999, 10:57:14 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/virtual.cpp
r657 r673 1 /* $Id: virtual.cpp,v 1. 2 1999-08-24 12:23:25 sandervlExp $ */1 /* $Id: virtual.cpp,v 1.3 1999-08-25 08:55:19 phaller Exp $ */ 2 2 3 3 /* … … 20 20 #include <heapstring.h> 21 21 #include "mmap.h" 22 #include <handlemanager.h> 22 23 23 24 /*********************************************************************** … … 38 39 LPCSTR name /* [in] Name of file-mapping object */ ) 39 40 { 40 HANDLE dupHandle; 41 42 if((hFile == -1 && size_low == 0) || size_high || 43 protect & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|SEC_COMMIT|SEC_IMAGE|SEC_RESERVE|SEC_NOCACHE) || 44 ((protect & SEC_COMMIT) && (protect & SEC_RESERVE))) 45 { 46 47 dprintf(("CreateFileMappingA: invalid parameter (combination)!")); 48 SetLastError(ERROR_INVALID_PARAMETER); 49 return 0; 50 } 51 if(DuplicateHandle(GetCurrentProcess(), hFile, GetCurrentProcess(), 52 &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE) 53 { 54 dprintf(("CreateFileMappingA: DuplicateHandle failed!")); 55 return 0; 56 } 57 return dupHandle; 41 return HMCreateFileMapping(hFile, sa, protect, size_high, size_low, name); 58 42 } 59 43 … … 63 47 * See CreateFileMapping32A 64 48 */ 65 HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES attr, 66 DWORD protect, DWORD size_high, 49 HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES attr, 50 DWORD protect, DWORD size_high, 67 51 DWORD size_low, LPCWSTR name ) 68 52 { … … 88 72 LPCSTR name ) /* [in] Name of file-mapping object */ 89 73 { 90 dprintf(("OpenFileMappingA: NOT IMPLEMENTED")); 91 return 0; 74 return (HMOpenFileMapping(access, inherit, name)); 92 75 } 93 76 … … 120 103 DWORD offset_low, /* [in] Low-order 32 bits of file offset */ 121 104 DWORD count /* [in] Number of bytes to map */ 122 ) 123 { 124 return MapViewOfFileEx( mapping, access, offset_high,125 offset_low, count, NULL);105 ) 106 { 107 return HMMapViewOfFile( mapping, access, offset_high, 108 offset_low, count); 126 109 } 127 110 … … 142 125 DWORD count, /* [in] Number of bytes to map */ 143 126 LPVOID addr /* [in] Suggested starting address for mapped view */ 144 ) 145 { 146 DWORD filesize, bytesread; 147 LPSTR lpBuffer; 148 149 filesize = GetFileSize(handle, 0); 150 if(filesize == 0) { 151 dprintf(("MapViewOfFileEx: filesize = 0!")); 152 return 0; 153 } 154 lpBuffer = (LPSTR)VirtualAlloc(0, filesize, MEM_COMMIT, PAGE_READWRITE); 155 if(lpBuffer == 0) { 156 dprintf(("MapViewOfFileEx: VirtualAlloc failed (%d bytes)!", filesize)); 157 return 0; 158 } 159 if(ReadFile(handle, lpBuffer, filesize, &bytesread, NULL) == FALSE) { 160 dprintf(("MapViewOfFileEx: ReadFile failed (%d bytes)!", filesize)); 161 VirtualFree(lpBuffer, 0, MEM_RELEASE); 162 return 0; 163 } 164 return lpBuffer; 127 ) 128 { 129 return HMMapViewOfFileEx( handle, access, offset_high, 130 offset_low, count, addr); 165 131 } 166 132 … … 177 143 LPCVOID base, /* [in] Start address of byte range to flush */ 178 144 DWORD cbFlush /* [in] Number of bytes in range */ 179 ) 180 { 181 dprintf(("FlushViewOfFile: NOT IMPLEMENTED")); 182 return TRUE; 145 ) 146 { 147 return HMFlushViewOfFile( (LPVOID)base, cbFlush); 183 148 } 184 149 … … 196 161 */ 197 162 BOOL WINAPI UnmapViewOfFile(LPVOID addr /* [in] Address where mapped view begins */ 198 ) 199 { 200 if (!addr) 201 { 202 SetLastError( ERROR_INVALID_PARAMETER ); 203 return FALSE; 204 } 205 return VirtualFree(addr, 0, MEM_RELEASE); 206 } 163 ) 164 { 165 return HMUnmapViewOfFile( addr ); 166 } 167 207 168 208 169 /*********************************************************************** … … 210 171 * 211 172 * Helper function to map a file to memory: 212 * name - file name 173 * name - file name 213 174 * [RETURN] ptr - pointer to mapped file 214 175 */ … … 218 179 LPVOID ptr = NULL; 219 180 220 hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, 181 hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, 221 182 OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0); 222 183 if (hFile != INVALID_HANDLE_VALUE) … … 237 198 * 238 199 * Helper function to map a file to memory: 239 * name - file name 200 * name - file name 240 201 * [RETURN] ptr - pointer to mapped file 241 202 */ … … 245 206 LPVOID ptr = NULL; 246 207 247 hFile = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL, 208 hFile = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL, 248 209 OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0); 249 210 if (hFile != INVALID_HANDLE_VALUE) … … 259 220 return ptr; 260 221 } 222
Note:
See TracChangeset
for help on using the changeset viewer.