- Timestamp:
- Jun 1, 2000, 1:28:48 PM (25 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/Fileio.cpp
r3588 r3642 1 /* $Id: Fileio.cpp,v 1.3 3 2000-05-22 19:07:53sandervl Exp $ */1 /* $Id: Fileio.cpp,v 1.34 2000-06-01 11:28:45 sandervl Exp $ */ 2 2 3 3 /* … … 234 234 //****************************************************************************** 235 235 ODINFUNCTION2(INT, CompareFileTime, 236 FILETIME *, arg1, 237 FILETIME *, arg2) 238 { 239 return O32_CompareFileTime(arg1, arg2); 236 FILETIME *, lpft1, 237 FILETIME *, lpft2) 238 { 239 if (lpft1 == NULL || lpft2 == NULL) { 240 SetLastError(ERROR_INVALID_PARAMETER); 241 return -1; 242 } 243 244 if(lpft1->dwHighDateTime > lpft2->dwHighDateTime) 245 return 1; 246 247 if(lpft1->dwHighDateTime < lpft2->dwHighDateTime) 248 return -1; 249 250 if(lpft1->dwLowDateTime > lpft2->dwLowDateTime) 251 return 1; 252 253 if(lpft1->dwLowDateTime < lpft2->dwLowDateTime) 254 return -1; 255 256 return 0; //equal 240 257 } 241 258 //****************************************************************************** … … 288 305 BOOL rc; 289 306 290 rc = O32_DeleteFile(lpszFile); 307 #if 0 308 return 1; 309 #else 310 rc = OSLibDosDelete((LPSTR)lpszFile); 291 311 if(!rc) { 292 312 dprintf(("DeleteFileA %s returned FALSE; last error %x", lpszFile, GetLastError())); … … 298 318 299 319 return rc; 320 #endif 300 321 } 301 322 //****************************************************************************** … … 382 403 //****************************************************************************** 383 404 //****************************************************************************** 384 ODINFUNCTION4(DWORD, SetFilePointer, 385 HANDLE, hFile, 386 LONG, lDistanceToMove, 387 PLONG, lpDistanceToMoveHigh, 388 DWORD, dwMoveMethod) 389 { 390 dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n", 391 hFile, 392 lDistanceToMove, 393 lpDistanceToMoveHigh, 394 dwMoveMethod)); 395 396 return(HMSetFilePointer(hFile, 397 lDistanceToMove, 398 lpDistanceToMoveHigh, 399 dwMoveMethod)); 405 ODINFUNCTION5(BOOL, ReadFileEx, 406 HANDLE, hFile, 407 LPVOID, lpBuffer, 408 DWORD, nNumberOfBytesToRead, 409 LPOVERLAPPED, lpOverlapped, 410 LPOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine) 411 { 412 return (HMReadFileEx(hFile, 413 lpBuffer, 414 nNumberOfBytesToRead, 415 lpOverlapped, lpCompletionRoutine)); 400 416 } 401 417 //****************************************************************************** … … 408 424 LPOVERLAPPED, lpOverlapped) 409 425 { 410 dprintf(("KERNEL32: WriteFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",411 hFile,412 buffer,413 nrbytes,414 nrbyteswritten,415 lpOverlapped));416 417 426 return (HMWriteFile(hFile, 418 427 buffer, … … 420 429 nrbyteswritten, 421 430 lpOverlapped)); 431 } 432 /***************************************************************************** 433 * Name : BOOL WriteFileEx 434 * Purpose : The WriteFileEx function writes data to a file. It is designed 435 * solely for asynchronous operation, unlike WriteFile, which is 436 * designed for both synchronous and asynchronous operation. 437 * WriteFileEx reports its completion status asynchronously, 438 * calling a specified completion routine when writing is completed 439 * and the calling thread is in an alertable wait state. 440 * Parameters: HANDLE hFile handle of file to write 441 * LPVOID lpBuffer address of buffer 442 * DWORD nNumberOfBytesToRead number of bytes to write 443 * LPOVERLAPPED lpOverlapped address of offset 444 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine 445 * Variables : 446 * Result : TRUE / FALSE 447 * Remark : 448 * Status : UNTESTED STUB 449 * 450 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 451 *****************************************************************************/ 452 453 ODINFUNCTION5(BOOL, WriteFileEx, 454 HANDLE, hFile, 455 LPVOID, lpBuffer, 456 DWORD, nNumberOfBytesToWrite, 457 LPOVERLAPPED, lpOverlapped, 458 LPOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine) 459 { 460 return (HMWriteFileEx(hFile, 461 lpBuffer, 462 nNumberOfBytesToWrite, 463 lpOverlapped, lpCompletionRoutine)); 464 } 465 //****************************************************************************** 466 //****************************************************************************** 467 ODINFUNCTION4(DWORD, SetFilePointer, 468 HANDLE, hFile, 469 LONG, lDistanceToMove, 470 PLONG, lpDistanceToMoveHigh, 471 DWORD, dwMoveMethod) 472 { 473 dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n", 474 hFile, 475 lDistanceToMove, 476 lpDistanceToMoveHigh, 477 dwMoveMethod)); 478 479 return(HMSetFilePointer(hFile, 480 lDistanceToMove, 481 lpDistanceToMoveHigh, 482 dwMoveMethod)); 422 483 } 423 484 //****************************************************************************** … … 751 812 lpOverlapped)); 752 813 753 return(HMUnlockFile(hFile, 754 lpOverlapped->Offset, 755 lpOverlapped->OffsetHigh, 756 nNumberOfBytesToLockLow, 757 nNumberOfBytesToLockHigh)); 814 return(HMUnlockFileEx(hFile, dwReserved, 815 nNumberOfBytesToLockLow, 816 nNumberOfBytesToLockHigh, 817 lpOverlapped)); 758 818 } 759 819 //****************************************************************************** -
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, -
trunk/src/kernel32/async.cpp
r2802 r3642 1 /* $Id: async.cpp,v 1. 7 2000-02-16 14:25:30sandervl Exp $ */1 /* $Id: async.cpp,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */ 2 2 3 3 /* … … 114 114 } 115 115 116 117 /*****************************************************************************118 * Name : BOOL ReadFileEx119 * Purpose : The ReadFileEx function reads data from a file asynchronously.120 * It is designed solely for asynchronous operation, unlike the121 * ReadFile function, which is designed for both synchronous and122 * asynchronous operation. ReadFileEx lets an application perform123 * other processing during a file read operation.124 * The ReadFileEx function reports its completion status asynchronously,125 * calling a specified completion routine when reading is completed126 * and the calling thread is in an alertable wait state.127 * Parameters: HANDLE hFile handle of file to read128 * LPVOID lpBuffer address of buffer129 * DWORD nNumberOfBytesToRead number of bytes to read130 * LPOVERLAPPED lpOverlapped address of offset131 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine132 * Variables :133 * Result : TRUE / FALSE134 * Remark :135 * Status : UNTESTED STUB136 *137 * Author : Patrick Haller [Mon, 1998/06/15 08:00]138 *****************************************************************************/139 140 #define LPOVERLAPPED_COMPLETION_ROUTINE LPVOID141 142 DWORD WIN32API ReadFileEx(HANDLE hFile,143 LPVOID lpBuffer,144 DWORD nNumberOfBytesToRead,145 LPOVERLAPPED lpOverlapped,146 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)147 {148 dprintf(("Kernel32: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",149 hFile,150 lpBuffer,151 nNumberOfBytesToRead,152 lpOverlapped,153 lpCompletionRoutine));154 155 156 return (FALSE);157 }158 159 160 /*****************************************************************************161 * Name : BOOL WriteFileEx162 * Purpose : The WriteFileEx function writes data to a file. It is designed163 * solely for asynchronous operation, unlike WriteFile, which is164 * designed for both synchronous and asynchronous operation.165 * WriteFileEx reports its completion status asynchronously,166 * calling a specified completion routine when writing is completed167 * and the calling thread is in an alertable wait state.168 * Parameters: HANDLE hFile handle of file to write169 * LPVOID lpBuffer address of buffer170 * DWORD nNumberOfBytesToRead number of bytes to write171 * LPOVERLAPPED lpOverlapped address of offset172 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine173 * Variables :174 * Result : TRUE / FALSE175 * Remark :176 * Status : UNTESTED STUB177 *178 * Author : Patrick Haller [Mon, 1998/06/15 08:00]179 *****************************************************************************/180 181 DWORD WIN32API WriteFileEx(HANDLE hFile,182 LPVOID lpBuffer,183 DWORD nNumberOfBytesToWrite,184 LPOVERLAPPED lpOverlapped,185 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)186 {187 dprintf(("Kernel32: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",188 hFile,189 lpBuffer,190 nNumberOfBytesToWrite,191 lpOverlapped,192 lpCompletionRoutine));193 194 195 return (FALSE);196 }197 198 199 116 #endif /* _ASYNCIOSUBSYSTEM_H_ */ -
trunk/src/kernel32/dbglocal.cpp
r3483 r3642 1 /* $Id: dbglocal.cpp,v 1. 7 2000-05-02 20:53:11sandervl Exp $ */1 /* $Id: dbglocal.cpp,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */ 2 2 3 3 /* … … 118 118 "hmprocess", 119 119 "vsemaphore", 120 "exceptstackdump" 120 "exceptstackdump", 121 "hmfile" 121 122 }; 122 123 //****************************************************************************** -
trunk/src/kernel32/dbglocal.h
r3483 r3642 1 /* $Id: dbglocal.h,v 1. 7 2000-05-02 20:53:12sandervl Exp $ */1 /* $Id: dbglocal.h,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */ 2 2 3 3 /* … … 118 118 #define DBG_VSemaphore 96 119 119 #define DBG_exceptstackdump 97 120 #define DBG_MAXFILES 98 120 #define DBG_hmfile 98 121 #define DBG_MAXFILES 99 121 122 122 123 extern USHORT DbgEnabled[DBG_MAXFILES]; -
trunk/src/kernel32/directory.cpp
r3625 r3642 1 /* $Id: directory.cpp,v 1.2 2 2000-05-28 16:45:12sandervl Exp $ */1 /* $Id: directory.cpp,v 1.23 2000-06-01 11:28:44 sandervl Exp $ */ 2 2 3 3 /* … … 159 159 160 160 strcpy(tmp, lpPathName); 161 //SvL: Don't remove terminating backslash if it wants to chdir to root dir 162 if(tmp[len -1] == '\\' && len != 1) 161 if(tmp[len - 1] == '/') { 162 tmp[len-1] = '\\'; 163 } 164 //SvL: Don't remove trailing backslash if it wants to chdir to root dir 165 if((tmp[len - 1] == '\\') && len != 1) 163 166 tmp[len -1] = 0; 164 167 -
trunk/src/kernel32/hmdevice.cpp
r3588 r3642 1 /* $Id: hmdevice.cpp,v 1. 19 2000-05-22 19:07:54sandervl Exp $ */1 /* $Id: hmdevice.cpp,v 1.20 2000-06-01 11:28:45 sandervl Exp $ */ 2 2 3 3 /* … … 126 126 srcprocess, pHMSrcHandle, destprocess, desthandle)); 127 127 128 return (ERROR_INVALID_FUNCTION);128 return FALSE; 129 129 } 130 130 … … 208 208 dprintf(("KERNEL32:HandleManager::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 209 209 lpHMDeviceName, 210 pHMHandleData ,210 pHMHandleData->hHMHandle, 211 211 lpBuffer, 212 212 nNumberOfBytesToRead, … … 218 218 } 219 219 220 /***************************************************************************** 221 * Name : BOOL ReadFileEx 222 * Purpose : The ReadFileEx function reads data from a file asynchronously. 223 * It is designed solely for asynchronous operation, unlike the 224 * ReadFile function, which is designed for both synchronous and 225 * asynchronous operation. ReadFileEx lets an application perform 226 * other processing during a file read operation. 227 * The ReadFileEx function reports its completion status asynchronously, 228 * calling a specified completion routine when reading is completed 229 * and the calling thread is in an alertable wait state. 230 * Parameters: HANDLE hFile handle of file to read 231 * LPVOID lpBuffer address of buffer 232 * DWORD nNumberOfBytesToRead number of bytes to read 233 * LPOVERLAPPED lpOverlapped address of offset 234 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine 235 * Variables : 236 * Result : TRUE / FALSE 237 * Remark : 238 * Status : UNTESTED STUB 239 * 240 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 241 *****************************************************************************/ 242 BOOL HMDeviceHandler::ReadFileEx(PHMHANDLEDATA pHMHandleData, 243 LPVOID lpBuffer, 244 DWORD nNumberOfBytesToRead, 245 LPOVERLAPPED lpOverlapped, 246 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 247 { 248 dprintf(("ERROR: ReadFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 249 lpHMDeviceName, 250 pHMHandleData->hHMHandle, 251 lpBuffer, 252 nNumberOfBytesToRead, 253 lpOverlapped, 254 lpCompletionRoutine)); 255 256 SetLastError(ERROR_INVALID_FUNCTION); 257 return FALSE; 258 } 220 259 221 260 /***************************************************************************** … … 243 282 dprintf(("KERNEL32:HandleManager::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 244 283 lpHMDeviceName, 245 pHMHandleData ,284 pHMHandleData->hHMHandle, 246 285 lpBuffer, 247 286 nNumberOfBytesToWrite, … … 253 292 } 254 293 294 295 /***************************************************************************** 296 * Name : BOOL WriteFileEx 297 * Purpose : The WriteFileEx function writes data to a file. It is designed 298 * solely for asynchronous operation, unlike WriteFile, which is 299 * designed for both synchronous and asynchronous operation. 300 * WriteFileEx reports its completion status asynchronously, 301 * calling a specified completion routine when writing is completed 302 * and the calling thread is in an alertable wait state. 303 * Parameters: HANDLE hFile handle of file to write 304 * LPVOID lpBuffer address of buffer 305 * DWORD nNumberOfBytesToRead number of bytes to write 306 * LPOVERLAPPED lpOverlapped address of offset 307 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine 308 * Variables : 309 * Result : TRUE / FALSE 310 * Remark : 311 * Status : UNTESTED STUB 312 * 313 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 314 *****************************************************************************/ 315 316 BOOL HMDeviceHandler::WriteFileEx(PHMHANDLEDATA pHMHandleData, 317 LPVOID lpBuffer, 318 DWORD nNumberOfBytesToWrite, 319 LPOVERLAPPED lpOverlapped, 320 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 321 { 322 dprintf(("ERROR: WriteFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 323 lpHMDeviceName, 324 pHMHandleData->hHMHandle, 325 lpBuffer, 326 nNumberOfBytesToWrite, 327 lpOverlapped, 328 lpCompletionRoutine)); 329 330 SetLastError(ERROR_INVALID_FUNCTION); 331 return FALSE; 332 } 255 333 256 334 /***************************************************************************** … … 579 657 * Purpose : file locking 580 658 * Parameters: PHMHANDLEDATA pHMHandleData 581 * DWORD dwFlags582 659 * DWORD dwReserved 583 660 * DWORD nNumberOfBytesToLockLow … … 593 670 594 671 DWORD HMDeviceHandler::UnlockFileEx(PHMHANDLEDATA pHMHandleData, 595 DWORD dwFlags,596 672 DWORD dwReserved, 597 673 DWORD nNumberOfBytesToLockLow, … … 599 675 LPOVERLAPPED lpOverlapped) 600 676 { 601 dprintf(("KERNEL32: HandleManager::DeviceHandler::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 602 lpHMDeviceName, 603 pHMHandleData, 604 dwFlags, 677 dprintf(("KERNEL32: HandleManager::DeviceHandler::UnlockFileEx %s,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 678 lpHMDeviceName, 679 pHMHandleData, 605 680 dwReserved, 606 681 nNumberOfBytesToLockLow, -
trunk/src/kernel32/hmdevice.h
r3588 r3642 1 /* $Id: hmdevice.h,v 1.1 8 2000-05-22 19:07:55sandervl Exp $ */1 /* $Id: hmdevice.h,v 1.19 2000-06-01 11:28:46 sandervl Exp $ */ 2 2 3 3 /* … … 112 112 LPOVERLAPPED lpOverlapped); 113 113 114 /* this is a handler method for calls to ReadFileEx() */ 115 virtual BOOL ReadFileEx(PHMHANDLEDATA pHMHandleData, 116 LPVOID lpBuffer, 117 DWORD nNumberOfBytesToRead, 118 LPOVERLAPPED lpOverlapped, 119 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); 120 114 121 /* this is a handler method for calls to WriteFile() */ 115 122 virtual BOOL WriteFile (PHMHANDLEDATA pHMHandleData, … … 118 125 LPDWORD lpNumberOfBytesWritten, 119 126 LPOVERLAPPED lpOverlapped); 127 128 /* this is a handler method for calls to WriteFileEx() */ 129 virtual BOOL WriteFileEx(PHMHANDLEDATA pHMHandleData, 130 LPVOID lpBuffer, 131 DWORD nNumberOfBytesToWrite, 132 LPOVERLAPPED lpOverlapped, 133 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); 120 134 121 135 /* this is a handler method for calls to GetFileType() */ … … 185 199 /* this is a handler method for calls to UnlockFileEx() */ 186 200 virtual DWORD UnlockFileEx(PHMHANDLEDATA pHMHandleData, 187 DWORD dwFlags,188 201 DWORD dwReserved, 189 202 DWORD nNumberOfBytesToLockLow, -
trunk/src/kernel32/hmopen32.cpp
r3593 r3642 1 /* $Id: hmopen32.cpp,v 1.2 3 2000-05-23 18:45:12sandervl Exp $ */1 /* $Id: hmopen32.cpp,v 1.24 2000-06-01 11:28:47 sandervl Exp $ */ 2 2 3 3 /* … … 71 71 } 72 72 73 /***************************************************************************** 74 * Name : DWORD HMDeviceOpen32Class::CloseHandle 75 * Purpose : close the handle 76 * Parameters: PHMHANDLEDATA pHMHandleData 77 * Variables : 78 * Result : API returncode 79 * Remark : 80 * Status : 81 * 82 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 83 *****************************************************************************/ 84 85 DWORD HMDeviceOpen32Class::CloseHandle(PHMHANDLEDATA pHMHandleData) 86 { 87 BOOL bRC; 88 89 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle(%08x)\n", 90 pHMHandleData->hHMHandle)); 91 92 bRC = O32_CloseHandle(pHMHandleData->hHMHandle); 93 94 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle returned %08xh\n", 95 bRC)); 96 97 return (DWORD)bRC; 98 } 73 99 74 100 /***************************************************************************** … … 100 126 srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle)); 101 127 102 #if 1103 128 rc = O32_DuplicateHandle(srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle, fdwAccess, fInherit, fdwOptions); 104 129 105 130 if(rc == TRUE) { 106 131 pHMHandleData->hHMHandle = *desthandle; 107 return (NO_ERROR);132 return TRUE; 108 133 } 109 else return(O32_GetLastError()); 110 #else 111 rc = OSLibDosDupHandle(pHMSrcHandle->hHMHandle, desthandle); 112 if(rc == NO_ERROR) 113 { 114 pHMHandleData->hHMHandle = *desthandle; 115 return (NO_ERROR); 116 } 117 else 118 { 119 dprintfl(("KERNEL32: HandleManager::Open32::DuplicateHandle Error %d\n",rc)); 120 O32_SetLastError(rc); 121 return(rc); 122 } 123 #endif 124 } 125 126 /***************************************************************************** 127 * Name : DWORD HMDeviceOpen32Class::CreateFile 128 * Purpose : this is called from the handle manager if a CreateFile() is 129 * performed on a handle 130 * Parameters: LPCSTR lpFileName name of the file / device 131 * PHMHANDLEDATA pHMHandleData data of the NEW handle 132 * PVOID lpSecurityAttributes ignored 133 * PHMHANDLEDATA pHMHandleDataTemplate data of the template handle 134 * Variables : 135 * Result : 136 * Remark : 137 * Status : NO_ERROR - API succeeded 138 * other - what is to be set in SetLastError 139 * 140 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 141 *****************************************************************************/ 142 143 DWORD HMDeviceOpen32Class::CreateFile (LPCSTR lpFileName, 144 PHMHANDLEDATA pHMHandleData, 145 PVOID lpSecurityAttributes, 146 PHMHANDLEDATA pHMHandleDataTemplate) 147 { 148 HFILE hFile; 149 HFILE hTemplate; 150 151 dprintfl(("KERNEL32: HandleManager::Open32::CreateFile %s(%s,%08x,%08x,%08x) - stub?\n", 152 lpHMDeviceName, 153 lpFileName, 154 pHMHandleData, 155 lpSecurityAttributes, 156 pHMHandleDataTemplate)); 157 158 if (strncmp(lpFileName, // "support" for local unc names 159 "\\\\.\\", 160 4) == 0) 161 { 162 lpFileName+=4; 163 } 164 165 // create from template 166 if (pHMHandleDataTemplate != NULL) 167 hTemplate = pHMHandleDataTemplate->hHMHandle; 168 else 169 hTemplate = 0; 170 171 #if 1 172 //SvL: Open32 doesn't like this flag 173 if(pHMHandleData->dwShare & FILE_SHARE_DELETE) { 174 pHMHandleData->dwShare &= ~FILE_SHARE_DELETE; 175 } 176 177 hFile = O32_CreateFile(lpFileName, 178 pHMHandleData->dwAccess, 179 pHMHandleData->dwShare, 180 //(LPSECURITY_ATTRIBUTES)lpSecurityAttributes, 181 NULL, 182 pHMHandleData->dwCreation, 183 pHMHandleData->dwFlags, 184 hTemplate); 185 if (hFile != INVALID_HANDLE_ERROR) 186 { 187 pHMHandleData->hHMHandle = hFile; 188 return (NO_ERROR); 189 } 190 else { 191 dprintf(("CreateFile failed; error %x", O32_GetLastError())); 192 return(O32_GetLastError()); 193 } 194 #else 195 196 rc = OSLibDosCreate((char *)lpFileName, 197 pHMHandleData->dwAccess, 198 pHMHandleData->dwShare, 199 //(LPSECURITY_ATTRIBUTES)lpSecurityAttributes, 200 NULL, 201 pHMHandleData->dwCreation, 202 pHMHandleData->dwFlags, 203 hTemplate, &hFile); 204 if(rc) 205 { 206 dprintfl(("KERNEL32: HandleManager::Open32::CreateFile Error %d\n",rc)); 207 O32_SetLastError(rc); 208 return(rc); 209 } 210 else 211 { 212 pHMHandleData->hHMHandle = hFile; 213 return (NO_ERROR); 214 } 215 #endif 216 } 217 218 219 /***************************************************************************** 220 * Name : DWORD HMDeviceOpen32Class::CloseHandle 221 * Purpose : close the handle 222 * Parameters: PHMHANDLEDATA pHMHandleData 223 * Variables : 224 * Result : API returncode 225 * Remark : 226 * Status : 227 * 228 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 229 *****************************************************************************/ 230 231 DWORD HMDeviceOpen32Class::CloseHandle(PHMHANDLEDATA pHMHandleData) 232 { 233 BOOL bRC; 234 235 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle(%08x)\n", 236 pHMHandleData->hHMHandle)); 237 238 #if 1 239 bRC = O32_CloseHandle(pHMHandleData->hHMHandle); 240 241 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle returned %08xh\n", 242 bRC)); 243 244 return (DWORD)bRC; 245 #else 246 bRC = OSLibDosClose(pHMHandleData->hHMHandle); 247 if(bRC) 248 { 249 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle Error %d\n",bRC)); 250 O32_SetLastError(bRC); 251 return TRUE; // MUTEX Problem 252 return FALSE; 253 } 254 else 255 { 256 return TRUE; 257 } 258 #endif 259 } 260 261 262 /***************************************************************************** 263 * Name : BOOL HMDeviceOpen32Class::ReadFile 264 * Purpose : read data from handle / device 265 * Parameters: PHMHANDLEDATA pHMHandleData, 266 * LPCVOID lpBuffer, 267 * DWORD nNumberOfBytesToRead, 268 * LPDWORD lpNumberOfBytesRead, 269 * LPOVERLAPPED lpOverlapped 270 * Variables : 271 * Result : Boolean 272 * Remark : 273 * Status : 274 * 275 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 276 *****************************************************************************/ 277 278 BOOL HMDeviceOpen32Class::ReadFile(PHMHANDLEDATA pHMHandleData, 279 LPCVOID lpBuffer, 280 DWORD nNumberOfBytesToRead, 281 LPDWORD lpNumberOfBytesRead, 282 LPOVERLAPPED lpOverlapped) 283 { 284 BOOL bRC; 285 LPVOID lpRealBuf; 286 287 dprintfl(("KERNEL32: HandleManager::Open32::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 288 lpHMDeviceName, 289 pHMHandleData, 290 lpBuffer, 291 nNumberOfBytesToRead, 292 lpNumberOfBytesRead, 293 lpOverlapped)); 294 295 #if 1 296 Win32MemMap *map; 297 DWORD offset; 298 299 //SvL: DosRead doesn't like writing to memory addresses returned by 300 // DosAliasMem -> search for original memory mapped pointer and use 301 // that one 302 map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ); 303 if(map) { 304 lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset); 305 DWORD nrpages = nNumberOfBytesToRead/4096; 306 if(offset & 0xfff) 307 nrpages++; 308 else 309 if(nNumberOfBytesToRead & 0xfff) 310 nrpages++; 311 312 map->commitPage(offset & ~0xfff, TRUE, nrpages); 313 } 314 else lpRealBuf = (LPVOID)lpBuffer; 315 316 bRC = O32_ReadFile(pHMHandleData->hHMHandle, 317 (PVOID)lpRealBuf, 318 nNumberOfBytesToRead, 319 lpNumberOfBytesRead, 320 lpOverlapped); 321 322 if(bRC == 0) { 323 dprintf(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh %x\n", 324 bRC, GetLastError())); 325 dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead))); 326 } 327 else dprintfl(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh\n", 328 bRC)); 329 330 return bRC; 331 #else 332 rc = OSLibDosRead(pHMHandleData->hHMHandle, 333 (PVOID) lpBuffer, 334 nNumberOfBytesToRead, 335 lpNumberOfBytesRead); 336 if(rc) 337 { 338 dprintfl(("KERNEL32: HandleManager::Open32::ReadFile Error %d\n",rc)); 339 O32_SetLastError(rc); 340 return FALSE; 341 } 342 else 343 { 344 return TRUE; 345 } 346 #endif 347 } 348 349 350 /***************************************************************************** 351 * Name : BOOL HMDeviceOpen32Class::WriteFile 352 * Purpose : write data to handle / device 353 * Parameters: PHMHANDLEDATA pHMHandleData, 354 * LPCVOID lpBuffer, 355 * DWORD nNumberOfBytesToWrite, 356 * LPDWORD lpNumberOfBytesWritten, 357 * LPOVERLAPPED lpOverlapped 358 * Variables : 359 * Result : Boolean 360 * Remark : 361 * Status : 362 * 363 * Author : Patrick Haller [Wed, 1998/02/11 20:44] 364 *****************************************************************************/ 365 366 BOOL HMDeviceOpen32Class::WriteFile(PHMHANDLEDATA pHMHandleData, 367 LPCVOID lpBuffer, 368 DWORD nNumberOfBytesToWrite, 369 LPDWORD lpNumberOfBytesWritten, 370 LPOVERLAPPED lpOverlapped) 371 { 372 BOOL bRC; 373 374 dprintfl(("KERNEL32: HandleManager::Open32::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 375 lpHMDeviceName, 376 pHMHandleData, 377 lpBuffer, 378 nNumberOfBytesToWrite, 379 lpNumberOfBytesWritten, 380 lpOverlapped)); 381 382 #if 1 383 bRC = O32_WriteFile(pHMHandleData->hHMHandle, 384 lpBuffer, 385 nNumberOfBytesToWrite, 386 lpNumberOfBytesWritten, 387 lpOverlapped); 388 389 dprintfl(("KERNEL32: HandleManager::Open32::WriteFile returned %08xh\n", 390 bRC)); 391 392 return bRC; 393 #else 394 rc = OSLibDosWrite(pHMHandleData->hHMHandle, 395 (PVOID) lpBuffer, 396 nNumberOfBytesToWrite, 397 lpNumberOfBytesWritten); 398 if(rc) 399 { 400 dprintfl(("KERNEL32: HandleManager::Open32::WriteFile Error %d\n",rc)); 401 O32_SetLastError(rc); 402 return FALSE; 403 } 404 else 405 { 406 return TRUE; 407 } 408 #endif 409 } 410 134 else return FALSE; 135 } 411 136 412 137 /***************************************************************************** … … 428 153 pHMHandleData)); 429 154 430 #if 1 155 //TODO: return FILE_TYPE_UNKNOWN for standard in/out handles; correct?? 431 156 return O32_GetFileType(pHMHandleData->hHMHandle); 432 #else433 // TODO: FILE_TYPE_DISK434 return FILE_TYPE_CHAR;435 #endif436 157 } 437 158 … … 461 182 pHFI); 462 183 } 463 464 465 /*****************************************************************************466 * Name : BOOL HMDeviceOpen32Class::SetEndOfFile467 * Purpose : set end of file marker468 * Parameters: PHMHANDLEDATA pHMHandleData469 * Variables :470 * Result : API returncode471 * Remark :472 * Status :473 *474 * Author : Patrick Haller [Wed, 1999/06/17 20:44]475 *****************************************************************************/476 477 BOOL HMDeviceOpen32Class::SetEndOfFile(PHMHANDLEDATA pHMHandleData)478 {479 dprintfl(("KERNEL32: HandleManager::Open32::SetEndOfFile %s(%08xh)\n",480 lpHMDeviceName,481 pHMHandleData));482 483 return O32_SetEndOfFile(pHMHandleData->hHMHandle);484 }485 486 487 /*****************************************************************************488 * Name : BOOL HMDeviceOpen32Class::SetFileTime489 * Purpose : set file time490 * Parameters: PHMHANDLEDATA pHMHandleData491 * PFILETIME pFT1492 * PFILETIME pFT2493 * PFILETIME pFT3494 * Variables :495 * Result : API returncode496 * Remark :497 * Status :498 *499 * Author : Patrick Haller [Wed, 1999/06/17 20:44]500 *****************************************************************************/501 502 BOOL HMDeviceOpen32Class::SetFileTime(PHMHANDLEDATA pHMHandleData,503 LPFILETIME pFT1,504 LPFILETIME pFT2,505 LPFILETIME pFT3)506 {507 dprintfl(("KERNEL32: HandleManager::Open32::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",508 lpHMDeviceName,509 pHMHandleData,510 pFT1,511 pFT2,512 pFT3));513 514 return O32_SetFileTime(pHMHandleData->hHMHandle,515 pFT1,516 pFT2,517 pFT3);518 }519 520 /*****************************************************************************521 * Name : BOOL HMDeviceOpen32Class::GetFileTime522 * Purpose : get file time523 * Parameters: PHMHANDLEDATA pHMHandleData524 * PFILETIME pFT1525 * PFILETIME pFT2526 * PFILETIME pFT3527 * Variables :528 * Result : API returncode529 * Remark :530 * Status :531 *532 * Author : SvL533 *****************************************************************************/534 535 BOOL HMDeviceOpen32Class::GetFileTime(PHMHANDLEDATA pHMHandleData,536 LPFILETIME pFT1,537 LPFILETIME pFT2,538 LPFILETIME pFT3)539 {540 return O32_GetFileTime(pHMHandleData->hHMHandle,541 pFT1,542 pFT2,543 pFT3);544 }545 546 547 /*****************************************************************************548 * Name : DWORD HMDeviceOpen32Class::GetFileSize549 * Purpose : set file time550 * Parameters: PHMHANDLEDATA pHMHandleData551 * PDWORD pSize552 * Variables :553 * Result : API returncode554 * Remark :555 * Status :556 *557 * Author : Patrick Haller [Wed, 1999/06/17 20:44]558 *****************************************************************************/559 560 DWORD HMDeviceOpen32Class::GetFileSize(PHMHANDLEDATA pHMHandleData,561 PDWORD lpdwFileSizeHigh)562 {563 dprintfl(("KERNEL32: HandleManager::Open32::GetFileSize %s(%08xh,%08xh)\n",564 lpHMDeviceName,565 pHMHandleData,566 lpdwFileSizeHigh));567 568 #if 1569 if(lpdwFileSizeHigh)570 *lpdwFileSizeHigh = 0;571 572 return O32_GetFileSize(pHMHandleData->hHMHandle,573 lpdwFileSizeHigh);574 #else575 size = OSLibDosGetFileSize(pHMHandleData->hHMHandle);576 if(pSize)577 *pSize = 0;578 return size;579 #endif580 }581 582 583 /*****************************************************************************584 * Name : DWORD HMDeviceOpen32Class::SetFilePointer585 * Purpose : set file pointer586 * Parameters: PHMHANDLEDATA pHMHandleData587 * LONG lDistanceToMove588 * PLONG lpDistanceToMoveHigh589 * DWORD dwMoveMethod590 * Variables :591 * Result : API returncode592 * Remark :593 * Status :594 *595 * Author : Patrick Haller [Wed, 1999/06/17 20:44]596 *****************************************************************************/597 598 DWORD HMDeviceOpen32Class::SetFilePointer(PHMHANDLEDATA pHMHandleData,599 LONG lDistanceToMove,600 PLONG lpDistanceToMoveHigh,601 DWORD dwMoveMethod)602 {603 dprintfl(("KERNEL32: HandleManager::Open32::SetFilePointer %s(%08xh,%08xh,%08xh,%08xh)\n",604 lpHMDeviceName,605 pHMHandleData,606 lDistanceToMove,607 lpDistanceToMoveHigh,608 dwMoveMethod));609 610 #if 1611 DWORD ret;612 613 if(lpDistanceToMoveHigh)614 *lpDistanceToMoveHigh = 0;615 616 ret = O32_SetFilePointer(pHMHandleData->hHMHandle,617 lDistanceToMove,618 lpDistanceToMoveHigh,619 dwMoveMethod);620 621 // if(ret == -1) {622 // dprintf(("current position %x (error = %x)", O32_SetFilePointer(pHMHandleData->hHMHandle,0, 0, 1), GetLastError()));623 // }624 return ret;625 #else626 627 if(lpDistanceToMoveHigh)628 *lpDistanceToMoveHigh = 0;629 pos = OSLibDosSetFilePtr2(pHMHandleData->hHMHandle, lDistanceToMove, dwMoveMethod);630 return pos;631 #endif632 }633 634 635 /*****************************************************************************636 * Name : DWORD HMDeviceOpen32Class::LockFile637 * Purpose : file locking638 * Parameters: PHMHANDLEDATA pHMHandleData639 * DWORD arg2640 * DWORD arg3641 * DWORD arg4642 * DWORD arg5643 * Variables :644 * Result : API returncode645 * Remark :646 * Status :647 *648 * Author : Patrick Haller [Wed, 1999/06/17 20:44]649 *****************************************************************************/650 651 DWORD HMDeviceOpen32Class::LockFile(PHMHANDLEDATA pHMHandleData,652 DWORD arg2,653 DWORD arg3,654 DWORD arg4,655 DWORD arg5)656 {657 dprintfl(("KERNEL32: HandleManager::Open32::LockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",658 lpHMDeviceName,659 pHMHandleData,660 arg2,661 arg3,662 arg4,663 arg5));664 665 return O32_LockFile(pHMHandleData->hHMHandle,666 arg2,667 arg3,668 arg4,669 arg5);670 }671 672 673 674 /*****************************************************************************675 * Name : DWORD HMDeviceOpen32Class::LockFileEx676 * Purpose : file locking677 * Parameters: PHMHANDLEDATA pHMHandleData678 * DWORD dwFlags679 * DWORD dwReserved680 * DWORD nNumberOfBytesToLockLow681 * DWORD nNumberOfBytesToLockHigh682 * LPOVERLAPPED lpOverlapped683 * Variables :684 * Result : API returncode685 * Remark :686 * Status :687 *688 * Author : Patrick Haller [Wed, 1999/06/17 20:44]689 *****************************************************************************/690 691 DWORD HMDeviceOpen32Class::LockFileEx(PHMHANDLEDATA pHMHandleData,692 DWORD dwFlags,693 DWORD dwReserved,694 DWORD nNumberOfBytesToLockLow,695 DWORD nNumberOfBytesToLockHigh,696 LPOVERLAPPED lpOverlapped)697 {698 699 dprintfl(("KERNEL32: HandleManager::Open32::LockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",700 lpHMDeviceName,701 pHMHandleData,702 dwFlags,703 dwReserved,704 nNumberOfBytesToLockLow,705 nNumberOfBytesToLockHigh,706 lpOverlapped));707 708 709 return(O32_LockFile(pHMHandleData->hHMHandle,710 lpOverlapped->Offset,711 lpOverlapped->OffsetHigh,712 nNumberOfBytesToLockLow,713 nNumberOfBytesToLockHigh));714 }715 716 717 /*****************************************************************************718 * Name : DWORD HMDeviceOpen32Class::OpenFile719 * Purpose : this is called from the handle manager if a OpenFile() is720 * performed on a handle721 * Parameters: LPCSTR lpFileName name of the file / device722 * PHMHANDLEDATA pHMHandleData data of the NEW handle723 * PVOID lpSecurityAttributes ignored724 * PHMHANDLEDATA pHMHandleDataTemplate data of the template handle725 * Variables :726 * Result :727 * Remark :728 * Status : NO_ERROR - API succeeded729 * other - what is to be set in SetLastError730 *731 * Author : Patrick Haller [Wed, 1998/02/11 20:44]732 *****************************************************************************/733 734 DWORD HMDeviceOpen32Class::OpenFile (LPCSTR lpFileName,735 PHMHANDLEDATA pHMHandleData,736 OFSTRUCT *pOFStruct,737 UINT fuMode)738 {739 HFILE hFile;740 FILETIME filetime;741 WORD filedatetime[2];742 char filepath[260];743 744 dprintfl(("KERNEL32: HandleManager::Open32::OpenFile %s(%s,%08x,%08x,%08x) - stub?\n",745 lpHMDeviceName,746 lpFileName,747 pHMHandleData,748 pOFStruct,749 fuMode));750 751 if(strcmp(lpFileName, // "support" for local unc names752 "\\\\.\\") == 0)753 {754 lpFileName+=4;755 }756 else757 if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\'))758 {759 //filename only; search for file in following order760 //1: dir from which the app loaded761 //2: current dir762 //3: windows system dir763 //4: windows dir764 //5: dirs in path path environment variable765 //SearchPath does exactly that766 LPSTR filenameinpath;767 768 if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0769 && !(fuMode & OF_CREATE) ) {770 SetLastError(ERROR_FILE_NOT_FOUND);771 return HFILE_ERROR;772 }773 lpFileName = filepath;774 }775 // filling OFSTRUCT776 memset(pOFStruct, 0, sizeof(OFSTRUCT));777 pOFStruct->cBytes = sizeof(OFSTRUCT);778 pOFStruct->nErrCode = 0;779 strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME - 1);780 781 hFile = O32_OpenFile(lpFileName,782 pOFStruct,783 fuMode);784 if (hFile != INVALID_HANDLE_ERROR)785 {786 pHMHandleData->hHMHandle = hFile;787 788 GetFileTime(pHMHandleData,789 NULL,790 NULL,791 &filetime );792 FileTimeToDosDateTime(&filetime,793 &filedatetime[0],794 &filedatetime[1] );795 memcpy(pOFStruct->reserved,796 filedatetime,797 sizeof(pOFStruct->reserved) );798 799 return (NO_ERROR);800 }801 802 // error branch803 pOFStruct->nErrCode = O32_GetLastError();804 dprintf(("KERNEL32: HandleManager::Open32::OpenFile Error %08xh\n",805 pOFStruct->nErrCode));806 807 // return != NO_ERROR => error code808 return(hFile);809 }810 811 812 /*****************************************************************************813 * Name : DWORD HMDeviceOpen32Class::UnlockFile814 * Purpose : file locking815 * Parameters: PHMHANDLEDATA pHMHandleData816 * DWORD arg2817 * DWORD arg3818 * DWORD arg4819 * DWORD arg5820 * Variables :821 * Result : API returncode822 * Remark :823 * Status :824 *825 * Author : Patrick Haller [Wed, 1999/06/17 20:44]826 *****************************************************************************/827 828 DWORD HMDeviceOpen32Class::UnlockFile(PHMHANDLEDATA pHMHandleData,829 DWORD arg2,830 DWORD arg3,831 DWORD arg4,832 DWORD arg5)833 {834 dprintfl(("KERNEL32: HandleManager::Open32::UnlockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",835 lpHMDeviceName,836 pHMHandleData,837 arg2,838 arg3,839 arg4,840 arg5));841 842 return O32_UnlockFile(pHMHandleData->hHMHandle,843 arg2,844 arg3,845 arg4,846 arg5);847 }848 849 850 851 /*****************************************************************************852 * Name : DWORD HMDeviceOpen32Class::UnlockFileEx853 * Purpose : file locking854 * Parameters: PHMHANDLEDATA pHMHandleData855 * DWORD dwFlags856 * DWORD dwReserved857 * DWORD nNumberOfBytesToLockLow858 * DWORD nNumberOfBytesToLockHigh859 * LPOVERLAPPED lpOverlapped860 * Variables :861 * Result : API returncode862 * Remark :863 * Status :864 *865 * Author : Patrick Haller [Wed, 1999/06/17 20:44]866 *****************************************************************************/867 868 DWORD HMDeviceOpen32Class::UnlockFileEx(PHMHANDLEDATA pHMHandleData,869 DWORD dwFlags,870 DWORD dwReserved,871 DWORD nNumberOfBytesToLockLow,872 DWORD nNumberOfBytesToLockHigh,873 LPOVERLAPPED lpOverlapped)874 {875 876 dprintfl(("KERNEL32: HandleManager::Open32::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",877 lpHMDeviceName,878 pHMHandleData,879 dwFlags,880 dwReserved,881 nNumberOfBytesToLockLow,882 nNumberOfBytesToLockHigh,883 lpOverlapped));884 885 return(O32_UnlockFile(pHMHandleData->hHMHandle,886 lpOverlapped->Offset,887 lpOverlapped->OffsetHigh,888 nNumberOfBytesToLockLow,889 nNumberOfBytesToLockHigh));890 }891 892 184 893 185 /***************************************************************************** … … 955 247 } 956 248 957 958 /*****************************************************************************959 * Name : DWORD HMDeviceOpen32Class::FlushFileBuffers960 * Purpose : flush the buffers of a file961 * Parameters: PHMHANDLEDATA pHMHandleData962 * Variables :963 * Result : API returncode964 * Remark :965 * Status :966 *967 * Author : Patrick Haller [Wed, 1999/06/17 20:44]968 *****************************************************************************/969 970 BOOL HMDeviceOpen32Class::FlushFileBuffers(PHMHANDLEDATA pHMHandleData)971 {972 dprintfl(("KERNEL32: HandleManager::Open32:FlushFileBuffers(%08xh)\n",973 pHMHandleData->hHMHandle));974 975 return(O32_FlushFileBuffers(pHMHandleData->hHMHandle));976 }977 978 979 /*****************************************************************************980 * Name : DWORD HMDeviceOpen32Class::GetOverlappedResult981 * Purpose : asynchronus I/O982 * Parameters: PHMHANDLEDATA pHMHandleData983 * LPOVERLAPPED arg2984 * LPDWORD arg3985 * BOOL arg4986 * Variables :987 * Result : API returncode988 * Remark :989 * Status :990 *991 * Author : Patrick Haller [Wed, 1999/06/17 20:44]992 *****************************************************************************/993 994 BOOL HMDeviceOpen32Class::GetOverlappedResult(PHMHANDLEDATA pHMHandleData,995 LPOVERLAPPED arg2,996 LPDWORD arg3,997 BOOL arg4)998 {999 dprintfl(("KERNEL32: HandleManager::Open32::GetOverlappedResult(%08xh,%08xh,%08xh,%08xh)\n",1000 pHMHandleData->hHMHandle,1001 arg2,1002 arg3,1003 arg4));1004 1005 return(O32_GetOverlappedResult(pHMHandleData->hHMHandle,1006 arg2,1007 arg3,1008 arg4));1009 }1010 -
trunk/src/kernel32/hmopen32.h
r3588 r3642 1 /* $Id: hmopen32.h,v 1. 5 2000-05-22 19:07:56sandervl Exp $ */1 /* $Id: hmopen32.h,v 1.6 2000-06-01 11:28:47 sandervl Exp $ */ 2 2 3 3 /* … … 50 50 DWORD fdwOptions); 51 51 52 /* this is a handler method for calls to CreateFile() */53 virtual DWORD CreateFile (LPCSTR lpFileName,54 PHMHANDLEDATA pHMHandleData,55 PVOID lpSecurityAttributes,56 PHMHANDLEDATA pHMHandleDataTemplate);57 58 /* this is a handler method for calls to OpenFile() */59 virtual DWORD OpenFile (LPCSTR lpFileName,60 PHMHANDLEDATA pHMHandleData,61 OFSTRUCT* pOFStruct,62 UINT fuMode);63 64 52 /* this is a handler method for calls to CloseHandle() */ 65 53 virtual DWORD CloseHandle(PHMHANDLEDATA pHMHandleData); 66 67 /* this is a handler method for calls to ReadFile() */68 virtual BOOL ReadFile (PHMHANDLEDATA pHMHandleData,69 LPCVOID lpBuffer,70 DWORD nNumberOfBytesToRead,71 LPDWORD lpNumberOfBytesRead,72 LPOVERLAPPED lpOverlapped);73 74 /* this is a handler method for calls to WriteFile() */75 virtual BOOL WriteFile (PHMHANDLEDATA pHMHandleData,76 LPCVOID lpBuffer,77 DWORD nNumberOfBytesToWrite,78 LPDWORD lpNumberOfBytesWritten,79 LPOVERLAPPED lpOverlapped);80 54 81 55 /* this is a handler method for calls to GetFileType() */ … … 85 59 virtual DWORD GetFileInformationByHandle(PHMHANDLEDATA pHMHandleData, 86 60 BY_HANDLE_FILE_INFORMATION* pHFI); 87 88 /* this is a handler method for calls to SetEndOfFile() */89 virtual BOOL SetEndOfFile(PHMHANDLEDATA pHMHandleData);90 91 /* this is a handler method for calls to SetFileTime() */92 virtual BOOL SetFileTime (PHMHANDLEDATA pHMHandleData,93 LPFILETIME pFT1,94 LPFILETIME pFT2,95 LPFILETIME pFT3);96 97 /* this is a handler method for calls to GetFileTime() */98 virtual BOOL GetFileTime (PHMHANDLEDATA pHMHandleData,99 LPFILETIME pFT1,100 LPFILETIME pFT2,101 LPFILETIME pFT3);102 103 /* this is a handler method for calls to GetFileSize() */104 virtual DWORD GetFileSize(PHMHANDLEDATA pHMHandleData,105 PDWORD pSizeHigh);106 107 /* this is a handler method for calls to SetFilePointer() */108 virtual DWORD SetFilePointer(PHMHANDLEDATA pHMHandleData,109 LONG lDistanceToMove,110 PLONG lpDistanceToMoveHigh,111 DWORD dwMoveMethod);112 113 /* this is a handler method for calls to LockFile() */114 virtual DWORD LockFile(PHMHANDLEDATA pHMHandleData,115 DWORD arg2,116 DWORD arg3,117 DWORD arg4,118 DWORD arg5);119 120 /* this is a handler method for calls to LockFileEx() */121 virtual DWORD LockFileEx(PHMHANDLEDATA pHMHandleData,122 DWORD dwFlags,123 DWORD dwReserved,124 DWORD nNumberOfBytesToLockLow,125 DWORD nNumberOfBytesToLockHigh,126 LPOVERLAPPED lpOverlapped);127 128 /* this is a handler method for calls to UnlockFile() */129 virtual DWORD UnlockFile(PHMHANDLEDATA pHMHandleData,130 DWORD arg2,131 DWORD arg3,132 DWORD arg4,133 DWORD arg5);134 135 /* this is a handler method for calls to UnlockFileEx() */136 virtual DWORD UnlockFileEx(PHMHANDLEDATA pHMHandleData,137 DWORD dwFlags,138 DWORD dwReserved,139 DWORD nNumberOfBytesToLockLow,140 DWORD nNumberOfBytesToLockHigh,141 LPOVERLAPPED lpOverlapped);142 61 143 62 /* this is a handler method for calls to WaitForSingleObject */ … … 149 68 DWORD dwTimeout, 150 69 BOOL fAlertable); 151 152 /* this is a handler method for calls to FlushFileBuffers */153 virtual BOOL FlushFileBuffers(PHMHANDLEDATA pHMHandleData);154 155 /* this is a handler method for calls to GetOverlappedResult */156 virtual BOOL GetOverlappedResult(PHMHANDLEDATA pHMHandleData,157 LPOVERLAPPED arg2,158 LPDWORD arg3,159 BOOL arg4);160 70 }; 161 71 -
trunk/src/kernel32/initterm.cpp
r3461 r3642 1 /* $Id: initterm.cpp,v 1.4 1 2000-04-29 18:26:59sandervl Exp $ */1 /* $Id: initterm.cpp,v 1.42 2000-06-01 11:28:47 sandervl Exp $ */ 2 2 3 3 /* … … 154 154 flAllocMem = PAG_ANY; // high memory support. Let's use it! 155 155 ulMaxAddr = ulSysinfo * (1024*1024); 156 OSLibInitWSeBFileIO(); 156 157 } 157 158 else -
trunk/src/kernel32/makefile
r3483 r3642 1 # $Id: makefile,v 1.9 4 2000-05-02 20:53:13sandervl Exp $1 # $Id: makefile,v 1.95 2000-06-01 11:28:47 sandervl Exp $ 2 2 3 3 # … … 72 72 $(OBJDIR)\hmobjects.obj \ 73 73 $(OBJDIR)\hmevent.obj \ 74 $(OBJDIR)\hmfile.obj \ 74 75 $(OBJDIR)\hmmutex.obj \ 75 76 $(OBJDIR)\hmcomm.obj \ -
trunk/src/kernel32/oslibdos.cpp
r3593 r3642 1 /* $Id: oslibdos.cpp,v 1.2 8 2000-05-23 18:45:12sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.29 2000-06-01 11:28:47 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 33 33 #include "dbglocal.h" 34 34 35 static PROC_DosSetFileSizeL DosSetFileSizeLProc = 0; 36 static PROC_DosSetFilePtrL DosSetFilePtrLProc = 0; 37 static PROC_DosSetFileLocksL DosSetFileLocksLProc = 0; 38 static BOOL f64BitIO = FALSE; 39 //****************************************************************************** 40 //****************************************************************************** 41 void OSLibInitWSeBFileIO() 42 { 43 HMODULE hDoscalls; 44 45 if(DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR) { 46 return; 47 } 48 if(DosQueryProcAddr(hDoscalls, 989, NULL, (PFN *)&DosSetFileSizeLProc) != NO_ERROR) { 49 return; 50 } 51 if(DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&DosSetFilePtrLProc) != NO_ERROR) { 52 return; 53 } 54 if(DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&DosSetFileLocksLProc) != NO_ERROR) { 55 return; 56 } 57 f64BitIO = TRUE; 58 } 59 //****************************************************************************** 60 //****************************************************************************** 61 APIRET OdinDosSetFileSizeL(HFILE hFile, LONGLONG cbSize) 62 { 63 APIRET yyrc; 64 USHORT sel = RestoreOS2FS(); 65 66 yyrc = DosSetFileSizeLProc(hFile, cbSize); 67 SetFS(sel); 68 69 return yyrc; 70 } 71 //****************************************************************************** 72 //****************************************************************************** 73 APIRET OdinDosSetFilePtrL(HFILE hFile, LONGLONG ib, ULONG method, PLONGLONG ibActual) 74 { 75 APIRET yyrc; 76 USHORT sel = RestoreOS2FS(); 77 78 yyrc = DosSetFilePtrLProc(hFile, ib, method, ibActual); 79 SetFS(sel); 80 81 return yyrc; 82 } 83 //****************************************************************************** 84 //****************************************************************************** 85 APIRET OdinDosSetFileLocksL(HFILE hFile, PFILELOCKL pflUnlock, PFILELOCKL pflLock, 86 ULONG timeout, ULONG flags) 87 { 88 APIRET yyrc; 89 USHORT sel = RestoreOS2FS(); 90 91 yyrc = DosSetFileLocksLProc(hFile, pflUnlock, pflLock, timeout, flags); 92 SetFS(sel); 93 94 return yyrc; 95 } 35 96 //****************************************************************************** 36 97 // translate OS/2 error codes to Windows codes … … 42 103 { 43 104 case NO_ERROR: //0 44 return ERROR_SUCCESS_W; 105 return ERROR_SUCCESS_W; 106 107 case ERROR_INVALID_FUNCTION: //1 108 return ERROR_INVALID_FUNCTION_W; 45 109 46 110 case ERROR_FILE_NOT_FOUND: //2 47 return ERROR_FILE_NOT_FOUND_W;111 return ERROR_FILE_NOT_FOUND_W; 48 112 49 113 case ERROR_PATH_NOT_FOUND: //3 50 return ERROR_PATH_NOT_FOUND_W; 114 return ERROR_PATH_NOT_FOUND_W; 115 116 case ERROR_TOO_MANY_OPEN_FILES: //4 117 return ERROR_TOO_MANY_OPEN_FILES_W; 51 118 52 119 case ERROR_ACCESS_DENIED: //5 53 return ERROR_ACCESS_DENIED_W;120 return ERROR_ACCESS_DENIED_W; 54 121 55 122 case ERROR_INVALID_HANDLE: //6 56 return ERROR_INVALID_HANDLE_W;123 return ERROR_INVALID_HANDLE_W; 57 124 58 125 case ERROR_NOT_ENOUGH_MEMORY: //8 59 return ERROR_NOT_ENOUGH_MEMORY_W;126 return ERROR_NOT_ENOUGH_MEMORY_W; 60 127 61 128 case ERROR_BAD_FORMAT: //11 62 return ERROR_BAD_FORMAT_W; 129 return ERROR_BAD_FORMAT_W; 130 131 case ERROR_INVALID_ACCESS: //12 132 return ERROR_INVALID_ACCESS_W; 63 133 64 134 case ERROR_NO_MORE_FILES: //18 65 return ERROR_NO_MORE_FILES_W; 135 return ERROR_NO_MORE_FILES_W; 136 137 case ERROR_WRITE_PROTECT: //19 138 return ERROR_WRITE_PROTECT_W; 66 139 67 140 case ERROR_NOT_DOS_DISK: //26 68 return ERROR_NOT_DOS_DISK_W; 141 return ERROR_NOT_DOS_DISK_W; 142 143 case ERROR_WRITE_FAULT: //29 144 return ERROR_WRITE_FAULT_W; 145 146 case ERROR_SHARING_VIOLATION: //32 147 return ERROR_SHARING_VIOLATION_W; 148 149 case ERROR_LOCK_VIOLATION: //32 150 return ERROR_LOCK_VIOLATION_W; 151 152 case ERROR_SHARING_BUFFER_EXCEEDED: //36 153 return ERROR_SHARING_BUFFER_EXCEEDED_W; 154 155 case ERROR_CANNOT_MAKE: //82 156 return ERROR_CANNOT_MAKE_W; 69 157 70 158 case ERROR_OUT_OF_STRUCTURES: //84 71 return ERROR_OUT_OF_STRUCTURES_W;159 return ERROR_OUT_OF_STRUCTURES_W; 72 160 73 161 case ERROR_INVALID_PARAMETER: //87 74 return ERROR_INVALID_PARAMETER_W;162 return ERROR_INVALID_PARAMETER_W; 75 163 76 164 case ERROR_INTERRUPT: //95 77 return ERROR_INVALID_AT_INTERRUPT_TIME_W; //CB: right??? 165 return ERROR_INVALID_AT_INTERRUPT_TIME_W; //CB: right??? 166 167 case ERROR_DEVICE_IN_USE: //99 168 return ERROR_DEVICE_IN_USE_W; 78 169 79 170 case ERROR_DRIVE_LOCKED: //108 80 return ERROR_DRIVE_LOCKED_W;171 return ERROR_DRIVE_LOCKED_W; 81 172 82 173 case ERROR_BROKEN_PIPE: //109 83 return ERROR_BROKEN_PIPE_W; 174 return ERROR_BROKEN_PIPE_W; 175 176 case ERROR_OPEN_FAILED: //110 177 return ERROR_OPEN_FAILED_W; 84 178 85 179 case ERROR_BUFFER_OVERFLOW: //111 86 return ERROR_BUFFER_OVERFLOW_W; 180 return ERROR_BUFFER_OVERFLOW_W; 181 182 case ERROR_DISK_FULL: //112 183 return ERROR_DISK_FULL_W; 87 184 88 185 case ERROR_NO_MORE_SEARCH_HANDLES: //113 89 return ERROR_NO_MORE_SEARCH_HANDLES_W;186 return ERROR_NO_MORE_SEARCH_HANDLES_W; 90 187 91 188 case ERROR_SEM_TIMEOUT: //121 92 return ERROR_SEM_TIMEOUT_W; 189 return ERROR_SEM_TIMEOUT_W; 190 191 case ERROR_DIRECT_ACCESS_HANDLE: //130 192 return ERROR_DIRECT_ACCESS_HANDLE_W; 193 194 case ERROR_NEGATIVE_SEEK: //131 195 return ERROR_NEGATIVE_SEEK; 196 197 case ERROR_SEEK_ON_DEVICE: //132 198 return ERROR_SEEK_ON_DEVICE_W; 93 199 94 200 case ERROR_DISCARDED: //157 95 return ERROR_DISCARDED_W;201 return ERROR_DISCARDED_W; 96 202 97 203 case ERROR_FILENAME_EXCED_RANGE: //206 98 return ERROR_FILENAME_EXCED_RANGE_W;204 return ERROR_FILENAME_EXCED_RANGE_W; 99 205 100 206 case ERROR_META_EXPANSION_TOO_LONG: //208 101 return ERROR_META_EXPANSION_TOO_LONG_W;207 return ERROR_META_EXPANSION_TOO_LONG_W; 102 208 103 209 case ERROR_BAD_PIPE: //230 104 return ERROR_BAD_PIPE_W;210 return ERROR_BAD_PIPE_W; 105 211 106 212 case ERROR_PIPE_BUSY: //231 107 return ERROR_PIPE_BUSY_W; 213 return ERROR_PIPE_BUSY_W; 214 215 case ERROR_NO_DATA: //232 216 return ERROR_NO_DATA_W; 108 217 109 218 case ERROR_PIPE_NOT_CONNECTED: //233 110 return ERROR_PIPE_NOT_CONNECTED_W;219 return ERROR_PIPE_NOT_CONNECTED_W; 111 220 112 221 case ERROR_MORE_DATA: //234 113 return ERROR_MORE_DATA_W;222 return ERROR_MORE_DATA_W; 114 223 115 224 case ERROR_INVALID_EA_NAME: //254 116 return ERROR_INVALID_EA_NAME_W;225 return ERROR_INVALID_EA_NAME_W; 117 226 118 227 case ERROR_EA_LIST_INCONSISTENT: //255 119 return ERROR_EA_LIST_INCONSISTENT_W;228 return ERROR_EA_LIST_INCONSISTENT_W; 120 229 121 230 case ERROR_EAS_DIDNT_FIT: //275 122 return ERROR_EAS_DIDNT_FIT;231 return ERROR_EAS_DIDNT_FIT; 123 232 124 233 default: 125 return defaultCode; 234 dprintf(("WARNING: error2WinError: error %d not included!!!!", rc)); 235 return defaultCode; 126 236 } 127 237 } … … 382 492 //****************************************************************************** 383 493 //****************************************************************************** 384 DWORD OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead) 385 { 386 return DosRead(hFile, lpBuffer, size, nrBytesRead); 387 } 388 //****************************************************************************** 389 //****************************************************************************** 390 DWORD OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten) 391 { 392 return DosWrite(hFile, lpBuffer, size, nrBytesWritten); 494 BOOL OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead) 495 { 496 APIRET rc; 497 498 rc = DosRead(hFile, lpBuffer, size, nrBytesRead); 499 SetLastError(error2WinError(rc)); 500 return (rc == NO_ERROR); 501 } 502 //****************************************************************************** 503 //****************************************************************************** 504 BOOL OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten) 505 { 506 APIRET rc; 507 508 rc = DosWrite(hFile, lpBuffer, size, nrBytesWritten); 509 SetLastError(error2WinError(rc)); 510 return (rc == NO_ERROR); 393 511 } 394 512 //****************************************************************************** … … 421 539 //****************************************************************************** 422 540 //****************************************************************************** 423 DWORD OSLibDosDelete(char *lpszFileName) 424 { 425 return DosDelete(lpszFileName); 541 BOOL OSLibDosDelete(char *lpszFileName) 542 { 543 APIRET rc; 544 545 rc = DosDelete(lpszFileName); 546 if(rc) { 547 SetLastError(error2WinError(rc)); 548 return FALSE; 549 } 550 return TRUE; 426 551 } 427 552 //****************************************************************************** … … 552 677 //****************************************************************************** 553 678 //****************************************************************************** 554 DWORD OSLibDosCreate(CHAR *lpFileName, 555 DWORD dwAccess, 556 DWORD dwShare, 557 LPSECURITY_ATTRIBUTES lpSecurityAttributes, 558 DWORD dwCreation, 559 DWORD dwFlags, 560 HANDLE hTemplate, 561 DWORD *dwFile) 562 { 563 APIRET rc; 564 HFILE hFile; 565 ULONG ulAction=0; 566 DWORD os2Attrib=0; 567 DWORD os2Flags = 0; //OPEN_FLAGS_NOINHERIT; 568 DWORD os2Open=0; 569 570 if(dwAccess == (GENERIC_READ_W | GENERIC_WRITE_W)) 571 os2Flags |= OPEN_ACCESS_READWRITE; 572 else if(dwAccess & GENERIC_WRITE_W) 573 os2Flags |= OPEN_ACCESS_WRITEONLY; 574 else if(dwAccess & GENERIC_READ_W) 575 os2Flags |= OPEN_ACCESS_READONLY; 576 577 if(dwShare == 0) 578 os2Flags |= OPEN_SHARE_DENYREADWRITE; 579 else if(dwShare == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) 580 os2Flags |= OPEN_SHARE_DENYNONE; 581 else if(dwShare & FILE_SHARE_READ_W) 582 os2Flags |= OPEN_SHARE_DENYWRITE; 583 else if(dwShare & FILE_SHARE_WRITE_W) 584 os2Flags |= OPEN_SHARE_DENYREAD; 585 586 if(dwCreation == CREATE_NEW_W) 587 os2Open = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 588 else if(dwCreation == CREATE_ALWAYS_W) 589 os2Open = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 590 else if(dwCreation == OPEN_EXISTING_W) 591 os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 592 else if(dwCreation == OPEN_ALWAYS_W) 593 os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 594 else if(dwCreation == TRUNCATE_EXISTING_W) 595 os2Open = OPEN_ACTION_REPLACE_IF_EXISTS;// |OPEN_ACTION_FAIL_IF_NEW; 596 597 if(dwFlags & FILE_ATTRIBUTE_READONLY_W) 598 os2Attrib |= FILE_READONLY; 599 if(dwFlags & FILE_ATTRIBUTE_HIDDEN_W) 600 os2Attrib |= FILE_HIDDEN; 601 if(dwFlags & FILE_ATTRIBUTE_SYSTEM_W) 602 os2Attrib |= FILE_SYSTEM; 603 if(dwFlags & FILE_ATTRIBUTE_DIRECTORY_W) 604 os2Attrib |= FILE_DIRECTORY; 605 if(dwFlags & FILE_ATTRIBUTE_ARCHIVE_W) 606 os2Attrib |= FILE_ARCHIVED; 607 if(dwFlags & FILE_ATTRIBUTE_NORMAL_W) 608 os2Attrib |= FILE_NORMAL; 609 610 if(dwFlags & FILE_FLAG_WRITE_THROUGH_W) 611 os2Flags |= OPEN_FLAGS_WRITE_THROUGH; 612 if(dwFlags & FILE_FLAG_NO_BUFFERING_W) 613 os2Flags |= OPEN_FLAGS_NO_CACHE; 614 if(dwFlags & FILE_FLAG_RANDOM_ACCESS_W) 615 os2Flags |= OPEN_FLAGS_RANDOM; 616 if(dwFlags & FILE_FLAG_SEQUENTIAL_SCAN_W) 617 os2Flags |= OPEN_FLAGS_SEQUENTIAL; 618 619 // TODO: 620 // if(dwFlags & FILE_FLAG_OVERLAPPED_W) 621 // if(dwFlags & FILE_FLAG_DELETE_ON_CLOSE_W 622 623 rc = DosOpen(lpFileName, &hFile, &ulAction, 0, 624 os2Attrib, os2Open, os2Flags, 0); 625 626 if(rc) 627 { 628 // TODO: TEST TEST 629 dprintf(("DosOpen Error rc:%d, try without GENERIC_WRITE_W", rc)); 630 if(dwAccess & GENERIC_WRITE_W) 631 os2Flags &= ~(OPEN_ACCESS_READWRITE | OPEN_ACCESS_WRITEONLY); 632 rc = DosOpen(lpFileName, &hFile, &ulAction, 0, 633 os2Attrib, os2Open, os2Flags, 0); 634 if(rc) 635 { 636 dprintf(("DosOpen Error rc:%d os2Attrib:%X os2Open:%X os2Flags:%X", 637 rc, os2Attrib, os2Open, os2Flags)); 638 hFile = -1; 639 } 640 } 641 642 *dwFile = hFile; 643 return rc; 644 } 645 //****************************************************************************** 646 //(without changing file pointer) 647 //****************************************************************************** 648 DWORD OSLibDosGetFileSize(DWORD hFile) 649 { 650 FILESTATUS3 fsts3ConfigInfo = {{0}}; 651 ULONG ulBufSize = sizeof(FILESTATUS3); 652 653 DosQueryFileInfo(hFile, FIL_STANDARD, &fsts3ConfigInfo, ulBufSize); 654 return fsts3ConfigInfo.cbFile; 679 APIRET OSLibDosQueryPathInfo(PSZ pszPathName, 680 ULONG ulInfoLevel, 681 PVOID pInfoBuf, 682 ULONG cbInfoBuf) 683 { 684 APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel, 685 pInfoBuf, cbInfoBuf ); 686 687 if(rc == ERROR_TOO_MANY_OPEN_FILES) 688 { 689 LONG reqCount = 2; 690 ULONG maxFiles; 691 692 if(DosSetRelMaxFH(&reqCount, &maxFiles) == NO_ERROR) 693 rc = DosQueryPathInfo(pszPathName, ulInfoLevel, 694 pInfoBuf, cbInfoBuf ); 695 } 696 return rc; 697 } 698 //****************************************************************************** 699 //****************************************************************************** 700 DWORD OSLibDosCreateFile(CHAR *lpszFile, 701 DWORD fuAccess, 702 DWORD fuShare, 703 LPSECURITY_ATTRIBUTES lpSecurityAttributes, 704 DWORD fuCreate, 705 DWORD fuAttrFlags, 706 HANDLE hTemplateFile) 707 { 708 HFILE hFile; 709 ULONG actionTaken = 0; 710 ULONG fileSize = 0; 711 ULONG fileAttr = FILE_NORMAL; 712 ULONG openFlag = 0; 713 ULONG openMode = 0; 714 APIRET rc = ERROR_NOT_ENOUGH_MEMORY;; 715 716 //TODO: lpSecurityAttributes (inheritance) 717 718 if(fuAttrFlags & FILE_ATTRIBUTE_ARCHIVE_W) 719 fileAttr |= FILE_ARCHIVED; 720 if(fuAttrFlags & FILE_ATTRIBUTE_HIDDEN_W) 721 fileAttr |= FILE_HIDDEN; 722 if(fuAttrFlags & FILE_ATTRIBUTE_SYSTEM_W) 723 fileAttr |= FILE_SYSTEM; 724 if(fuAttrFlags & FILE_ATTRIBUTE_READONLY_W) 725 fileAttr |= FILE_READONLY; 726 // TODO: FILE_ATTRIBUTE_TEMPORARY_W 727 728 switch(fuCreate) 729 { 730 case CREATE_NEW_W: 731 openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS; 732 break; 733 case CREATE_ALWAYS_W: 734 openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; 735 break; 736 case OPEN_EXISTING_W: 737 openFlag |= OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; 738 break; 739 case OPEN_ALWAYS_W: 740 openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; 741 break; 742 case TRUNCATE_EXISTING_W: 743 openFlag |= OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; 744 break; 745 } 746 747 if(fuAttrFlags & FILE_FLAG_WRITE_THROUGH_W) openMode |= OPEN_FLAGS_WRITE_THROUGH; 748 if(fuAttrFlags & FILE_FLAG_NO_BUFFERING_W) openMode |= OPEN_FLAGS_NO_CACHE; 749 if(fuAttrFlags & FILE_FLAG_RANDOM_ACCESS_W) openMode |= OPEN_FLAGS_RANDOM; 750 if(fuAttrFlags & FILE_FLAG_SEQUENTIAL_SCAN_W) openMode |= OPEN_FLAGS_SEQUENTIAL; 751 // TODO: FILE_FLAG_BACKUP_SEMANTICS_W 752 // FILE_FLAG_POSIX_SEMANTICS_W are not supported 753 754 if(fuShare == 0) 755 openMode |= OPEN_SHARE_DENYREADWRITE; 756 else 757 if(fuShare == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) 758 openMode |= OPEN_SHARE_DENYNONE; 759 else 760 if(fuShare & FILE_SHARE_READ_W) 761 openMode |= OPEN_SHARE_DENYWRITE; 762 else 763 if(fuShare & FILE_SHARE_WRITE_W) 764 openMode |= OPEN_SHARE_DENYREAD; 765 766 if(fuAccess == (GENERIC_READ_W | GENERIC_WRITE_W)) 767 openMode |= OPEN_ACCESS_READWRITE; 768 else 769 if(fuAccess & GENERIC_READ_W) 770 openMode |= OPEN_ACCESS_READONLY; 771 else 772 if(fuAccess & GENERIC_WRITE_W) 773 openMode |= OPEN_ACCESS_WRITEONLY; 774 775 int retry = 0; 776 while(retry < 2) 777 { 778 rc = DosOpen((PSZ)lpszFile, 779 &hFile, 780 &actionTaken, 781 fileSize, 782 fileAttr, 783 openFlag, 784 openMode, 785 NULL); 786 if(rc == ERROR_TOO_MANY_OPEN_FILES) 787 { 788 ULONG CurMaxFH; 789 LONG ReqCount = 32; 790 791 rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH); 792 if(rc) { 793 dprintf(("DosSetRelMaxFH returned %d", rc)); 794 SetLastError(ERROR_TOO_MANY_OPEN_FILES_W); 795 return INVALID_HANDLE_VALUE_W; 796 } 797 dprintf(("DosOpen failed -> increased nr open files to %d", CurMaxFH)); 798 } 799 else break; 800 retry++; 801 } 802 803 if(rc) 804 { 805 SetLastError(error2WinError(rc)); 806 return INVALID_HANDLE_VALUE_W; 807 } 808 SetLastError(ERROR_SUCCESS_W); 809 return hFile; 810 } 811 //****************************************************************************** 812 //****************************************************************************** 813 DWORD OSLibDosOpenFile(CHAR *lpszFile, UINT fuMode) 814 { 815 ULONG actionTaken = 0; 816 ULONG fileSize = 0; 817 ULONG fileAttr = FILE_NORMAL; 818 ULONG openFlag = 0; 819 ULONG openMode = 0; 820 APIRET rc = ERROR_NOT_ENOUGH_MEMORY; 821 HFILE hFile; 822 823 if(!(fuMode & (OF_CREATE_W | OF_READWRITE_W | OF_WRITE_W))) 824 { 825 openMode |= OPEN_ACCESS_READONLY; 826 openFlag |= OPEN_ACTION_OPEN_IF_EXISTS; 827 } 828 else 829 { 830 if(fuMode & OF_CREATE_W) { 831 openFlag |= OPEN_ACTION_CREATE_IF_NEW | 832 OPEN_ACTION_REPLACE_IF_EXISTS; 833 } 834 else openFlag |= OPEN_ACTION_OPEN_IF_EXISTS; //180575 835 836 if(fuMode & OF_READWRITE_W) 837 openMode |= OPEN_ACCESS_READWRITE; 838 else 839 if(fuMode & OF_WRITE_W) 840 openMode |= OPEN_ACCESS_WRITEONLY; 841 else 842 if(fuMode & OF_CREATE_W) 843 openMode |= OPEN_ACCESS_READWRITE; 844 } 845 846 if((fuMode & OF_SHARE_DENY_WRITE_W) || 847 !(fuMode & (OF_SHARE_DENY_READ_W | OF_SHARE_DENY_NONE_W | OF_SHARE_EXCLUSIVE_W))) 848 openMode |= OPEN_SHARE_DENYWRITE; 849 else 850 if (fuMode & OF_SHARE_DENY_NONE_W) 851 openMode |= OPEN_SHARE_DENYNONE; 852 else 853 if (fuMode & OF_SHARE_DENY_READ_W) 854 openMode |= OPEN_SHARE_DENYREAD; 855 else 856 if (fuMode & OF_SHARE_EXCLUSIVE_W) 857 openMode |= OPEN_SHARE_DENYREADWRITE; 858 859 rc = DosOpen((PSZ)lpszFile, 860 &hFile, 861 &actionTaken, 862 fileSize, 863 fileAttr, 864 openFlag, 865 openMode, 866 NULL); 867 868 if(rc != NO_ERROR) 869 { 870 if(fuMode & OF_EXIST_W) 871 { 872 if(rc == ERROR_OPEN_FAILED || rc == ERROR_FILE_NOT_FOUND) 873 { 874 SetLastError(ERROR_FILE_NOT_FOUND_W); 875 return HFILE_ERROR_W; 876 } 877 } 878 if((rc == ERROR_OPEN_FAILED) && (openFlag & OPEN_ACTION_OPEN_IF_EXISTS)) 879 { 880 SetLastError(ERROR_FILE_NOT_FOUND_W); 881 } 882 else SetLastError(error2WinError(rc)); 883 884 return HFILE_ERROR_W; 885 } 886 SetLastError(ERROR_SUCCESS_W); 887 return hFile; 888 } 889 //****************************************************************************** 890 //****************************************************************************** 891 BOOL OSLibDosLockFile(DWORD hFile, DWORD dwFlags, 892 DWORD OffsetLow, DWORD OffsetHigh, 893 DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, 894 LPOVERLAPPED lpOverlapped) 895 { 896 APIRET rc; 897 898 // Set 5 secs timeout for locking file and no other can access this 899 // file region 900 901 if(lpOverlapped) {//TODO: 902 dprintf(("OSLibDosLockFile: overlapped lock not yet implemented!!")); 903 } 904 //TODO: Locking region crossing end of file is permitted. Works in OS/2?? 905 if(f64BitIO) 906 { 907 FILELOCKL lockRangeL; 908 909 lockRangeL.lOffset.ulLo = OffsetLow; 910 lockRangeL.lOffset.ulHi = OffsetHigh; 911 lockRangeL.lRange.ulLo = nNumberOfBytesToLockLow; 912 lockRangeL.lRange.ulHi = nNumberOfBytesToLockHigh; 913 914 rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL, 915 (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0); 916 } 917 else 918 { 919 FILELOCK lockRange = { OffsetLow, nNumberOfBytesToLockLow }; 920 921 rc = DosSetFileLocks(hFile, NULL, &lockRange, 922 (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0); 923 } 924 if(rc) { 925 SetLastError(error2WinError(rc)); 926 return FALSE; 927 } 928 SetLastError(ERROR_SUCCESS_W); 929 return TRUE; 930 } 931 //****************************************************************************** 932 //****************************************************************************** 933 BOOL OSLibDosUnlockFile(DWORD hFile, DWORD OffsetLow, DWORD OffsetHigh, 934 DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, 935 LPOVERLAPPED lpOverlapped) 936 { 937 APIRET rc; 938 939 // Set 5 secs timeout for unlocking file and no other can access this 940 // file region 941 942 if(lpOverlapped) {//TODO: 943 dprintf(("OSLibDosUnlockFile: overlapped unlock not yet implemented!!")); 944 } 945 if(f64BitIO) 946 { 947 FILELOCKL unlockRangeL; 948 949 unlockRangeL.lOffset.ulLo = OffsetLow; 950 unlockRangeL.lOffset.ulHi = OffsetHigh; 951 unlockRangeL.lRange.ulLo = nNumberOfBytesToLockLow; 952 unlockRangeL.lRange.ulHi = nNumberOfBytesToLockHigh; 953 954 rc = OdinDosSetFileLocksL(hFile, &unlockRangeL, NULL, 5000, 0); 955 } 956 else 957 { 958 FILELOCK unlockRange = { OffsetLow, nNumberOfBytesToLockLow }; 959 960 rc = DosSetFileLocks(hFile, &unlockRange, NULL, 5000, 0); 961 } 962 if(rc) { 963 SetLastError(error2WinError(rc)); 964 return FALSE; 965 } 966 SetLastError(ERROR_SUCCESS_W); 967 return TRUE; 968 } 969 //****************************************************************************** 970 //****************************************************************************** 971 BOOL OSLibDosFlushFileBuffers(DWORD hFile) 972 { 973 APIRET rc; 974 975 rc = DosResetBuffer(hFile); 976 SetLastError(error2WinError(rc)); 977 return (rc == NO_ERROR); 978 } 979 //****************************************************************************** 980 //****************************************************************************** 981 DWORD OSLibDosGetFileSize(DWORD hFile, LPDWORD lpdwFileSizeHigh) 982 { 983 APIRET rc; 984 ULONG sizeLow; 985 986 if(f64BitIO) 987 { 988 FILESTATUS3L fsts3ConfigInfoL = {{0}}; 989 ULONG ulBufSize = sizeof(FILESTATUS3L); 990 991 rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &fsts3ConfigInfoL, ulBufSize); 992 if(lpdwFileSizeHigh) { 993 *lpdwFileSizeHigh = fsts3ConfigInfoL.cbFile.ulHi; 994 } 995 sizeLow = fsts3ConfigInfoL.cbFile.ulLo; 996 } 997 else 998 { 999 FILESTATUS3 fsts3ConfigInfo = {{0}}; 1000 ULONG ulBufSize = sizeof(FILESTATUS3); 1001 1002 if(lpdwFileSizeHigh) { 1003 *lpdwFileSizeHigh = 0; 1004 } 1005 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fsts3ConfigInfo, ulBufSize); 1006 sizeLow = fsts3ConfigInfo.cbFile; 1007 } 1008 if(rc) { 1009 SetLastError(error2WinError(rc)); 1010 return -1; 1011 } 1012 SetLastError(ERROR_SUCCESS_W); 1013 return sizeLow; 1014 } 1015 //****************************************************************************** 1016 //****************************************************************************** 1017 DWORD OSLibDosSetFilePointer(DWORD hFile, DWORD OffsetLow, DWORD *OffsetHigh, DWORD method) 1018 { 1019 LONGLONG offsetL; 1020 LONGLONG newoffsetL; 1021 APIRET rc; 1022 DWORD newoffset; 1023 1024 switch(method) { 1025 case FILE_BEGIN_W: 1026 method = FILE_BEGIN; 1027 break; 1028 1029 case FILE_CURRENT_W: 1030 method = FILE_CURRENT; 1031 break; 1032 1033 case FILE_END_W: 1034 method = FILE_END; 1035 break; 1036 } 1037 if(f64BitIO) { 1038 offsetL.ulLo = OffsetLow; 1039 offsetL.ulHi = (OffsetHigh) ? *OffsetHigh : 0; 1040 rc = OdinDosSetFilePtrL(hFile, offsetL, method, &newoffsetL); 1041 if(OffsetHigh) { 1042 *OffsetHigh = newoffsetL.ulHi; 1043 } 1044 newoffset = newoffsetL.ulLo; 1045 } 1046 else rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset); 1047 if(rc) { 1048 SetLastError(error2WinError(rc)); 1049 return -1; 1050 } 1051 SetLastError(ERROR_SUCCESS_W); 1052 return newoffset; 1053 } 1054 //****************************************************************************** 1055 //****************************************************************************** 1056 BOOL OSLibDosSetEndOfFile(DWORD hFile) 1057 { 1058 ULONG newFilePos; 1059 LONGLONG FilePosL = {0,0}; 1060 LONGLONG newFilePosL; 1061 APIRET rc; 1062 1063 if(f64BitIO) { 1064 rc = OdinDosSetFilePtrL(hFile, FilePosL, FILE_CURRENT, &newFilePosL); 1065 if(rc == 0) { 1066 rc = OdinDosSetFileSizeL(hFile, newFilePosL); 1067 } 1068 } 1069 else { 1070 rc = DosSetFilePtr(hFile, 0, FILE_CURRENT, &newFilePos); 1071 if(rc == 0) { 1072 rc = DosSetFileSize(hFile, newFilePos); 1073 } 1074 } 1075 if(rc) { 1076 SetLastError(error2WinError(rc)); 1077 return FALSE; 1078 } 1079 SetLastError(ERROR_SUCCESS_W); 1080 return TRUE; 1081 } 1082 //****************************************************************************** 1083 //****************************************************************************** 1084 BOOL OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pInfo) 1085 { 1086 APIRET rc; 1087 1088 if(f64BitIO) 1089 { 1090 FILESTATUS4L statusL = { 0 }; 1091 1092 rc = DosQueryFileInfo(hFile, 1093 FIL_QUERYEASIZEL, 1094 &statusL, 1095 sizeof(statusL)); 1096 if(rc == NO_ERROR) 1097 { 1098 pInfo->dwFileAttributes = 0; 1099 if(!(statusL.attrFile & NOT_NORMAL)) 1100 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL_W; 1101 if(statusL.attrFile & FILE_READONLY) 1102 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_READONLY_W; 1103 if(statusL.attrFile & FILE_HIDDEN) 1104 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN_W; 1105 if(statusL.attrFile & FILE_SYSTEM) 1106 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM_W; 1107 if(statusL.attrFile & FILE_DIRECTORY) 1108 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY_W; 1109 if(statusL.attrFile & FILE_ARCHIVED) 1110 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_ARCHIVE_W; 1111 1112 pmDateTimeToFileTime(&statusL.fdateCreation, 1113 &statusL.ftimeCreation, 1114 &pInfo->ftCreationTime); 1115 pmDateTimeToFileTime(&statusL.fdateLastAccess, 1116 &statusL.ftimeLastAccess, 1117 &pInfo->ftLastAccessTime); 1118 pmDateTimeToFileTime(&statusL.fdateLastWrite, 1119 &statusL.ftimeLastWrite, 1120 &pInfo->ftLastWriteTime); 1121 1122 pInfo->nFileSizeHigh = statusL.cbFile.ulHi; 1123 pInfo->nFileSizeLow = statusL.cbFile.ulLo; 1124 pInfo->dwVolumeSerialNumber = 0; //todo 1125 pInfo->nNumberOfLinks = 1; 1126 pInfo->nFileIndexHigh = 0; 1127 pInfo->nFileIndexLow = 0; 1128 } 1129 } 1130 else 1131 { 1132 FILESTATUS4 status = { 0 }; 1133 1134 rc = DosQueryFileInfo(hFile, 1135 FIL_QUERYEASIZE, 1136 &status, 1137 sizeof(status)); 1138 if(rc == NO_ERROR) 1139 { 1140 pInfo->dwFileAttributes = 0; 1141 if(!(status.attrFile & NOT_NORMAL)) 1142 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL_W; 1143 if(status.attrFile & FILE_READONLY) 1144 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_READONLY_W; 1145 if(status.attrFile & FILE_HIDDEN) 1146 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN_W; 1147 if(status.attrFile & FILE_SYSTEM) 1148 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM_W; 1149 if(status.attrFile & FILE_DIRECTORY) 1150 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY_W; 1151 if(status.attrFile & FILE_ARCHIVED) 1152 pInfo->dwFileAttributes |= FILE_ATTRIBUTE_ARCHIVE_W; 1153 1154 pmDateTimeToFileTime(&status.fdateCreation, 1155 &status.ftimeCreation, 1156 &pInfo->ftCreationTime); 1157 pmDateTimeToFileTime(&status.fdateLastAccess, 1158 &status.ftimeLastAccess, 1159 &pInfo->ftLastAccessTime); 1160 pmDateTimeToFileTime(&status.fdateLastWrite, 1161 &status.ftimeLastWrite, 1162 &pInfo->ftLastWriteTime); 1163 1164 pInfo->nFileSizeHigh = 0; 1165 pInfo->nFileSizeLow = status.cbFile; 1166 pInfo->dwVolumeSerialNumber = 0; //todo 1167 pInfo->nNumberOfLinks = 1; 1168 pInfo->nFileIndexHigh = 0; 1169 pInfo->nFileIndexLow = 0; 1170 } 1171 } 1172 if(rc) { 1173 SetLastError(error2WinError(rc)); 1174 return FALSE; 1175 } 1176 SetLastError(ERROR_SUCCESS_W); 1177 return TRUE; 1178 } 1179 //****************************************************************************** 1180 //****************************************************************************** 1181 BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 1182 WORD lastaccessdate, WORD lastaccesstime, 1183 WORD lastwritedate, WORD lastwritetime) 1184 { 1185 FILESTATUS3 fileInfo; 1186 APIRET rc; 1187 1188 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo)); 1189 1190 if(rc == NO_ERROR) 1191 { 1192 if(creationdate && creationtime) { 1193 fileInfo.fdateCreation = *(FDATE *)&creationdate; 1194 fileInfo.ftimeCreation = *(FTIME *)&creationtime; 1195 } 1196 if(lastaccessdate && lastaccesstime) { 1197 fileInfo.fdateLastAccess = *(FDATE *)&lastaccessdate; 1198 fileInfo.ftimeLastAccess = *(FTIME *)&lastaccesstime; 1199 } 1200 if(lastwritedate && lastwritetime) { 1201 fileInfo.fdateLastWrite = *(FDATE *)&lastwritedate; 1202 fileInfo.ftimeLastWrite = *(FTIME *)&lastwritetime; 1203 } 1204 1205 rc = DosSetFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo)); 1206 } 1207 1208 if(rc) 1209 { 1210 SetLastError(error2WinError(rc)); 1211 return FALSE; 1212 } 1213 SetLastError(ERROR_SUCCESS_W); 1214 return TRUE; 1215 } 1216 //****************************************************************************** 1217 //****************************************************************************** 1218 BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 1219 WORD *lastaccessdate, WORD *lastaccesstime, 1220 WORD *lastwritedate, WORD *lastwritetime) 1221 { 1222 FILESTATUS3 fileInfo; 1223 APIRET rc; 1224 1225 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo)); 1226 1227 if(rc == NO_ERROR) 1228 { 1229 *creationdate = *(WORD *)&fileInfo.fdateCreation; 1230 *creationtime = *(WORD *)&fileInfo.ftimeCreation; 1231 *lastaccessdate = *(WORD *)&fileInfo.fdateLastAccess; 1232 *lastaccesstime = *(WORD *)&fileInfo.ftimeLastAccess; 1233 *lastwritedate = *(WORD *)&fileInfo.fdateLastWrite; 1234 *lastwritetime = *(WORD *)&fileInfo.ftimeLastWrite; 1235 } 1236 1237 if(rc) 1238 { 1239 SetLastError(error2WinError(rc)); 1240 return FALSE; 1241 } 1242 SetLastError(ERROR_SUCCESS_W); 1243 return TRUE; 655 1244 } 656 1245 //****************************************************************************** … … 662 1251 663 1252 664 rc = DosSetFilePtr(hFile, offset, method, &newoffset); 665 if(rc) { 666 dprintf(("DosSetFilePtr Error rc:%d", rc)); 667 return -1; 668 } 669 else return newoffset; 670 } 671 //****************************************************************************** 672 //(FlushBuffer) 673 //****************************************************************************** 674 DWORD OSLibDosResetBuffer(DWORD hFile) 675 { 676 return DosResetBuffer(hFile); 1253 rc = DosSetFilePtr(hFile, offset, method, &newoffset); 1254 if(rc) { 1255 dprintf(("DosSetFilePtr Error rc:%d", rc)); 1256 return -1; 1257 } 1258 else return newoffset; 677 1259 } 678 1260 //****************************************************************************** … … 680 1262 DWORD OSLibDosDupHandle(DWORD hFile, DWORD *hNew) 681 1263 { 682 *hNew = -1;683 return DosDupHandle(hFile, hNew);1264 *hNew = -1; 1265 return DosDupHandle(hFile, hNew); 684 1266 } 685 1267 //****************************************************************************** … … 687 1269 void OSLibDosDisableHardError(BOOL fTurnOff) 688 1270 { 689 DosError((fTurnOff) ? FERR_DISABLEHARDERR : FERR_ENABLEHARDERR);1271 DosError((fTurnOff) ? FERR_DISABLEHARDERR : FERR_ENABLEHARDERR); 690 1272 } 691 1273 //****************************************************************************** -
trunk/src/kernel32/oslibdos.h
r3593 r3642 1 /* $Id: oslibdos.h,v 1.1 5 2000-05-23 18:45:13sandervl Exp $ */1 /* $Id: oslibdos.h,v 1.16 2000-06-01 11:28:48 sandervl Exp $ */ 2 2 3 3 /* … … 13 13 #define __OSLIBDOS_H__ 14 14 15 16 void OSLibInitWSeBFileIO(); 15 17 16 18 DWORD OSLibDosAliasMem(LPVOID pb, ULONG cb, LPVOID *ppbAlias, ULONG fl); … … 68 70 DWORD OSLibDosOpen(char *lpszFileName, DWORD flags); 69 71 DWORD OSLibDosClose(DWORD hFile); 70 DWORD OSLibDosGetFileSize(DWORD hFile); 71 DWORD OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead); 72 DWORD OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten); 73 DWORD OSLibDosDelete(char *lpszFileName); 72 BOOL OSLibDosDelete(char *lpszFileName); 74 73 75 74 #define OSLIB_SETPTR_FILE_CURRENT 1 … … 86 85 DWORD OSLibDosSearchPath(DWORD cmd, char *path, char *name, char *full_name, DWORD length_fullname); 87 86 88 89 DWORD OSLibDosCreate(CHAR *lpFileName, 90 DWORD dwAccess, 91 DWORD dwShare, 92 LPSECURITY_ATTRIBUTES lpSecurityAttributes, 93 DWORD dwCreation, 94 DWORD dwFlags, 95 HANDLE hTemplate, 96 DWORD *dwFile); 97 98 DWORD OSLibDosResetBuffer(DWORD hFile); 87 DWORD OSLibDosCreateFile(CHAR *lpFileName, DWORD dwAccess, 88 DWORD dwShare, LPSECURITY_ATTRIBUTES lpSecurityAttributes, 89 DWORD dwCreation, DWORD dwFlags, HANDLE hTemplate); 90 91 DWORD OSLibDosOpenFile(CHAR *lpszFile, UINT fuMode); 92 93 BOOL OSLibDosLockFile(DWORD hFile, DWORD dwFlags, 94 DWORD OffsetLow, DWORD OffsetHigh, 95 DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, 96 LPOVERLAPPED lpOverlapped); 97 98 BOOL OSLibDosUnlockFile(DWORD hFile, DWORD OffsetLow, DWORD OffsetHigh, 99 DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, 100 LPOVERLAPPED lpOverlapped); 101 102 BOOL OSLibDosFlushFileBuffers(DWORD hFile); 103 BOOL OSLibDosSetEndOfFile(DWORD hFile); 104 105 DWORD OSLibDosGetFileSize(DWORD hFile, LPDWORD lpdwFileSizeHigh); 106 BOOL OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead); 107 BOOL OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten); 108 109 BOOL OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pHFI); 110 111 BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 112 WORD lastaccessdate, WORD lastaccesstime, 113 WORD lastwritedate, WORD lastwritetime); 114 115 BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 116 WORD *lastaccessdate, WORD *lastaccesstime, 117 WORD *lastwritedate, WORD *lastwritetime); 118 119 DWORD OSLibDosSetFilePointer(DWORD hFile, DWORD OffsetLow, DWORD *OffsetHigh, DWORD method); 120 99 121 DWORD OSLibDosDupHandle(DWORD hFile, DWORD *hNew); 100 122 DWORD OSLibDosSetFilePtr2(DWORD hFile, DWORD offset, DWORD method); … … 156 178 157 179 158 #endif 180 #ifdef OS2DEF_INCLUDED 181 #ifndef FIL_STANDARDL 182 typedef struct _LONGLONG { /* LONGLONG */ 183 ULONG ulLo; 184 LONG ulHi; 185 } LONGLONG; 186 typedef LONGLONG *PLONGLONG; 187 188 typedef struct _ULONGLONG { /* ULONGLONG */ 189 ULONG ulLo; 190 ULONG ulHi; 191 } ULONGLONG; 192 typedef ULONGLONG *PULONGLONG; 193 194 #define FIL_STANDARDL 11 /* LFS - Info level 11, standard file info for large files*/ 195 #define FIL_QUERYEASIZEL 12 /* LFS - Level 12, return Full EA size for large files */ 196 #define FIL_QUERYEASFROMLISTL 13 /* LFS - Level 13, return requested EA's */ 197 198 typedef struct _FILESTATUS3L /* fsts3L */ 199 { 200 FDATE fdateCreation; 201 FTIME ftimeCreation; 202 FDATE fdateLastAccess; 203 FTIME ftimeLastAccess; 204 FDATE fdateLastWrite; 205 FTIME ftimeLastWrite; 206 LONGLONG cbFile; 207 LONGLONG cbFileAlloc; 208 ULONG attrFile; 209 } FILESTATUS3L; 210 typedef FILESTATUS3L *PFILESTATUS3L; 211 212 /* Large File Support >2GB */ 213 typedef struct _FILESTATUS4L /* fsts4L */ 214 { 215 FDATE fdateCreation; 216 FTIME ftimeCreation; 217 FDATE fdateLastAccess; 218 FTIME ftimeLastAccess; 219 FDATE fdateLastWrite; 220 FTIME ftimeLastWrite; 221 LONGLONG cbFile; 222 LONGLONG cbFileAlloc; 223 ULONG attrFile; 224 ULONG cbList; 225 } FILESTATUS4L; 226 typedef FILESTATUS4L *PFILESTATUS4L; 227 228 typedef struct _FILELOCKL /* flock */ 229 { 230 LONGLONG lOffset; 231 LONGLONG lRange; 232 } FILELOCKL; 233 typedef FILELOCKL *PFILELOCKL; 234 #endif 235 236 237 typedef APIRET (* APIENTRY PROC_DosSetFileSizeL)(HFILE hFile, LONGLONG cbSize); 238 APIRET OdinDosSetFileSize(HFILE hFile, 239 LONGLONG cbSize); 240 241 typedef APIRET (* APIENTRY PROC_DosSetFilePtrL)(HFILE hFile, LONGLONG ib, ULONG method, PLONGLONG ibActual); 242 APIRET OdinDosSetFilePtr(HFILE hFile, 243 LONGLONG ib, 244 ULONG method, 245 PLONGLONG ibActual); 246 247 typedef APIRET (* APIENTRY PROC_DosSetFileLocksL)(HFILE hFile, PFILELOCKL pflUnlock, PFILELOCKL pflLock, ULONG timeout, ULONG flags); 248 APIRET OdinDosSetFileLocks(HFILE hFile, 249 PFILELOCKL pflUnlock, 250 PFILELOCKL pflLock, 251 ULONG timeout, 252 ULONG flags); 253 #endif 254 255 #endif -
trunk/src/kernel32/winimagepeldr.cpp
r3635 r3642 1 /* $Id: winimagepeldr.cpp,v 1.4 5 2000-05-29 22:32:09sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.46 2000-06-01 11:28:48 sandervl Exp $ */ 2 2 3 3 /* … … 212 212 213 213 if(oh.SizeOfImage == 0) {//just in case 214 oh.SizeOfImage = OSLibDosGetFileSize(hFile );214 oh.SizeOfImage = OSLibDosGetFileSize(hFile, NULL); 215 215 } 216 216
Note:
See TracChangeset
for help on using the changeset viewer.