Changeset 664 for trunk/src/kernel32
- Timestamp:
- Aug 24, 1999, 8:48:10 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r659 r664 1 /* $Id: HandleManager.cpp,v 1.1 2 1999-08-24 14:36:04 phallerExp $ */1 /* $Id: HandleManager.cpp,v 1.13 1999-08-24 18:46:38 sandervl Exp $ */ 2 2 3 3 /* … … 56 56 #include "HMMutex.h" 57 57 #include "HMSemaphore.h" 58 #include "HMFileMapping.h" 59 58 #include "HMMMap.h" 60 59 61 60 /***************************************************************************** … … 122 121 HMDeviceHandler *pHMMutex; 123 122 HMDeviceHandler *pHMSemaphore; 124 HMDeviceHandler *pHMFileMapping; 123 HMDeviceHandler *pHMFileMapping; /* static instances of subsystems */ 125 124 126 125 ULONG ulHandleLast; /* index of last used handle */ … … 197 196 { 198 197 /* free handle found ? */ 199 if (INVALID_HANDLE_VALUE == TabWin32Handles[ulLoop].hmHandleData.hHMHandle) 200 return (ulLoop); /* OK, then return it to the caller */ 198 if (INVALID_HANDLE_VALUE == TabWin32Handles[ulLoop].hmHandleData.hHMHandle) { 199 TabWin32Handles[ulLoop].hmHandleData.dwUserData = 0; 200 TabWin32Handles[ulLoop].hmHandleData.dwInternalType = HMTYPE_UNKNOWN; 201 return (ulLoop); /* OK, then return it to the caller */ 202 } 201 203 } 202 204 … … 313 315 314 316 /* create handle manager instance for Open32 handles */ 315 HMGlobals.pHMOpen32 316 HMGlobals.pHMEvent 317 HMGlobals.pHMMutex 318 HMGlobals.pHMSemaphore 319 HMGlobals.pHMFileMapping = new HMDeviceFileMappingClass("\\\\FILEMAPPING\\");317 HMGlobals.pHMOpen32 = new HMDeviceOpen32Class("\\\\.\\"); 318 HMGlobals.pHMEvent = new HMDeviceEventClass("\\\\EVENT\\"); 319 HMGlobals.pHMMutex = new HMDeviceMutexClass("\\\\MUTEX\\"); 320 HMGlobals.pHMSemaphore = new HMDeviceSemaphoreClass("\\\\SEM\\"); 321 HMGlobals.pHMFileMapping = new HMDeviceMemMapClass("\\\\MEMMAP\\"); 320 322 } 321 323 return (NO_ERROR); … … 2151 2153 2152 2154 /***************************************************************************** 2153 * Name : HMWaitForMultipleObjects2154 * Purpose : router function for WaitForMultipleObjects2155 * Parameters:2156 * Variables :2157 * Result :2158 * Remark :2159 * Status :2160 *2161 * Author : Patrick Haller [Wed, 1999/06/17 20:44]2162 *****************************************************************************/2163 2164 DWORD HMWaitForMultipleObjects (DWORD cObjects,2165 PHANDLE lphObjects,2166 BOOL fWaitAll,2167 DWORD dwTimeout)2168 {2169 ULONG ulIndex;2170 PHANDLE pArrayOfHandles;2171 PHANDLE pLoop1 = lphObjects;2172 PHANDLE pLoop2;2173 DWORD rc;2174 2175 // allocate array for handle table2176 pArrayOfHandles = (PHANDLE)malloc(cObjects * sizeof(HANDLE));2177 if (pArrayOfHandles == NULL)2178 {2179 O32_SetLastError(ERROR_NOT_ENOUGH_MEMORY);2180 return WAIT_FAILED;2181 }2182 else2183 pLoop2 = pArrayOfHandles;2184 2185 // convert array to odin handles2186 for (ulIndex = 0;2187 2188 ulIndex < cObjects;2189 2190 ulIndex++,2191 pLoop1++,2192 pLoop2++)2193 {2194 rc = HMHandleTranslateToOS2 (*pLoop1, // translate handle2195 pLoop2);2196 2197 if (rc != NO_ERROR)2198 {2199 free (pArrayOfHandles); // free memory2200 O32_SetLastError(ERROR_INVALID_HANDLE);2201 return (WAIT_FAILED);2202 }2203 }2204 2205 // OK, now forward to Open32.2206 // @@@PH: Note this will fail on handles that do NOT belong to Open322207 // but to i.e. the console subsystem!2208 rc = O32_WaitForMultipleObjects(cObjects,2209 pArrayOfHandles,2210 fWaitAll,2211 dwTimeout);2212 2213 free(pArrayOfHandles); // free memory2214 return (rc); // OK, done2215 }2216 2217 2218 /*****************************************************************************2219 * Name : HMWaitForMultipleObjectsEx2220 * Purpose : router function for WaitForMultipleObjectsEx2221 * Parameters:2222 * Variables :2223 * Result :2224 * Remark :2225 * Status :2226 *2227 * Author : Patrick Haller [Wed, 1999/06/17 20:44]2228 *****************************************************************************/2229 2230 DWORD HMWaitForMultipleObjectsEx (DWORD cObjects,2231 PHANDLE lphObjects,2232 BOOL fWaitAll,2233 DWORD dwTimeout,2234 BOOL fAlertable)2235 {2236 // @@@PH: Note: fAlertable is ignored !2237 return (HMWaitForMultipleObjects(cObjects,2238 lphObjects,2239 fWaitAll,2240 dwTimeout));2241 }2242 2243 2244 /*****************************************************************************2245 2155 * Name : HANDLE HMCreateFileMapping 2246 2156 * Purpose : Wrapper for the CreateFileMapping() API … … 2350 2260 } 2351 2261 2352 2353 /* initialize the complete HMHANDLEDATA structure */ 2262 /* initialize the complete HMHANDLEDATA structure */ 2354 2263 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2355 2264 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ … … 2361 2270 2362 2271 2363 2364 2365 2366 2272 /* we've got to mark the handle as occupied here, since another device */ 2273 /* could be created within the device handler -> deadlock */ 2274 2275 /* write appropriate entry into the handle table if open succeeded */ 2367 2276 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 2368 2277 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; … … 2370 2279 /* call the device handler */ 2371 2280 rc = pDeviceHandler->OpenFileMapping(&TabWin32Handles[iIndexNew].hmHandleData, 2281 fdwAccess, 2372 2282 fInherit, 2373 2283 lpName); … … 2381 2291 return iIndexNew; /* return valid handle */ 2382 2292 } 2383 2384 2385 /*****************************************************************************2386 * Name : HMMapViewOfFile2387 * Purpose : router function for MapViewOfFile2388 * Parameters:2389 * Variables :2390 * Result :2391 * Remark :2392 * Status :2393 *2394 * Author : Patrick Haller [Wed, 1999/06/17 20:44]2395 *****************************************************************************/2396 2397 LPVOID HMMapViewOfFile(HANDLE hFileMappingObject,2398 DWORD dwDesiredAccess,2399 DWORD dwFileOffsetHigh,2400 DWORD dwFileOffsetLow,2401 DWORD dwNumberOfBytesToMap)2402 {2403 int iIndex; /* index into the handle table */2404 LPVOID lpResult; /* result from the device handler's API */2405 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */2406 2407 /* validate handle */2408 iIndex = _HMHandleQuery(hFileMappingObject); /* get the index */2409 if (-1 == iIndex) /* error ? */2410 {2411 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */2412 return (NULL); /* signal failure */2413 }2414 2415 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */2416 lpResult = pHMHandle->pDeviceHandler->MapViewOfFile(&pHMHandle->hmHandleData,2417 dwDesiredAccess,2418 dwFileOffsetHigh,2419 dwFileOffsetLow,2420 dwNumberOfBytesToMap);2421 2422 return (lpResult); /* deliver return code */2423 }2424 2425 2293 2426 2294 … … 2458 2326 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2459 2327 lpResult = pHMHandle->pDeviceHandler->MapViewOfFileEx(&pHMHandle->hmHandleData, 2460 2461 2462 2463 2464 2328 dwDesiredAccess, 2329 dwFileOffsetHigh, 2330 dwFileOffsetLow, 2331 dwNumberOfBytesToMap, 2332 lpBaseAddress); 2465 2333 2466 2334 return (lpResult); /* deliver return code */ 2467 2335 } 2468 2336 2469 2470 /***************************************************************************** 2471 * Name : HMUnmapViewOfFile 2472 * Purpose : router function for UnmapViewOfFile 2473 * Parameters: 2474 * Variables : 2475 * Result : 2476 * Remark : No handle is specified, that makes things a bit more difficult! 2477 * We've got to identify the object by the base address and check 2478 * back with HandleManager manually! 2337 /***************************************************************************** 2338 * Name : HMWaitForMultipleObjects 2339 * Purpose : router function for WaitForMultipleObjects 2340 * Parameters: 2341 * Variables : 2342 * Result : 2343 * Remark : 2479 2344 * Status : 2480 2345 * … … 2482 2347 *****************************************************************************/ 2483 2348 2484 BOOL HMUnmapViewOfFile(LPVOID lpBaseAddress) 2485 { 2486 int iIndex; /* index into the handle table */ 2487 BOOL flResult; /* result from the device handler's API */ 2488 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 2489 2490 // Identify the correct handle by the base address. Thus call a special 2491 // static function within the FileMapping class. 2492 iIndex = HMDeviceFileMappingClass::findByBaseAddress(lpBaseAddress); /* validate handle */ 2493 if (-1 == iIndex) /* error ? */ 2494 { 2495 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 2496 return (FALSE); /* signal failure */ 2497 } 2498 2499 flResult = pHMHandle->pDeviceHandler->UnmapViewOfFile(&pHMHandle->hmHandleData, 2500 lpBaseAddress); 2501 2502 // @@@PH automatically call CloseHandle of no more references to the object 2503 // are active. 2504 2505 return (flResult); /* deliver return code */ 2506 } 2507 2508 2509 /***************************************************************************** 2510 * Name : HMFlushViewOfFile 2511 * Purpose : router function for FlushViewOfFile 2512 * Parameters: 2513 * Variables : 2514 * Result : 2515 * Remark : No handle is specified, that makes things a bit more difficult! 2516 * We've got to identify the object by the base address and check 2517 * back with HandleManager manually! 2349 DWORD HMWaitForMultipleObjects (DWORD cObjects, 2350 PHANDLE lphObjects, 2351 BOOL fWaitAll, 2352 DWORD dwTimeout) 2353 { 2354 ULONG ulIndex; 2355 PHANDLE pArrayOfHandles; 2356 PHANDLE pLoop1 = lphObjects; 2357 PHANDLE pLoop2; 2358 DWORD rc; 2359 2360 // allocate array for handle table 2361 pArrayOfHandles = (PHANDLE)malloc(cObjects * sizeof(HANDLE)); 2362 if (pArrayOfHandles == NULL) 2363 { 2364 O32_SetLastError(ERROR_NOT_ENOUGH_MEMORY); 2365 return WAIT_FAILED; 2366 } 2367 else 2368 pLoop2 = pArrayOfHandles; 2369 2370 // convert array to odin handles 2371 for (ulIndex = 0; 2372 2373 ulIndex < cObjects; 2374 2375 ulIndex++, 2376 pLoop1++, 2377 pLoop2++) 2378 { 2379 rc = HMHandleTranslateToOS2 (*pLoop1, // translate handle 2380 pLoop2); 2381 2382 if (rc != NO_ERROR) 2383 { 2384 free (pArrayOfHandles); // free memory 2385 O32_SetLastError(ERROR_INVALID_HANDLE); 2386 return (WAIT_FAILED); 2387 } 2388 } 2389 2390 // OK, now forward to Open32. 2391 // @@@PH: Note this will fail on handles that do NOT belong to Open32 2392 // but to i.e. the console subsystem! 2393 rc = O32_WaitForMultipleObjects(cObjects, 2394 pArrayOfHandles, 2395 fWaitAll, 2396 dwTimeout); 2397 2398 free(pArrayOfHandles); // free memory 2399 return (rc); // OK, done 2400 } 2401 2402 2403 /***************************************************************************** 2404 * Name : HMWaitForMultipleObjectsEx 2405 * Purpose : router function for WaitForMultipleObjectsEx 2406 * Parameters: 2407 * Variables : 2408 * Result : 2409 * Remark : 2518 2410 * Status : 2519 2411 * … … 2521 2413 *****************************************************************************/ 2522 2414 2523 BOOL HMFlushViewOfFile(LPVOID lpBaseAddress, 2524 DWORD dwNumberOfBytesToFlush) 2525 { 2526 int iIndex; /* index into the handle table */ 2527 BOOL flResult; /* result from the device handler's API */ 2528 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 2529 2530 // Identify the correct handle by the base address. Thus call a special 2531 // static function within the FileMapping class. 2532 iIndex = HMDeviceFileMappingClass::findByBaseAddress(lpBaseAddress); /* validate handle */ 2533 if (-1 == iIndex) /* error ? */ 2534 { 2535 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 2536 return (FALSE); /* signal failure */ 2537 } 2538 2539 flResult = pHMHandle->pDeviceHandler->FlushViewOfFile(&pHMHandle->hmHandleData, 2540 lpBaseAddress, 2541 dwNumberOfBytesToFlush); 2542 2543 return (flResult); /* deliver return code */ 2544 } 2415 DWORD HMWaitForMultipleObjectsEx (DWORD cObjects, 2416 PHANDLE lphObjects, 2417 BOOL fWaitAll, 2418 DWORD dwTimeout, 2419 BOOL fAlertable) 2420 { 2421 // @@@PH: Note: fAlertable is ignored ! 2422 return (HMWaitForMultipleObjects(cObjects, 2423 lphObjects, 2424 fWaitAll, 2425 dwTimeout)); 2426 } 2427 -
trunk/src/kernel32/hmdevice.cpp
r659 r664 1 /* $Id: hmdevice.cpp,v 1. 3 1999-08-24 14:36:05 phallerExp $ */1 /* $Id: hmdevice.cpp,v 1.4 1999-08-24 18:46:39 sandervl Exp $ */ 2 2 3 3 /* … … 890 890 pHMHandleData->hHMHandle)); 891 891 892 return( FALSE);892 return(ERROR_INVALID_FUNCTION); 893 893 } 894 894 … … 920 920 arg4)); 921 921 922 return(FALSE); 923 } 924 922 return(ERROR_INVALID_FUNCTION); 923 } 925 924 926 925 /***************************************************************************** … … 978 977 979 978 DWORD HMDeviceHandler::OpenFileMapping(PHMHANDLEDATA pHMHandleData, 979 DWORD fdwAccess, 980 980 BOOL fInherit, 981 981 LPCTSTR lpName) 982 982 { 983 dprintf(("KERNEL32: HandleManager::DeviceHandler::OpenFileMapping(%08xh,%08xh,%08xh )\n",983 dprintf(("KERNEL32: HandleManager::DeviceHandler::OpenFileMapping(%08xh,%08xh,%08xh,%08xh)\n", 984 984 pHMHandleData->hHMHandle, 985 fdwAccess, 985 986 fInherit, 986 987 lpName)); … … 988 989 return(ERROR_INVALID_FUNCTION); 989 990 } 990 991 991 992 992 /***************************************************************************** … … 1006 1006 *****************************************************************************/ 1007 1007 1008 LPVOID HMDeviceHandler::MapViewOfFile (PHMHANDLEDATA pHMHandleData,1008 LPVOID HMDeviceHandler::MapViewOfFileEx(PHMHANDLEDATA pHMHandleData, 1009 1009 DWORD dwDesiredAccess, 1010 1010 DWORD dwFileOffsetHigh, 1011 1011 DWORD dwFileOffsetLow, 1012 DWORD dwNumberOfBytesToMap) 1013 { 1014 dprintf(("KERNEL32: HandleManager::DeviceHandler::MapViewOfFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n", 1015 pHMHandleData->hHMHandle, 1016 dwDesiredAccess, 1017 dwFileOffsetHigh, 1018 dwFileOffsetLow, 1019 dwNumberOfBytesToMap)); 1020 1021 return(NULL); 1022 } 1023 1024 1025 /***************************************************************************** 1026 * Name : DWORD HMDeviceHandler::MapViewOfFileEx 1027 * Purpose : map memory mapped file 1028 * Parameters: PHMHANDLEDATA pHMHandleData 1029 * DWORD dwDesiredAccess, 1030 * DWORD dwFileOffsetHigh, 1031 * DWORD dwFileOffsetLow, 1032 * DWORD dwNumberOfBytesToMap 1033 * LPVOID lpBaseAddress 1034 * Variables : 1035 * Result : address to memory mapped region 1036 * Remark : 1037 * Status : 1038 * 1039 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1040 *****************************************************************************/ 1041 1042 LPVOID HMDeviceHandler::MapViewOfFileEx(PHMHANDLEDATA pHMHandleData, 1043 DWORD dwDesiredAccess, 1044 DWORD dwFileOffsetHigh, 1045 DWORD dwFileOffsetLow, 1046 DWORD dwNumberOfBytesToMap, 1047 LPVOID lpBaseAddress) 1012 DWORD dwNumberOfBytesToMap, 1013 LPVOID lpBaseAddress) 1048 1014 { 1049 1015 dprintf(("KERNEL32: HandleManager::DeviceHandler::MapViewOfFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", … … 1052 1018 dwFileOffsetHigh, 1053 1019 dwFileOffsetLow, 1054 dwNumberOfBytesToMap, 1055 lpBaseAddress)); 1020 dwNumberOfBytesToMap, lpBaseAddress)); 1056 1021 1057 1022 return(NULL); 1058 1023 } 1059 1060 1061 /*****************************************************************************1062 * Name : DWORD HMDeviceHandler::UnmapViewOfFile1063 * Purpose : unmap memory mapped file1064 * Parameters: PHMHANDLEDATA pHMHandleData1065 * LPVOID lpBaseAddress1066 * Variables :1067 * Result : TRUE / FALSE1068 * Remark :1069 * Status :1070 *1071 * Author : Patrick Haller [Wed, 1999/06/17 20:44]1072 *****************************************************************************/1073 1074 BOOL HMDeviceHandler::UnmapViewOfFile(PHMHANDLEDATA pHMHandleData,1075 LPVOID lpBaseAddress)1076 {1077 dprintf(("KERNEL32: HandleManager::DeviceHandler::UnmapViewOfFile(%08xh,%08xh)\n",1078 pHMHandleData->hHMHandle,1079 lpBaseAddress));1080 1081 return(FALSE);1082 }1083 1084 1085 /*****************************************************************************1086 * Name : DWORD HMDeviceHandler::FlushViewOfFile1087 * Purpose : flush memory mapped file1088 * Parameters: PHMHANDLEDATA pHMHandleData1089 * LPVOID lpBaseAddress1090 * DWORD dwNumberOfBytesToFlush1091 * Variables :1092 * Result : TRUE / FALSE1093 * Remark :1094 * Status :1095 *1096 * Author : Patrick Haller [Wed, 1999/06/17 20:44]1097 *****************************************************************************/1098 1099 BOOL HMDeviceHandler::FlushViewOfFile(PHMHANDLEDATA pHMHandleData,1100 LPVOID lpBaseAddress,1101 DWORD dwNumberOfBytesToFlush)1102 {1103 dprintf(("KERNEL32: HandleManager::DeviceHandler::FlushViewOfFile(%08xh,%08xh,%08xh)\n",1104 pHMHandleData->hHMHandle,1105 lpBaseAddress,1106 dwNumberOfBytesToFlush));1107 1108 return(FALSE);1109 }1110 -
trunk/src/kernel32/hmdevice.h
r659 r664 1 /* $Id: hmdevice.h,v 1. 4 1999-08-24 14:36:05 phallerExp $ */1 /* $Id: hmdevice.h,v 1.5 1999-08-24 18:46:39 sandervl Exp $ */ 2 2 3 3 /* … … 21 21 *****************************************************************************/ 22 22 23 /***************************************************************************** 24 * defines * 25 *****************************************************************************/ 26 27 #define HMTYPE_UNKNOWN 0 28 #define HMTYPE_MEMMAP 1 29 //..... 23 30 24 31 /***************************************************************************** … … 36 43 DWORD dwCreation; /* dwCreationDisposition */ 37 44 DWORD dwFlags; /* flags and attributes */ 45 46 DWORD dwUserData; 47 DWORD dwInternalType; 38 48 39 49 LPVOID lpHandlerData; /* for private use of the device handler */ … … 239 249 LPLONG lpPreviousCount); 240 250 241 242 /***************************************************************************243 * File Mappings *244 ***************************************************************************/245 246 251 /* this is a handler method for calls to CreateFileMapping() */ 247 252 virtual DWORD CreateFileMapping (PHMHANDLEDATA pHMHandleData, … … 251 256 DWORD dwMaximumSizeHigh, 252 257 DWORD dwMaximumSizeLow, 253 LPC TSTRlpName);258 LPCSTR lpName); 254 259 255 260 /* this is a handler method for calls to OpenFileMapping() */ 256 261 virtual DWORD OpenFileMapping (PHMHANDLEDATA pHMHandleData, 262 DWORD access, /* [in] Access mode */ 257 263 BOOL fInherit, 258 LPCTSTR lpName); 259 260 /* this is a handler method for calls to MapViewOfFile() */ 261 virtual LPVOID MapViewOfFile (PHMHANDLEDATA pHMHandleData, 262 DWORD dwDesiredAccess, 263 DWORD dwFileOffsetHigh, 264 DWORD dwFileOffsetLow, 265 DWORD dwNumberOfBytesToMap); 266 267 /* this is a handler method for calls to MapViewOfFileEx() */ 264 LPCSTR lpName); 265 266 /* this is a handler method for calls to MapViewOfFileEx() */ 268 267 virtual LPVOID MapViewOfFileEx (PHMHANDLEDATA pHMHandleData, 269 268 DWORD dwDesiredAccess, … … 271 270 DWORD dwFileOffsetLow, 272 271 DWORD dwNumberOfBytesToMap, 273 LPVOID lpBaseAddress); 274 275 /* this is a handler method for calls to UnmapViewOfFile() */ 276 virtual BOOL UnmapViewOfFile (PHMHANDLEDATA pHMHandleData, 277 LPVOID lpBaseAddress); 278 279 /* this is a handler method for calls to FlushViewOfFile() */ 280 virtual BOOL FlushViewOfFile (PHMHANDLEDATA pHMHandleData, 281 LPVOID lpBaseAddress, 282 DWORD dwNumberOfBytesToFlush); 272 LPVOID lpBaseAddress); 283 273 284 274 }; -
trunk/src/kernel32/makefile
r659 r664 1 # $Id: makefile,v 1.2 8 1999-08-24 14:36:05 phallerExp $1 # $Id: makefile,v 1.29 1999-08-24 18:46:39 sandervl Exp $ 2 2 3 3 # … … 27 27 WIN32UTIL.OBJ heap.OBJ heapstring.obj os2heap.OBJ \ 28 28 vmutex.OBJ initterm.OBJ os2util.OBJ handlemanager.OBJ \ 29 hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj hmfilemapping.obj\29 hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj \ 30 30 hmmutex.obj hmsemaphore.obj wprocess.OBJ conprop.OBJ \ 31 31 winimage.OBJ windll.OBJ winexe.OBJ time.obj mmap.obj \ 32 32 pefile.OBJ winimgres.OBJ wintls.obj async.OBJ fileio.obj \ 33 atom.obj disk.obj directory.obj cvtbitmap.obj \33 atom.obj disk.obj directory.obj cvtbitmap.obj hmmmap.obj \ 34 34 cvtmenu.obj cvtaccel.obj cvticon.obj cvticongrp.obj \ 35 cvtcursor.obj cvtcursorgrp.obj stubs.obj 35 cvtcursor.obj cvtcursorgrp.obj stubs.obj 36 36 37 37 … … 251 251 handlemanager.OBJ: \ 252 252 .\handlemanager.cpp \ 253 .\hmevent.h \ 254 .\hmmutex.h \ 255 .\hmopen32.h \ 256 .\hmsemaphore.h \ 257 .\hmmmap.h \ 253 258 $(PDWIN32_INCLUDE)\handlemanager.h 254 259 … … 286 291 .\hmopen32.h 287 292 288 hmfilemapping.obj: \ 289 .\hmfilemapping.cpp \ 290 .\hmfilemapping.h \ 291 .\hmdevice.h 293 hmmmap.obj: hmmmap.cpp hmdevice.h hmopen32.h mmap.h 292 294 293 295 conprop.OBJ: \ … … 301 303 $(PDWIN32_INCLUDE)\unicode.h 302 304 303 virtual.obj: virtual.cpp $(PDWIN32_INCLUDE)\win\virtual.h mmap.h305 virtual.obj: virtual.cpp $(PDWIN32_INCLUDE)\win\virtual.h $(PDWIN32_INCLUDE)\handlemanager.h 304 306 mmap.obj: mmap.cpp mmap.h $(PDWIN32_INCLUDE)\vmutex.h 305 307 -
trunk/src/kernel32/mmap.cpp
r657 r664 1 /* $Id: mmap.cpp,v 1. 7 1999-08-24 12:23:54sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.8 1999-08-24 18:46:40 sandervl Exp $ */ 2 2 3 3 /* … … 36 36 //****************************************************************************** 37 37 Win32MemMap::Win32MemMap(HFILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName) 38 : fMapped(FALSE), pMapping(NULL), mMapAccess(0) 38 : fMapped(FALSE), pMapping(NULL), mMapAccess(0), referenced(0) 39 39 { 40 40 globalmapMutex.enter(); … … 56 56 //****************************************************************************** 57 57 //****************************************************************************** 58 HANDLE Win32MemMap::Init()58 BOOL Win32MemMap::Init(HANDLE hMemMap) 59 59 { 60 60 mapMutex.enter(); … … 68 68 } 69 69 } 70 if(HMHandleAllocate(&hMemMap, (ULONG)this) != 0) 71 { 72 dprintf(("Win32MemMap::Init HMHandleAllocate failed!!")); 73 DebugInt3(); 74 goto fail; 75 } 76 mapMutex.leave(); 77 return hMemMap; 70 this->hMemMap = hMemMap; 71 mapMutex.leave(); 72 return TRUE; 78 73 fail: 79 74 mapMutex.leave(); 80 return 0;75 return FALSE; 81 76 } 82 77 //****************************************************************************** … … 84 79 Win32MemMap::~Win32MemMap() 85 80 { 86 unmap FileView();81 unmapViewOfFile(); 87 82 if(lpszMapName) { 88 83 free(lpszMapName); … … 120 115 //****************************************************************************** 121 116 //****************************************************************************** 122 BOOL Win32MemMap::unmap FileView()117 BOOL Win32MemMap::unmapViewOfFile() 123 118 { 124 119 if(fMapped == FALSE) … … 137 132 //****************************************************************************** 138 133 //****************************************************************************** 139 LPVOID Win32MemMap::map FileView(ULONG size, ULONG offset, ULONG fdwAccess)134 LPVOID Win32MemMap::mapViewOfFile(ULONG size, ULONG offset, ULONG fdwAccess) 140 135 { 141 136 mapMutex.enter(); 142 137 ULONG memFlags = (mProtFlags & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY)); 143 138 ULONG fAlloc = 0; 144 145 if(fdwAccess & FILE_MAP_WRITE && mProtFlags & (PAGE_READONLY|PAGE_WRITECOPY)) 146 goto parmfail; 147 if(fdwAccess & FILE_MAP_READ && mProtFlags & PAGE_WRITECOPY) 148 goto parmfail; 149 if(fdwAccess & FILE_MAP_ALL_ACCESS && mProtFlags & (PAGE_READONLY|PAGE_WRITECOPY)) 150 goto parmfail; 151 if(fdwAccess & FILE_MAP_COPY && mProtFlags & PAGE_WRITECOPY) 139 LPVOID mapview; 140 141 if(fdwAccess & (FILE_MAP_WRITE|FILE_MAP_ALL_ACCESS) && !(mProtFlags & PAGE_READWRITE)) 142 goto parmfail; 143 if(fdwAccess & FILE_MAP_READ && !(mProtFlags & (PAGE_READWRITE|PAGE_READONLY))) 144 goto parmfail; 145 if(fdwAccess & FILE_MAP_COPY && !(mProtFlags & PAGE_WRITECOPY)) 152 146 goto parmfail; 153 147 … … 157 151 fAlloc |= MEM_RESERVE; 158 152 159 pMapping = VirtualAlloc(0, mSize, fAlloc, memFlags); 160 if(pMapping == NULL) { 161 dprintf(("Win32MemMap::mapFileView: VirtualAlloc %x %x %x failed!", mSize, fAlloc, memFlags)); 162 goto fail; 163 } 164 mapMutex.leave(); 165 return pMapping; 153 if(fMapped == FALSE) {//if not mapped, reserve/commit entire view 154 pMapping = VirtualAlloc(0, mSize, fAlloc, mProtFlags); 155 if(pMapping == NULL) { 156 dprintf(("Win32MemMap::mapFileView: VirtualAlloc %x %x %x failed!", mSize, fAlloc, memFlags)); 157 goto fail; 158 } 159 fMapped = TRUE; 160 } 161 mapview = (LPVOID)((ULONG)pMapping + offset); 162 mapMutex.leave(); 163 return mapview; 166 164 167 165 parmfail: -
trunk/src/kernel32/mmap.h
r657 r664 1 /* $Id: mmap.h,v 1. 5 1999-08-24 12:23:54sandervl Exp $ */1 /* $Id: mmap.h,v 1.6 1999-08-24 18:46:40 sandervl Exp $ */ 2 2 3 3 /* … … 25 25 ~Win32MemMap(); 26 26 27 HANDLE Init();27 BOOL Init(HANDLE hMemMap); 28 28 BOOL flushView(LPVOID lpvBase, ULONG cbFlush); 29 LPVOID map FileView(ULONG size, ULONG offset, ULONG fdwAccess);30 BOOL unmap FileView();29 LPVOID mapViewOfFile(ULONG size, ULONG offset, ULONG fdwAccess); 30 BOOL unmapViewOfFile(); 31 31 32 32 HFILE getMapHandle() { return hMemMap; }; 33 33 LPSTR getMemName() { return lpszMapName; }; 34 DWORD getProtFlags() { return mProtFlags; }; 35 36 void AddRef() { ++referenced; }; 37 void Release() { if(--referenced == 0) delete this; }; 34 38 35 39 static Win32MemMap *findMap(LPSTR lpszName); … … 45 49 BOOL fMapped; 46 50 51 ULONG referenced; 52 47 53 VMutex mapMutex; 48 54
Note:
See TracChangeset
for help on using the changeset viewer.