- Timestamp:
- Jun 2, 2003, 6:25:36 PM (22 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r10109 r10132 1 /* $Id: HandleManager.cpp,v 1.10 3 2003-05-23 13:53:42sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.104 2003-06-02 16:25:15 sandervl Exp $ */ 2 2 3 3 /* … … 4523 4523 * Author : Przemyslaw Dobrowolski 4524 4524 *****************************************************************************/ 4525 DWORDHMCreateNamedPipe(LPCTSTR lpName,4525 HANDLE HMCreateNamedPipe(LPCTSTR lpName, 4526 4526 DWORD dwOpenMode, 4527 4527 DWORD dwPipeMode, … … 4546 4546 { 4547 4547 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 4548 return 0;4548 return INVALID_HANDLE_VALUE; 4549 4549 } 4550 4550 … … 4575 4575 { 4576 4576 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 4577 return 0;/* signal error */4577 return INVALID_HANDLE_VALUE; /* signal error */ 4578 4578 } 4579 4579 … … 4820 4820 4821 4821 /***************************************************************************** 4822 * Name : HMCreatePipe4823 * Purpose :4824 * Parameters:4825 * Variables :4826 * Result :4827 * Remark :4828 * Status : NOT TESTED!4829 *4830 * Author : Przemyslaw Dobrowolski4831 *****************************************************************************/4832 BOOL HMCreatePipe(PHANDLE phRead,4833 PHANDLE phWrite,4834 LPSECURITY_ATTRIBUTES lpsa,4835 DWORD cbPipe)4836 {4837 int iIndex; /* index into the handle table */4838 int iIndexNewRead; /* index into the handle table */4839 int iIndexNewWrite; /* index into the handle table */4840 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */4841 PHMHANDLEDATA pHMHandleData;4842 HANDLE rc; /* API return code */4843 4844 SetLastError(ERROR_SUCCESS);4845 4846 pDeviceHandler = HMGlobals.pHMNamedPipe; /* device is predefined */4847 4848 iIndexNewRead = _HMHandleGetFree(); /* get free handle */4849 if (-1 == iIndexNewRead) /* oops, no free handles ! */4850 {4851 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */4852 return 0;4853 }4854 4855 iIndexNewWrite = _HMHandleGetFree(); /* get free handle */4856 if (-1 == iIndexNewWrite) /* oops, no free handles ! */4857 {4858 HMHandleFree(iIndexNewRead);4859 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */4860 return 0;4861 }4862 4863 4864 /* initialize the complete HMHANDLEDATA structure */4865 pHMHandleData = &TabWin32Handles[iIndexNewRead].hmHandleData;4866 pHMHandleData->dwAccess = 0;4867 pHMHandleData->dwShare = 0;4868 pHMHandleData->dwCreation = 0;4869 pHMHandleData->dwFlags = 0;4870 pHMHandleData->lpHandlerData = NULL;4871 4872 /* we've got to mark the handle as occupied here, since another device */4873 /* could be created within the device handler -> deadlock */4874 4875 /* write appropriate entry into the handle table if open succeeded */4876 TabWin32Handles[iIndexNewRead].hmHandleData.hHMHandle = iIndexNewRead;4877 TabWin32Handles[iIndexNewRead].pDeviceHandler = pDeviceHandler;4878 4879 /* initialize the complete HMHANDLEDATA structure */4880 pHMHandleData = &TabWin32Handles[iIndexNewWrite].hmHandleData;4881 pHMHandleData->dwAccess = 0;4882 pHMHandleData->dwShare = 0;4883 pHMHandleData->dwCreation = 0;4884 pHMHandleData->dwFlags = 0;4885 pHMHandleData->lpHandlerData = NULL;4886 4887 /* we've got to mark the handle as occupied here, since another device */4888 /* could be created within the device handler -> deadlock */4889 4890 /* write appropriate entry into the handle table if open succeeded */4891 TabWin32Handles[iIndexNewWrite].hmHandleData.hHMHandle = iIndexNewWrite;4892 TabWin32Handles[iIndexNewWrite].pDeviceHandler = pDeviceHandler;4893 /* call the device handler */4894 4895 rc = pDeviceHandler->CreatePipe(&TabWin32Handles[iIndexNewRead].hmHandleData,4896 &TabWin32Handles[iIndexNewWrite].hmHandleData,4897 lpsa,4898 cbPipe);4899 4900 if (rc == 0) /* oops, creation failed within the device handler */4901 {4902 HMHandleFree(iIndexNewRead);4903 HMHandleFree(iIndexNewWrite);4904 return FALSE; /* signal error */4905 }4906 4907 dprintf(("Read pipe %x, Write pipe %x", iIndexNewRead, iIndexNewWrite));4908 if(lpsa && lpsa->bInheritHandle) {4909 dprintf(("Set inheritance for child processes"));4910 HMSetHandleInformation(iIndexNewRead, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);4911 HMSetHandleInformation(iIndexNewWrite, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);4912 }4913 4914 *phRead = iIndexNewRead;4915 *phWrite = iIndexNewWrite;4916 4917 return TRUE;4918 }4919 4920 /*****************************************************************************4921 4822 * Name : HMCreateMailslotA 4922 4823 * Purpose : -
trunk/src/kernel32/hmdevice.cpp
r10073 r10132 1 /* $Id: hmdevice.cpp,v 1.3 6 2003-05-06 12:06:09sandervl Exp $ */1 /* $Id: hmdevice.cpp,v 1.37 2003-06-02 16:25:16 sandervl Exp $ */ 2 2 3 3 /* … … 1782 1782 1783 1783 /***************************************************************************** 1784 * Name : BOOL HMDeviceHandler::CreatePipe1785 * Purpose :1786 * Variables :1787 * Result :1788 * Remark :1789 * Status :1790 *1791 * Author : Przemyslaw Dobrowolski1792 *****************************************************************************/1793 BOOL HMDeviceHandler::CreatePipe(PHMHANDLEDATA pHMHandleDataRead,1794 PHMHANDLEDATA pHMHandleDataWrite,1795 LPSECURITY_ATTRIBUTES lpsa,1796 DWORD cbPipe)1797 {1798 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::CreatePipe (%08x,%08x)\n",1799 pHMHandleDataRead->hHMHandle,pHMHandleDataWrite->hHMHandle));1800 1801 return(FALSE);1802 }1803 /*****************************************************************************1804 1784 * Name : BOOL HMDeviceHandler::GetMailslotInfo 1805 1785 * Purpose : -
trunk/src/kernel32/hmdevice.h
r10073 r10132 1 /* $Id: hmdevice.h,v 1.3 5 2003-05-06 12:06:09sandervl Exp $ */1 /* $Id: hmdevice.h,v 1.36 2003-06-02 16:25:17 sandervl Exp $ */ 2 2 3 3 /* … … 452 452 LPDWORD lpdwCollectDataTimeout); 453 453 454 virtual BOOL CreatePipe(PHMHANDLEDATA pHMHandleDataRead,455 PHMHANDLEDATA pHMHandleDataWrite,456 LPSECURITY_ATTRIBUTES lpsa,457 DWORD cbPipe);458 459 454 virtual BOOL GetMailslotInfo(PHMHANDLEDATA pHMHandleData, 460 455 LPDWORD lpMaxMessageSize, -
trunk/src/kernel32/hmnpipe.cpp
r9660 r10132 1 /* $Id: hmnpipe.cpp,v 1.1 0 2003-01-10 15:19:53sandervl Exp $ */1 /* $Id: hmnpipe.cpp,v 1.11 2003-06-02 16:25:18 sandervl Exp $ */ 2 2 /* 3 3 * Project Odin Software License can be found in LICENSE.TXT … … 12 12 * 13 13 */ 14 #include <stdio.h> 14 15 #include <odin.h> 15 16 #include <os2win.h> … … 187 188 //****************************************************************************** 188 189 //****************************************************************************** 189 BOOL HMDeviceNamedPipeClass::CreatePipe(PHMHANDLEDATA pHMHandleDataRead,190 PHMHANDLEDATA pHMHandleDataWrite,191 LPSECURITY_ATTRIBUTES lpsa,192 DWORD cbPipe)193 {194 pHMHandleDataRead->dwInternalType = HMTYPE_PIPE;195 pHMHandleDataWrite->dwInternalType = HMTYPE_PIPE;196 197 dprintfl(("KERNEL32: HMDeviceNamedPipeClass::CreatePipe"));198 199 if(!OSLibDosCreatePipe(&pHMHandleDataRead->hHMHandle,200 &pHMHandleDataWrite->hHMHandle,201 lpsa,202 cbPipe))203 {204 return TRUE;205 }206 else207 return FALSE;208 }209 //******************************************************************************210 //******************************************************************************211 190 BOOL HMDeviceNamedPipeClass::ConnectNamedPipe( PHMHANDLEDATA pHMHandleData, 212 191 LPOVERLAPPED lpOverlapped) -
trunk/src/kernel32/hmnpipe.h
r7927 r10132 1 /* $Id: hmnpipe.h,v 1. 6 2002-02-15 19:14:52sandervl Exp $ */1 /* $Id: hmnpipe.h,v 1.7 2003-06-02 16:25:18 sandervl Exp $ */ 2 2 /* 3 3 * Project Odin Software License can be found in LICENSE.TXT … … 95 95 LPDWORD arg3, 96 96 BOOL arg4); 97 98 virtual BOOL CreatePipe(PHMHANDLEDATA pHMHandleDataRead,99 PHMHANDLEDATA pHMHandleDataWrite,100 LPSECURITY_ATTRIBUTES lpsa,101 DWORD cbPipe);102 103 104 97 }; 105 98 -
trunk/src/kernel32/npipe.cpp
r9975 r10132 1 /* $Id: npipe.cpp,v 1.1 1 2003-04-02 12:58:30sandervl Exp $ */1 /* $Id: npipe.cpp,v 1.12 2003-06-02 16:25:18 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Named pipes API … … 38 38 LPSECURITY_ATTRIBUTES lpsa, DWORD cbPipe) 39 39 { 40 return (HMCreatePipe(phRead,phWrite,lpsa,cbPipe)); 40 char szPipeName[64]; 41 HANDLE hPipeRead, hPipeWrite; 42 43 // create a unique pipe name 44 for(int i=0;i<16;i++) 45 { 46 sprintf(szPipeName, "\\\\.\\pipe\\Win32.Pipes.%08x.%08x", GetCurrentProcessId(), GetCurrentTime()); 47 hPipeRead = ::CreateNamedPipeA(szPipeName, PIPE_ACCESS_DUPLEX, 48 PIPE_TYPE_BYTE | PIPE_WAIT, 1, cbPipe, cbPipe, 49 NMPWAIT_USE_DEFAULT_WAIT, lpsa); 50 if(hPipeRead != INVALID_HANDLE_VALUE) break; 51 52 Sleep(10); 53 } 54 55 if (hPipeRead == INVALID_HANDLE_VALUE) { 56 dprintf(("ERROR: Unable to create named pipe with unique name!! (%s)", szPipeName)); 57 return FALSE; 58 } 59 60 ULONG mode = PIPE_NOWAIT|PIPE_READMODE_BYTE; 61 62 //Set pipe in non-blocking mode 63 SetNamedPipeHandleState(hPipeRead, &mode, NULL, NULL); 64 65 //Set pipe in listening mode (so the next CreateFile will succeed) 66 ConnectNamedPipe(hPipeRead, NULL); 67 68 //Put pipe back in blocking mode 69 mode = PIPE_WAIT|PIPE_READMODE_BYTE; 70 SetNamedPipeHandleState(hPipeRead, &mode, NULL, NULL); 71 72 //Create write pipe 73 hPipeWrite = CreateFileA(szPipeName, GENERIC_WRITE, 0, lpsa, OPEN_EXISTING, 0, 0); 74 if (hPipeWrite == INVALID_HANDLE_VALUE) 75 { 76 dprintf(("ERROR: Unable to create write handle for anonymous pipe!!")); 77 CloseHandle(hPipeRead); 78 return FALSE; 79 } 80 81 dprintf(("Created pipe with handles %x and %x", hPipeRead, hPipeWrite)); 82 *phRead = hPipeRead; 83 *phWrite = hPipeWrite; 84 return TRUE; 41 85 } 42 86 //****************************************************************************** -
trunk/src/kernel32/oslibdos.cpp
r9945 r10132 1 /* $Id: oslibdos.cpp,v 1.1 19 2003-03-27 14:00:52sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.120 2003-06-02 16:25:19 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 1595 1595 DWORD rc, ulAction; 1596 1596 1597 if ( dwOpenMode &PIPE_ACCESS_DUPLEX_W)1597 if ((dwOpenMode & PIPE_ACCESS_DUPLEX_W) == PIPE_ACCESS_DUPLEX_W) 1598 1598 dwOS2Mode |= NP_ACCESS_DUPLEX; 1599 1599 else
Note:
See TracChangeset
for help on using the changeset viewer.