⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosbpb.h

📁 从大量的wince源代码中剥离出的fat文件系统源代码.移植性非常高. 里面带有source i.rar
💻 H
📖 第 1 页 / 共 2 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
/****************************************************************************\
*
*       BPB (Bios Parameter Block) Data Structure
*
*
\****************************************************************************/

#ifndef INCLUDE_DOSBPB
#define INCLUDE_DOSBPB 1

#ifndef HVOLB
#define HVOLB   HANDLE
#endif

//
//  Media descriptor values for different floppy drives
//  NOTE: these are not all unique!
//
#define MEDIA_160   0xFE    // 160KB
#define MEDIA_320   0xFF    // 320KB
#define MEDIA_180   0xFC    // 180KB
#define MEDIA_360   0xFD    // 360KB
#define MEDIA_1200  0xF9    // 1.2MB
#define MEDIA_720   0xF9    // 720KB
#define MEDIA_HD    0xF8    // hard disk
#define MEDIA_1440  0xF0    // 1.44M
#define MEDIA_2880  0xF0    // 2.88M


#pragma pack(1)

typedef struct  BPB { /* */
        WORD    BPB_BytesPerSector;     /* Sector size                      */
        BYTE    BPB_SectorsPerCluster;  /* sectors per allocation unit      */
        WORD    BPB_ReservedSectors;    /* DOS reserved sectors             */
        BYTE    BPB_NumberOfFATs;       /* Number of FATS                   */
        WORD    BPB_RootEntries;        /* Number of directories            */
        WORD    BPB_TotalSectors;       /* Partition size in sectors        */
        BYTE    BPB_MediaDescriptor;    /* Media descriptor                 */
        WORD    BPB_SectorsPerFAT;      /* Fat sectors                      */
        WORD    BPB_SectorsPerTrack;    /* Sectors Per Track                */
        WORD    BPB_Heads;              /* Number heads                     */
        DWORD   BPB_HiddenSectors;      /* Hidden sectors                   */
        DWORD   BPB_BigTotalSectors;    /* Number sectors                   */
} BPB;
typedef BPB UNALIGNED *PBPB;
typedef BPB UNALIGNED FAR *LPBPB;


typedef struct  BIGFATBPB { /* */
        BPB     oldBPB;
        DWORD   BGBPB_BigSectorsPerFAT;   /* BigFAT Fat sectors              */
        WORD    BGBPB_ExtFlags;           /* Other flags                     */
        WORD    BGBPB_FS_Version;         /* File system version             */
        DWORD   BGBPB_RootDirStrtClus;    /* Starting cluster of root directory */
        WORD    BGBPB_FSInfoSec;          /* Sector number in the reserved   */
                                          /* area where the BIGFATBOOTFSINFO */
                                          /* structure is. If this is >=     */
                                          /* oldBPB.BPB_ReservedSectors or   */
                                          /* == 0 there is no FSInfoSec      */
        WORD    BGBPB_BkUpBootSec;        /* Sector number in the reserved   */
                                          /* area where there is a backup    */
                                          /* copy of all of the boot sectors */
                                          /* If this is >=                   */
                                          /* oldBPB.BPB_ReservedSectors or   */
                                          /* == 0 there is no backup copy.   */
        WORD    BGBPB_Reserved[6];        /* Reserved for future expansion   */
} BIGFATBPB;
typedef BIGFATBPB UNALIGNED *PBIGFATBPB;
typedef BIGFATBPB UNALIGNED FAR *LPBIGFATBPB;


/*
 * Bits of BGBPB_ExtFlags
 *    The low 4 bits are the 0 based FAT number of the Active FAT
 */
#define BGBPB_F_ActiveFATMsk    0x000F
#define BGBPB_F_NoFATMirror     0x0080  /* Do not Mirror active FAT to inactive FATs */
#define BGBPB_F_CompressedVol   0x0100  /* Volume is compressed             */


/*
 * Current version of the file system. Basically this allows a version
 *  bind to prevent old versions of the file system drivers from recognizing
 *  new versions of the on disk format. The proper bind is:
 *
 *  if(BIGFATBPB.BGBPB_FS_Version > FAT32_Curr_FS_Version)
 *      do not recognize volume
 */
#define FAT32_Curr_FS_Version   0x0000
#define FAT32_Curr_Version      FAT32_Curr_FS_Version


/* The final two bytes of this BPB variant were originally intended for     */
/* future expansion.  They are never used for anything by the system.       */
/* In most cases where BPBs are manipulated, these bytes are not even       */
/* included.  They are stored in the recommended BPB structure in the BDS,  */
/* and they are passed in through the Get/Set Device Parameters Generic     */
/* IOCTL call.                                                              */

typedef struct A_BPB { /* */
        WORD    A_BPB_BytesPerSector;     /* Sector size                    */
        BYTE    A_BPB_SectorsPerCluster;  /* sectors per allocation unit    */
        WORD    A_BPB_ReservedSectors;    /* DOS reserved sectors           */
        BYTE    A_BPB_NumberOfFATs;       /* Number of FATS                 */
        WORD    A_BPB_RootEntries;        /* Number of directories          */
        WORD    A_BPB_TotalSectors;       /* Partition size in sectors      */
        BYTE    A_BPB_MediaDescriptor;    /* Media descriptor               */
        WORD    A_BPB_SectorsPerFAT;      /* Fat sectors                    */
        WORD    A_BPB_SectorsPerTrack;    /* Sectors Per Track              */
        WORD    A_BPB_Heads;              /* Number heads                   */
        DWORD   A_BPB_HiddenSectors;      /* Hidden sectors                 */
        DWORD   A_BPB_BigTotalSectors;    /* Number sectors                 */
        BYTE    A_BPB_Reserved[6];        /* Unused                         */
} A_BPB;
typedef A_BPB UNALIGNED *PA_BPB;


typedef struct A_BF_BPB { /* */
        WORD    A_BF_BPB_BytesPerSector;     /* Sector size                    */
        BYTE    A_BF_BPB_SectorsPerCluster;  /* sectors per allocation unit    */
        WORD    A_BF_BPB_ReservedSectors;    /* DOS reserved sectors           */
        BYTE    A_BF_BPB_NumberOfFATs;       /* Number of FATS             */
        WORD    A_BF_BPB_RootEntries;        /* Number of directories          */
        WORD    A_BF_BPB_TotalSectors;       /* Partition size in sectors      */
        BYTE    A_BF_BPB_MediaDescriptor;    /* Media descriptor           */
        WORD    A_BF_BPB_SectorsPerFAT;      /* Fat sectors                    */
        WORD    A_BF_BPB_SectorsPerTrack;    /* Sectors Per Track              */
        WORD    A_BF_BPB_Heads;              /* Number heads                   */
        DWORD   A_BF_BPB_HiddenSectors;      /* Hidden sectors                 */
        DWORD   A_BF_BPB_BigTotalSectors;    /* Number sectors                 */
        DWORD   A_BF_BPB_BigSectorsPerFAT;   /* BigFAT Fat sectors             */
        WORD    A_BF_BPB_ExtFlags;           /* Other flags                    */
        WORD    A_BF_BPB_FS_Version;         /* File system version            */
        DWORD   A_BF_BPB_RootDirStrtClus;    /* Starting cluster of root directory */
        WORD    A_BF_BPB_FSInfoSec;          /* Sector number of FSInfo sec    */
        WORD    A_BF_BPB_BkUpBootSec;        /* Sector number of backupboot    */
        WORD    A_BF_BPB_Reserved[6];        /* Reserved for future expansion   */
} A_BF_BPB;
typedef A_BF_BPB UNALIGNED *PA_BF_BPB;


// Redundant definitions (kept to avoid lots of work)

typedef struct EXT_BPB_INFO { /* */
        WORD    EBPB_BYTESPERSECTOR;
        BYTE    EBPB_SECTORSPERCLUSTER;
        WORD    EBPB_RESERVEDSECTORS;
        BYTE    EBPB_NUMBEROFFATS;
        WORD    EBPB_ROOTENTRIES;
        WORD    EBPB_TOTALSECTORS;
        BYTE    EBPB_MEDIADESCRIPTOR;
        WORD    EBPB_SECTORSPERFAT;
        WORD    EBPB_SECTORSPERTRACK;
        WORD    EBPB_HEADS;
        DWORD   EBPB_HIDDENSECTOR;
        DWORD   EBPB_BIGTOTALSECTORS;
} EXT_BPB_INFO;

typedef struct EXT_BIGBPB_INFO { /* */
        WORD    EBGBPB_BYTESPERSECTOR;
        BYTE    EBGBPB_SECTORSPERCLUSTER;
        WORD    EBGBPB_RESERVEDSECTORS;
        BYTE    EBGBPB_NUMBEROFFATS;
        WORD    EBGBPB_ROOTENTRIES;
        WORD    EBGBPB_TOTALSECTORS;
        BYTE    EBGBPB_MEDIADESCRIPTOR;
        WORD    EBGBPB_SECTORSPERFAT;
        WORD    EBGBPB_SECTORSPERTRACK;
        WORD    EBGBPB_HEADS;
        DWORD   EBGBPB_HIDDENSECTOR;
        DWORD   EBGBPB_BIGTOTALSECTORS;
        DWORD   EBGBPB_BIGSECTORSPERFAT;
        WORD    EBGBPB_EXTFLAGS;
        WORD    EBGBPB_FS_VERSION;
        DWORD   EBGBPB_ROOTDIRSTRTCLUS;
        WORD    EBGBPB_FSINFOSEC;
        WORD    EBGBPB_BKUPBOOTSEC;
        DWORD   EBGBPB_RESERVED[3];
} EXT_BIGBPB_INFO;

/* ASM
.errnz  EXT_BPB_INFO.EBPB_BYTESPERSECTOR            NE  BPB.BPB_BytesPerSector
.errnz  EXT_BPB_INFO.EBPB_SECTORSPERCLUSTER         NE  BPB.BPB_SectorsPerCluster
.errnz  EXT_BPB_INFO.EBPB_RESERVEDSECTORS           NE  BPB.BPB_ReservedSectors
.errnz  EXT_BPB_INFO.EBPB_NUMBEROFFATS              NE  BPB.BPB_NumberOfFATs
.errnz  EXT_BPB_INFO.EBPB_ROOTENTRIES               NE  BPB.BPB_RootEntries
.errnz  EXT_BPB_INFO.EBPB_TOTALSECTORS              NE  BPB.BPB_TotalSectors
.errnz  EXT_BPB_INFO.EBPB_MEDIADESCRIPTOR           NE  BPB.BPB_MediaDescriptor
.errnz  EXT_BPB_INFO.EBPB_SECTORSPERFAT             NE  BPB.BPB_SectorsPerFAT
.errnz  EXT_BPB_INFO.EBPB_SECTORSPERTRACK           NE  BPB.BPB_SectorsPerTrack
.errnz  EXT_BPB_INFO.EBPB_HEADS                     NE  BPB.BPB_Heads
.errnz  EXT_BPB_INFO.EBPB_HIDDENSECTOR              NE  BPB.BPB_HiddenSectors
.errnz  EXT_BPB_INFO.EBPB_BIGTOTALSECTORS           NE  BPB.BPB_BigTotalSectors
.errnz  (SIZE EXT_BPB_INFO) NE  (SIZE BPB)

.errnz  EXT_BIGBPB_INFO.EBGBPB_BYTESPERSECTOR       NE  EXT_BPB_INFO.EBPB_BYTESPERSECTOR
.errnz  EXT_BIGBPB_INFO.EBGBPB_SECTORSPERCLUSTER    NE  EXT_BPB_INFO.EBPB_SECTORSPERCLUSTER
.errnz  EXT_BIGBPB_INFO.EBGBPB_RESERVEDSECTORS      NE  EXT_BPB_INFO.EBPB_RESERVEDSECTORS
.errnz  EXT_BIGBPB_INFO.EBGBPB_NUMBEROFFATS         NE  EXT_BPB_INFO.EBPB_NUMBEROFFATS
.errnz  EXT_BIGBPB_INFO.EBGBPB_ROOTENTRIES          NE  EXT_BPB_INFO.EBPB_ROOTENTRIES
.errnz  EXT_BIGBPB_INFO.EBGBPB_TOTALSECTORS         NE  EXT_BPB_INFO.EBPB_TOTALSECTORS
.errnz  EXT_BIGBPB_INFO.EBGBPB_MEDIADESCRIPTOR      NE  EXT_BPB_INFO.EBPB_MEDIADESCRIPTOR
.errnz  EXT_BIGBPB_INFO.EBGBPB_SECTORSPERFAT        NE  EXT_BPB_INFO.EBPB_SECTORSPERFAT
.errnz  EXT_BIGBPB_INFO.EBGBPB_SECTORSPERTRACK      NE  EXT_BPB_INFO.EBPB_SECTORSPERTRACK
.errnz  EXT_BIGBPB_INFO.EBGBPB_HEADS                NE  EXT_BPB_INFO.EBPB_HEADS
.errnz  EXT_BIGBPB_INFO.EBGBPB_HIDDENSECTOR         NE  EXT_BPB_INFO.EBPB_HIDDENSECTOR
.errnz  EXT_BIGBPB_INFO.EBGBPB_BIGTOTALSECTORS      NE  EXT_BPB_INFO.EBPB_BIGTOTALSECTORS
;.errnz  (SIZE EXT_BIGBPB_INFO.EBGBPB_BIGTOTALSECTORS) NE (SIZE EXT_BPB_INFO.EBPB_BIGTOTALSECTORS)
 */

typedef struct EXT_IBMBOOT_HEADER { /* */
        BYTE    EXT_BOOT_JUMP[3];
        BYTE    EXT_BOOT_OEM[8];
        EXT_BPB_INFO EXT_BOOT_BPB;
        BYTE    EXT_PHYDRV;
        BYTE    EXT_CURHD;
        BYTE    EXT_BOOT_SIG;
        DWORD   EXT_BOOT_SERIAL;
        BYTE    EXT_BOOT_VOL_LABEL[11];
        BYTE    EXT_SYSTEM_ID[8];
} EXT_IBMBOOT_HEADER;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -