// DFS disk structure definitions // // Author: J. van Wijk // // JvW 17-06-95 Initial version, split off from HPFSDEF.H // #ifndef DFSDISK_H #define DFSDISK_H #define SECTORSIZE 512 // Mapping macro's from DFS SecCyl USHORT to sector and cylinder values #define DFSC2SECTOR(sc) (USHORT)((sc)&0x3F) #define DFSC2CYLIND(sc) (USHORT)(HIBYTE(sc)+(((USHORT)(LOBYTE(sc)&0xC0))<<2)) #define DFSCOMBINE(s,c) (USHORT)(((c & 0xff) << 8) | ((c & 0x0300) >> 2) | s) // Sector to (double) Mb value and (ULONG) Mb value to sectors #define DFS2MB(sectors) TPS2MB(sectors, dfsGetSectorSize()) #define DFSMB2SECTS(mb) (mb * (ULONG)((ULONG) ((ULONG)1024*(ULONG)1024) \ / (ULONG) dfsGetSectorSize())) typedef char SECTOR[SECTORSIZE]; typedef char BIGSEC[2048]; // biggest supported sectorsize typedef ULONG LSN; // Logical Sector Number typedef struct vcn // Virtual Cluster Number { ULONG lo; // low 32 bits ULONG hi; // high 32 bits } LCN; // end of struct "vcn" typedef struct xlong // eXtreme LONG value (64 bits) { ULONG lo; // low 32 bits ULONG hi; // high 32 bits } XLONG; // end of struct "xlong" #define LSN_NULL ((LSN) 0xffffffff) #define CHS_NULL ((USHORT) 0xffff) #define SIZE_MAX ((ULONG) 0xffffffff) #define LSN_BOOTR 0x00 #define LEN_BOOTR 0x40 #pragma pack(1) // byte packing typedef struct _DFSC { // gives sector position BYTE Head; // Read/Write head USHORT SecCyl; // Sector & cylinder number } DFSC; typedef struct _DFSPARTENTRY // partition table entry { BYTE Status; // partition status DFSC FirstSector; // First sector BYTE PartitionType; // Partition type DFSC LastSector; // Last sector ULONG BootSectorOffset; // Boot sector Offset ULONG NumberOfSectors; // Number of sectors } DFSPARTENTRY; typedef enum dfs_os_boot { DFS_OS, // generic OS boot-record DFS_NT, // NT type OS boot-record DFS_F2 // FAT32 type boot-record } DFS_OS_BOOT; // end of enum "dfs_os_boot" #define BT_LABL_L 11 #define BT_TYPE_L 8 typedef struct dfsosinfo // generic OS bootrec info { BYTE PhysDriveNr; // Drive number (80 for HD 1) BYTE HeadState; // head / CHKDSK/SCAN required BYTE Signature; // bpb signature, 28, 29, 80 ULONG SerialNr; // volume serial number char Label[BT_LABL_L]; // volume label char Type[BT_TYPE_L]; // volume type (BPB end) USHORT CodeStart; // Bootcode, start ULONG Code[82]; // Bootcode, in ULONG's USHORT CodeEnd; // Bootcode, upto BootMgr info } DFSOSINFO; // end of struct "dfsosinfo" typedef struct dfsf2info // FAT32 bootrec info { ULONG FatSectors; // nr of sectors per FAT ULONG reserved1; ULONG RootCluster; // Cluster nr for Root Dir USHORT shortval1; USHORT shortval2; ULONG longzero1; ULONG longzero2; ULONG longzero3; BYTE PhysDriveNr; // Drive number (80 for HD 1) BYTE HeadState; // head / CHKDSK/SCAN required BYTE Signature; // bpb signature, 28, 29, 80 ULONG SerialNr; // volume serial number char Label[BT_LABL_L]; // volume label char Type[BT_TYPE_L]; // volume type (BPB end) char fil1[304]; // filler, upto BootMgr info } DFSF2INFO; // end of struct "dfsf2info" typedef struct dfsntinfo // specific NT bootrec info { BYTE PhysDriveNr; // Drive number (80 for HD 1) BYTE HeadState; // head / CHKDSK/SCAN required BYTE Signature; // bpb signature, 28, 29, 80 BYTE fil1; // unknown LCN VolSize; // volume size, in sectors LCN MftClus; // MFT cluster LCN MftCopy; // MFT copy cluster ULONG MftSize; // MFT record size (clust/byte) ULONG DirSize; // DIR (INDX) size (clust/byte) char fil4[319]; // filler, upto BootMgr info } DFSNTINFO; // end of struct "dfsntinfo" // Note: MftSize and DirSize are estimated guesses, it is likely that the // value is clusters/record if positive and indicates a power of 2 // when negative. example 0x000000f6 ==> minus 10 ==> 2^10 == 1024 bytes #define BT_BM_L 8 #define BT_SYST_L 8 #define SV_BOOTR (USHORT) 0xaa55 typedef struct s_bootr // Boot sector { BYTE Instruction[3]; // first bootcode instruction char OpSys[BT_SYST_L]; // source operating system TPFS_EBPB eb; // extended BPB union { DFSOSINFO os; // generic OS info DFSNTINFO nt; // specific NT info DFSF2INFO f2; // specific FAT32 info }; // end of anonymous union char BootMgrFlag; // Part for this EBR in BootMgr char BootMgrName[BT_BM_L +1]; // Null terminated BootMgr name char BootMgrNext[BT_BM_L +1]; // Null term next EBR PSN ascii char fil3[27]; // filler, upto part table ULONG NTsignature; // NT Disk Administrator sign. USHORT reserved; // unknown DFSPARTENTRY PartitionTable[4]; // partition table-entries USHORT Signature; } S_BOOTR; // end of struct "s_bootr" // EA type indicators (EAT) as used by OS/2 on HPFS and FAT EA data // Values 0xFFFE thru 0x8000 are reserved. (for 'IBM' use) // Values 0x0000 thru 0x7fff are user definable. (but hardly seen) // Value 0xFFFC is not used #define DFS_EA_BINARY 0xFFFE //- Single EA binary #define DFS_EA_ASCII 0xFFFD //- Single EA ASCII #define DFS_EA_BITMAP 0xFFFB //- Single EA bitmap #define DFS_EA_METAFILE 0xFFFA //- Single EA metafile #define DFS_EA_ICON 0xFFF9 //- Single EA icon #define DFS_EA_EA 0xFFEE //- Single EA ASCII //- name of associated data (#include) #define DFS_EA_MVMT 0xFFDF //- multi-valued, multi-typed EA #define DFS_EA_MVST 0xFFDE //- multi-valued, single-typed EA #define DFS_EA_ASN1 0xFFDD //- ASN.1 ISO multi-value data stream typedef struct s_ea_atom { USHORT Length; // Length of single EA char Data[1]; // Actual EA data } S_EA_ATOM; // end of struct "s_ea_atom" typedef struct s_easingle // normal EA { USHORT Type; // Type of the EA, length S_EA_ATOM Ea; // Length and data of EA } S_EASINGLE; // end of struct "s_easingle" typedef struct s_ea_mvmt // multi-value multi-type combo { USHORT Type; // Type of the EA, length S_EA_ATOM Ea; // Length and data of EA } S_EA_MVMT; // end of struct "s_ea_mvmt" typedef struct s_ea_mvst // multi-value single-type combo { USHORT Type; // Type of the EA, length S_EA_ATOM Ea[1]; // Repeated Length and data } S_EA_MVST; // end of struct "s_ea_mvst" typedef struct s_eamulti { USHORT Type; // Multi/Single typed indicator USHORT CodePage; // CodePage value USHORT Count; // Number of entries union { S_EA_MVMT Mt[1]; // Repeated multi-typed S_EA_MVST St; // Single typed } Tp; // end of union multi-ea } S_EAMULTI; // end of struct "s_eamulti" typedef union s_eadata { S_EASINGLE Sv; // single value S_EAMULTI Mv; // multi value } S_EADATA; // end of union "s_eadata" typedef struct s_eablk // Generic definition of EA { // for HPFS, FAT and ... ? BYTE Flag; // EA flag, type of EA BYTE NameLength; // length of name excl \0 USHORT DataLength; // length of EA data area char Name[1]; // ASCIIZ EA name // Followed by EA data area } S_EABLK; // end of struct "s_eablk" #endif