GPT template for gptparser
Gary C. Kessler, 6/15/2011

NOTE: Numbers are interpreted in little endian (except as noted), hex fields
are interpreted in byte-order, and binary fields are generally displayed in
hex and ASCII.

In the GPT vernacular, a sector (512 bytes) is referred to as a Logical Block
Address, or LBA.

The generic layout of a GPT disk ("LBA -n" below refers to "n" sectors from the end): 

LBA   0   Legacy/Protective MBR
LBA   1   Primary GPT Header
LBA   2   Partition Table entries 1-4
      :    
LBA  33   Partition Table entries 125-128
LBA  34   Partition 1
      :    
      :   Partitions....... 
      :    
LBA -34  
LBA -33   Partition Table entries 1-4
      :    
LBA  -2   Partition Table entries 125-128
LBA  -1   Secondary GPT Header


LBA 0: LEGACY MASTER BOOT RECORD
(The MBR is displayed in this program but not interpreted. The ending signature
value is interpreted and evaluated.)

LBA 1: PRIMARY PARTITION TABLE HEADER (Secondary Header is in LBA-1 on disk)

Beg  End  Type    Purpose
---  ---  ------  ---------------------------------------------------------
000  007  Hex     Signature ("EFI PART")
008  011  Hex     Revision (0x00-00-01-00 = v1.0)
012  015  Number  Header size (Usually 92 bytes)
016  019  Hex     CRC32 for bytes 0-15 (UNTESTED AT THIS TIME)
020  023  Hex     Reserved (must be 0)
024  031  Number  LBA of primary GPT header (should be 1)
032  039  Number  LBA of backup GPT header (should be last LBA on disk)
040  047  Number  First usable LBA for partitions
                  (should be LBA_of_last_partition_table_entry + 1)
048  055  Number  Last usable LBA for partitions
                  (should be LBA_of_first_backup_partition_table_entry - 1)
056  071  Hex     Disk GUID
072  079  Number  LBA of first partition table entries
                  (should be 2 in primary GPT header)
080  083  Number  Number of partition entries (usually 128)
084  087  Number  Size of partition entries (usually 128 bytes)
088  091  Hex     CRC32 of partition array (UNTESTED AT THIS TIME)
092  end  Hex     Reserved (must be zero)


PARTITION TABLE ENTRY (relative byte numbers)

Beg  End  Type    Purpose
---  ---  ------  ---------------------------------------------------------
000  015  Hex     Partition type GUID
016  031  Hex     Unique partition GUID
032  039  Number  First LBA (little endian)
040  047  Number  Last LBA (usually odd)
048  055  Number  Attribute flags
056  127  Hex     Partition name (UTF-16, little endian)


GUID TRANSLATION

The GUIDs are 16 bytes long, or 32 hex digits. They are written in groupings, separated by dashes ("-"); four bytes, three groups of two bytes, followed by six bytes. BUT, the translation is not consistent as little or big endian; in fact, just the first three groups are little endian. So.... if we had a GUID represented by these 16 bytes:

  0x01-23-45-67-89-AB-CD-EF-08-19-2A-3B-4C-5D-6E-7F

the GUID would be written as:

  67452301-AB89-EFCD-0819-2A3B4C5D6E7F

