Changeset 3642 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Jun 1, 2000, 1:28:48 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r3588 r3642 1 /* $Id: HandleManager.cpp,v 1. 39 2000-05-22 19:07:52 sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.40 2000-06-01 11:28:42 sandervl Exp $ */ 2 2 3 3 /* … … 52 52 #include "HMOpen32.h" 53 53 #include "HMEvent.h" 54 #include "HMFile.h" 54 55 #include "HMMutex.h" 55 56 #include "HMSemaphore.h" … … 125 126 HMDeviceHandler *pHMOpen32; /* default handle manager instance */ 126 127 HMDeviceHandler *pHMEvent; /* static instances of subsystems */ 128 HMDeviceHandler *pHMFile; 127 129 HMDeviceHandler *pHMMutex; 128 130 HMDeviceHandler *pHMSemaphore; … … 354 356 HMGlobals.pHMOpen32 = new HMDeviceOpen32Class("\\\\.\\"); 355 357 HMGlobals.pHMEvent = new HMDeviceEventClass("\\\\EVENT\\"); 358 HMGlobals.pHMFile = new HMDeviceFileClass("\\\\FILE\\"); 356 359 HMGlobals.pHMMutex = new HMDeviceMutexClass("\\\\MUTEX\\"); 357 360 HMGlobals.pHMSemaphore = new HMDeviceSemaphoreClass("\\\\SEM\\"); … … 383 386 delete HMGlobals.pHMOpen32; 384 387 delete HMGlobals.pHMEvent; 388 delete HMGlobals.pHMFile; 385 389 delete HMGlobals.pHMMutex; 386 390 delete HMGlobals.pHMSemaphore; … … 706 710 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 707 711 PHMHANDLEDATA pHMHandleData; 708 DWORDrc; /* API return code */712 BOOL rc; /* API return code */ 709 713 710 714 if(HMHandleValidate(srchandle) != NO_ERROR) … … 758 762 HMCloseHandle(srchandle); 759 763 760 if (rc != NO_ERROR) /* oops, creation failed within the device handler */764 if(rc == FALSE) /* oops, creation failed within the device handler */ 761 765 { 762 766 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 763 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */764 767 return FALSE; /* signal error */ 765 768 } … … 827 830 else 828 831 pHMHandleData = NULL; 832 833 if(pDeviceHandler == HMGlobals.pHMOpen32) { 834 pDeviceHandler = HMGlobals.pHMFile; 835 } 829 836 } 830 837 … … 962 969 pHMHandleData = NULL; 963 970 971 if(pDeviceHandler == HMGlobals.pHMOpen32) { 972 pDeviceHandler = HMGlobals.pHMFile; 973 } 964 974 965 975 iIndexNew = _HMHandleGetFree(); /* get free handle */ … … 1003 1013 #endif 1004 1014 1005 if (rc != NO_ERROR) /* oops, creation failed within the device handler */ 1006 { 1007 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1008 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1009 return (INVALID_HANDLE_VALUE); /* signal error */ 1010 } 1011 else 1012 SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this? 1015 if(rc != NO_ERROR) /* oops, creation failed within the device handler */ 1016 { 1017 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1018 SetLastError(rc); /* Hehe, OS/2 and NT are pretty compatible :) */ 1019 return (INVALID_HANDLE_VALUE); /* signal error */ 1020 } 1021 else { 1022 if(fuMode & (OF_DELETE|OF_EXIST)) { 1023 //file handle already closed 1024 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1025 return TRUE; //TODO: correct? 1026 } 1027 if(fuMode & OF_PARSE) { 1028 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1029 return 0; 1030 } 1031 if(fuMode & OF_VERIFY) { 1032 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 1033 return 1; //TODO: correct? 1034 } 1035 } 1013 1036 1014 1037 #ifdef DEBUG_LOCAL … … 1119 1142 return (fResult); /* deliver return code */ 1120 1143 } 1121 1144 /***************************************************************************** 1145 * Name : HANDLE HMReadFileEx 1146 * Purpose : Wrapper for the ReadFileEx() API 1147 * Parameters: 1148 * Variables : 1149 * Result : 1150 * Remark : 1151 * Status : 1152 * 1153 * Author : SvL 1154 *****************************************************************************/ 1155 BOOL HMReadFileEx(HANDLE hFile, 1156 LPVOID lpBuffer, 1157 DWORD nNumberOfBytesToRead, 1158 LPOVERLAPPED lpOverlapped, 1159 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1160 { 1161 int iIndex; /* index into the handle table */ 1162 BOOL fResult; /* result from the device handler's CloseHandle() */ 1163 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1164 1165 /* validate handle */ 1166 iIndex = _HMHandleQuery(hFile); /* get the index */ 1167 if (-1 == iIndex) /* error ? */ 1168 { 1169 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1170 return (FALSE); /* signal failure */ 1171 } 1172 1173 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1174 fResult = pHMHandle->pDeviceHandler->ReadFileEx(&pHMHandle->hmHandleData, 1175 lpBuffer, 1176 nNumberOfBytesToRead, 1177 lpOverlapped, 1178 lpCompletionRoutine); 1179 1180 return (fResult); /* deliver return code */ 1181 } 1122 1182 1123 1183 /***************************************************************************** … … 1134 1194 1135 1195 BOOL HMWriteFile(HANDLE hFile, 1136 1137 1138 1139 1196 LPCVOID lpBuffer, 1197 DWORD nNumberOfBytesToWrite, 1198 LPDWORD lpNumberOfBytesWritten, 1199 LPOVERLAPPED lpOverlapped) 1140 1200 { 1141 1201 int iIndex; /* index into the handle table */ … … 1157 1217 lpNumberOfBytesWritten, 1158 1218 lpOverlapped); 1219 1220 return (fResult); /* deliver return code */ 1221 } 1222 1223 /***************************************************************************** 1224 * Name : HANDLE HMWriteFileEx 1225 * Purpose : Wrapper for the WriteFileEx() API 1226 * Parameters: 1227 * Variables : 1228 * Result : 1229 * Remark : 1230 * Status : 1231 * 1232 * Author : SvL 1233 *****************************************************************************/ 1234 BOOL HMWriteFileEx(HANDLE hFile, 1235 LPVOID lpBuffer, 1236 DWORD nNumberOfBytesToWrite, 1237 LPOVERLAPPED lpOverlapped, 1238 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1239 { 1240 int iIndex; /* index into the handle table */ 1241 BOOL fResult; /* result from the device handler's CloseHandle() */ 1242 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1243 1244 /* validate handle */ 1245 iIndex = _HMHandleQuery(hFile); /* get the index */ 1246 if (-1 == iIndex) /* error ? */ 1247 { 1248 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1249 return (FALSE); /* signal failure */ 1250 } 1251 1252 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1253 fResult = pHMHandle->pDeviceHandler->WriteFileEx(&pHMHandle->hmHandleData, 1254 lpBuffer, 1255 nNumberOfBytesToWrite, 1256 lpOverlapped, 1257 lpCompletionRoutine); 1159 1258 1160 1259 return (fResult); /* deliver return code */ … … 1598 1697 1599 1698 BOOL HMUnlockFileEx(HANDLE hFile, 1600 DWORD dwFlags,1601 1699 DWORD dwReserved, 1602 1700 DWORD nNumberOfBytesToLockLow, … … 1618 1716 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1619 1717 dwResult = pHMHandle->pDeviceHandler->UnlockFileEx(&pHMHandle->hmHandleData, 1620 dwFlags,1621 1718 dwReserved, 1622 1719 nNumberOfBytesToLockLow,
Note:
See TracChangeset
for help on using the changeset viewer.