mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 19:25:05 -05:00
Add bpi partition support
This commit is contained in:
parent
66198345ef
commit
287dd9a066
2 changed files with 15 additions and 2 deletions
|
@ -5,6 +5,7 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
from io import BytesIO
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from struct import unpack, pack
|
from struct import unpack, pack
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
@ -160,7 +161,7 @@ class gpt(metaclass=LogBase):
|
||||||
def parseheader(self, gptdata, sectorsize=512):
|
def parseheader(self, gptdata, sectorsize=512):
|
||||||
return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
||||||
|
|
||||||
def parse_bpi(self, gptdata):
|
def parse_bpi(self, gptdata, pagesize=0x200):
|
||||||
class partf:
|
class partf:
|
||||||
unique = b""
|
unique = b""
|
||||||
first_lba = 0
|
first_lba = 0
|
||||||
|
@ -171,7 +172,7 @@ class gpt(metaclass=LogBase):
|
||||||
type = b""
|
type = b""
|
||||||
name = ""
|
name = ""
|
||||||
entryoffset = 0
|
entryoffset = 0
|
||||||
self.sectorsize = 0x200
|
self.sectorsize = pagesize
|
||||||
self.totalsectors = 0
|
self.totalsectors = 0
|
||||||
self.partentries = []
|
self.partentries = []
|
||||||
for pos in range(0x800,len(gptdata),0x80):
|
for pos in range(0x800,len(gptdata),0x80):
|
||||||
|
|
|
@ -29,6 +29,18 @@ class Partition(metaclass=LogBase):
|
||||||
|
|
||||||
def get_gpt(self, gpt_settings, parttype="user"):
|
def get_gpt(self, gpt_settings, parttype="user"):
|
||||||
data = self.readflash(addr=0, length=2 * self.config.pagesize, filename="", parttype=parttype, display=False)
|
data = self.readflash(addr=0, length=2 * self.config.pagesize, filename="", parttype=parttype, display=False)
|
||||||
|
if data[:4] == b"BPI\x00":
|
||||||
|
guid_gpt = gpt(
|
||||||
|
num_part_entries=gpt_settings.gpt_num_part_entries,
|
||||||
|
part_entry_size=gpt_settings.gpt_part_entry_size,
|
||||||
|
part_entry_start_lba=gpt_settings.gpt_part_entry_start_lba,
|
||||||
|
)
|
||||||
|
data = self.readflash(addr=0, length=32 * self.config.pagesize, filename="",
|
||||||
|
parttype=parttype, display=False)
|
||||||
|
if data == b"":
|
||||||
|
return None, None
|
||||||
|
guid_gpt.parse_bpi(data, self.config.pagesize)
|
||||||
|
return data, guid_gpt
|
||||||
if data[:9] == b"EMMC_BOOT" and self.read_pmt is not None:
|
if data[:9] == b"EMMC_BOOT" and self.read_pmt is not None:
|
||||||
partdata, partentries = self.read_pmt()
|
partdata, partentries = self.read_pmt()
|
||||||
if partdata == b"":
|
if partdata == b"":
|
||||||
|
|
Loading…
Reference in a new issue