Changeset 7549 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Dec 5, 2001, 3:16:38 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r7532 r7549 1 /* $Id: HandleManager.cpp,v 1.8 2 2001-12-03 12:13:06 sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.83 2001-12-05 14:15:56 sandervl Exp $ */ 2 2 3 3 /* … … 268 268 TabWin32Handles[ulLoop].hmHandleData.dwUserData = 0; 269 269 TabWin32Handles[ulLoop].hmHandleData.dwInternalType = HMTYPE_UNKNOWN; 270 TabWin32Handles[ulLoop].hmHandleData.hWin32Handle = (HANDLE)ulLoop; 270 271 TabWin32Handles[ulLoop].hmHandleData.lpDeviceData = NULL; 271 272 handleMutex.leave(); … … 845 846 /* initialize the complete HMHANDLEDATA structure */ 846 847 pHMHandleData = &TabWin32Handles[hHandle].hmHandleData; 847 pHMHandleData->dwType = FILE_TYPE_CHAR;848 848 pHMHandleData->dwAccess = 0; 849 849 pHMHandleData->dwShare = 0; … … 916 916 /* initialize the complete HMHANDLEDATA structure */ 917 917 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 918 pHMHandleData->dwType = TabWin32Handles[srchandle].hmHandleData.dwType;919 918 if (fdwOptions & DUPLICATE_SAME_ACCESS) 920 pHMHandleData->dwAccess = TabWin32Handles[srchandle].hmHandleData.dwAccess;919 pHMHandleData->dwAccess = TabWin32Handles[srchandle].hmHandleData.dwAccess; 921 920 else 922 pHMHandleData->dwAccess = fdwAccess;921 pHMHandleData->dwAccess = fdwAccess; 923 922 924 923 if((fdwOdinOptions & DUPLICATE_ACCESS_READWRITE) == DUPLICATE_ACCESS_READWRITE) { 925 pHMHandleData->dwAccess = GENERIC_READ | GENERIC_WRITE;924 pHMHandleData->dwAccess = GENERIC_READ | GENERIC_WRITE; 926 925 } 927 926 else 928 927 if(fdwOdinOptions & DUPLICATE_ACCESS_READ) { 929 pHMHandleData->dwAccess = GENERIC_READ;928 pHMHandleData->dwAccess = GENERIC_READ; 930 929 } 931 930 932 931 if(fdwOdinOptions & DUPLICATE_SHARE_READ) { 933 pHMHandleData->dwShare = FILE_SHARE_READ;932 pHMHandleData->dwShare = FILE_SHARE_READ; 934 933 } 935 934 else 936 935 if(fdwOdinOptions & DUPLICATE_SHARE_DENYNONE) { 937 pHMHandleData->dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE;936 pHMHandleData->dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE; 938 937 } 939 938 else pHMHandleData->dwShare = TabWin32Handles[srchandle].hmHandleData.dwShare; … … 1069 1068 else 1070 1069 { 1071 HMHandleTemp.dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */1072 1070 HMHandleTemp.dwAccess = dwDesiredAccess; 1073 1071 HMHandleTemp.dwShare = dwShareMode; … … 1089 1087 sizeof(HMHANDLEDATA)); 1090 1088 1091 rc = pDeviceHandler->CreateFile( (HANDLE)iIndexNew,lpFileName, /* call the device handler */1089 rc = pDeviceHandler->CreateFile(lpFileName, /* call the device handler */ 1092 1090 &HMHandleTemp, 1093 1091 lpSecurityAttributes, … … 1215 1213 } 1216 1214 1217 1218 /* initialize the complete HMHANDLEDATA structure */ 1215 /* initialize the complete HMHANDLEDATA structure */ 1219 1216 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 1220 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */1221 1217 1222 1218 FILE_ConvertOFMode(fuMode, /* map OF_flags */ … … 1231 1227 pHMHandleData->lpDeviceData = pDevData; 1232 1228 1233 1234 1235 1236 1229 /* we've got to mark the handle as occupied here, since another device */ 1230 /* could be created within the device handler -> deadlock */ 1231 1232 /* write appropriate entry into the handle table if open succeeded */ 1237 1233 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 1238 1234 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 1239 1235 1240 rc = pDeviceHandler->OpenFile ((HANDLE)iIndexNew,lpFileName, /* call the device handler */1241 1242 1243 1236 rc = pDeviceHandler->OpenFile(lpFileName, /* call the device handler */ 1237 &TabWin32Handles[iIndexNew].hmHandleData, 1238 pOFStruct, 1239 fuMode); 1244 1240 1245 1241 #ifdef DEBUG_LOCAL … … 1356 1352 DWORD nNumberOfBytesToRead, 1357 1353 LPDWORD lpNumberOfBytesRead, 1358 LPOVERLAPPED lpOverlapped) 1354 LPOVERLAPPED lpOverlapped, 1355 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1359 1356 { 1360 1357 int iIndex; /* index into the handle table */ … … 1375 1372 nNumberOfBytesToRead, 1376 1373 lpNumberOfBytesRead, 1377 lpOverlapped); 1378 1379 return (fResult); /* deliver return code */ 1380 } 1381 /***************************************************************************** 1382 * Name : HANDLE HMReadFileEx 1383 * Purpose : Wrapper for the ReadFileEx() API 1384 * Parameters: 1385 * Variables : 1386 * Result : 1387 * Remark : 1388 * Status : 1389 * 1390 * Author : SvL 1391 *****************************************************************************/ 1392 BOOL HMReadFileEx(HANDLE hFile, 1393 LPVOID lpBuffer, 1394 DWORD nNumberOfBytesToRead, 1395 LPOVERLAPPED lpOverlapped, 1396 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1397 { 1398 int iIndex; /* index into the handle table */ 1399 BOOL fResult; /* result from the device handler's CloseHandle() */ 1400 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1401 1402 /* validate handle */ 1403 iIndex = _HMHandleQuery(hFile); /* get the index */ 1404 if (-1 == iIndex) /* error ? */ 1405 { 1406 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1407 return (FALSE); /* signal failure */ 1408 } 1409 1410 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1411 fResult = pHMHandle->pDeviceHandler->ReadFileEx(&pHMHandle->hmHandleData, 1412 lpBuffer, 1413 nNumberOfBytesToRead, 1414 lpOverlapped, 1415 lpCompletionRoutine); 1374 lpOverlapped, lpCompletionRoutine); 1416 1375 1417 1376 return (fResult); /* deliver return code */ … … 1434 1393 DWORD nNumberOfBytesToWrite, 1435 1394 LPDWORD lpNumberOfBytesWritten, 1436 LPOVERLAPPED lpOverlapped) 1395 LPOVERLAPPED lpOverlapped, 1396 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1437 1397 { 1438 1398 int iIndex; /* index into the handle table */ … … 1453 1413 nNumberOfBytesToWrite, 1454 1414 lpNumberOfBytesWritten, 1455 lpOverlapped); 1456 1457 return (fResult); /* deliver return code */ 1458 } 1459 1460 /***************************************************************************** 1461 * Name : HANDLE HMWriteFileEx 1462 * Purpose : Wrapper for the WriteFileEx() API 1463 * Parameters: 1464 * Variables : 1465 * Result : 1466 * Remark : 1467 * Status : 1468 * 1469 * Author : SvL 1470 *****************************************************************************/ 1471 BOOL HMWriteFileEx(HANDLE hFile, 1472 LPVOID lpBuffer, 1473 DWORD nNumberOfBytesToWrite, 1474 LPOVERLAPPED lpOverlapped, 1475 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1476 { 1477 int iIndex; /* index into the handle table */ 1478 BOOL fResult; /* result from the device handler's CloseHandle() */ 1479 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 1480 1481 /* validate handle */ 1482 iIndex = _HMHandleQuery(hFile); /* get the index */ 1483 if (-1 == iIndex) /* error ? */ 1484 { 1485 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1486 return (FALSE); /* signal failure */ 1487 } 1488 1489 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1490 fResult = pHMHandle->pDeviceHandler->WriteFileEx(&pHMHandle->hmHandleData, 1491 lpBuffer, 1492 nNumberOfBytesToWrite, 1493 lpOverlapped, 1494 lpCompletionRoutine); 1415 lpOverlapped, lpCompletionRoutine); 1495 1416 1496 1417 return (fResult); /* deliver return code */ … … 2346 2267 /* Initialize the complete HMHANDLEDATA structure */ 2347 2268 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2348 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2349 2269 pHMHandleData->dwAccess = 0; 2350 2270 pHMHandleData->dwShare = 0; … … 2424 2344 /* initialize the complete HMHANDLEDATA structure */ 2425 2345 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2426 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2427 2346 pHMHandleData->dwAccess = 0; 2428 2347 pHMHandleData->dwShare = 0; … … 2492 2411 /* initialize the complete HMHANDLEDATA structure */ 2493 2412 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2494 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2495 2413 pHMHandleData->dwAccess = fdwAccess; 2496 2414 pHMHandleData->dwShare = 0; … … 2559 2477 /* initialize the complete HMHANDLEDATA structure */ 2560 2478 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2561 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2562 2479 pHMHandleData->dwAccess = fdwAccess; 2563 2480 pHMHandleData->dwShare = 0; … … 2636 2553 /* initialize the complete HMHANDLEDATA structure */ 2637 2554 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2638 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2639 2555 pHMHandleData->dwAccess = 0; 2640 2556 pHMHandleData->dwShare = 0; … … 2705 2621 /* initialize the complete HMHANDLEDATA structure */ 2706 2622 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2707 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2708 2623 pHMHandleData->dwAccess = fdwAccess; 2709 2624 pHMHandleData->dwShare = 0; … … 2812 2727 /* initialize the complete HMHANDLEDATA structure */ 2813 2728 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2814 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2815 2729 pHMHandleData->dwAccess = 0; 2816 2730 pHMHandleData->dwShare = 0; … … 2890 2804 /* initialize the complete HMHANDLEDATA structure */ 2891 2805 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2892 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */2893 2806 pHMHandleData->dwAccess = fdwAccess; 2894 2807 pHMHandleData->dwShare = 0; … … 3878 3791 /* initialize the complete HMHANDLEDATA structure */ 3879 3792 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 3880 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */3881 3793 pHMHandleData->dwAccess = DesiredAccess; 3882 3794 pHMHandleData->dwShare = 0; … … 3946 3858 /* initialize the complete HMHANDLEDATA structure */ 3947 3859 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 3948 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */3949 3860 pHMHandleData->dwAccess = DesiredAccess; 3950 3861 pHMHandleData->dwShare = 0; … … 4018 3929 /* initialize the complete HMHANDLEDATA structure */ 4019 3930 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 4020 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */4021 3931 pHMHandleData->dwAccess = 0; 4022 3932 pHMHandleData->dwShare = 0; … … 4411 4321 /* initialize the complete HMHANDLEDATA structure */ 4412 4322 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 4413 pHMHandleData->dwType = FILE_TYPE_PIPE;4414 4323 pHMHandleData->dwAccess = 0; 4415 4324 pHMHandleData->dwShare = 0; … … 4721 4630 /* initialize the complete HMHANDLEDATA structure */ 4722 4631 pHMHandleData = &TabWin32Handles[iIndexNewRead].hmHandleData; 4723 pHMHandleData->dwType = FILE_TYPE_PIPE;4724 4632 pHMHandleData->dwAccess = 0; 4725 4633 pHMHandleData->dwShare = 0; … … 4737 4645 /* initialize the complete HMHANDLEDATA structure */ 4738 4646 pHMHandleData = &TabWin32Handles[iIndexNewWrite].hmHandleData; 4739 pHMHandleData->dwType = FILE_TYPE_PIPE;4740 4647 pHMHandleData->dwAccess = 0; 4741 4648 pHMHandleData->dwShare = 0; … … 4804 4711 /* initialize the complete HMHANDLEDATA structure */ 4805 4712 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 4806 pHMHandleData->dwType = FILE_TYPE_UNKNOWN;4807 4713 pHMHandleData->dwAccess = 0; 4808 4714 pHMHandleData->dwShare = 0;
Note:
See TracChangeset
for help on using the changeset viewer.