- Timestamp:
- May 10, 2002, 4:55:13 PM (23 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r7927 r8401 1 /* $Id: HandleManager.cpp,v 1.8 7 2002-02-15 19:14:50sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.88 2002-05-10 14:55:09 sandervl Exp $ */ 2 2 3 3 /* … … 1667 1667 { 1668 1668 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 1669 return (INVALID_HANDLE_ERROR); /* signal failure */1669 return -1; //INVALID_SET_FILE_POINTER 1670 1670 } 1671 1671 -
trunk/src/kernel32/disk.cpp
r8397 r8401 1 /* $Id: disk.cpp,v 1.3 5 2002-05-09 13:55:33sandervl Exp $ */1 /* $Id: disk.cpp,v 1.36 2002-05-10 14:55:10 sandervl Exp $ */ 2 2 3 3 /* … … 24 24 #include "oslibdos.h" 25 25 #include "osliblvm.h" 26 #include " exceptutil.h"26 #include "asmutil.h" 27 27 #include "profile.h" 28 28 #include "hmdisk.h" … … 240 240 pszVolume = (char *)alloca(length); 241 241 242 strcpy(pszVolume, &lpszDrive[sizeof(VOLUME_NAME_PREFIX)-1+1]); //-zero term + starting '{' 243 length -= sizeof(VOLUME_NAME_PREFIX)-1+1; 244 if(pszVolume[length-2] == '}') { 245 pszVolume[length-2] = 0; 242 if(OSLibLVMStripVolumeName(lpszDrive, pszVolume, length)) 243 { 246 244 rc = OSLibLVMGetDriveType(pszVolume); 247 245 dprintf(("KERNEL32: GetDriveType %s = %d (LVM)", lpszDrive, rc)); … … 314 312 pszVolume = (char *)alloca(length); 315 313 316 strcpy(pszVolume, &lpRootPathName[sizeof(VOLUME_NAME_PREFIX)-1]);317 length -= sizeof(VOLUME_NAME_PREFIX)-1;318 if(pszVolume[length-1] == '}') {314 if(OSLibLVMStripVolumeName(lpRootPathName, pszVolume, length)) 315 { 316 pszVolume[length-2] = 0; 319 317 fVolumeName = TRUE; 320 318 goto proceed; … … 361 359 else 362 360 if(!strcmp(lpFileSystemNameBuffer, "CDFS") || 363 !strcmp(lpFileSystemNameBuffer, "UDF")) 361 !strcmp(lpFileSystemNameBuffer, "UDF") || 362 !strcmp(lpFileSystemNameBuffer, "NTFS") || 363 !strcmp(lpFileSystemNameBuffer, "FAT32")) 364 364 { 365 365 //do nothing … … 738 738 DWORD cchBufferLength) 739 739 { 740 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 741 SetLastError(ERROR_NOT_SUPPORTED); 742 return FALSE; 743 } 744 745 dprintf(("GetVolumeNameForVolumeMountPointA: %s", lpszVolumeMountPoint)); 746 if(OSLibLVMGetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint, lpszVolumeName, 740 LPSTR pszvol; 741 742 pszvol = (char *)alloca(cchBufferLength); 743 if(pszvol == NULL) { 744 DebugInt3(); 745 return FALSE; 746 } 747 748 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 749 SetLastError(ERROR_NOT_SUPPORTED); 750 return FALSE; 751 } 752 753 if(OSLibLVMGetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint, pszvol, 747 754 cchBufferLength) == TRUE) 748 755 { 756 int length = strlen(pszvol); 757 if(length + sizeof(VOLUME_NAME_PREFIX) - 1 + 3 > cchBufferLength) { 758 SetLastError(ERROR_INSUFFICIENT_BUFFER); 759 return FALSE; 760 } 761 sprintf(lpszVolumeName, VOLUME_NAME_PREFIX"{%s}\\", pszvol); 762 763 dprintf(("GetVolumeNameForVolumeMountPointA %s returned %s", lpszVolumeMountPoint, lpszVolumeName)); 749 764 SetLastError(ERROR_SUCCESS); 750 765 return TRUE; 751 766 } 767 dprintf(("GetVolumeNameForVolumeMountPointA: %s not found!!", lpszVolumeMountPoint)); 752 768 SetLastError(ERROR_FILE_NOT_FOUND); 753 769 return FALSE; -
trunk/src/kernel32/exceptstackdump.cpp
r6375 r8401 1 /* $Id: exceptstackdump.cpp,v 1. 4 2001-07-20 15:33:29sandervl Exp $ */1 /* $Id: exceptstackdump.cpp,v 1.5 2002-05-10 14:55:11 sandervl Exp $ */ 2 2 /* 3 3 * Stack dump code … … 20 20 #include "exceptstackdump.h" 21 21 #include "exceptutil.h" 22 #include "asmutil.h" 22 23 #include "oslibmisc.h" 23 24 #include "winexebase.h" -
trunk/src/kernel32/exceptutil.asm
r6375 r8401 1 ; $Id: exceptutil.asm,v 1.1 8 2001-07-20 15:33:29sandervl Exp $1 ; $Id: exceptutil.asm,v 1.19 2002-05-10 14:55:11 sandervl Exp $ 2 2 3 3 ;/* … … 154 154 _SetExceptionChain endp 155 155 156 PUBLIC getEAX157 PUBLIC getEBX158 getEAX proc near159 ret160 getEAX endp161 162 public getEDX163 getEDX proc near164 mov EAX, EDX165 ret166 endp167 168 getEBX proc near169 mov eax, ebx170 ret171 getEBX endp172 173 PUBLIC GetFS174 GetFS proc near175 mov eax, fs176 ret177 GetFS endp178 179 PUBLIC SetFS180 SetFS proc near181 mov eax, [esp+4]182 mov fs, eax183 ret184 SetFS endp185 186 PUBLIC getCS187 getCS proc near188 mov eax, cs189 ret190 getCS endp191 192 PUBLIC getDS193 getDS proc near194 mov eax, ds195 ret196 getDS endp197 198 PUBLIC SetReturnFS199 SetReturnFS proc near200 push fs201 mov eax, [esp+8]202 mov fs, eax203 pop eax204 ret205 SetReturnFS endp206 207 PUBLIC getSS208 getSS proc near209 mov ax, ss210 ret211 getSS endp212 213 PUBLIC getES214 getES proc near215 mov eax, es216 ret217 getES endp218 219 PUBLIC getGS220 getGS proc near221 mov eax, gs222 ret223 getGS endp224 225 PUBLIC getESP226 getESP proc near227 mov eax, esp228 ret229 getESP endp230 231 PUBLIC RestoreOS2FS232 RestoreOS2FS proc near233 push 150bh234 mov ax, fs235 pop fs236 ret237 RestoreOS2FS endp238 239 PUBLIC _Mul32x32to64240 _Mul32x32to64 proc near241 push ebp242 mov ebp, esp243 push eax244 push edx245 push edi246 247 mov edi, [ebp+8] ;64 bits result248 mov eax, [ebp+12] ;op1249 mov edx, [ebp+16] ;op2250 mul edx251 mov [edi], eax252 mov [edi+4], edx253 254 pop edi255 pop edx256 pop eax257 pop ebp258 ret259 _Mul32x32to64 endp260 156 261 157 PUBLIC _AsmCallThreadHandler -
trunk/src/kernel32/exceptutil.h
r6133 r8401 1 /* $Id: exceptutil.h,v 1.1 2 2001-06-27 19:09:35sandervl Exp $ */1 /* $Id: exceptutil.h,v 1.13 2002-05-10 14:55:11 sandervl Exp $ */ 2 2 3 3 /* … … 32 32 #endif 33 33 34 ULONG getEAX();35 ULONG getEBX();36 ULONG getESP();37 USHORT getSS();38 USHORT getDS();39 USHORT getCS();40 USHORT getSS();41 USHORT getES();42 USHORT getFS();43 USHORT getGS();44 45 void CDECL Mul32x32to64(PVOID result, DWORD op1, DWORD op2);46 47 34 ULONG CDECL AsmCallThreadHandler(ULONG handler, LPVOID parameter); 48 35 -
trunk/src/kernel32/hmdevice.cpp
r7549 r8401 1 /* $Id: hmdevice.cpp,v 1.3 1 2001-12-05 14:15:59sandervl Exp $ */1 /* $Id: hmdevice.cpp,v 1.32 2002-05-10 14:55:11 sandervl Exp $ */ 2 2 3 3 /* … … 426 426 pSize)); 427 427 428 return (ERROR_INVALID_FUNCTION);428 return -1; //INVALID_SET_FILE_POINTER 429 429 } 430 430 -
trunk/src/kernel32/hmdisk.cpp
r8397 r8401 1 /* $Id: hmdisk.cpp,v 1.4 3 2002-05-09 13:55:33sandervl Exp $ */1 /* $Id: hmdisk.cpp,v 1.44 2002-05-10 14:55:11 sandervl Exp $ */ 2 2 3 3 /* 4 4 * Win32 Disk API functions for OS/2 5 5 * 6 * Copyright 2000 Sander van Leeuwen6 * Copyright 2000-2002 Sander van Leeuwen 7 7 * 8 8 * … … 12 12 #include <os2win.h> 13 13 #include <string.h> 14 #include <stdio.h> 14 15 #include <versionos2.h> 15 16 … … 23 24 #include "oslibdos.h" 24 25 #include "osliblvm.h" 26 #include "asmutil.h" 25 27 26 28 #define DBG_LOCALLOG DBG_hmdisk … … 35 37 { 36 38 HINSTANCE hInstAspi; 37 DWORD (WIN32API *GetASPI32SupportInfo)();38 DWORD (CDECL *SendASPI32Command)(LPSRB lpSRB);39 DWORD (WIN32API *GetASPI32SupportInfo)(); 40 DWORD (CDECL *SendASPI32Command)(LPSRB lpSRB); 39 41 ULONG driveLetter; 40 42 ULONG driveType; … … 47 49 LPSECURITY_ATTRIBUTES lpSecurityAttributes; 48 50 HFILE hTemplate; 51 BOOL fPhysicalDisk; 52 LARGE_INTEGER StartingOffset; 53 LARGE_INTEGER PartitionSize; 54 LARGE_INTEGER CurrentFilePointer; 55 CHAR szVolumeName[256]; 49 56 } DRIVE_INFO; 50 57 … … 70 77 BOOL HMDeviceDiskClass::FindDevice(LPCSTR lpClassDevName, LPCSTR lpDeviceName, int namelength) 71 78 { 72 // check for "x:" 73 if (namelength == 2) 74 { 75 if (lpDeviceName[1] != ':') 76 return FALSE; 77 78 if ( (lpDeviceName[0] < 'A') || 79 (lpDeviceName[0] > 'Z') ) 80 return FALSE; 81 82 return TRUE; 83 } 79 // check for "x:" 80 if (namelength == 2) 81 { 82 if (lpDeviceName[1] != ':') 83 return FALSE; 84 85 if (!( ((lpDeviceName[0] >= 'A') && 86 (lpDeviceName[0] <= 'Z')) || 87 ((lpDeviceName[0] >= 'a') && 88 (lpDeviceName[0] <= 'z')) )) 89 return FALSE; 90 91 return TRUE; 92 } 84 93 85 94 //\\.\x: -> length 6 … … 94 103 } 95 104 96 // SvL:\\.\x: -> drive x (i.e. \\.\C:)97 // 105 // \\.\x: -> drive x (i.e. \\.\C:) 106 // \\.\PHYSICALDRIVEn -> drive n (n>=0) 98 107 if((strncmp(lpDeviceName, "\\\\.\\", 4) == 0) && 99 108 namelength == 6 && lpDeviceName[5] == ':') … … 107 116 } 108 117 //****************************************************************************** 109 //TODO: PHYSICALDRIVEn!!110 118 //****************************************************************************** 111 119 DWORD HMDeviceDiskClass::CreateFile (LPCSTR lpFileName, … … 114 122 PHMHANDLEDATA pHMHandleDataTemplate) 115 123 { 116 HFILE hFile; 117 HFILE hTemplate; 118 DWORD dwDriveType; 124 HFILE hFile; 125 HFILE hTemplate; 126 DWORD dwDriveType; 127 CHAR szDiskName[256]; 128 CHAR szVolumeName[256] = ""; 129 VOLUME_DISK_EXTENTS volext = {0}; 130 BOOL fPhysicalDisk = FALSE; 119 131 120 132 dprintf2(("KERNEL32: HMDeviceDiskClass::CreateFile %s(%s,%08x,%08x,%08x)\n", 121 lpHMDeviceName, 122 lpFileName, 123 pHMHandleData, 124 lpSecurityAttributes, 125 pHMHandleDataTemplate)); 133 lpHMDeviceName, lpFileName, pHMHandleData, lpSecurityAttributes, pHMHandleDataTemplate)); 126 134 127 135 //TODO: check in NT if CREATE_ALWAYS is allowed!! … … 136 144 137 145 //if volume name, query 138 if(VERSION_IS_WIN2000_OR_HIGHER() && !strncmp(lpFileName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) { 139 char *pszVolume; 140 int length; 141 142 //strip volume name prefix (\\\\?\\Volume\\) 143 length = strlen(lpFileName); 144 pszVolume = (char *)alloca(length); 145 146 strcpy(pszVolume, &lpFileName[sizeof(VOLUME_NAME_PREFIX)-1+1]); //-zero term + starting '{' 147 length -= sizeof(VOLUME_NAME_PREFIX)-1+1; 148 if(pszVolume[length-2] == '}') { 149 pszVolume[length-2] = 0; 150 szDrive[0] = OSLibLVMQueryDriveFromVolumeName(pszVolume); 146 if(!strncmp(lpFileName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) 147 { 148 int length; 149 150 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 151 return ERROR_FILE_NOT_FOUND; //not allowed 152 } 153 if(OSLibLVMStripVolumeName(lpFileName, szVolumeName, sizeof(szVolumeName))) 154 { 155 BOOL fLVMVolume; 156 157 dwDriveType = GetDriveTypeA(lpFileName); 158 159 szDrive[0] = OSLibLVMQueryDriveFromVolumeName(szVolumeName); 160 if(szDrive[0] == -1) { 161 return ERROR_FILE_NOT_FOUND; //not found 162 } 163 if((dwDriveType == DRIVE_FIXED) && OSLibLVMGetVolumeExtents(szDrive[0], szVolumeName, &volext, &fLVMVolume) == FALSE) { 164 return ERROR_FILE_NOT_FOUND; //not found 165 } 166 if(szDrive[0] == 0) 167 { 168 //volume isn't mounted 169 170 //Note: this only works on Warp 4.5 and up 171 sprintf(szDiskName, "\\\\.\\Physical_Disk%d", volext.Extents[0].DiskNumber); 172 fPhysicalDisk = TRUE; 173 174 if(fLVMVolume && (pHMHandleData->dwAccess & GENERIC_WRITE)) { 175 //no write access allowed for LVM volumes 176 dprintf(("CreateFile: WARNING: Write access to LVM volume denied!!")); 177 pHMHandleData->dwAccess &= ~GENERIC_WRITE; 178 } 179 } 180 else { 181 //mounted drive, make sure access requested is readonly, else fail 182 if(pHMHandleData->dwAccess & GENERIC_WRITE) { 183 //no write access allowed for mounted partitions 184 dprintf(("CreateFile: WARNING: Write access to mounted partition denied!!")); 185 pHMHandleData->dwAccess &= ~GENERIC_WRITE; 186 } 187 strcpy(szDiskName, szDrive); 188 } 151 189 } 152 190 else return ERROR_FILE_NOT_FOUND; 153 191 } 192 else 193 if(strncmp(lpFileName, "\\\\.\\PHYSICALDRIVE", 17) == 0) 194 { 195 //Note: this only works on Warp 4.5 and up 196 sprintf(szDiskName, "\\\\.\\Physical_Disk%c", lpFileName[17]); 197 fPhysicalDisk = TRUE; 198 199 //TODO: could be removable in theory 200 dwDriveType = DRIVE_FIXED; 201 202 if(pHMHandleData->dwAccess & GENERIC_WRITE) { 203 //no write access allowed for whole disks 204 dprintf(("CreateFile: WARNING: Write access to whole disk denied!!")); 205 pHMHandleData->dwAccess &= ~GENERIC_WRITE; 206 } 154 207 } 155 208 else { 209 strcpy(szDiskName, lpFileName); 156 210 szDrive[0] = *lpFileName; 157 }158 dwDriveType = GetDriveTypeA(szDrive);211 dwDriveType = GetDriveTypeA(szDrive); 212 } 159 213 160 214 //Disable error popus. NT allows an app to open a cdrom/dvd drive without a disk inside 161 215 //OS/2 fails in that case with error ERROR_NOT_READY 162 216 ULONG oldmode = SetErrorMode(SEM_FAILCRITICALERRORS); 163 hFile = OSLibDosCreateFile( (LPSTR)lpFileName,217 hFile = OSLibDosCreateFile(szDiskName, 164 218 pHMHandleData->dwAccess, 165 219 pHMHandleData->dwShare, … … 177 231 { 178 232 pHMHandleData->dwAccess &= ~GENERIC_WRITE; 179 hFile = OSLibDosCreateFile((LPSTR) lpFileName,233 hFile = OSLibDosCreateFile((LPSTR)szDiskName, 180 234 pHMHandleData->dwAccess, 181 235 pHMHandleData->dwShare, … … 211 265 drvInfo->dwAccess = pHMHandleData->dwFlags; 212 266 drvInfo->hTemplate = hTemplate; 267 268 //save volume start & length if volume must be accessed through the physical disk 269 //(no other choice for unmounted volumes) 270 drvInfo->fPhysicalDisk = fPhysicalDisk; 271 drvInfo->StartingOffset = volext.Extents[0].StartingOffset; 272 drvInfo->PartitionSize = volext.Extents[0].ExtentLength; 273 274 //save volume name for later (IOCtls) 275 strncpy(drvInfo->szVolumeName, szVolumeName, sizeof(drvInfo->szVolumeName)-1); 213 276 214 277 drvInfo->driveLetter = *lpFileName; //save drive letter … … 242 305 } 243 306 244 if(hFile ) {307 if(hFile && drvInfo->driveType != DRIVE_FIXED) { 245 308 OSLibDosQueryVolumeSerialAndName(1 + drvInfo->driveLetter - 'A', &drvInfo->dwVolumelabel, NULL, 0); 246 309 } 247 310 311 //for an unmounted partition we open the physical disk that contains it, so we 312 //must set the file pointer to the correct beginning 313 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 314 drvInfo->StartingOffset.LowPart != 0)) 315 { 316 SetFilePointer(pHMHandleData, 0, NULL, FILE_BEGIN); 317 } 248 318 return (NO_ERROR); 249 319 } … … 618 688 { 619 689 APIRET rc; 620 DWORD ret;690 DWORD ret; 621 691 ULONG ulBytesRead = 0; /* Number of bytes read by DosRead */ 622 692 ULONG ulWrote = 0; /* Number of bytes written by DosWrite */ … … 638 708 return FALSE; 639 709 } 710 else 711 if(drvInfo->driveType == DRIVE_FIXED) { 712 SetLastError(ERROR_SUCCESS); 713 return TRUE; 714 } 640 715 641 716 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0); … … 720 795 //label has changed 721 796 //TODO: Find better way to determine if floppy was removed or switched 722 rc = OSLibDosQueryVolumeSerialAndName(1 + drvInfo->driveLetter - 'A', &volumelabel, NULL, 0); 723 if(rc) { 724 dprintf(("IOCTL_DISK_GET_DRIVE_GEOMETRY: OSLibDosQueryVolumeSerialAndName failed with rc %d", GetLastError())); 725 if(pHMHandleData->hHMHandle) OSLibDosClose(pHMHandleData->hHMHandle); 726 pHMHandleData->hHMHandle = 0; 727 SetLastError(ERROR_MEDIA_CHANGED); 728 return FALSE; 729 } 730 if(volumelabel != drvInfo->dwVolumelabel) { 731 dprintf(("IOCTL_DISK_GET_DRIVE_GEOMETRY: volume changed %x -> %x", drvInfo->dwVolumelabel, volumelabel)); 732 SetLastError(ERROR_MEDIA_CHANGED); 733 return FALSE; 797 if(drvInfo->driveType != DRIVE_FIXED) 798 { 799 rc = OSLibDosQueryVolumeSerialAndName(1 + drvInfo->driveLetter - 'A', &volumelabel, NULL, 0); 800 if(rc) { 801 dprintf(("IOCTL_DISK_GET_DRIVE_GEOMETRY: OSLibDosQueryVolumeSerialAndName failed with rc %d", GetLastError())); 802 if(pHMHandleData->hHMHandle) OSLibDosClose(pHMHandleData->hHMHandle); 803 pHMHandleData->hHMHandle = 0; 804 SetLastError(ERROR_MEDIA_CHANGED); 805 return FALSE; 806 } 807 if(volumelabel != drvInfo->dwVolumelabel) { 808 dprintf(("IOCTL_DISK_GET_DRIVE_GEOMETRY: volume changed %x -> %x", drvInfo->dwVolumelabel, volumelabel)); 809 SetLastError(ERROR_MEDIA_CHANGED); 810 return FALSE; 811 } 734 812 } 735 813 … … 754 832 *lpBytesReturned = sizeof(PARTITION_INFORMATION); 755 833 } 756 if(OSLibLVMGetPartitionInfo(drvInfo->driveLetter, pPartition)) {834 if(OSLibLVMGetPartitionInfo(drvInfo->driveLetter, drvInfo->szVolumeName, pPartition) == FALSE) { 757 835 SetLastError(ERROR_NOT_ENOUGH_MEMORY); //wrong error, but who cares 758 836 return FALSE; … … 781 859 return FALSE; 782 860 } 783 if(OSLibLVMGetVolumeExtents(drvInfo->driveLetter, pVolExtent)) {861 if(OSLibLVMGetVolumeExtents(drvInfo->driveLetter, drvInfo->szVolumeName, pVolExtent) == FALSE) { 784 862 SetLastError(ERROR_NOT_ENOUGH_MEMORY); //wrong error, but who cares 785 863 return FALSE; … … 816 894 } ParameterBlock; 817 895 #pragma pack() 818 819 896 PCDROM_TOC pTOC = (PCDROM_TOC)lpOutBuffer; 820 897 DWORD rc, numtracks; … … 915 992 case IOCTL_CDROM_PLAY_AUDIO_MSF: 916 993 { 917 dprintf(("Play CDROM audio playback"));918 919 994 #pragma pack(1) 920 995 struct … … 926 1001 } ParameterBlock; 927 1002 #pragma pack() 1003 dprintf(("Play CDROM audio playback")); 928 1004 929 1005 PCDROM_PLAY_AUDIO_MSF pPlay = (PCDROM_PLAY_AUDIO_MSF)lpInBuffer; … … 1096 1172 case IOCTL_STORAGE_CHECK_VERIFY: 1097 1173 { 1174 #pragma pack(1) 1175 typedef struct 1176 { 1177 BYTE ucCommandInfo; 1178 WORD usDriveUnit; 1179 } ParameterBlock; 1180 #pragma pack() 1181 1098 1182 dprintf(("IOCTL_CDROM(DISK/STORAGE)CHECK_VERIFY %s", drvInfo->signature)); 1099 1183 if(lpBytesReturned) { … … 1109 1193 } 1110 1194 } 1111 1112 #pragma pack(1)1113 typedef struct1114 {1115 BYTE ucCommandInfo;1116 WORD usDriveUnit;1117 } ParameterBlock;1118 #pragma pack()1119 1195 1120 1196 DWORD parsize = sizeof(ParameterBlock); … … 1354 1430 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1355 1431 { 1356 LPVOID lpRealBuf; 1357 Win32MemMap *map; 1358 DWORD offset, bytesread; 1359 BOOL bRC; 1360 1361 dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)", 1362 lpHMDeviceName, 1363 pHMHandleData, 1364 lpBuffer, 1365 nNumberOfBytesToRead, 1366 lpNumberOfBytesRead, 1367 lpOverlapped)); 1368 1369 //SvL: It's legal for this pointer to be NULL 1370 if(lpNumberOfBytesRead) 1371 *lpNumberOfBytesRead = 0; 1372 else 1373 lpNumberOfBytesRead = &bytesread; 1374 1375 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 1376 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 1377 SetLastError(ERROR_INVALID_PARAMETER); 1378 return FALSE; 1379 } 1380 1381 if(lpCompletionRoutine) { 1382 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1383 } 1384 1385 //If we didn't get an OS/2 handle for the disk before, get one now 1386 if(!pHMHandleData->hHMHandle) { 1387 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1388 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1389 if(!pHMHandleData->hHMHandle) { 1390 dprintf(("No disk inserted; aborting")); 1391 SetLastError(ERROR_NOT_READY); 1392 return FALSE; 1393 } 1394 } 1395 1396 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 1397 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1398 } 1399 1400 //SvL: DosRead doesn't like writing to memory addresses returned by 1401 // DosAliasMem -> search for original memory mapped pointer and use 1402 // that one + commit pages if not already present 1403 map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_WRITE); 1404 if(map) { 1405 lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset); 1406 DWORD nrpages = nNumberOfBytesToRead/4096; 1407 if(offset & 0xfff) 1408 nrpages++; 1409 if(nNumberOfBytesToRead & 0xfff) 1410 nrpages++; 1411 1412 map->commitPage(offset & ~0xfff, TRUE, nrpages); 1413 } 1414 else lpRealBuf = (LPVOID)lpBuffer; 1415 1416 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1417 dprintf(("ERROR: Overlapped IO not yet implememented!!")); 1418 } 1419 // else { 1432 LPVOID lpRealBuf; 1433 Win32MemMap *map; 1434 DWORD offset, bytesread; 1435 BOOL bRC; 1436 1437 dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)", 1438 lpHMDeviceName, pHMHandleData, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped)); 1439 1440 //It's legal for this pointer to be NULL 1441 if(lpNumberOfBytesRead) 1442 *lpNumberOfBytesRead = 0; 1443 else 1444 lpNumberOfBytesRead = &bytesread; 1445 1446 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 1447 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 1448 SetLastError(ERROR_INVALID_PARAMETER); 1449 return FALSE; 1450 } 1451 1452 if(lpCompletionRoutine) { 1453 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1454 } 1455 1456 //If we didn't get an OS/2 handle for the disk before, get one now 1457 if(!pHMHandleData->hHMHandle) { 1458 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1459 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1460 if(!pHMHandleData->hHMHandle) { 1461 dprintf(("No disk inserted; aborting")); 1462 SetLastError(ERROR_NOT_READY); 1463 return FALSE; 1464 } 1465 } 1466 1467 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 1468 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1469 } 1470 1471 //SvL: DosRead doesn't like writing to memory addresses returned by 1472 // DosAliasMem -> search for original memory mapped pointer and use 1473 // that one + commit pages if not already present 1474 map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_WRITE); 1475 if(map) { 1476 lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset); 1477 DWORD nrpages = nNumberOfBytesToRead/4096; 1478 if(offset & 0xfff) 1479 nrpages++; 1480 if(nNumberOfBytesToRead & 0xfff) 1481 nrpages++; 1482 1483 map->commitPage(offset & ~0xfff, TRUE, nrpages); 1484 } 1485 else lpRealBuf = (LPVOID)lpBuffer; 1486 1487 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1488 dprintf(("ERROR: Overlapped IO not yet implememented!!")); 1489 } 1490 // else { 1420 1491 bRC = OSLibDosRead(pHMHandleData->hHMHandle, 1421 1492 (PVOID)lpRealBuf, … … 1424 1495 // } 1425 1496 1426 if(bRC == 0) {1427 dprintf(("KERNEL32: HMDeviceDiskClass::ReadFile returned %08xh %x", bRC, GetLastError()));1428 dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));1429 }1430 else dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile read %x bytes pos %x", *lpNumberOfBytesRead, SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT)));1431 1432 return bRC;1497 if(bRC == 0) { 1498 dprintf(("KERNEL32: HMDeviceDiskClass::ReadFile returned %08xh %x", bRC, GetLastError())); 1499 dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead))); 1500 } 1501 else dprintf2(("KERNEL32: HMDeviceDiskClass::ReadFile read %x bytes pos %x", *lpNumberOfBytesRead, SetFilePointer(pHMHandleData, 0, NULL, FILE_CURRENT))); 1502 1503 return bRC; 1433 1504 } 1434 1505 /***************************************************************************** … … 1446 1517 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1447 1518 *****************************************************************************/ 1448 1449 1519 DWORD HMDeviceDiskClass::SetFilePointer(PHMHANDLEDATA pHMHandleData, 1450 1520 LONG lDistanceToMove, … … 1452 1522 DWORD dwMoveMethod) 1453 1523 { 1454 DWORD ret; 1455 1456 dprintf2(("KERNEL32: HMDeviceDiskClass::SetFilePointer %s(%08xh,%08xh,%08xh,%08xh)\n", 1457 lpHMDeviceName, 1458 pHMHandleData, 1459 lDistanceToMove, 1460 lpDistanceToMoveHigh, 1461 dwMoveMethod)); 1462 1463 if(!pHMHandleData->hHMHandle) { 1464 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1465 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1466 if(!pHMHandleData->hHMHandle) { 1467 dprintf(("No disk inserted; aborting")); 1468 SetLastError(ERROR_NOT_READY); 1469 return -1; 1470 } 1471 } 1472 1473 ret = OSLibDosSetFilePointer(pHMHandleData->hHMHandle, 1474 lDistanceToMove, 1475 (DWORD *)lpDistanceToMoveHigh, 1476 dwMoveMethod); 1477 1478 if(ret == -1) { 1479 dprintf(("SetFilePointer failed (error = %d)", GetLastError())); 1480 } 1481 return ret; 1524 DWORD ret; 1525 1526 if(lpDistanceToMoveHigh) { 1527 dprintf(("KERNEL32: HMDeviceDiskClass::SetFilePointer %s %08x%08x %d", 1528 lpHMDeviceName, *lpDistanceToMoveHigh, lDistanceToMove, dwMoveMethod)); 1529 } 1530 1531 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1532 if(drvInfo == NULL) { 1533 dprintf(("ERROR: SetFilePointer: drvInfo == NULL!!!")); 1534 DebugInt3(); 1535 SetLastError(ERROR_INVALID_HANDLE); 1536 return FALSE; 1537 } 1538 1539 if(!pHMHandleData->hHMHandle) { 1540 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1541 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1542 if(!pHMHandleData->hHMHandle) { 1543 dprintf(("No disk inserted; aborting")); 1544 SetLastError(ERROR_NOT_READY); 1545 return -1; 1546 } 1547 } 1548 1549 //if unmounted volume, add starting offset to position as we're accessing the entire physical drive 1550 //instead of just the volume 1551 if(drvInfo->fPhysicalDisk && (drvInfo->StartingOffset.HighPart != 0 || 1552 drvInfo->StartingOffset.LowPart != 0)) 1553 { 1554 LARGE_INTEGER distance, result, endpos; 1555 LARGE_INTEGER position; 1556 1557 if(lpDistanceToMoveHigh) { 1558 distance.HighPart = *lpDistanceToMoveHigh; 1559 } 1560 else { 1561 if(lDistanceToMove < 0) { 1562 distance.HighPart = -1; 1563 } 1564 else distance.HighPart = 0; 1565 } 1566 distance.LowPart = lDistanceToMove; 1567 1568 //calculate end position in partition 1569 Add64(&drvInfo->StartingOffset, &drvInfo->PartitionSize, &endpos); 1570 result.HighPart = 0; 1571 result.LowPart = 1; 1572 Sub64(&endpos, &result, &endpos); 1573 1574 switch(dwMoveMethod) { 1575 case FILE_BEGIN: 1576 Add64(&distance, &drvInfo->StartingOffset, &result); 1577 break; 1578 case FILE_CURRENT: 1579 Add64(&distance, &drvInfo->CurrentFilePointer, &result); 1580 break; 1581 case FILE_END: 1582 Add64(&distance, &endpos, &result); 1583 break; 1584 } 1585 //check upper boundary 1586 if(result.HighPart > endpos.HighPart || 1587 (result.HighPart == endpos.HighPart && result.LowPart > endpos.LowPart) ) 1588 { 1589 SetLastError(ERROR_INVALID_PARAMETER); 1590 return -1; 1591 } 1592 //check lower boundary 1593 if(result.HighPart < drvInfo->StartingOffset.HighPart || 1594 (result.HighPart == drvInfo->StartingOffset.HighPart && result.LowPart < drvInfo->StartingOffset.LowPart)) 1595 { 1596 SetLastError(ERROR_NEGATIVE_SEEK); 1597 return -1; 1598 } 1599 1600 dprintf(("SetFilePointer (unmounted partition) %08x%08x -> %08x%08x", distance.HighPart, distance.LowPart, result.HighPart, result.LowPart)); 1601 ret = OSLibDosSetFilePointer(pHMHandleData->hHMHandle, 1602 result.LowPart, 1603 (DWORD *)&result.HighPart, 1604 FILE_BEGIN); 1605 1606 Sub64(&result, &drvInfo->StartingOffset, &drvInfo->CurrentFilePointer); 1607 ret = drvInfo->CurrentFilePointer.LowPart; 1608 if(lpDistanceToMoveHigh) { 1609 *lpDistanceToMoveHigh = drvInfo->CurrentFilePointer.HighPart; 1610 } 1611 } 1612 else { 1613 ret = OSLibDosSetFilePointer(pHMHandleData->hHMHandle, 1614 lDistanceToMove, 1615 (DWORD *)lpDistanceToMoveHigh, 1616 dwMoveMethod); 1617 } 1618 1619 if(ret == -1) { 1620 dprintf(("SetFilePointer failed (error = %d)", GetLastError())); 1621 } 1622 return ret; 1482 1623 } 1483 1624 … … 1499 1640 1500 1641 BOOL HMDeviceDiskClass::WriteFile(PHMHANDLEDATA pHMHandleData, 1501 1502 1503 1504 1505 1642 LPCVOID lpBuffer, 1643 DWORD nNumberOfBytesToWrite, 1644 LPDWORD lpNumberOfBytesWritten, 1645 LPOVERLAPPED lpOverlapped, 1646 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 1506 1647 { 1507 LPVOID lpRealBuf; 1508 Win32MemMap *map; 1509 DWORD offset, byteswritten; 1510 BOOL bRC; 1511 1512 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 1513 lpHMDeviceName, 1514 pHMHandleData, 1515 lpBuffer, 1516 nNumberOfBytesToWrite, 1517 lpNumberOfBytesWritten, 1518 lpOverlapped)); 1519 1520 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1521 if(drvInfo == NULL) { 1522 dprintf(("ERROR: DeviceIoControl: drvInfo == NULL!!!")); 1523 DebugInt3(); 1524 SetLastError(ERROR_INVALID_HANDLE); 1525 return FALSE; 1526 } 1527 1528 //SvL: It's legal for this pointer to be NULL 1529 if(lpNumberOfBytesWritten) 1530 *lpNumberOfBytesWritten = 0; 1531 else 1532 lpNumberOfBytesWritten = &byteswritten; 1533 1534 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 1535 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 1536 SetLastError(ERROR_INVALID_PARAMETER); 1537 return FALSE; 1538 } 1539 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 1540 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1541 } 1542 if(lpCompletionRoutine) { 1543 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1544 } 1545 1546 //If we didn't get an OS/2 handle for the disk before, get one now 1547 if(!pHMHandleData->hHMHandle) { 1548 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1549 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1550 if(!pHMHandleData->hHMHandle) { 1551 dprintf(("No disk inserted; aborting")); 1552 SetLastError(ERROR_NOT_READY); 1553 return FALSE; 1554 } 1555 } 1556 //NOTE: For now only allow an application to write to drive A 1557 // Might want to extend this to all removable media, but it's 1558 // too dangerous to allow win32 apps to write to the harddisk directly 1559 if(drvInfo->driveLetter != 'A') { 1560 SetLastError(ERROR_ACCESS_DENIED); 1561 return FALSE; 1562 } 1563 1564 1565 //SvL: DosWrite doesn't like reading from memory addresses returned by 1566 // DosAliasMem -> search for original memory mapped pointer and use 1567 // that one + commit pages if not already present 1568 map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ); 1569 if(map) { 1570 lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset); 1571 DWORD nrpages = nNumberOfBytesToWrite/4096; 1572 if(offset & 0xfff) 1573 nrpages++; 1574 if(nNumberOfBytesToWrite & 0xfff) 1575 nrpages++; 1576 1577 map->commitPage(offset & ~0xfff, TRUE, nrpages); 1578 } 1579 else lpRealBuf = (LPVOID)lpBuffer; 1580 1581 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0); 1582 1583 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1584 dprintf(("ERROR: Overlapped IO not yet implememented!!")); 1585 } 1648 LPVOID lpRealBuf; 1649 Win32MemMap *map; 1650 DWORD offset, byteswritten; 1651 BOOL bRC; 1652 1653 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n", 1654 lpHMDeviceName, pHMHandleData, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, 1655 lpOverlapped)); 1656 1657 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1658 if(drvInfo == NULL) { 1659 dprintf(("ERROR: WriteFile: drvInfo == NULL!!!")); 1660 DebugInt3(); 1661 SetLastError(ERROR_INVALID_HANDLE); 1662 return FALSE; 1663 } 1664 if(!(drvInfo->dwAccess & GENERIC_WRITE)) { 1665 dprintf(("ERROR: WriteFile: write access denied!")); 1666 SetLastError(ERROR_ACCESS_DENIED); 1667 return FALSE; 1668 } 1669 //It's legal for this pointer to be NULL 1670 if(lpNumberOfBytesWritten) 1671 *lpNumberOfBytesWritten = 0; 1672 else 1673 lpNumberOfBytesWritten = &byteswritten; 1674 1675 if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) { 1676 dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!")); 1677 SetLastError(ERROR_INVALID_PARAMETER); 1678 return FALSE; 1679 } 1680 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 1681 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1682 } 1683 if(lpCompletionRoutine) { 1684 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1685 } 1686 1687 //If we didn't get an OS/2 handle for the disk before, get one now 1688 if(!pHMHandleData->hHMHandle) { 1689 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1690 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1691 if(!pHMHandleData->hHMHandle) { 1692 dprintf(("No disk inserted; aborting")); 1693 SetLastError(ERROR_NOT_READY); 1694 return FALSE; 1695 } 1696 } 1697 1698 //SvL: DosWrite doesn't like reading from memory addresses returned by 1699 // DosAliasMem -> search for original memory mapped pointer and use 1700 // that one + commit pages if not already present 1701 map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ); 1702 if(map) { 1703 lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset); 1704 DWORD nrpages = nNumberOfBytesToWrite/4096; 1705 if(offset & 0xfff) 1706 nrpages++; 1707 if(nNumberOfBytesToWrite & 0xfff) 1708 nrpages++; 1709 1710 map->commitPage(offset & ~0xfff, TRUE, nrpages); 1711 } 1712 else lpRealBuf = (LPVOID)lpBuffer; 1713 1714 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_LOCKDRIVE,0,0,0,0,0,0); 1715 1716 if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) { 1717 dprintf(("ERROR: Overlapped IO not yet implememented!!")); 1718 } 1586 1719 // else { 1587 1720 bRC = OSLibDosWrite(pHMHandleData->hHMHandle, … … 1591 1724 // } 1592 1725 1593 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_UNLOCKDRIVE,0,0,0,0,0,0);1594 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile returned %08xh\n",1595 bRC));1596 1597 return bRC;1726 OSLibDosDevIOCtl(pHMHandleData->hHMHandle,IOCTL_DISK,DSK_UNLOCKDRIVE,0,0,0,0,0,0); 1727 dprintf2(("KERNEL32: HMDeviceDiskClass::WriteFile returned %08xh\n", 1728 bRC)); 1729 1730 return bRC; 1598 1731 } 1599 1732 1733 /***************************************************************************** 1734 * Name : DWORD HMDeviceDiskClass::GetFileSize 1735 * Purpose : set file time 1736 * Parameters: PHMHANDLEDATA pHMHandleData 1737 * PDWORD pSize 1738 * Variables : 1739 * Result : API returncode 1740 * Remark : 1741 * Status : 1742 * 1743 * Author : Patrick Haller [Wed, 1999/06/17 20:44] 1744 *****************************************************************************/ 1745 1746 DWORD HMDeviceDiskClass::GetFileSize(PHMHANDLEDATA pHMHandleData, 1747 PDWORD lpdwFileSizeHigh) 1748 { 1749 DRIVE_INFO *drvInfo = (DRIVE_INFO*)pHMHandleData->dwUserData; 1750 if(drvInfo == NULL) { 1751 dprintf(("ERROR: GetFileSize: drvInfo == NULL!!!")); 1752 DebugInt3(); 1753 SetLastError(ERROR_INVALID_HANDLE); 1754 return -1; //INVALID_SET_FILE_POINTER 1755 } 1756 1757 dprintf2(("KERNEL32: HMDeviceDiskClass::GetFileSize %s(%08xh,%08xh)\n", 1758 lpHMDeviceName, pHMHandleData, lpdwFileSizeHigh)); 1759 1760 //If we didn't get an OS/2 handle for the disk before, get one now 1761 if(!pHMHandleData->hHMHandle) { 1762 pHMHandleData->hHMHandle = OpenDisk(drvInfo); 1763 if(!pHMHandleData->hHMHandle) { 1764 dprintf(("No disk inserted; aborting")); 1765 SetLastError(ERROR_NOT_READY); 1766 return -1; //INVALID_SET_FILE_POINTER 1767 } 1768 } 1769 1770 if(drvInfo->PartitionSize.HighPart || drvInfo->PartitionSize.LowPart) { 1771 if(lpdwFileSizeHigh) 1772 *lpdwFileSizeHigh = drvInfo->PartitionSize.HighPart; 1773 1774 return drvInfo->PartitionSize.LowPart; 1775 } 1776 else { 1777 LARGE_INTEGER position, size; 1778 1779 //get current position 1780 position.HighPart = 0; 1781 position.LowPart = SetFilePointer(pHMHandleData, 0, (PLONG)&position.HighPart, FILE_CURRENT); 1782 SetFilePointer(pHMHandleData, 0, NULL, FILE_BEGIN); 1783 size.HighPart = 0; 1784 size.LowPart = SetFilePointer(pHMHandleData, 0, (PLONG)&size.HighPart, FILE_END); 1785 1786 //restore old position 1787 SetFilePointer(pHMHandleData, position.LowPart, (PLONG)&position.HighPart, FILE_BEGIN); 1788 1789 if(lpdwFileSizeHigh) 1790 *lpdwFileSizeHigh = size.HighPart; 1791 1792 return size.LowPart; 1793 } 1794 } 1600 1795 1601 1796 /***************************************************************************** … … 1613 1808 DWORD HMDeviceDiskClass::GetFileType(PHMHANDLEDATA pHMHandleData) 1614 1809 { 1615 dprintf2(("KERNEL32: HMDeviceDiskClass::GetFileType %s(%08x)\n", 1616 lpHMDeviceName, 1617 pHMHandleData)); 1618 1619 return FILE_TYPE_DISK; 1810 dprintf2(("KERNEL32: HMDeviceDiskClass::GetFileType %s(%08x)\n", 1811 lpHMDeviceName, pHMHandleData)); 1812 1813 return FILE_TYPE_DISK; 1620 1814 } 1621 1815 //****************************************************************************** -
trunk/src/kernel32/hmdisk.h
r8397 r8401 1 /* $Id: hmdisk.h,v 1. 9 2002-05-09 13:55:33sandervl Exp $ */1 /* $Id: hmdisk.h,v 1.10 2002-05-10 14:55:12 sandervl Exp $ */ 2 2 3 3 #ifndef __HMDISK_H__ … … 11 11 #include "HMDevice.h" 12 12 #include "HMObjects.h" 13 14 #define VOLUME_NAME_PREFIX "\\\\?\\Volume\\"15 13 16 14 /***************************************************************************** … … 62 60 LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); 63 61 62 /* this is a handler method for calls to GetFileSize() */ 63 virtual DWORD GetFileSize(PHMHANDLEDATA pHMHandleData, 64 PDWORD pSizeHigh); 65 64 66 /* this is a handler method for calls to GetFileType() */ 65 67 virtual DWORD GetFileType (PHMHANDLEDATA pHMHandleData); -
trunk/src/kernel32/hmthread.cpp
r8015 r8401 1 /* $Id: hmthread.cpp,v 1.1 0 2002-02-26 11:11:17sandervl Exp $ */1 /* $Id: hmthread.cpp,v 1.11 2002-05-10 14:55:12 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 #include <win\thread.h> 30 30 #include "thread.h" 31 #include " exceptutil.h"31 #include "asmutil.h" 32 32 33 33 #define DBG_LOCALLOG DBG_hmthread -
trunk/src/kernel32/kernel32.mak
r8397 r8401 1 # $Id: kernel32.mak,v 1. 29 2002-05-09 13:55:33sandervl Exp $1 # $Id: kernel32.mak,v 1.30 2002-05-10 14:55:12 sandervl Exp $ 2 2 3 3 # … … 64 64 $(OBJDIR)\misc.obj \ 65 65 $(OBJDIR)\exceptutil.obj \ 66 $(OBJDIR)\asmutil.obj \ 66 67 $(OBJDIR)\lang.obj \ 67 68 $(OBJDIR)\iccio.obj \ -
trunk/src/kernel32/oslibdos.cpp
r8397 r8401 1 /* $Id: oslibdos.cpp,v 1.10 1 2002-05-09 13:55:34sandervl Exp $ */1 /* $Id: oslibdos.cpp,v 1.102 2002-05-10 14:55:12 sandervl Exp $ */ 2 2 /* 3 3 * Wrappers for OS/2 Dos* API … … 244 244 case ERROR_CRC: //23 245 245 return ERROR_CRC_W; 246 247 case ERROR_SEEK: 248 return ERROR_SEEK_W; 246 249 247 250 case ERROR_NOT_DOS_DISK: //26 … … 1123 1126 1124 1127 if(strlen(lpszFile) == 2 && lpszFile[1] == ':') { 1125 //app tries to open physical disk1128 //app tries to open logical volume/partition 1126 1129 openMode |= OPEN_FLAGS_DASD; 1127 1130 } -
trunk/src/kernel32/osliblvm.cpp
r8397 r8401 1 /* $Id: osliblvm.cpp,v 1. 1 2002-05-09 13:55:34sandervl Exp $ */1 /* $Id: osliblvm.cpp,v 1.2 2002-05-10 14:55:13 sandervl Exp $ */ 2 2 3 3 /* … … 329 329 //****************************************************************************** 330 330 //****************************************************************************** 331 static Volume_Information_Record OSLibLVMFindVolume FromDriveLetter(ULONG driveLetter,332 333 331 static Volume_Information_Record OSLibLVMFindVolumeByDriveLetter(ULONG driveLetter, 332 Volume_Control_Record *pVolRec, 333 CARDINAL32 *lasterror) 334 334 { 335 335 Volume_Control_Array *volctrl; … … 367 367 //****************************************************************************** 368 368 //****************************************************************************** 369 static Volume_Information_Record OSLibLVMFindVolume FromName(LPSTR pszVolName,370 371 369 static Volume_Information_Record OSLibLVMFindVolumeByName(LPSTR pszVolName, 370 Volume_Control_Record *pVolRec, 371 CARDINAL32 *lasterror) 372 372 { 373 373 Volume_Control_Array *volctrl; … … 405 405 //****************************************************************************** 406 406 //****************************************************************************** 407 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, PPARTITION_INFORMATION pPartition)407 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, LPSTR lpszVolumeName, PPARTITION_INFORMATION pPartition) 408 408 { 409 409 Volume_Information_Record volinfo; … … 412 412 CARDINAL32 lasterror; 413 413 414 volinfo = OSLibLVMFindVolumeFromDriveLetter(driveLetter, &volctrl, &lasterror); 415 if(lasterror != LVM_ENGINE_NO_ERROR) { 416 DebugInt3(); 417 return FALSE; 418 } 419 420 //We will not return information about LVM volumes (too dangerous as 421 //they contain extra information in the volume and can be spanned) 422 if(volinfo.Compatibility_Volume == FALSE) { 414 if(lpszVolumeName && lpszVolumeName[0]) { 415 volinfo = OSLibLVMFindVolumeByName(lpszVolumeName, &volctrl, &lasterror); 416 } 417 else volinfo = OSLibLVMFindVolumeByDriveLetter(driveLetter, &volctrl, &lasterror); 418 if(lasterror != LVM_ENGINE_NO_ERROR) { 419 DebugInt3(); 423 420 return FALSE; 424 421 } 425 422 426 423 partctrl = Get_Partitions(volctrl.Volume_Handle, &lasterror); 427 if(lasterror != LVM_ENGINE_NO_ERROR ) {424 if(lasterror != LVM_ENGINE_NO_ERROR || partctrl.Count == 0) { 428 425 return FALSE; 429 426 } … … 445 442 //****************************************************************************** 446 443 //****************************************************************************** 447 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, PVOLUME_DISK_EXTENTS pVolExtent) 444 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, LPSTR lpszVolumeName, PVOLUME_DISK_EXTENTS pVolExtent, 445 BOOL *pfLVMVolume) 448 446 { 449 447 Volume_Information_Record volinfo; 450 448 Volume_Control_Record volctrl; 449 Drive_Control_Array diskinfo; 451 450 Partition_Information_Array partctrl; 452 451 CARDINAL32 lasterror; 453 454 volinfo = OSLibLVMFindVolumeFromDriveLetter(driveLetter, &volctrl, &lasterror); 455 if(lasterror != LVM_ENGINE_NO_ERROR) { 456 DebugInt3(); 457 return FALSE; 458 } 459 //We will not return information about LVM volumes (too dangerous as 460 //they contain extra information in the volume and can be spanned) 461 if(volinfo.Compatibility_Volume == FALSE) { 452 BOOL ret = TRUE; 453 454 if(lpszVolumeName && lpszVolumeName[0]) { 455 volinfo = OSLibLVMFindVolumeByName(lpszVolumeName, &volctrl, &lasterror); 456 } 457 else volinfo = OSLibLVMFindVolumeByDriveLetter(driveLetter, &volctrl, &lasterror); 458 if(lasterror != LVM_ENGINE_NO_ERROR) { 459 DebugInt3(); 462 460 return FALSE; 463 461 } 464 462 465 463 partctrl = Get_Partitions(volctrl.Volume_Handle, &lasterror); 466 if(lasterror != LVM_ENGINE_NO_ERROR ) {464 if(lasterror != LVM_ENGINE_NO_ERROR || partctrl.Count == 0) { 467 465 return FALSE; 468 466 } … … 475 473 pVolExtent->Extents[0].ExtentLength.u.LowPart = partctrl.Partition_Array[0].Usable_Partition_Size << 9; 476 474 475 dprintf(("pVolExtent->NumberOfDiskExtents %d", pVolExtent->NumberOfDiskExtents)); 476 dprintf(("pVolExtent->Extents[0].DiskNumber %d", pVolExtent->Extents[0].DiskNumber)); 477 dprintf(("pVolExtent->Extents[0].StartingOffset %08x%08x", pVolExtent->Extents[0].StartingOffset.u.HighPart, pVolExtent->Extents[0].StartingOffset.u.LowPart)); 478 dprintf(("pVolExtent->Extents[0].ExtentLength %08x%08x", pVolExtent->Extents[0].ExtentLength.u.HighPart, pVolExtent->Extents[0].ExtentLength.u.LowPart)); 479 480 //find number of disk on which this volume is located 481 diskinfo = Get_Drive_Control_Data(&lasterror); 482 if(lasterror != LVM_ENGINE_NO_ERROR) { 483 return FALSE; 484 } 485 for(int i=0;i<diskinfo.Count;i++) { 486 if(diskinfo.Drive_Control_Data[i].Drive_Handle == partctrl.Partition_Array[0].Drive_Handle) { 487 pVolExtent->Extents[0].DiskNumber = diskinfo.Drive_Control_Data[i].Drive_Number; 488 break; 489 } 490 } 491 if(i == diskinfo.Count) { 492 ret = FALSE; 493 } 494 if(pfLVMVolume) { 495 *pfLVMVolume = (volinfo.Compatibility_Volume == FALSE); 496 } 497 Free_Engine_Memory((ULONG)diskinfo.Drive_Control_Data); 477 498 Free_Engine_Memory((ULONG)partctrl.Partition_Array); 478 return TRUE;499 return ret; 479 500 } 480 501 //****************************************************************************** … … 487 508 CARDINAL32 lasterror; 488 509 489 volinfo = OSLibLVMFindVolume FromName((char *)lpszVolume, &volctrl, &lasterror);510 volinfo = OSLibLVMFindVolumeByName((char *)lpszVolume, &volctrl, &lasterror); 490 511 if(lasterror != LVM_ENGINE_NO_ERROR) { 491 512 DebugInt3(); … … 512 533 } 513 534 //****************************************************************************** 535 // OSLibLVMQueryDriveFromVolumeName 536 // 537 // Returns: 538 // - drive letter corresponding to volume name 539 // - -1 if volume wasn't found 540 // - 0 if volume is present, but not mounted 541 // 514 542 //****************************************************************************** 515 543 CHAR OSLibLVMQueryDriveFromVolumeName(LPCSTR lpszVolume) … … 519 547 CARDINAL32 lasterror; 520 548 521 volinfo = OSLibLVMFindVolume FromName((char *)lpszVolume, NULL, &lasterror);522 if(lasterror != LVM_ENGINE_NO_ERROR) { 523 DebugInt3(); 524 return 0;549 volinfo = OSLibLVMFindVolumeByName((char *)lpszVolume, NULL, &lasterror); 550 if(lasterror != LVM_ENGINE_NO_ERROR) { 551 DebugInt3(); 552 return -1; //not found 525 553 } 526 554 return volinfo.Current_Drive_Letter; … … 533 561 CARDINAL32 lasterror; 534 562 535 volinfo = OSLibLVMFindVolume FromName(lpszVolume, NULL, &lasterror);563 volinfo = OSLibLVMFindVolumeByName(lpszVolume, NULL, &lasterror); 536 564 if(lasterror != LVM_ENGINE_NO_ERROR) { 537 565 DebugInt3(); … … 551 579 int i; 552 580 553 volinfo = OSLibLVMFindVolume FromName(lpszVolume, &volctrl, &lasterror);581 volinfo = OSLibLVMFindVolumeByName(lpszVolume, &volctrl, &lasterror); 554 582 if(lasterror != LVM_ENGINE_NO_ERROR) { 555 583 DebugInt3(); … … 576 604 //We only support drive letters as mountpoint names 577 605 if('A' <= *lpszVolumeMountPoint && *lpszVolumeMountPoint <= 'Z') { 578 drive = *lpszVolumeMountPoint - 'A' + 1;606 drive = *lpszVolumeMountPoint - 'A'; 579 607 } 580 608 else 581 609 if('a' <= *lpszVolumeMountPoint && *lpszVolumeMountPoint <= 'z') { 582 drive = *lpszVolumeMountPoint - 'a' + 1;610 drive = *lpszVolumeMountPoint - 'a'; 583 611 } 584 612 else { … … 592 620 CARDINAL32 lasterror; 593 621 594 volinfo = OSLibLVMFindVolume FromDriveLetter(drive, NULL, &lasterror);622 volinfo = OSLibLVMFindVolumeByDriveLetter(drive, NULL, &lasterror); 595 623 if(lasterror != LVM_ENGINE_NO_ERROR) { 596 624 DebugInt3(); … … 603 631 //****************************************************************************** 604 632 //****************************************************************************** 605 633 BOOL OSLibLVMStripVolumeName(LPCSTR lpszWin32VolumeName, LPSTR lpszOS2VolumeName, DWORD cchBufferLength) 634 { 635 int length; 636 637 //strip volume name prefix (\\\\?\\Volume\\) 638 length = strlen(lpszWin32VolumeName); 639 640 strncpy(lpszOS2VolumeName, &lpszWin32VolumeName[sizeof(VOLUME_NAME_PREFIX)-1+1], cchBufferLength-1); //-zero term + starting '{' 641 length -= sizeof(VOLUME_NAME_PREFIX)-1+1; 642 if(lpszOS2VolumeName[length-2] == '}') 643 { 644 lpszOS2VolumeName[length-2] = 0; 645 return TRUE; 646 } 647 else 648 if(lpszOS2VolumeName[length-1] == '}') 649 { 650 lpszOS2VolumeName[length-1] = 0; 651 return TRUE; 652 } 653 return FALSE; 654 } 655 //****************************************************************************** 656 //****************************************************************************** 657 -
trunk/src/kernel32/osliblvm.h
r8397 r8401 1 /* $Id: osliblvm.h,v 1. 1 2002-05-09 13:55:35sandervl Exp $ */1 /* $Id: osliblvm.h,v 1.2 2002-05-10 14:55:13 sandervl Exp $ */ 2 2 /* 3 3 * OS/2 LVM (Logical Volume Management) functions … … 321 321 #endif 322 322 323 #define VOLUME_NAME_PREFIX "\\\\?\\Volume\\" 323 324 324 325 BOOL OSLibLVMInit(); … … 329 330 LPSTR lpszVolumeName, DWORD cchBufferLength); 330 331 331 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, PPARTITION_INFORMATION pPartition); 332 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, PVOLUME_DISK_EXTENTS pVolExtent); 332 BOOL OSLibLVMGetPartitionInfo(ULONG driveLetter, LPSTR lpszVolumeName, PPARTITION_INFORMATION pPartition); 333 BOOL OSLibLVMGetVolumeExtents(ULONG driveLetter, LPSTR lpszVolumeName, PVOLUME_DISK_EXTENTS pVolExtent, BOOL *pfLVMVolume = NULL); 334 333 335 ULONG OSLibLVMGetDriveType(LPCSTR lpszVolume); 334 336 CHAR OSLibLVMQueryDriveFromVolumeName(LPCSTR lpszVolume); … … 340 342 DWORD OSLibLVMQueryVolumeSerialAndName(LPSTR lpszVolume, LPDWORD lpVolumeSerialNumber, LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize); 341 343 344 BOOL OSLibLVMStripVolumeName(LPCSTR lpszWin32VolumeName, LPSTR lpszOS2VolumeName, DWORD cchBufferLength); 345 342 346 #endif //__OSLIBLVM_H__ -
trunk/src/kernel32/wprocess.cpp
r8327 r8401 1 /* $Id: wprocess.cpp,v 1.15 0 2002-04-29 17:05:30sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.151 2002-05-10 14:55:13 sandervl Exp $ */ 2 2 3 3 /* … … 34 34 #include "odin32validate.h" 35 35 #include "exceptutil.h" 36 #include "asmutil.h" 36 37 #include "oslibdos.h" 37 38 #include "oslibmisc.h"
Note:
See TracChangeset
for help on using the changeset viewer.