Changeset 5587 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Apr 26, 2001, 3:22:49 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r5019 r5587 1 /* $Id: HandleManager.cpp,v 1.6 2 2001-01-23 18:31:25sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.63 2001-04-26 13:22:42 sandervl Exp $ */ 2 2 3 3 /* … … 62 62 #include "HMNPipe.h" 63 63 #include "HMStd.h" 64 #include "HMMailslot.h" 65 64 66 #include <vmutex.h> 65 67 #include <win\thread.h> … … 142 144 HMDeviceHandler *pHMThread; 143 145 HMDeviceHandler *pHMNamedPipe; 146 HMDeviceHandler *pHMMailslot; 144 147 145 148 ULONG ulHandleLast; /* index of last used handle */ … … 422 425 HMGlobals.pHMThread = new HMDeviceThreadClass("\\\\THREAD\\"); 423 426 HMGlobals.pHMNamedPipe = new HMDeviceNamedPipeClass("\\\\PIPE\\"); 427 HMGlobals.pHMMailslot = new HMMailslotClass("\\MAILSLOT\\"); 424 428 } 425 429 return (NO_ERROR); … … 463 467 if(HMGlobals.pHMNamedPipe) 464 468 delete HMGlobals.pHMNamedPipe; 469 if(HMGlobals.pHMMailslot) 470 delete HMGlobals.pHMMailslot; 465 471 if(HMGlobals.pHMDisk) 466 472 delete HMGlobals.pHMDisk; … … 4198 4204 nDefaultTimeOut,lpSecurityAttributes); 4199 4205 4200 if (rc == 0) /* oops, creation failed within the device handler */4206 if (rc == -1) /* oops, creation failed within the device handler */ 4201 4207 { 4202 4208 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 4203 return 0; /* signal error */4209 return 0; /* signal error */ 4204 4210 } 4205 4211 … … 4534 4540 return TRUE; 4535 4541 } 4542 4543 /***************************************************************************** 4544 * Name : HMCreateMailslotA 4545 * Purpose : 4546 * Parameters: 4547 * Variables : 4548 * Result : 4549 * Remark : 4550 * Status : 4551 * 4552 * Author : SvL 4553 *****************************************************************************/ 4554 HANDLE HMCreateMailslotA(LPCSTR lpName, DWORD nMaxMessageSize, 4555 DWORD lReadTimeout, 4556 LPSECURITY_ATTRIBUTES lpSecurityAttributes) 4557 { 4558 int iIndex; /* index into the handle table */ 4559 int iIndexNew; /* index into the handle table */ 4560 HMMailslotClass *pDeviceHandler; /* device handler for this handle */ 4561 PHMHANDLEDATA pHMHandleData; 4562 BOOL rc; /* API return code */ 4563 4564 SetLastError(ERROR_SUCCESS); 4565 4566 pDeviceHandler = (HMMailslotClass *)HMGlobals.pHMMailslot; /* device is predefined */ 4567 4568 iIndexNew = _HMHandleGetFree(); /* get free handle */ 4569 if (-1 == iIndexNew) /* oops, no free handles ! */ 4570 { 4571 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 4572 return 0; 4573 } 4574 4575 /* initialize the complete HMHANDLEDATA structure */ 4576 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 4577 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; 4578 pHMHandleData->dwAccess = 0; 4579 pHMHandleData->dwShare = 0; 4580 pHMHandleData->dwCreation = 0; 4581 pHMHandleData->dwFlags = 0; 4582 pHMHandleData->lpHandlerData = NULL; 4583 4584 /* we've got to mark the handle as occupied here, since another device */ 4585 /* could be created within the device handler -> deadlock */ 4586 4587 /* write appropriate entry into the handle table if open succeeded */ 4588 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 4589 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 4590 4591 /* call the device handler */ 4592 4593 rc = pDeviceHandler->CreateMailslotA(&TabWin32Handles[iIndexNew].hmHandleData, 4594 lpName, nMaxMessageSize, 4595 lReadTimeout, lpSecurityAttributes); 4596 4597 if (rc == FALSE) /* oops, creation failed within the device handler */ 4598 { 4599 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 4600 return 0; /* signal error */ 4601 } 4602 4603 return iIndexNew; 4604 } 4605 /***************************************************************************** 4606 * Name : HMGetMailslotInfo 4607 * Purpose : 4608 * Parameters: 4609 * Variables : 4610 * Result : 4611 * Remark : 4612 * Status : 4613 * 4614 * Author : SvL 4615 *****************************************************************************/ 4616 BOOL HMGetMailslotInfo(HANDLE hMailslot, 4617 LPDWORD lpMaxMessageSize, 4618 LPDWORD lpNextSize, 4619 LPDWORD lpMessageCount, 4620 LPDWORD lpReadTimeout) 4621 { 4622 int iIndex; /* index into the handle table */ 4623 BOOL lpResult; /* result from the device handler's API */ 4624 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 4625 4626 SetLastError(ERROR_SUCCESS); 4627 /* validate handle */ 4628 iIndex = _HMHandleQuery(hMailslot); /* get the index */ 4629 if (-1 == iIndex) /* error ? */ 4630 { 4631 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 4632 return FALSE; /* signal failure */ 4633 } 4634 4635 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 4636 lpResult = pHMHandle->pDeviceHandler->GetMailslotInfo(&TabWin32Handles[iIndex].hmHandleData, 4637 lpMaxMessageSize, 4638 lpNextSize, 4639 lpMessageCount, 4640 lpReadTimeout); 4641 return (lpResult); /* deliver return code */ 4642 } 4643 /***************************************************************************** 4644 * Name : HMSetMailslotInfo 4645 * Purpose : 4646 * Parameters: 4647 * Variables : 4648 * Result : 4649 * Remark : 4650 * Status : 4651 * 4652 * Author : SvL 4653 *****************************************************************************/ 4654 BOOL HMSetMailslotInfo(HANDLE hMailslot, 4655 DWORD dwReadTimeout) 4656 { 4657 int iIndex; /* index into the handle table */ 4658 BOOL lpResult; /* result from the device handler's API */ 4659 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 4660 4661 SetLastError(ERROR_SUCCESS); 4662 /* validate handle */ 4663 iIndex = _HMHandleQuery(hMailslot); /* get the index */ 4664 if (-1 == iIndex) /* error ? */ 4665 { 4666 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 4667 return FALSE; /* signal failure */ 4668 } 4669 4670 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 4671 lpResult = pHMHandle->pDeviceHandler->SetMailslotInfo(&TabWin32Handles[iIndex].hmHandleData, 4672 dwReadTimeout); 4673 4674 return (lpResult); /* deliver return code */ 4675 }
Note:
See TracChangeset
for help on using the changeset viewer.