Skip to content

Commit

Permalink
[Normal] Support android
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdWindScholar committed Feb 23, 2024
1 parent 082b003 commit 117d5bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 8 additions & 7 deletions ext4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class Ext4Error(Exception):
...


class BlockMapError(Ext4Error):
...


class EndOfStreamError(Ext4Error):
...

Expand Down Expand Up @@ -511,6 +507,10 @@ def block_size(self):
def get_block_count(self):
return self.superblock.s_blocks_count

@property
def get_mount_point(self):
return self.superblock.s_last_mounted.decode()

@property
def get_info_list(self):
data = [
Expand Down Expand Up @@ -855,11 +855,12 @@ def xattrs(self, check_inline=True, check_block=True, force_inline=False):
# Perhaps you think this code is a bit foolish, but that's all others can do
print(f"Invalid magic value in xattrs block header at offset 0x{xattrs_block_start:X} of "
f"inode {self.inode_idx:d}: 0x{xattrs_header.h_magic} (expected 0xEA020000)")
return '', ''

if xattrs_header.h_blocks != 1:
print(
f"Invalid number of xattr blocks at offset 0x{xattrs_block_start:X} "
f"of inode {self.inode_idx:d}: {xattrs_header.h_blocks:d} (expected 1)")
print(f"Invalid number of xattr blocks at offset 0x{xattrs_block_start:X} "
f"of inode {self.inode_idx:d}: {xattrs_header.h_blocks:d} (expected 1)")
return '', ''

offset = 4 * ((ctypes.sizeof(
ext4_xattr_header) + 3) // 4)
Expand Down
2 changes: 1 addition & 1 deletion imgextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def scan_dir(root_inode, root_path=""):
os.makedirs(self.CONFING_DIR)
self.__append(os.path.getsize(self.OUTPUT_IMAGE_FILE), self.CONFING_DIR + os.sep + self.FileName + '_size.txt')
with open(self.OUTPUT_IMAGE_FILE, 'rb') as file:
dir_r = self.__out_name(os.path.basename(self.OUTPUT_IMAGE_FILE).rsplit('.', 1)[0])
dir_r = self.FileName
self.DIR = dir_r
scan_dir(ext4.Volume(file).root)
self.fs_config.insert(0, '/ 0 2000 0755' if dir_r == 'vendor' else '/ 0 0 0755')
Expand Down
6 changes: 6 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from io import BytesIO
from os import path as o_path
import banner
import ext4
from Magisk import Magisk_patch
import os

Expand Down Expand Up @@ -1700,6 +1701,11 @@ def unpack(file, info, project):
filepath = os.path.dirname(file)
unpack(os.path.join(filepath, file), gettype(os.path.join(filepath, file)), project)
elif info == 'ext':
with open(file, 'rb+') as e:
mount = ext4.Volume(e).get_mount_point
if mount[:1] == '/':
mount = mount[1:]
parts[mount] = 'ext'
with Console().status(f"[yellow]正在提取{os.path.basename(file)}[/]"):
imgextractor.Extractor().main(file, project + os.sep + os.path.basename(file).split('.')[0], project)
try:
Expand Down

0 comments on commit 117d5bb

Please sign in to comment.