[Frhed-commits] SF.net SVN: frhed:[22] trunk/FRHED
Brought to you by:
kimmov
From: <ki...@us...> - 2008-08-18 19:20:40
|
Revision: 22 http://frhed.svn.sourceforge.net/frhed/?rev=22&view=rev Author: kimmov Date: 2008-08-18 19:20:44 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Simplify Windows platform type (W9X or NT) check. Remove header file that was copied from Platform SDK. We can't distribute such files. This means we now require PSDK for compiling. This is part of Jochen's refactorings for WinMerge. Modified Paths: -------------- trunk/FRHED/FRHED.dsp trunk/FRHED/PhysicalDrive.cpp trunk/FRHED/PhysicalDrive.h trunk/FRHED/precomp.h Removed Paths: ------------- trunk/FRHED/ntdiskspec.h Property Changed: ---------------- trunk/FRHED/PhysicalDrive.cpp trunk/FRHED/PhysicalDrive.h trunk/FRHED/precomp.h Modified: trunk/FRHED/FRHED.dsp =================================================================== --- trunk/FRHED/FRHED.dsp 2008-08-18 17:16:39 UTC (rev 21) +++ trunk/FRHED/FRHED.dsp 2008-08-18 19:20:44 UTC (rev 22) @@ -215,10 +215,6 @@ # End Source File # Begin Source File -SOURCE=.\ntdiskspec.h -# End Source File -# Begin Source File - SOURCE=.\PDrive95.h # End Source File # Begin Source File Modified: trunk/FRHED/PhysicalDrive.cpp =================================================================== --- trunk/FRHED/PhysicalDrive.cpp 2008-08-18 17:16:39 UTC (rev 21) +++ trunk/FRHED/PhysicalDrive.cpp 2008-08-18 19:20:44 UTC (rev 22) @@ -1,3 +1,27 @@ +// License (GPLv2+): +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +///////////////////////////////////////////////////////////////////////////// +/** + * @file PhysicalDrive.cpp + * + * @brief Drive/partition information class implementations. + * + */ +// ID line follows -- this is updated by SVN +// $Id$ + #include "precomp.h" #include "physicaldrive.h" #include <assert.h> @@ -4,64 +28,21 @@ #include "pdrive95.h" #include "pdrivent.h" -WINDOWS_VERSION RefreshWindowsVersion() +IPhysicalDrive *CreatePhysicalDriveInstance() { - OSVERSIONINFOEX osvi; - BOOL bOsVersionInfoEx; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - if( !(bOsVersionInfoEx = GetVersionEx( (OSVERSIONINFO*) &osvi)) ) - { - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - if( !GetVersionEx( (OSVERSIONINFO*) &osvi) ) - return IS_WINDOWS_UNKNOWN; - } + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof osvi); + osvi.dwOSVersionInfoSize = sizeof osvi; + if (!GetVersionEx(&osvi)) + osvi.dwPlatformId = 0; switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: - if( osvi.dwMajorVersion <= 4 ) - return IS_WINDOWS_NT; - - if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) - return IS_WINDOWS_2000; - - if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) - return IS_WINDOWS_XP; - - return IS_WINDOWS_NT; - - case VER_PLATFORM_WIN32_WINDOWS: - if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) - return IS_WINDOWS_95; - - if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) - { - if( osvi.szCSDVersion[1] == 'A' ) - return IS_WINDOWS_98SE; - return IS_WINDOWS_98; - } - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) - return IS_WINDOWS_ME; - - return IS_WINDOWS_95; - } - return IS_WINDOWS_UNKNOWN; -} - -static WINDOWS_VERSION wv; - -IPhysicalDrive* CreatePhysicalDriveInstance() -{ - wv = RefreshWindowsVersion(); - if( (wv == IS_WINDOWS_NT) || (wv == IS_WINDOWS_2000) || (wv == IS_WINDOWS_XP) ) - { return new PNtPhysicalDrive; - } - else - { + case VER_PLATFORM_WIN32_WINDOWS: return new P9xPhysicalDrive; } + return 0; } PString PartitionInfo::GetNameAsString() Property changes on: trunk/FRHED/PhysicalDrive.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Modified: trunk/FRHED/PhysicalDrive.h =================================================================== --- trunk/FRHED/PhysicalDrive.h 2008-08-18 17:16:39 UTC (rev 21) +++ trunk/FRHED/PhysicalDrive.h 2008-08-18 19:20:44 UTC (rev 22) @@ -1,54 +1,65 @@ +///////////////////////////////////////////////////////////////////////////// +// License (GPLv2+): +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +///////////////////////////////////////////////////////////////////////////// +/** + * @file PhysicalDrive.h + * + * @brief Drive/partition information class declarations. + * + */ +// ID line follows -- this is updated by SVN +// $Id$ + #ifndef PNtPhysicalDrive_h #define PNtPhysicalDrive_h -#include "ntdiskspec.h" +#include <WinIoCtl.h> -typedef enum -{ - IS_WINDOWS_NT, - IS_WINDOWS_2000, - IS_WINDOWS_XP, - IS_WINDOWS_95, - IS_WINDOWS_98, - IS_WINDOWS_98SE, - IS_WINDOWS_ME, - IS_WINDOWS_UNKNOWN, -} WINDOWS_VERSION; - -WINDOWS_VERSION RefreshWindowsVersion(); - class PartitionInfo : public PNode { - public: - DWORD m_dwDrive; - DWORD m_dwPartition; - BOOL m_bIsPartition; - DWORD m_dwBytesPerSector; - INT64 m_NumberOfSectors; - INT64 m_StartingOffset; - INT64 m_StartingSector; - INT64 m_PartitionLength; +public: + DWORD m_dwDrive; + DWORD m_dwPartition; + BOOL m_bIsPartition; + DWORD m_dwBytesPerSector; + INT64 m_NumberOfSectors; + INT64 m_StartingOffset; + INT64 m_StartingSector; + INT64 m_PartitionLength; - PString GetNameAsString(); - PString GetSizeAsString(); + PString GetNameAsString(); + PString GetSizeAsString(); }; //This is an abstract class for a physical drive layout class IPhysicalDrive { - public: - virtual BOOL Open( int iDrive ) = 0; - virtual void Close() = 0; - virtual BOOL GetDriveGeometry( DISK_GEOMETRY* lpDG ) = 0; - virtual BOOL GetDriveGeometryEx( DISK_GEOMETRY_EX* lpDG, DWORD dwSize ) = 0; - virtual BOOL GetDriveLayout( LPBYTE lpbMemory, DWORD dwSize ) = 0; - virtual BOOL GetDriveLayoutEx( LPBYTE lpbMemory, DWORD dwSize ) = 0; - virtual BOOL ReadAbsolute( LPBYTE lpbMemory, DWORD dwSize, INT64 Sector ) = 0; - virtual BOOL IsOpen() = 0; +public: + virtual BOOL Open( int iDrive ) = 0; + virtual void Close() = 0; + virtual BOOL GetDriveGeometry( DISK_GEOMETRY* lpDG ) = 0; + virtual BOOL GetDriveGeometryEx( DISK_GEOMETRY_EX* lpDG, DWORD dwSize ) = 0; + virtual BOOL GetDriveLayout( LPBYTE lpbMemory, DWORD dwSize ) = 0; + virtual BOOL GetDriveLayoutEx( LPBYTE lpbMemory, DWORD dwSize ) = 0; + virtual BOOL ReadAbsolute( LPBYTE lpbMemory, DWORD dwSize, INT64 Sector ) = 0; + virtual BOOL IsOpen() = 0; - //Creates a list of PartitionInfo elements - virtual void GetPartitionInfo(PList* lpList); + //Creates a list of PartitionInfo elements + virtual void GetPartitionInfo(PList* lpList); }; IPhysicalDrive* CreatePhysicalDriveInstance(); Property changes on: trunk/FRHED/PhysicalDrive.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Deleted: trunk/FRHED/ntdiskspec.h =================================================================== --- trunk/FRHED/ntdiskspec.h 2008-08-18 17:16:39 UTC (rev 21) +++ trunk/FRHED/ntdiskspec.h 2008-08-18 19:20:44 UTC (rev 22) @@ -1,169 +0,0 @@ -#ifndef ntdiskspec_h -#define ntdiskspec_h - -/* -code bits taken from WINTIOCTL.H (the cygwin version doesn't have dis) -This header is *NOT* copyrighted by me, but contains code copyrighted by Microsoft. -Download the latest version (of WINIOCTL.H) for free from -http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ -*/ - -#ifndef IsContainerPartition - -typedef struct _PARTITION_INFORMATION { - LARGE_INTEGER StartingOffset; - LARGE_INTEGER PartitionLength; - DWORD HiddenSectors; - DWORD PartitionNumber; - BYTE PartitionType; - BOOLEAN BootIndicator; - BOOLEAN RecognizedPartition; - BOOLEAN RewritePartition; -} PARTITION_INFORMATION, *PPARTITION_INFORMATION; - -typedef struct _DRIVE_LAYOUT_INFORMATION { - DWORD PartitionCount; - DWORD Signature; - PARTITION_INFORMATION PartitionEntry[1]; -} DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION; - -typedef enum _MEDIA_TYPE { - Unknown, // Format is unknown - F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector - F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector - F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector - F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector - F3_720_512, // 3.5", 720KB, 512 bytes/sector - F5_360_512, // 5.25", 360KB, 512 bytes/sector - F5_320_512, // 5.25", 320KB, 512 bytes/sector - F5_320_1024, // 5.25", 320KB, 1024 bytes/sector - F5_180_512, // 5.25", 180KB, 512 bytes/sector - F5_160_512, // 5.25", 160KB, 512 bytes/sector - RemovableMedia, // Removable media other than floppy - FixedMedia, // Fixed hard disk media - F3_120M_512, // 3.5", 120M Floppy - F3_640_512, // 3.5" , 640KB, 512 bytes/sector - F5_640_512, // 5.25", 640KB, 512 bytes/sector - F5_720_512, // 5.25", 720KB, 512 bytes/sector - F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector - F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector - F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector - F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector - F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector - F8_256_128 // 8", 256KB, 128 bytes/sector -} MEDIA_TYPE, *PMEDIA_TYPE; - - -typedef struct _DISK_GEOMETRY { - LARGE_INTEGER Cylinders; - MEDIA_TYPE MediaType; - DWORD TracksPerCylinder; - DWORD SectorsPerTrack; - DWORD BytesPerSector; -} DISK_GEOMETRY, *PDISK_GEOMETRY; - -typedef enum -{ - AttributeStandardInformation = 0x10, - AttributeAttributeList = 0x20, - AttributeFileName = 0x30, - AttributeObjectID = 0x40, - AttributeSecurityDescriptor = 0x50, - AttributeVolumeName = 0x60, - AttributeVolumeInformation = 0x70, - AttributeData = 0x80, - AttributeIndexRoot = 0x90, - AttributeIndexAllocation = 0xA0, - AttributeBitmap = 0xB0, - AttributeReparsePoint = 0xC0, - AttributeEAInformation = 0xD0, - AttributeEA = 0xE0, - AttributePropertySet = 0xF0, - AttributeLoggedUtilityStream = 0x100, -} ATTRIBUTE_TYPE, *PATTRIBUTE_TYPE; - -#define FILE_DEVICE_DISK 0x00000007 -#define IOCTL_DISK_BASE FILE_DEVICE_DISK -#define METHOD_BUFFERED 0 -#define FILE_ANY_ACCESS 0 -#define FILE_READ_ACCESS ( 0x0001 )// file & pipe - -#define CTL_CODE(DeviceType,Function,Method,Access) ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) ) -#define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS) -#endif - -#ifndef IOCTL_DISK_GET_DRIVE_LAYOUT_EX - -#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS) - -typedef struct _DISK_GEOMETRY_EX { - DISK_GEOMETRY Geometry; // Standard disk geometry: may be faked by driver. - LARGE_INTEGER DiskSize; // Must always be correct - BYTE Data[1]; // Partition, Detect info -} DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX; - -typedef struct _DRIVE_LAYOUT_INFORMATION_GPT { - GUID DiskId; - LARGE_INTEGER StartingUsableOffset; - LARGE_INTEGER UsableLength; - DWORD MaxPartitionCount; -} DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT; - -// -// MBR specific drive layout information. -// - -typedef struct _DRIVE_LAYOUT_INFORMATION_MBR { - DWORD Signature; -} DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR; - -typedef enum _PARTITION_STYLE { - PARTITION_STYLE_MBR, - PARTITION_STYLE_GPT, - PARTITION_STYLE_RAW -} PARTITION_STYLE; - - -typedef struct _PARTITION_INFORMATION_MBR { - BYTE PartitionType; - BOOLEAN BootIndicator; - BOOLEAN RecognizedPartition; - DWORD HiddenSectors; -} PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR; - -typedef struct _PARTITION_INFORMATION_GPT { - GUID PartitionType; // Partition type. See table 16-3. - GUID PartitionId; // Unique GUID for this partition. - DWORD64 Attributes; // See table 16-4. - WCHAR Name [36]; // Partition Name in Unicode. -} PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT; - -typedef struct _PARTITION_INFORMATION_EX { - PARTITION_STYLE PartitionStyle; - LARGE_INTEGER StartingOffset; - LARGE_INTEGER PartitionLength; - DWORD PartitionNumber; - BOOLEAN RewritePartition; - union { - PARTITION_INFORMATION_MBR Mbr; - PARTITION_INFORMATION_GPT Gpt; - }; -} PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX; - - -typedef struct _DRIVE_LAYOUT_INFORMATION_EX { - DWORD PartitionStyle; - DWORD PartitionCount; - union { - DRIVE_LAYOUT_INFORMATION_MBR Mbr; - DRIVE_LAYOUT_INFORMATION_GPT Gpt; - }; - PARTITION_INFORMATION_EX PartitionEntry[1]; -} DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX; - -#endif - -#endif // ntdiskspec_h Modified: trunk/FRHED/precomp.h =================================================================== --- trunk/FRHED/precomp.h 2008-08-18 17:16:39 UTC (rev 21) +++ trunk/FRHED/precomp.h 2008-08-18 19:20:44 UTC (rev 22) @@ -1,3 +1,33 @@ +///////////////////////////////////////////////////////////////////////////// +// License (GPLv2+): +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +///////////////////////////////////////////////////////////////////////////// +/** + * @file precomp.h + * + * @brief Precompiled header files listing. + * + */ +// ID line follows -- this is updated by SVN +// $Id$ + +// Needed to include +// DISK_GEOMETRY_EX, PARTITION_INFORMATION_EX +// and couple of others from WinIoCtl.h +#define _WIN32_WINNT 0x0500 + #include <windows.h> #include <io.h> #include <fcntl.h> Property changes on: trunk/FRHED/precomp.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |