Changeset 278 for trunk/src/kernel32
- Timestamp:
- Jul 6, 1999, 5:48:48 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 8 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r271 r278 1 /* $Id: HandleManager.cpp,v 1. 5 1999-07-05 09:58:14phaller Exp $ */1 /* $Id: HandleManager.cpp,v 1.6 1999-07-06 15:48:45 phaller Exp $ */ 2 2 3 3 /* … … 52 52 #include "HMDevice.h" 53 53 #include "HMOpen32.h" 54 #include "HMEvent.h" 55 #include "HMMutex.h" 56 #include "HMSemaphore.h" 54 57 55 58 … … 59 62 60 63 /* this is the size of our currently static handle table */ 61 #define MAX_OS2_HMHANDLES 102464 #define MAX_OS2_HMHANDLES 2048 62 65 63 66 … … 83 86 84 87 85 typedef struct _HMTRANSHANDLE86 {87 /* @@@PH88 UCHAR ucSubsystemID; to determine "lost" handles89 */90 /* the index position in the array is the 16bit windows part of the handle */91 ULONG hHandle32; /* 32-bit OS/2 part of the handle */92 } HMTRANSHANDLE, *PHMTRANSHANDLE;93 94 95 88 /***************************************************************************** 96 89 * This pseudo-device logs all device requests to the logfile and returns * … … 123 116 /* this MUST !!! be false initially */ 124 117 125 HMDeviceHandler *pHMOpen32; /* default handle manager instance */ 118 HMDeviceHandler *pHMOpen32; /* default handle manager instance */ 119 HMDeviceHandler *pHMEvent; /* static instances of subsystems */ 120 HMDeviceHandler *pHMMutex; 121 HMDeviceHandler *pHMSemaphore; 126 122 127 123 ULONG ulHandleLast; /* index of last used handle */ … … 312 308 313 309 /* create handle manager instance for Open32 handles */ 314 HMGlobals.pHMOpen32 = new HMDeviceOpen32Class("\\\\.\\"); 310 HMGlobals.pHMOpen32 = new HMDeviceOpen32Class("\\\\.\\"); 311 HMGlobals.pHMEvent = new HMDeviceEventClass("\\\\EVENT\\"); 312 HMGlobals.pHMMutex = new HMDeviceMutexClass("\\\\MUTEX\\"); 313 HMGlobals.pHMSemaphore = new HMDeviceSemaphoreClass("\\\\SEM\\"); 315 314 } 316 315 return (NO_ERROR); … … 333 332 { 334 333 /* @@@PH we could deallocate the device list here */ 334 335 delete HMGlobals.pHMOpen32; 336 delete HMGlobals.pHMEvent; 337 delete HMGlobals.pHMMutex; 338 delete HMGlobals.pHMSemaphore; 335 339 336 340 return (NO_ERROR); … … 357 361 * Remark : no parameter checking is done, phHandle may not be invalid 358 362 * hHandle32 shouldn't be 0 363 * Should be protected with a HM-Mutex ! 359 364 * Status : 360 365 * … … 546 551 *****************************************************************************/ 547 552 548 DWORD 553 DWORD HMHandleTranslateToOS2i (ULONG hHandle16) 549 554 { 550 555 #ifdef DEBUG_LOCAL … … 922 927 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 923 928 *****************************************************************************/ 929 924 930 BOOL HMReadFile(HANDLE hFile, 925 931 LPVOID lpBuffer, … … 1038 1044 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1039 1045 *****************************************************************************/ 1046 1040 1047 DWORD HMDeviceRequest (HANDLE hFile, 1041 1048 ULONG ulRequestCode, … … 1080 1087 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1081 1088 *****************************************************************************/ 1082 DWORD HMGetFileInformationByHandle (HANDLE hFile, 1083 BY_HANDLE_FILE_INFORMATION *pHFI) 1089 1090 BOOL HMGetFileInformationByHandle (HANDLE hFile, 1091 BY_HANDLE_FILE_INFORMATION *pHFI) 1084 1092 { 1085 1093 int iIndex; /* index into the handle table */ … … 1103 1111 1104 1112 1105 1106 1113 /***************************************************************************** 1107 1114 * Name : HMDeviceHandler::SetEndOfFile … … 1115 1122 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1116 1123 *****************************************************************************/ 1124 1117 1125 BOOL HMSetEndOfFile (HANDLE hFile) 1118 1126 { … … 1147 1155 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1148 1156 *****************************************************************************/ 1157 1149 1158 BOOL HMSetFileTime (HANDLE hFile, 1150 1159 const FILETIME *pFT1, … … 1185 1194 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1186 1195 *****************************************************************************/ 1196 1187 1197 DWORD HMGetFileSize (HANDLE hFile, 1188 1198 PDWORD pSize) … … 1219 1229 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1220 1230 *****************************************************************************/ 1231 1221 1232 DWORD HMSetFilePointer (HANDLE hFile, 1222 1233 LONG lDistanceToMove, … … 1257 1268 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1258 1269 *****************************************************************************/ 1270 1259 1271 BOOL HMLockFile (HFILE hFile, 1260 1272 DWORD arg2, … … 1297 1309 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1298 1310 *****************************************************************************/ 1299 DWORD HMLockFileEx(HANDLE hFile, 1300 DWORD dwFlags, 1301 DWORD dwReserved, 1302 DWORD nNumberOfBytesToLockLow, 1303 DWORD nNumberOfBytesToLockHigh, 1304 LPOVERLAPPED lpOverlapped) 1311 1312 BOOL HMLockFileEx(HANDLE hFile, 1313 DWORD dwFlags, 1314 DWORD dwReserved, 1315 DWORD nNumberOfBytesToLockLow, 1316 DWORD nNumberOfBytesToLockHigh, 1317 LPOVERLAPPED lpOverlapped) 1305 1318 { 1306 1319 int iIndex; /* index into the handle table */ … … 1340 1353 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1341 1354 *****************************************************************************/ 1355 1342 1356 BOOL HMUnlockFile (HFILE hFile, 1343 1357 DWORD arg2, … … 1368 1382 } 1369 1383 1384 1370 1385 /***************************************************************************** 1371 1386 * Name : HMDeviceHandler::UnlockFileEx … … 1379 1394 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1380 1395 *****************************************************************************/ 1396 1381 1397 BOOL HMUnlockFileEx(HANDLE hFile, 1382 1398 DWORD dwFlags, … … 1409 1425 } 1410 1426 1427 1428 /***************************************************************************** 1429 * Name : HMDeviceHandler::WaitForSingleObject 1430 * Purpose : router function for WaitForSingleObject 1431 * Parameters: 1432 * Variables : 1433 * Result : 1434 * Remark : 1435 * Status : 1436 * 1437 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1438 *****************************************************************************/ 1439 1440 DWORD HMWaitForSingleObject(HANDLE hObject, 1441 DWORD dwTimeout) 1442 { 1443 int iIndex; /* index into the handle table */ 1444 DWORD dwResult; /* result from the device handler's API */ 1445 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1446 1447 /* validate handle */ 1448 iIndex = _HMHandleQuery(hObject); /* get the index */ 1449 if (-1 == iIndex) /* error ? */ 1450 { 1451 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1452 return (INVALID_HANDLE_ERROR); /* signal failure */ 1453 } 1454 1455 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1456 dwResult = pHMHandle->pDeviceHandler->WaitForSingleObject(&pHMHandle->hmHandleData, 1457 dwTimeout); 1458 1459 return (dwResult); /* deliver return code */ 1460 } 1461 1462 1463 /***************************************************************************** 1464 * Name : HMDeviceHandler::WaitForSingleObjectEx 1465 * Purpose : router function for WaitForSingleObjectEx 1466 * Parameters: 1467 * Variables : 1468 * Result : 1469 * Remark : 1470 * Status : 1471 * 1472 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1473 *****************************************************************************/ 1474 1475 DWORD HMWaitForSingleObjectEx(HANDLE hObject, 1476 DWORD dwTimeout, 1477 BOOL fAlertable) 1478 { 1479 int iIndex; /* index into the handle table */ 1480 DWORD dwResult; /* result from the device handler's API */ 1481 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1482 1483 /* validate handle */ 1484 iIndex = _HMHandleQuery(hObject); /* get the index */ 1485 if (-1 == iIndex) /* error ? */ 1486 { 1487 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1488 return (INVALID_HANDLE_ERROR); /* signal failure */ 1489 } 1490 1491 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1492 dwResult = pHMHandle->pDeviceHandler->WaitForSingleObjectEx(&pHMHandle->hmHandleData, 1493 dwTimeout, 1494 fAlertable); 1495 1496 return (dwResult); /* deliver return code */ 1497 } 1498 1499 1500 /***************************************************************************** 1501 * Name : HMDeviceHandler::FlushFileBuffers 1502 * Purpose : router function for FlushFileBuffers 1503 * Parameters: 1504 * Variables : 1505 * Result : 1506 * Remark : 1507 * Status : 1508 * 1509 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1510 *****************************************************************************/ 1511 1512 BOOL HMFlushFileBuffers(HANDLE hFile) 1513 { 1514 int iIndex; /* index into the handle table */ 1515 DWORD dwResult; /* result from the device handler's API */ 1516 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1517 1518 /* validate handle */ 1519 iIndex = _HMHandleQuery(hFile); /* get the index */ 1520 if (-1 == iIndex) /* error ? */ 1521 { 1522 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1523 return (INVALID_HANDLE_ERROR); /* signal failure */ 1524 } 1525 1526 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1527 dwResult = pHMHandle->pDeviceHandler->FlushFileBuffers(&pHMHandle->hmHandleData); 1528 1529 return (dwResult); /* deliver return code */ 1530 } 1531 1532 1533 /***************************************************************************** 1534 * Name : HMDeviceHandler::GetOverlappedResult 1535 * Purpose : router function for GetOverlappedResult 1536 * Parameters: 1537 * Variables : 1538 * Result : 1539 * Remark : 1540 * Status : 1541 * 1542 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1543 *****************************************************************************/ 1544 1545 BOOL HMGetOverlappedResult(HANDLE hObject, 1546 LPOVERLAPPED lpOverlapped, 1547 LPDWORD arg3, 1548 BOOL arg4) 1549 { 1550 int iIndex; /* index into the handle table */ 1551 DWORD dwResult; /* result from the device handler's API */ 1552 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1553 1554 /* validate handle */ 1555 iIndex = _HMHandleQuery(hObject); /* get the index */ 1556 if (-1 == iIndex) /* error ? */ 1557 { 1558 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1559 return (INVALID_HANDLE_ERROR); /* signal failure */ 1560 } 1561 1562 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1563 dwResult = pHMHandle->pDeviceHandler->GetOverlappedResult(&pHMHandle->hmHandleData, 1564 lpOverlapped, 1565 arg3, 1566 arg4); 1567 1568 return (dwResult); /* deliver return code */ 1569 } 1570 1571 1572 /***************************************************************************** 1573 * Name : HMReleaseMutex 1574 * Purpose : router function for ReleaseMutex 1575 * Parameters: 1576 * Variables : 1577 * Result : 1578 * Remark : 1579 * Status : 1580 * 1581 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1582 *****************************************************************************/ 1583 1584 BOOL HMReleaseMutex(HANDLE hObject) 1585 { 1586 int iIndex; /* index into the handle table */ 1587 DWORD dwResult; /* result from the device handler's API */ 1588 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1589 1590 /* validate handle */ 1591 iIndex = _HMHandleQuery(hObject); /* get the index */ 1592 if (-1 == iIndex) /* error ? */ 1593 { 1594 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1595 return (INVALID_HANDLE_ERROR); /* signal failure */ 1596 } 1597 1598 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1599 dwResult = pHMHandle->pDeviceHandler->ReleaseMutex(&pHMHandle->hmHandleData); 1600 1601 return (dwResult); /* deliver return code */ 1602 } 1603 1604 1605 /***************************************************************************** 1606 * Name : HMSetEvent 1607 * Purpose : router function for SetEvent 1608 * Parameters: 1609 * Variables : 1610 * Result : 1611 * Remark : 1612 * Status : 1613 * 1614 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1615 *****************************************************************************/ 1616 1617 BOOL HMSetEvent(HANDLE hEvent) 1618 { 1619 int iIndex; /* index into the handle table */ 1620 DWORD dwResult; /* result from the device handler's API */ 1621 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1622 1623 /* validate handle */ 1624 iIndex = _HMHandleQuery(hEvent); /* get the index */ 1625 if (-1 == iIndex) /* error ? */ 1626 { 1627 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1628 return (INVALID_HANDLE_ERROR); /* signal failure */ 1629 } 1630 1631 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1632 dwResult = pHMHandle->pDeviceHandler->SetEvent(&pHMHandle->hmHandleData); 1633 1634 return (dwResult); /* deliver return code */ 1635 } 1636 1637 1638 /***************************************************************************** 1639 * Name : HMPulseEvent 1640 * Purpose : router function for PulseEvent 1641 * Parameters: 1642 * Variables : 1643 * Result : 1644 * Remark : 1645 * Status : 1646 * 1647 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1648 *****************************************************************************/ 1649 1650 BOOL HMPulseEvent(HANDLE hEvent) 1651 { 1652 int iIndex; /* index into the handle table */ 1653 DWORD dwResult; /* result from the device handler's API */ 1654 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1655 1656 /* validate handle */ 1657 iIndex = _HMHandleQuery(hEvent); /* get the index */ 1658 if (-1 == iIndex) /* error ? */ 1659 { 1660 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1661 return (INVALID_HANDLE_ERROR); /* signal failure */ 1662 } 1663 1664 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1665 dwResult = pHMHandle->pDeviceHandler->PulseEvent(&pHMHandle->hmHandleData); 1666 1667 return (dwResult); /* deliver return code */ 1668 } 1669 1670 1671 /***************************************************************************** 1672 * Name : HMResetEvent 1673 * Purpose : router function for ResetEvent 1674 * Parameters: 1675 * Variables : 1676 * Result : 1677 * Remark : 1678 * Status : 1679 * 1680 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1681 *****************************************************************************/ 1682 1683 BOOL HMResetEvent(HANDLE hEvent) 1684 { 1685 int iIndex; /* index into the handle table */ 1686 DWORD dwResult; /* result from the device handler's API */ 1687 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1688 1689 /* validate handle */ 1690 iIndex = _HMHandleQuery(hEvent); /* get the index */ 1691 if (-1 == iIndex) /* error ? */ 1692 { 1693 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1694 return (INVALID_HANDLE_ERROR); /* signal failure */ 1695 } 1696 1697 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1698 dwResult = pHMHandle->pDeviceHandler->ResetEvent(&pHMHandle->hmHandleData); 1699 1700 return (dwResult); /* deliver return code */ 1701 } 1702 1703 1704 /***************************************************************************** 1705 * Name : HANDLE HMCreateEvent 1706 * Purpose : Wrapper for the CreateEvent() API 1707 * Parameters: 1708 * Variables : 1709 * Result : 1710 * Remark : 1711 * Status : 1712 * 1713 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1714 *****************************************************************************/ 1715 1716 HANDLE HMCreateEvent(LPSECURITY_ATTRIBUTES lpsa, 1717 BOOL bManualReset, 1718 BOOL bInitialState, 1719 LPCTSTR lpName) 1720 { 1721 int iIndex; /* index into the handle table */ 1722 int iIndexNew; /* index into the handle table */ 1723 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 1724 PHMHANDLEDATA pHMHandleData; 1725 DWORD rc; /* API return code */ 1726 1727 1728 pDeviceHandler = HMGlobals.pHMEvent; /* device is predefined */ 1729 1730 iIndexNew = _HMHandleGetFree(); /* get free handle */ 1731 if (-1 == iIndexNew) /* oops, no free handles ! */ 1732 { 1733 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 1734 return (INVALID_HANDLE_VALUE); /* signal error */ 1735 } 1736 1737 1738 /* initialize the complete HMHANDLEDATA structure */ 1739 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 1740 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 1741 pHMHandleData->dwAccess = 0; 1742 pHMHandleData->dwShare = 0; 1743 pHMHandleData->dwCreation = 0; 1744 pHMHandleData->dwFlags = 0; 1745 pHMHandleData->lpHandlerData = NULL; 1746 1747 1748 /* we've got to mark the handle as occupied here, since another device */ 1749 /* could be created within the device handler -> deadlock */ 1750 1751 /* write appropriate entry into the handle table if open succeeded */ 1752 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 1753 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 1754 1755 /* call the device handler */ 1756 rc = pDeviceHandler->CreateEvent(&TabWin32Handles[iIndexNew].hmHandleData, 1757 lpsa, 1758 bManualReset, 1759 bInitialState, 1760 lpName); 1761 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 1762 { 1763 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1764 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1765 return (INVALID_HANDLE_VALUE); /* signal error */ 1766 } 1767 1768 return iIndexNew; /* return valid handle */ 1769 } 1770 1771 1772 /***************************************************************************** 1773 * Name : HANDLE HMCreateMutex 1774 * Purpose : Wrapper for the CreateMutex() API 1775 * Parameters: 1776 * Variables : 1777 * Result : 1778 * Remark : 1779 * Status : 1780 * 1781 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1782 *****************************************************************************/ 1783 1784 HANDLE HMCreateMutex(LPSECURITY_ATTRIBUTES lpsa, 1785 BOOL bInitialOwner, 1786 LPCTSTR lpName) 1787 { 1788 int iIndex; /* index into the handle table */ 1789 int iIndexNew; /* index into the handle table */ 1790 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 1791 PHMHANDLEDATA pHMHandleData; 1792 DWORD rc; /* API return code */ 1793 1794 1795 pDeviceHandler = HMGlobals.pHMMutex; /* device is predefined */ 1796 1797 iIndexNew = _HMHandleGetFree(); /* get free handle */ 1798 if (-1 == iIndexNew) /* oops, no free handles ! */ 1799 { 1800 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 1801 return (INVALID_HANDLE_VALUE); /* signal error */ 1802 } 1803 1804 1805 /* initialize the complete HMHANDLEDATA structure */ 1806 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 1807 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 1808 pHMHandleData->dwAccess = 0; 1809 pHMHandleData->dwShare = 0; 1810 pHMHandleData->dwCreation = 0; 1811 pHMHandleData->dwFlags = 0; 1812 pHMHandleData->lpHandlerData = NULL; 1813 1814 1815 /* we've got to mark the handle as occupied here, since another device */ 1816 /* could be created within the device handler -> deadlock */ 1817 1818 /* write appropriate entry into the handle table if open succeeded */ 1819 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 1820 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 1821 1822 /* call the device handler */ 1823 rc = pDeviceHandler->CreateMutex(&TabWin32Handles[iIndexNew].hmHandleData, 1824 lpsa, 1825 bInitialOwner, 1826 lpName); 1827 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 1828 { 1829 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1830 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1831 return (INVALID_HANDLE_VALUE); /* signal error */ 1832 } 1833 1834 return iIndexNew; /* return valid handle */ 1835 } 1836 1837 1838 /***************************************************************************** 1839 * Name : HANDLE HMOpenEvent 1840 * Purpose : Wrapper for the OpenEvent() API 1841 * Parameters: 1842 * Variables : 1843 * Result : 1844 * Remark : 1845 * Status : 1846 * 1847 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1848 *****************************************************************************/ 1849 1850 HANDLE HMOpenEvent(DWORD fdwAccess, 1851 BOOL fInherit, 1852 LPCTSTR lpName) 1853 { 1854 int iIndex; /* index into the handle table */ 1855 int iIndexNew; /* index into the handle table */ 1856 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 1857 PHMHANDLEDATA pHMHandleData; 1858 DWORD rc; /* API return code */ 1859 1860 1861 pDeviceHandler = HMGlobals.pHMEvent; /* device is predefined */ 1862 1863 iIndexNew = _HMHandleGetFree(); /* get free handle */ 1864 if (-1 == iIndexNew) /* oops, no free handles ! */ 1865 { 1866 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 1867 return (INVALID_HANDLE_VALUE); /* signal error */ 1868 } 1869 1870 1871 /* initialize the complete HMHANDLEDATA structure */ 1872 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 1873 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 1874 pHMHandleData->dwAccess = fdwAccess; 1875 pHMHandleData->dwShare = 0; 1876 pHMHandleData->dwCreation = 0; 1877 pHMHandleData->dwFlags = 0; 1878 pHMHandleData->lpHandlerData = NULL; 1879 1880 1881 /* we've got to mark the handle as occupied here, since another device */ 1882 /* could be created within the device handler -> deadlock */ 1883 1884 /* write appropriate entry into the handle table if open succeeded */ 1885 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 1886 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 1887 1888 /* call the device handler */ 1889 rc = pDeviceHandler->OpenEvent(&TabWin32Handles[iIndexNew].hmHandleData, 1890 fInherit, 1891 lpName); 1892 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 1893 { 1894 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1895 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1896 return (INVALID_HANDLE_VALUE); /* signal error */ 1897 } 1898 1899 return iIndexNew; /* return valid handle */ 1900 } 1901 1902 1903 /***************************************************************************** 1904 * Name : HANDLE HMOpenMutex 1905 * Purpose : Wrapper for the OpenMutex() API 1906 * Parameters: 1907 * Variables : 1908 * Result : 1909 * Remark : 1910 * Status : 1911 * 1912 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1913 *****************************************************************************/ 1914 1915 HANDLE HMOpenMutex(DWORD fdwAccess, 1916 BOOL fInherit, 1917 LPCTSTR lpName) 1918 { 1919 int iIndex; /* index into the handle table */ 1920 int iIndexNew; /* index into the handle table */ 1921 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 1922 PHMHANDLEDATA pHMHandleData; 1923 DWORD rc; /* API return code */ 1924 1925 1926 pDeviceHandler = HMGlobals.pHMMutex; /* device is predefined */ 1927 1928 iIndexNew = _HMHandleGetFree(); /* get free handle */ 1929 if (-1 == iIndexNew) /* oops, no free handles ! */ 1930 { 1931 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 1932 return (INVALID_HANDLE_VALUE); /* signal error */ 1933 } 1934 1935 1936 /* initialize the complete HMHANDLEDATA structure */ 1937 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 1938 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 1939 pHMHandleData->dwAccess = fdwAccess; 1940 pHMHandleData->dwShare = 0; 1941 pHMHandleData->dwCreation = 0; 1942 pHMHandleData->dwFlags = 0; 1943 pHMHandleData->lpHandlerData = NULL; 1944 1945 1946 /* we've got to mark the handle as occupied here, since another device */ 1947 /* could be created within the device handler -> deadlock */ 1948 1949 /* write appropriate entry into the handle table if open succeeded */ 1950 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 1951 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 1952 1953 /* call the device handler */ 1954 rc = pDeviceHandler->OpenMutex(&TabWin32Handles[iIndexNew].hmHandleData, 1955 fInherit, 1956 lpName); 1957 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 1958 { 1959 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1960 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1961 return (INVALID_HANDLE_VALUE); /* signal error */ 1962 } 1963 1964 return iIndexNew; /* return valid handle */ 1965 } 1966 1967 1968 /***************************************************************************** 1969 * Name : HANDLE HMCreateSemaphore 1970 * Purpose : Wrapper for the CreateSemaphore() API 1971 * Parameters: 1972 * Variables : 1973 * Result : 1974 * Remark : 1975 * Status : 1976 * 1977 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 1978 *****************************************************************************/ 1979 1980 HANDLE HMCreateSemaphore(LPSECURITY_ATTRIBUTES lpsa, 1981 LONG lInitialCount, 1982 LONG lMaximumCount, 1983 LPCTSTR lpName) 1984 { 1985 int iIndex; /* index into the handle table */ 1986 int iIndexNew; /* index into the handle table */ 1987 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 1988 PHMHANDLEDATA pHMHandleData; 1989 DWORD rc; /* API return code */ 1990 1991 1992 pDeviceHandler = HMGlobals.pHMEvent; /* device is predefined */ 1993 1994 iIndexNew = _HMHandleGetFree(); /* get free handle */ 1995 if (-1 == iIndexNew) /* oops, no free handles ! */ 1996 { 1997 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 1998 return (INVALID_HANDLE_VALUE); /* signal error */ 1999 } 2000 2001 2002 /* initialize the complete HMHANDLEDATA structure */ 2003 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2004 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 2005 pHMHandleData->dwAccess = 0; 2006 pHMHandleData->dwShare = 0; 2007 pHMHandleData->dwCreation = 0; 2008 pHMHandleData->dwFlags = 0; 2009 pHMHandleData->lpHandlerData = NULL; 2010 2011 2012 /* we've got to mark the handle as occupied here, since another device */ 2013 /* could be created within the device handler -> deadlock */ 2014 2015 /* write appropriate entry into the handle table if open succeeded */ 2016 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 2017 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 2018 2019 /* call the device handler */ 2020 rc = pDeviceHandler->CreateSemaphore(&TabWin32Handles[iIndexNew].hmHandleData, 2021 lpsa, 2022 lInitialCount, 2023 lMaximumCount, 2024 lpName); 2025 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 2026 { 2027 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 2028 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 2029 return (INVALID_HANDLE_VALUE); /* signal error */ 2030 } 2031 2032 return iIndexNew; /* return valid handle */ 2033 } 2034 2035 2036 /***************************************************************************** 2037 * Name : HANDLE HMOpenSemaphore 2038 * Purpose : Wrapper for the OpenSemaphore() API 2039 * Parameters: 2040 * Variables : 2041 * Result : 2042 * Remark : 2043 * Status : 2044 * 2045 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 2046 *****************************************************************************/ 2047 2048 HANDLE HMOpenSemaphore(DWORD fdwAccess, 2049 BOOL fInherit, 2050 LPCTSTR lpName) 2051 { 2052 int iIndex; /* index into the handle table */ 2053 int iIndexNew; /* index into the handle table */ 2054 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 2055 PHMHANDLEDATA pHMHandleData; 2056 DWORD rc; /* API return code */ 2057 2058 2059 pDeviceHandler = HMGlobals.pHMMutex; /* device is predefined */ 2060 2061 iIndexNew = _HMHandleGetFree(); /* get free handle */ 2062 if (-1 == iIndexNew) /* oops, no free handles ! */ 2063 { 2064 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 2065 return (INVALID_HANDLE_VALUE); /* signal error */ 2066 } 2067 2068 2069 /* initialize the complete HMHANDLEDATA structure */ 2070 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2071 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 2072 pHMHandleData->dwAccess = fdwAccess; 2073 pHMHandleData->dwShare = 0; 2074 pHMHandleData->dwCreation = 0; 2075 pHMHandleData->dwFlags = 0; 2076 pHMHandleData->lpHandlerData = NULL; 2077 2078 2079 /* we've got to mark the handle as occupied here, since another device */ 2080 /* could be created within the device handler -> deadlock */ 2081 2082 /* write appropriate entry into the handle table if open succeeded */ 2083 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 2084 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 2085 2086 /* call the device handler */ 2087 rc = pDeviceHandler->OpenSemaphore(&TabWin32Handles[iIndexNew].hmHandleData, 2088 fInherit, 2089 lpName); 2090 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 2091 { 2092 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 2093 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 2094 return (INVALID_HANDLE_VALUE); /* signal error */ 2095 } 2096 2097 return iIndexNew; /* return valid handle */ 2098 } 2099 2100 2101 /***************************************************************************** 2102 * Name : HMReleaseSemaphore 2103 * Purpose : router function for ReleaseSemaphore 2104 * Parameters: 2105 * Variables : 2106 * Result : 2107 * Remark : 2108 * Status : 2109 * 2110 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 2111 *****************************************************************************/ 2112 2113 BOOL HMReleaseSemaphore(HANDLE hEvent, 2114 LONG cReleaseCount, 2115 LPLONG lpPreviousCount) 2116 { 2117 int iIndex; /* index into the handle table */ 2118 DWORD dwResult; /* result from the device handler's API */ 2119 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 2120 2121 /* validate handle */ 2122 iIndex = _HMHandleQuery(hEvent); /* get the index */ 2123 if (-1 == iIndex) /* error ? */ 2124 { 2125 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 2126 return (INVALID_HANDLE_ERROR); /* signal failure */ 2127 } 2128 2129 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 2130 dwResult = pHMHandle->pDeviceHandler->ReleaseSemaphore(&pHMHandle->hmHandleData, 2131 cReleaseCount, 2132 lpPreviousCount); 2133 2134 return (dwResult); /* deliver return code */ 2135 } 2136 2137 2138 /***************************************************************************** 2139 * Name : HMWaitForMultipleObjects 2140 * Purpose : router function for WaitForMultipleObjects 2141 * Parameters: 2142 * Variables : 2143 * Result : 2144 * Remark : 2145 * Status : 2146 * 2147 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 2148 *****************************************************************************/ 2149 2150 DWORD HMWaitForMultipleObjects (DWORD cObjects, 2151 PHANDLE lphObjects, 2152 BOOL fWaitAll, 2153 DWORD dwTimeout) 2154 { 2155 ULONG ulIndex; 2156 PHANDLE pArrayOfHandles; 2157 PHANDLE pLoop1 = lphObjects; 2158 PHANDLE pLoop2; 2159 DWORD rc; 2160 2161 // allocate array for handle table 2162 pArrayOfHandles = (PHANDLE)malloc(cObjects * sizeof(HANDLE)); 2163 if (pArrayOfHandles == NULL) 2164 { 2165 O32_SetLastError(ERROR_NOT_ENOUGH_MEMORY); 2166 return WAIT_FAILED; 2167 } 2168 else 2169 pLoop2 = pArrayOfHandles; 2170 2171 // convert array to odin handles 2172 for (ulIndex = 0; 2173 2174 ulIndex < cObjects; 2175 2176 ulIndex++, 2177 pLoop1++, 2178 pLoop2++) 2179 { 2180 rc = HMHandleTranslateToOS2 (*pLoop1, // translate handle 2181 pLoop2); 2182 2183 if (rc != NO_ERROR) 2184 { 2185 free (pArrayOfHandles); // free memory 2186 O32_SetLastError(ERROR_INVALID_HANDLE); 2187 return (WAIT_FAILED); 2188 } 2189 } 2190 2191 // OK, now forward to Open32. 2192 // @@@PH: Note this will fail on handles that do NOT belong to Open32 2193 // but to i.e. the console subsystem! 2194 rc = O32_WaitForMultipleObjects(cObjects, 2195 pArrayOfHandles, 2196 fWaitAll, 2197 dwTimeout); 2198 2199 free(pArrayOfHandles); // free memory 2200 return (rc); // OK, done 2201 } 2202 2203 2204 /***************************************************************************** 2205 * Name : HMWaitForMultipleObjectsEx 2206 * Purpose : router function for WaitForMultipleObjectsEx 2207 * Parameters: 2208 * Variables : 2209 * Result : 2210 * Remark : 2211 * Status : 2212 * 2213 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 2214 *****************************************************************************/ 2215 2216 DWORD HMWaitForMultipleObjectsEx (DWORD cObjects, 2217 PHANDLE lphObjects, 2218 BOOL fWaitAll, 2219 DWORD dwTimeout, 2220 BOOL fAlertable) 2221 { 2222 // @@@PH: Note: fAlertable is ignored ! 2223 return (HMWaitForMultipleObjects(cObjects, 2224 lphObjects, 2225 fWaitAll, 2226 dwTimeout)); 2227 } 2228 -
trunk/src/kernel32/console.cpp
r120 r278 1 /* $Id: console.cpp,v 1. 7 1999-06-19 10:54:40 sandervlExp $ */1 /* $Id: console.cpp,v 1.8 1999-07-06 15:48:45 phaller Exp $ */ 2 2 3 3 /* … … 62 62 #define INCL_VIO 63 63 #define INCL_AVIO 64 #include <os2wrap.h> 64 #include <os2wrap.h> //Odin32 OS/2 api wrappers 65 65 #include <builtin.h> 66 66 #include <stdlib.h> -
trunk/src/kernel32/hmdevice.cpp
r111 r278 1 /* $Id: hmdevice.cpp,v 1. 1 1999-06-17 18:21:43phaller Exp $ */1 /* $Id: hmdevice.cpp,v 1.2 1999-07-06 15:48:46 phaller Exp $ */ 2 2 3 3 /* … … 536 536 LPOVERLAPPED lpOverlapped) 537 537 { 538 539 538 dprintf(("KERNEL32: HandleManager::DeviceHandler::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 540 539 lpHMDeviceName, … … 549 548 } 550 549 550 551 552 /***************************************************************************** 553 * Name : HMCreateSemaphore 554 * Purpose : router function for CreateSemaphore 555 * Parameters: 556 * Variables : 557 * Result : 558 * Remark : 559 * Status : 560 * 561 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 562 *****************************************************************************/ 563 564 DWORD HMDeviceHandler::CreateSemaphore(PHMHANDLEDATA pHMHandleData, 565 LPSECURITY_ATTRIBUTES lpsa, 566 LONG lInitialCount, 567 LONG lMaximumCount, 568 LPCTSTR lpszSemaphoreName) 569 { 570 dprintf(("KERNEL32: HandleManager::DeviceHandler::CreateSemaphore(%08xh,%08xh,%08xh,%08xh,%s)\n", 571 pHMHandleData, 572 lpsa, 573 lInitialCount, 574 lMaximumCount, 575 lpszSemaphoreName)); 576 577 return (ERROR_INVALID_FUNCTION); 578 } 579 580 581 /***************************************************************************** 582 * Name : HMOpenSemaphore 583 * Purpose : router function for OpenSemaphore 584 * Parameters: 585 * Variables : 586 * Result : 587 * Remark : 588 * Status : 589 * 590 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 591 *****************************************************************************/ 592 593 DWORD HMDeviceHandler::OpenSemaphore(PHMHANDLEDATA pHMHandleData, 594 BOOL fInheritHandle, 595 LPCTSTR lpszSemaphoreName) 596 { 597 dprintf(("KERNEL32: HandleManager::DeviceHandler::OpenSemaphore(%08xh,%08xh,%s)\n", 598 pHMHandleData, 599 fInheritHandle, 600 lpszSemaphoreName)); 601 602 return (ERROR_INVALID_FUNCTION); 603 } 604 605 606 /***************************************************************************** 607 * Name : HMReleaseSemaphore 608 * Purpose : router function for ReleaseSemaphore 609 * Parameters: 610 * Variables : 611 * Result : 612 * Remark : 613 * Status : 614 * 615 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 616 *****************************************************************************/ 617 618 BOOL HMDeviceHandler::ReleaseSemaphore(PHMHANDLEDATA pHMHandleData, 619 LONG cReleaseCount, 620 LPLONG lpPreviousCount) 621 { 622 dprintf(("KERNEL32: HandleManager::DeviceHandler::ReleaseSemaphore(%08xh,%08xh,%08xh)\n", 623 pHMHandleData->hHMHandle, 624 cReleaseCount, 625 lpPreviousCount)); 626 627 return (ERROR_INVALID_FUNCTION); 628 } 629 630 631 632 /***************************************************************************** 633 * Name : HMCreateMutex 634 * Purpose : router function for CreateMutex 635 * Parameters: 636 * Variables : 637 * Result : 638 * Remark : 639 * Status : 640 * 641 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 642 *****************************************************************************/ 643 644 DWORD HMDeviceHandler::CreateMutex(PHMHANDLEDATA pHMHandleData, 645 LPSECURITY_ATTRIBUTES lpsa, 646 BOOL fInitialOwner, 647 LPCTSTR lpszMutexName) 648 { 649 dprintf(("KERNEL32: HandleManager::DeviceHandler::CreateMutex(%08xh,%08xh,%08xh,%s)\n", 650 pHMHandleData, 651 lpsa, 652 fInitialOwner, 653 lpszMutexName)); 654 655 return (ERROR_INVALID_FUNCTION); 656 } 657 658 659 /***************************************************************************** 660 * Name : HMOpenMutex 661 * Purpose : router function for OpenMutex 662 * Parameters: 663 * Variables : 664 * Result : 665 * Remark : 666 * Status : 667 * 668 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 669 *****************************************************************************/ 670 671 DWORD HMDeviceHandler::OpenMutex(PHMHANDLEDATA pHMHandleData, 672 BOOL fInheritHandle, 673 LPCTSTR lpszMutexName) 674 { 675 dprintf(("KERNEL32: HandleManager::DeviceHandler::OpenMutex(%08xh,%08xh,%s)\n", 676 pHMHandleData, 677 fInheritHandle, 678 lpszMutexName)); 679 680 return (ERROR_INVALID_FUNCTION); 681 } 682 683 684 /***************************************************************************** 685 * Name : HMReleaseMutex 686 * Purpose : router function for ReleaseMutex 687 * Parameters: 688 * Variables : 689 * Result : 690 * Remark : 691 * Status : 692 * 693 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 694 *****************************************************************************/ 695 696 BOOL HMDeviceHandler::ReleaseMutex(PHMHANDLEDATA pHMHandleData) 697 { 698 dprintf(("KERNEL32: HandleManager::DeviceHandler::ReleaseMutex(%08xh)\n", 699 pHMHandleData->hHMHandle)); 700 701 return (ERROR_INVALID_FUNCTION); 702 } 703 704 705 /***************************************************************************** 706 * Name : HMCreateEvent 707 * Purpose : router function for CreateEvent 708 * Parameters: 709 * Variables : 710 * Result : 711 * Remark : 712 * Status : 713 * 714 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 715 *****************************************************************************/ 716 717 DWORD HMDeviceHandler::CreateEvent(PHMHANDLEDATA pHMHandleData, 718 LPSECURITY_ATTRIBUTES lpsa, 719 BOOL fManualReset, 720 BOOL fInitialState, 721 LPCTSTR lpszEventName) 722 { 723 dprintf(("KERNEL32: HandleManager::DeviceHandler::CreateEvent(%08xh,%08xh,%08xh,%08xh,%s)\n", 724 pHMHandleData, 725 lpsa, 726 fManualReset, 727 fInitialState, 728 lpszEventName)); 729 730 return (ERROR_INVALID_FUNCTION); 731 } 732 733 734 /***************************************************************************** 735 * Name : HMOpenEvent 736 * Purpose : router function for OpenEvent 737 * Parameters: 738 * Variables : 739 * Result : 740 * Remark : 741 * Status : 742 * 743 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 744 *****************************************************************************/ 745 746 DWORD HMDeviceHandler::OpenEvent(PHMHANDLEDATA pHMHandleData, 747 BOOL fInheritHandle, 748 LPCTSTR lpszEventName) 749 { 750 dprintf(("KERNEL32: HandleManager::DeviceHandler::OpenEvent(%08xh,%08xh,%s)\n", 751 pHMHandleData, 752 fInheritHandle, 753 lpszEventName)); 754 755 return (ERROR_INVALID_FUNCTION); 756 } 757 758 759 /***************************************************************************** 760 * Name : HMSetEvent 761 * Purpose : router function for SetEvent 762 * Parameters: 763 * Variables : 764 * Result : 765 * Remark : 766 * Status : 767 * 768 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 769 *****************************************************************************/ 770 771 BOOL HMDeviceHandler::SetEvent(PHMHANDLEDATA pHMHandleData) 772 { 773 dprintf(("KERNEL32: HandleManager::DeviceHandler::SetEvent(%08xh)\n", 774 pHMHandleData->hHMHandle)); 775 776 return (ERROR_INVALID_FUNCTION); 777 } 778 779 780 /***************************************************************************** 781 * Name : HMPulseEvent 782 * Purpose : router function for PulseEvent 783 * Parameters: 784 * Variables : 785 * Result : 786 * Remark : 787 * Status : 788 * 789 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 790 *****************************************************************************/ 791 792 BOOL HMDeviceHandler::PulseEvent(PHMHANDLEDATA pHMHandleData) 793 { 794 dprintf(("KERNEL32: HandleManager::DeviceHandler::PulseEvent(%08xh)\n", 795 pHMHandleData->hHMHandle)); 796 797 return (ERROR_INVALID_FUNCTION); 798 } 799 800 801 /***************************************************************************** 802 * Name : HMResetEvent 803 * Purpose : router function for ResetEvent 804 * Parameters: 805 * Variables : 806 * Result : 807 * Remark : 808 * Status : 809 * 810 * Author : Patrick Haller [Tue, 1999/07/06 20:44] 811 *****************************************************************************/ 812 813 BOOL HMDeviceHandler::ResetEvent(PHMHANDLEDATA pHMHandleData) 814 { 815 dprintf(("KERNEL32: HandleManager::DeviceHandler::ResetEvent(%08xh)\n", 816 pHMHandleData->hHMHandle)); 817 818 return (ERROR_INVALID_FUNCTION); 819 } 820 821 822 823 /***************************************************************************** 824 * Name : DWORD HMDeviceHandler::WaitForSingleObject 825 * Purpose : object synchronization 826 * Parameters: PHMHANDLEDATA pHMHandleData 827 * DWORD dwTimeout 828 * Variables : 829 * Result : API returncode 830 * Remark : 831 * Status : 832 * 833 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 834 *****************************************************************************/ 835 836 DWORD HMDeviceHandler::WaitForSingleObject(PHMHANDLEDATA pHMHandleData, 837 DWORD dwTimeout) 838 { 839 dprintf(("KERNEL32: HandleManager::DeviceHandler::WaitForSingleObject(%08xh,%08h)\n", 840 pHMHandleData->hHMHandle, 841 dwTimeout)); 842 843 return(ERROR_INVALID_FUNCTION); 844 } 845 846 847 /***************************************************************************** 848 * Name : DWORD HMDeviceHandler::WaitForSingleObjectEx 849 * Purpose : object synchronization 850 * Parameters: PHMHANDLEDATA pHMHandleData 851 * DWORD dwTimeout 852 * BOOL fAlertable 853 * Variables : 854 * Result : API returncode 855 * Remark : 856 * Status : 857 * 858 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 859 *****************************************************************************/ 860 861 DWORD HMDeviceHandler::WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData, 862 DWORD dwTimeout, 863 BOOL fAlertable) 864 { 865 dprintf(("KERNEL32: HandleManager::DeviceHandler::WaitForSingleObjectEx(%08xh,%08h,%08xh) not implemented correctly.\n", 866 pHMHandleData->hHMHandle, 867 dwTimeout, 868 fAlertable)); 869 870 //@@@PH: WARNING mapped to WaitForSingleObject simply. fAlertable missing! 871 return(ERROR_INVALID_FUNCTION); 872 } 873 874 875 /***************************************************************************** 876 * Name : DWORD HMDeviceHandler::FlushFileBuffers 877 * Purpose : flush the buffers of a file 878 * Parameters: PHMHANDLEDATA pHMHandleData 879 * Variables : 880 * Result : API returncode 881 * Remark : 882 * Status : 883 * 884 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 885 *****************************************************************************/ 886 887 BOOL HMDeviceHandler::FlushFileBuffers(PHMHANDLEDATA pHMHandleData) 888 { 889 dprintf(("KERNEL32: HandleManager::Open32:FlushFileBuffers(%08xh)\n", 890 pHMHandleData->hHMHandle)); 891 892 return(ERROR_INVALID_FUNCTION); 893 } 894 895 896 /***************************************************************************** 897 * Name : DWORD HMDeviceHandler::GetOverlappedResult 898 * Purpose : asynchronus I/O 899 * Parameters: PHMHANDLEDATA pHMHandleData 900 * LPOVERLAPPED arg2 901 * LPDWORD arg3 902 * BOOL arg4 903 * Variables : 904 * Result : API returncode 905 * Remark : 906 * Status : 907 * 908 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 909 *****************************************************************************/ 910 911 BOOL HMDeviceHandler::GetOverlappedResult(PHMHANDLEDATA pHMHandleData, 912 LPOVERLAPPED arg2, 913 LPDWORD arg3, 914 BOOL arg4) 915 { 916 dprintf(("KERNEL32: HandleManager::DeviceHandler::GetOverlappedResult(%08xh,%08xh,%08xh,%08xh)\n", 917 pHMHandleData->hHMHandle, 918 arg2, 919 arg3, 920 arg4)); 921 922 return(ERROR_INVALID_FUNCTION); 923 } 924 -
trunk/src/kernel32/hmdevice.h
r271 r278 1 /* $Id: hmdevice.h,v 1. 2 1999-07-05 09:58:14phaller Exp $ */1 /* $Id: hmdevice.h,v 1.3 1999-07-06 15:48:46 phaller Exp $ */ 2 2 3 3 /* … … 124 124 DWORD dwMoveMethod); 125 125 126 /* this is a handler method for calls to FlushFileBuffers() */ 127 virtual BOOL FlushFileBuffers(PHMHANDLEDATA pHMHandleData); 128 129 /* this is a handler method for calls to GetOverlappedResult() */ 130 virtual BOOL GetOverlappedResult (PHMHANDLEDATA pHMHandleData, 131 LPOVERLAPPED lpOverlapped, 132 LPDWORD arg3, 133 BOOL arg4); 134 126 135 /* this is a handler method for calls to LockFile() */ 127 136 virtual DWORD LockFile(PHMHANDLEDATA pHMHandleData, … … 153 162 DWORD nNumberOfBytesToLockHigh, 154 163 LPOVERLAPPED lpOverlapped); 164 165 /* this is a handler method for calls to WaitForSingleObject */ 166 virtual DWORD WaitForSingleObject (PHMHANDLEDATA pHMHandleData, 167 DWORD dwTimeout); 168 169 /* this is a handler method for calls to WaitForSingleObjectEx */ 170 virtual DWORD WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData, 171 DWORD dwTimeout, 172 BOOL fAlertable); 173 174 175 /*************************************************************************** 176 * Events * 177 ***************************************************************************/ 178 179 /* this is a handler method for calls to CreateEvent() */ 180 virtual DWORD CreateEvent (PHMHANDLEDATA pHMHandleData, 181 LPSECURITY_ATTRIBUTES lpsa, 182 BOOL fManualReset, 183 BOOL fInitialState, 184 LPCSTR lpszEventName); 185 186 /* this is a handler method for calls to OpenEvent() */ 187 virtual DWORD OpenEvent (PHMHANDLEDATA pHMHandleData, 188 BOOL fInheritHandle, 189 LPCSTR lpszEventName); 190 191 /* this is a handle method for calls to ResetEvent() */ 192 virtual BOOL ResetEvent (PHMHANDLEDATA pHMHandleData); 193 194 /* this is a handle method for calls to SetEvent() */ 195 virtual BOOL SetEvent (PHMHANDLEDATA pHMHandleData); 196 197 /* this is a handle method for calls to PulseEvent() */ 198 virtual BOOL PulseEvent (PHMHANDLEDATA pHMHandleData); 199 200 201 /*************************************************************************** 202 * Mutex * 203 ***************************************************************************/ 204 205 /* this is a handler method for calls to CreateMutex() */ 206 virtual DWORD CreateMutex (PHMHANDLEDATA pHMHandleData, 207 LPSECURITY_ATTRIBUTES lpsa, 208 BOOL fInitialOwner, 209 LPCSTR lpszMutexName); 210 211 /* this is a handler method for calls to OpenMutex() */ 212 virtual DWORD OpenMutex (PHMHANDLEDATA pHMHandleData, 213 BOOL fInheritHandle, 214 LPCSTR lpszMutexName); 215 216 /* this is a handle method for calls to ReleaseMutex() */ 217 virtual BOOL ReleaseMutex(PHMHANDLEDATA pHMHandleData); 218 219 220 /*************************************************************************** 221 * Semaphores * 222 ***************************************************************************/ 223 224 /* this is a handler method for calls to CreateSemaphore() */ 225 virtual DWORD CreateSemaphore (PHMHANDLEDATA pHMHandleData, 226 LPSECURITY_ATTRIBUTES lpsa, 227 LONG lInitialCount, 228 LONG lMaximumCount, 229 LPCSTR lpszSemaphoreName); 230 231 /* this is a handler method for calls to OpenSemaphore() */ 232 virtual DWORD OpenSemaphore (PHMHANDLEDATA pHMHandleData, 233 BOOL fInheritHandle, 234 LPCSTR lpszSemaphoreName); 235 236 /* this is a handle method for calls to ReleaseSemaphore() */ 237 virtual BOOL ReleaseSemaphore(PHMHANDLEDATA pHMHandleData, 238 LONG cReleaseCount, 239 LPLONG lpPreviousCount); 155 240 }; 156 241 -
trunk/src/kernel32/hmopen32.cpp
r271 r278 1 /* $Id: hmopen32.cpp,v 1. 7 1999-07-05 09:58:14phaller Exp $ */1 /* $Id: hmopen32.cpp,v 1.8 1999-07-06 15:48:47 phaller Exp $ */ 2 2 3 3 /* … … 645 645 nNumberOfBytesToLockHigh)); 646 646 } 647 648 649 /***************************************************************************** 650 * Name : DWORD HMDeviceOpen32Class::WaitForSingleObject 651 * Purpose : object synchronization 652 * Parameters: PHMHANDLEDATA pHMHandleData 653 * DWORD dwTimeout 654 * Variables : 655 * Result : API returncode 656 * Remark : 657 * Status : 658 * 659 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 660 *****************************************************************************/ 661 662 DWORD HMDeviceOpen32Class::WaitForSingleObject(PHMHANDLEDATA pHMHandleData, 663 DWORD dwTimeout) 664 { 665 dprintfl(("KERNEL32: HandleManager::Open32::WaitForSingleObject(%08xh,%08h)\n", 666 pHMHandleData->hHMHandle, 667 dwTimeout)); 668 669 return (O32_WaitForSingleObject(pHMHandleData->hHMHandle, 670 dwTimeout)); 671 } 672 673 674 /***************************************************************************** 675 * Name : DWORD HMDeviceOpen32Class::WaitForSingleObjectEx 676 * Purpose : object synchronization 677 * Parameters: PHMHANDLEDATA pHMHandleData 678 * DWORD dwTimeout 679 * BOOL fAlertable 680 * Variables : 681 * Result : API returncode 682 * Remark : 683 * Status : 684 * 685 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 686 *****************************************************************************/ 687 688 DWORD HMDeviceOpen32Class::WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData, 689 DWORD dwTimeout, 690 BOOL fAlertable) 691 { 692 dprintfl(("KERNEL32: HandleManager::Open32::WaitForSingleObjectEx(%08xh,%08h,%08xh) not implemented correctly.\n", 693 pHMHandleData->hHMHandle, 694 dwTimeout, 695 fAlertable)); 696 697 //@@@PH: WARNING mapped to WaitForSingleObject simply. fAlertable missing! 698 return (O32_WaitForSingleObject(pHMHandleData->hHMHandle, 699 dwTimeout)); 700 } 701 702 703 /***************************************************************************** 704 * Name : DWORD HMDeviceOpen32Class::FlushFileBuffers 705 * Purpose : flush the buffers of a file 706 * Parameters: PHMHANDLEDATA pHMHandleData 707 * Variables : 708 * Result : API returncode 709 * Remark : 710 * Status : 711 * 712 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 713 *****************************************************************************/ 714 715 BOOL HMDeviceOpen32Class::FlushFileBuffers(PHMHANDLEDATA pHMHandleData) 716 { 717 dprintfl(("KERNEL32: HandleManager::Open32:FlushFileBuffers(%08xh)\n", 718 pHMHandleData->hHMHandle)); 719 720 return(O32_FlushFileBuffers(pHMHandleData->hHMHandle)); 721 } 722 723 724 /***************************************************************************** 725 * Name : DWORD HMDeviceOpen32Class::GetOverlappedResult 726 * Purpose : asynchronus I/O 727 * Parameters: PHMHANDLEDATA pHMHandleData 728 * LPOVERLAPPED arg2 729 * LPDWORD arg3 730 * BOOL arg4 731 * Variables : 732 * Result : API returncode 733 * Remark : 734 * Status : 735 * 736 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 737 *****************************************************************************/ 738 739 BOOL HMDeviceOpen32Class::GetOverlappedResult(PHMHANDLEDATA pHMHandleData, 740 LPOVERLAPPED arg2, 741 LPDWORD arg3, 742 BOOL arg4) 743 { 744 dprintfl(("KERNEL32: HandleManager::Open32::GetOverlappedResult(%08xh,%08xh,%08xh,%08xh)\n", 745 pHMHandleData->hHMHandle, 746 arg2, 747 arg3, 748 arg4)); 749 750 return(O32_GetOverlappedResult(pHMHandleData->hHMHandle, 751 arg2, 752 arg3, 753 arg4)); 754 } 755 -
trunk/src/kernel32/hmopen32.h
r111 r278 1 /* $Id: hmopen32.h,v 1. 1 1999-06-17 18:21:43phaller Exp $ */1 /* $Id: hmopen32.h,v 1.2 1999-07-06 15:48:47 phaller Exp $ */ 2 2 3 3 /* … … 126 126 DWORD nNumberOfBytesToLockHigh, 127 127 LPOVERLAPPED lpOverlapped); 128 129 /* this is a handler method for calls to WaitForSingleObject */ 130 virtual DWORD WaitForSingleObject (PHMHANDLEDATA pHMHandleData, 131 DWORD dwTimeout); 132 133 /* this is a handler method for calls to WaitForSingleObjectEx */ 134 virtual DWORD WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData, 135 DWORD dwTimeout, 136 BOOL fAlertable); 137 138 /* this is a handler method for calls to FlushFileBuffers */ 139 virtual BOOL FlushFileBuffers(PHMHANDLEDATA pHMHandleData); 140 141 /* this is a handler method for calls to GetOverlappedResult */ 142 virtual BOOL GetOverlappedResult(PHMHANDLEDATA pHMHandleData, 143 LPOVERLAPPED arg2, 144 LPDWORD arg3, 145 BOOL arg4); 128 146 }; 129 147 -
trunk/src/kernel32/kobjects.cpp
r114 r278 1 /* $Id: kobjects.cpp,v 1. 1 1999-06-17 21:52:01phaller Exp $ */1 /* $Id: kobjects.cpp,v 1.2 1999-07-06 15:48:48 phaller Exp $ */ 2 2 3 3 /* … … 15 15 *****************************************************************************/ 16 16 #include <os2win.h> 17 //#include <winnt.h>18 //#include <winnls.h>19 //#include <stdlib.h>20 //#include <string.h>21 17 #include "misc.h" 22 18 #include "handlemanager.h" … … 25 21 26 22 // REMARK: THIS IS IN PREPARATION FOR HANDLEMANAGER SUPPORT (PH) !! 27 #define HMCreateEvent O32_CreateEvent28 #define HMCreateMutex O32_CreateMutex29 #define HMCreateSemaphore O32_CreateSemaphore30 #define HMSetEvent O32_SetEvent31 #define HMReleaseMutex O32_ReleaseMutex32 #define HMWaitForSingleObject O32_WaitForSingleObject33 #define HMWaitForSingleObjectEx O32_WaitForSingleObjectEx34 #define HMGetOverlappedResult O32_GetOverlappedResult35 #define HMOpenEvent O32_OpenEvent36 #define HMOpenMutex O32_OpenMutex37 #define HMOpenSemaphore O32_OpenSemaphore38 #define HMPulseEvent O32_PulseEvent39 #define HMReleaseSemaphore O32_ReleaseSemaphore40 #define HMResetEvent O32_ResetEvent41 #define HMWaitForMultipleObjects O32_WaitForMultipleObjects42 #define HMWaitForMultipleObjectsEx O32_WaitForMultipleObjectsEx43 #define HMFlushFileBuffers O32_FlushFileBuffers23 //#define HMCreateEvent O32_CreateEvent 24 //#define HMCreateMutex O32_CreateMutex 25 //#define HMCreateSemaphore O32_CreateSemaphore 26 //#define HMSetEvent O32_SetEvent 27 //#define HMReleaseMutex O32_ReleaseMutex 28 //#define HMWaitForSingleObject O32_WaitForSingleObject 29 //#define HMWaitForSingleObjectEx O32_WaitForSingleObjectEx 30 //#define HMGetOverlappedResult O32_GetOverlappedResult 31 //#define HMOpenEvent O32_OpenEvent 32 //#define HMOpenMutex O32_OpenMutex 33 //#define HMOpenSemaphore O32_OpenSemaphore 34 //#define HMPulseEvent O32_PulseEvent 35 //#define HMReleaseSemaphore O32_ReleaseSemaphore 36 //#define HMResetEvent O32_ResetEvent 37 //#define HMWaitForMultipleObjects O32_WaitForMultipleObjects 38 //#define HMWaitForMultipleObjectsEx O32_WaitForMultipleObjectsEx 39 //#define HMFlushFileBuffers O32_FlushFileBuffers 44 40 #define HMSetHandleCount O32_SetHandleCount 45 41 #define HMGetHandleCount O32_GetHandleCount … … 281 277 fAlertable)); 282 278 283 return(HMWaitForSingleObject(hObject, 284 dwTimeout)); 279 return(HMWaitForSingleObjectEx(hObject, 280 dwTimeout, 281 fAlertable)); 285 282 } 286 283 … … 743 740 744 741 return HMWaitForMultipleObjects(arg1, 745 arg2,742 (PHANDLE)arg2, 746 743 arg3, 747 744 arg4); … … 784 781 fAlertable)); 785 782 786 return(HMWaitForMultipleObjects(cObjects, 787 lphObjects, 788 fWaitAll, 789 dwTimeout)); 783 return(HMWaitForMultipleObjectsEx(cObjects, 784 (PHANDLE)lphObjects, 785 fWaitAll, 786 dwTimeout, 787 fAlertable)); 790 788 } 791 789 -
trunk/src/kernel32/makefile
r262 r278 1 # $Id: makefile,v 1.1 0 1999-07-04 09:41:33 sandervlExp $1 # $Id: makefile,v 1.11 1999-07-06 15:48:48 phaller Exp $ 2 2 3 3 # … … 57 57 hmdevice.obj \ 58 58 hmopen32.obj \ 59 hmobjects.obj \ 60 hmevent.obj \ 61 hmmutex.obj \ 62 hmsemaphore.obj \ 59 63 wprocess.OBJ \ 60 64 conprop.OBJ \ … … 297 301 $(PDWIN32_INCLUDE)\handlemanager.h 298 302 303 hmobjects.obj: \ 304 .\hmobjects.cpp \ 305 .\hmobjects.h \ 306 $(PDWIN32_INCLUDE)\handlemanager.h 307 308 hmevent.obj: \ 309 .\hmevent.cpp \ 310 .\hmevent.h \ 311 .\hmdevice.h \ 312 .\hmopen32.h 313 314 hmmutex.obj: \ 315 .\hmmutex.cpp \ 316 .\hmmutex.h \ 317 .\hmdevice.h \ 318 .\hmopen32.h 319 320 hmsemaphore.obj: \ 321 .\hmsemaphore.cpp \ 322 .\hmsemaphore.h \ 323 .\hmdevice.h \ 324 .\hmopen32.h 299 325 300 326 conprop.OBJ: \
Note:
See TracChangeset
for help on using the changeset viewer.