[HTC Desire 526] BigCountry907:
Gpt decoding continued

Before we move on to the next tool lets output the data from both partition tables to a readable text file.

Later on in the project we will need it. :D

cd ~/Desktop/526-Completed/Get-GPT_Info/gptparser_v1.4beta/
perl gptparser.pl -i ~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT.bin > ~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT-read1.txt
perl gptparser.pl -i ~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img > ~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img-read1.txt

For informational purposes this is the template that gptparser.pl uses.

GPT Parser V1.4 beta - Gary C. Kessler (14 March 2013)

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

Getting a HEX Dump of the GPT Table.

I decided that it would be the best to use a hexdump of the 526-EMMC-GPT.bin we created.

To generate the partition.xml file we would have to read all the data in the 526-EMMC-GPT-read1.txt and write the partition.xml by hand.

Otherwise we would need a script to take the 526-EMMC-GPT-read1.txt and output a partition.xml file.

I did not like the Idea of doing that.

If I make a raw hex dump of the 526-EMMC-GPT.bin we created at least I would be working with untranslated data.

Meaning no chance that any of the data could be corrupted. And I can open the HEX DUMP and the original 526-EMMC-GPT.bin we created in any HEX Editor and they both will be identical. If there not then you have corrupted data.

HEXDUMP BOTH GPT TO A READABLE TEXT FILE

hexdump -C -v ~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT.bin > ~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT-read2.txt
hexdump -C -v ~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img > ~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img-read2.txt

HEXDUMP 526-EMMC-GPT.bin

hexdump -C -v ~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT.bin

HEXDUMP gpt_main_8g.img

hexdump -C -v ~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img

I know your still wondering how were gonna make a partition.xml out of this.

We need a script to read the hexdump and generate a partition.xml.

Or we can write it by hand. :eek:

At any rate we need at least one more piece of data to make this easy.

This is basic partition reading of an android emmc device. (CAT /PROC/PARTITIONS)

After were done here we will be just about finished up with the GPT and ready to make the partition.xml

Connect your phone and open a terminal in linux.

Execute theese commands.

adb devices
adb shell
cat /proc/partitions > /sdcard/Partitions.txt
exit
cd ~/Desktop/526-Completed/Get-GPT_Info
adb pull /sdcard/Partitions.txt

Now we should have everything we need to easily make the partition.xml.

You can find all the files we made in this folder.

~/Desktop/526-Completed/Get-GPT_Info

IF YOU HAVE ALL OF THESE FILES YOU ARE READY FOR THE NEXT STEP

IF YOU DONT GO BACK AND MAKE THEM

FILES TO CREATE PARTITION.XML

~/Desktop/526-Completed/Get-GPT_Info/Partitions.txt
~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img-read2.txt
~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img-read1.txt
~/Desktop/526-Completed/Get-GPT_Info/gpt_main_8g.img
~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT-read2.txt
~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT-read1.txt
~/Desktop/526-Completed/Get-GPT_Info/526-EMMC-GPT.bin

Don't worry we are very close now. :rolleyes: