• Stars
    star
    146
  • Rank 252,769 (Top 5 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Patch img files with system.patch.dat, like OTA zip on PC

IMG Patch Tools

Patch image (.img) using sparse Android data image (.dat) in OTA zip with "BlockImageUpdate" Patch other files (boot.img, firmwares) using patch file (.p) with "ApplyPatchfn"

Downloads

Github Release

Requirements

For Building this tool you need :

  • zlib
  • libbz2
  • openssl

It currently supports Linux x86/x64 & MacOS, Not tested on Windows.

Usage

usage: ./BlockImageUpdate <system.img> <system.transfer.list> <system.new.dat> <system.patch.dat>

args:

  • <system.img> = block device (or file) to modify in-place
  • <system.transfer.list> = transfer list (blob) from OTA/rom zip
  • <system.new.dat> = new data stream from OTA/rom zip
  • <system.patch.dat> = patch stream from OTA/rom zip
./ApplyPatchfn <file> <target> <tgt_sha1> <size> <init_sha1(1)> <patch(1)> [init_sha1(2)] [patch(2)]...
  • <file> = source file from rom zip
  • <target> = target file (use "-" to patch source file)
  • <tgt_sha1> = target SHA1 Sum after patching
  • <size> = file size
  • <init_sha1> = file SHA1 sum
  • <patch> = patch file (.p) from OTA zip
usage: ./scriptpatcher.sh <updater-script>

args:

  • <updater-script> = updater-script from OTA zip to patch recovery commands

Example

for example from updater-script of OTA we have:

block_image_update("/dev/block/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat")

apply_patch("EMMC:/dev/block/bootdevice/by-name/boot:33554432:f32a854298814c18b12d56412f6e3a31afc95e42:33554432:0041a4df844d4b14c0085921d84572f48cc79ff4",
            "-", 0041a4df844d4b14c0085921d84572f48cc79ff4, 33554432,
            f32a854298814c18b12d56412f6e3a31afc95e42,
            package_extract_file("patch/boot.img.p"))

after getting system.img and boot.img from firmware This is equals of previous functions on PC with this tools:

~$ ./BlockImageUpdate system.img system.transfer.list system.new.dat system.patch.dat
~$ ./ApplyPatchfn boot.img - 0041a4df844d4b14c0085921d84572f48cc79ff4 33554432 f32a854298814c18b12d56412f6e3a31afc95e42

scriptpatcher.sh will generate all commands automatically from updater script so run it like:

~$ ./scriptpatcher.sh META-INF/com/google/android/updater-script > fullpatch.sh

check fullpatch.sh your self, you need to provide all images and files in correct name and patch as mentioned in mount and other commands of fullpatch.sh

Youtube

IMG Patch Tools

Info

For more information about this tools, visit https://forum.xda-developers.com/android/software-hacking/dev-img-patch-tools-sdat2img-ota-zips-t3640308.

More Repositories

1

ErfanGSIs

Just a tool to make GSI out of firmware from any phone
Python
494
star
2

Firmware_extractor

Extract any type of OEM firmware to images
Python
58
star
3

P_semiGSI

Shell
44
star
4

Capire-Le-Treble

Treble without Vendor Partition
Shell
40
star
5

waydroid

Just my personal experimental temp repo, checkout upstream:
Python
24
star
6

Motorola-OTA-Link-Generator-Tool

online tool to get OTA update ZIPs links without device and stock ROM
PHP
23
star
7

ROM_resigner

Python Script to resign an Android ROM using custom keys
Python
17
star
8

gbinder-python

Python bindings for libgbinder
Cython
10
star
9

proprietary_vendor_motorola

Force push warning
Makefile
8
star
10

android_device_halium_ubport

C++
8
star
11

android_device_xiaomi_ginkgo

C++
8
star
12

ubport_GSI

Shell
7
star
13

picklistmaker

Python
7
star
14

android_device_anbox_anbox_arm64

C++
7
star
15

erfanoabdi

6
star
16

plymouth

C
6
star
17

android_vendor_extra

Makefile
6
star
18

BatteryModPercentage

Read Battery Moto Mod Details
Java
6
star
19

vendor_vndk

Makefile
6
star
20

android_device_xiaomi_lavender

C++
5
star
21

platform_packages_apps_ParallelSpace

Java
5
star
22

update_payload_extractor

Python
5
star
23

android_device_xiaomi_sm6125-common

C++
5
star
24

android_kernel_motorola_sdm632

C
5
star
25

android_device_halium_anbox

C++
5
star
26

android_kernel_samsung_universal9810

C
5
star
27

android_device_samsung_universal9610-common

Makefile
5
star
28

android_device_samsung_universal9810-common

Makefile
4
star
29

android_device_motorola_sdm632-common

C++
4
star
30

android_kernel_gigaset_mt6768

C
4
star
31

android_kernel_xiaomi_sm6250

*deprecated* for new trees check link below
C
4
star
32

DesktopMode

Java
4
star
33

platform_packages_apps_Camera

Java
4
star
34

samsung_m31_dump

Shell
3
star
35

android_device_xiaomi_sm8350-common

C++
3
star
36

android_kernel_xiaomi_sm6125

C
3
star
37

libaperture-0

C
3
star
38

android_kernel_gigaset_mt6789

Moved to this address:
C
3
star
39

android_device_motorola_river_prebuiltvendor

Java
3
star
40

fake_crypt

Enable fingerprint on [email protected] devices
C++
3
star
41

android_kernel_teracube_mt6765

C
3
star
42

android_device_xiaomi_haydn

C++
2
star
43

nfcd

C
2
star
44

android_device_samsung_m31

Makefile
2
star
45

android_kernel_qcom_sm8450

C
2
star
46

android_packages_apps_MtkFMRadio

Java
2
star
47

geoclue

C
2
star
48

android_device_mediatek_sepolicy

Makefile
2
star
49

android_kernel_samsung_universal9610

C
2
star
50

sensorfw

C++
2
star
51

anbox-sensors

C++
2
star
52

android_external_wificonf

C++
2
star
53

allwinner_t3-p3_dump

Shell
2
star
54

motorola_racer_dump

Shell
2
star
55

android_device_xiaomi_sm6250-common

*deprecated* for new trees check link below
C++
2
star
56

Gradle-SystemUI

Kotlin
2
star
57

xorg-server

C
2
star
58

ubuntu-xenial

C
1
star
59

tecno_tecno-kf6j_dump

Shell
1
star
60

android_kernel-extra_qcom_sm8350

C
1
star
61

motorola_smith_dump

Shell
1
star
62

nfcd-pn54x-plugin

C
1
star
63

android_hardware_interfaces

C++
1
star
64

lg115x-kernel-netcast

C
1
star
65

libncicore

C
1
star
66

lxc-android

Shell
1
star
67

android_kernel_samsung_universal9810-star

C
1
star
68

moto_ims

Smali
1
star
69

android_kernel_oneplus_sdm845

C
1
star
70

samsung_a51_dump

Shell
1
star
71

gst-droid

C
1
star
72

cheese

C
1
star
73

libnciplugin

C
1
star
74

nfcd-binder-plugin

C
1
star
75

android_device_samsung_starlte

Makefile
1
star
76

lg115x-kernel-webos

Broken af
C
1
star
77

android_device_xiaomi_curtana

*deprecated* for new trees check link below
Makefile
1
star
78

proprietary_vendor_xiaomi2

Makefile
1
star
79

mobian-recipes

Shell
1
star
80

android_device_gigaset_GS5

Makefile
1
star
81

android_device_xiaomi_sm6150-common

C++
1
star
82

android_kernel_motorola_sm7250

*deprecated* for new trees check link below
C
1
star
83

android_device_samsung_a51

C++
1
star
84

proprietary_vendor_xiaomi_lavender

Makefile
1
star
85

android_device_samsung_crownlte

Makefile
1
star
86

hadess-sensorfw-proxy

C++
1
star
87

proprietary_vendor_samsung

Makefile
1
star
88

test_kernel

C
1
star
89

android_device_lg_lg1154

Makefile
1
star
90

android_external_gdbus

C
1
star