Changeset 6049 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Jun 19, 2001, 12:50:26 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r5791 r6049 1 /* $Id: HandleManager.cpp,v 1.6 4 2001-05-24 08:19:17sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.65 2001-06-19 10:50:23 sandervl Exp $ */ 2 2 3 3 /* … … 2223 2223 2224 2224 2225 if(lpName) { //check if shared event semaphore already exists 2226 //TODO: No inheritance?? 2227 HANDLE handle = HMOpenEvent(EVENT_ALL_ACCESS, FALSE, lpName); 2228 if(handle) { 2229 dprintf(("CreateEvent: return handle of existing event semaphore %x", handle)); 2230 return handle; 2231 } 2232 } 2233 2225 2234 pDeviceHandler = HMGlobals.pHMEvent; /* device is predefined */ 2235 2236 iIndexNew = _HMHandleGetFree(); /* get free handle */ 2237 if (-1 == iIndexNew) /* oops, no free handles ! */ 2238 { 2239 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 2240 return 0; /* signal error */ 2241 } 2242 2243 /* Initialize the complete HMHANDLEDATA structure */ 2244 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2245 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 2246 pHMHandleData->dwAccess = 0; 2247 pHMHandleData->dwShare = 0; 2248 pHMHandleData->dwCreation = 0; 2249 pHMHandleData->dwFlags = 0; 2250 pHMHandleData->lpHandlerData = NULL; 2251 2252 /* we've got to mark the handle as occupied here, since another device */ 2253 /* could be created within the device handler -> deadlock */ 2254 2255 /* write appropriate entry into the handle table if open succeeded */ 2256 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 2257 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 2258 2259 /* call the device handler */ 2260 rc = pDeviceHandler->CreateEvent(&TabWin32Handles[iIndexNew].hmHandleData, 2261 lpsa, 2262 bManualReset, 2263 bInitialState, 2264 lpName); 2265 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 2266 { 2267 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 2268 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 2269 return 0; /* signal error */ 2270 } 2271 else 2272 SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this? 2273 2274 return iIndexNew; /* return valid handle */ 2275 } 2276 2277 2278 /***************************************************************************** 2279 * Name : HANDLE HMCreateMutex 2280 * Purpose : Wrapper for the CreateMutex() API 2281 * Parameters: 2282 * Variables : 2283 * Result : 2284 * Remark : 2285 * Status : 2286 * 2287 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 2288 *****************************************************************************/ 2289 2290 HANDLE HMCreateMutex(LPSECURITY_ATTRIBUTES lpsa, 2291 BOOL bInitialOwner, 2292 LPCTSTR lpName) 2293 { 2294 int iIndex; /* index into the handle table */ 2295 int iIndexNew; /* index into the handle table */ 2296 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 2297 PHMHANDLEDATA pHMHandleData; 2298 DWORD rc; /* API return code */ 2299 2300 2301 if(lpName) { //check if shared mutex semaphore already exists 2302 //TODO: No inheritance?? 2303 HANDLE handle = HMOpenMutex(MUTEX_ALL_ACCESS, FALSE, lpName); 2304 if(handle) { 2305 dprintf(("CreateMutex: return handle of existing mutex semaphore %x", handle)); 2306 return handle; 2307 } 2308 } 2309 2310 pDeviceHandler = HMGlobals.pHMMutex; /* device is predefined */ 2226 2311 2227 2312 iIndexNew = _HMHandleGetFree(); /* get free handle */ … … 2251 2336 2252 2337 /* call the device handler */ 2253 rc = pDeviceHandler->CreateEvent(&TabWin32Handles[iIndexNew].hmHandleData,2254 lpsa,2255 bManualReset,2256 bInitialState,2257 lpName);2258 if (rc != NO_ERROR) /* oops, creation failed within the device handler */2259 {2260 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;2261 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */2262 return 0; /* signal error */2263 }2264 else2265 SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?2266 2267 return iIndexNew; /* return valid handle */2268 }2269 2270 2271 /*****************************************************************************2272 * Name : HANDLE HMCreateMutex2273 * Purpose : Wrapper for the CreateMutex() API2274 * Parameters:2275 * Variables :2276 * Result :2277 * Remark :2278 * Status :2279 *2280 * Author : Patrick Haller [Wed, 1998/02/11 20:44]2281 *****************************************************************************/2282 2283 HANDLE HMCreateMutex(LPSECURITY_ATTRIBUTES lpsa,2284 BOOL bInitialOwner,2285 LPCTSTR lpName)2286 {2287 int iIndex; /* index into the handle table */2288 int iIndexNew; /* index into the handle table */2289 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */2290 PHMHANDLEDATA pHMHandleData;2291 DWORD rc; /* API return code */2292 2293 2294 pDeviceHandler = HMGlobals.pHMMutex; /* device is predefined */2295 2296 iIndexNew = _HMHandleGetFree(); /* get free handle */2297 if (-1 == iIndexNew) /* oops, no free handles ! */2298 {2299 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */2300 return 0; /* signal error */2301 }2302 2303 2304 /* initialize the complete HMHANDLEDATA structure */2305 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData;2306 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2307 pHMHandleData->dwAccess = 0;2308 pHMHandleData->dwShare = 0;2309 pHMHandleData->dwCreation = 0;2310 pHMHandleData->dwFlags = 0;2311 pHMHandleData->lpHandlerData = NULL;2312 2313 2314 /* we've got to mark the handle as occupied here, since another device */2315 /* could be created within the device handler -> deadlock */2316 2317 /* write appropriate entry into the handle table if open succeeded */2318 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew;2319 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler;2320 2321 /* call the device handler */2322 2338 rc = pDeviceHandler->CreateMutex(&TabWin32Handles[iIndexNew].hmHandleData, 2323 2339 lpsa, … … 2494 2510 DWORD rc; /* API return code */ 2495 2511 2496 2512 if(lpName) { //check if shared event semaphore already exists 2513 //TODO: No inheritance?? 2514 HANDLE handle = HMOpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, lpName); 2515 if(handle) { 2516 dprintf(("CreateSemaphore: return handle of existing semaphore %x", handle)); 2517 return handle; 2518 } 2519 } 2520 2497 2521 pDeviceHandler = HMGlobals.pHMSemaphore; /* device is predefined */ 2498 2522 … … 2984 3008 pLoop2); 2985 3009 3010 dprintf2(("MsgWaitForMultipleObjects handle %x->%x", *pLoop1, *pLoop2)); 2986 3011 // SvL: We still use Open32 handles for threads & processes -> don't fail here! 2987 3012 if (rc != NO_ERROR)
Note:
See TracChangeset
for help on using the changeset viewer.