From 117d5bb67d1007ce127a561ed2d564884d358a93 Mon Sep 17 00:00:00 2001 From: ColdWindScholar <3590361911@qq.com> Date: Fri, 23 Feb 2024 20:47:26 +0800 Subject: [PATCH] [Normal] Support android --- ext4.py | 15 ++++++++------- imgextractor.py | 2 +- run.py | 6 ++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ext4.py b/ext4.py index 3e4026e..ea08ddd 100644 --- a/ext4.py +++ b/ext4.py @@ -19,10 +19,6 @@ class Ext4Error(Exception): ... -class BlockMapError(Ext4Error): - ... - - class EndOfStreamError(Ext4Error): ... @@ -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 = [ @@ -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) diff --git a/imgextractor.py b/imgextractor.py index 04c784e..3073c75 100644 --- a/imgextractor.py +++ b/imgextractor.py @@ -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') diff --git a/run.py b/run.py index 08976f9..34508a8 100644 --- a/run.py +++ b/run.py @@ -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 @@ -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: