-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathprevent_patch.cmd
134 lines (125 loc) · 3.81 KB
/
prevent_patch.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@echo off
setlocal
set sdk=%1
set bin=%~dsp0
:main
if "%sdk%"=="19" goto :common
if "%sdk%"=="20" goto :common
if "%sdk%"=="21" goto :sdk21
if "%sdk%"=="22" goto :sdk22
if "%sdk%"=="23" goto :common
if "%sdk%"=="24" goto :common
if "%sdk%"=="25" goto :common
if "%sdk%"=="26" goto :sdk26
if "%sdk%"=="27" goto :sdk27
if "%sdk%"=="28" goto :sdk28
:help
echo.
echo Usage: prevent_patch.cmd ^<sdk-version^>.
echo.
echo sdk-version:
echo 19: Android 4.4 KitKat
echo 20: Android 4.4W
echo 21: Android 5.0 Lollipop
echo 22: Android 5.1 Lollipop
echo 23: Android 6.0 Marshmallow
echo 24: Android 7.0 Nougat
echo 25: Android 7.1 Nougat
echo 26: Android 8.0 Oreo
echo 27: Android 8.1 Oreo
echo 28: Android 9.0 Pie
exit /b
:sdk21
:sdk22
if exist work_dir\odex\boot if exist work_dir\odex\services.odex (
cd work_dir\odex
echo Extracting boot.oat services.odex...
java -Xmx800m -jar "%bin%oat2dex.jar" boot boot.oat
java -Xmx800m -jar "%bin%oat2dex.jar" services.odex dex
cd ..
java -Xmx800m -jar "%bin%baksmali.jar" d odex\services.dex -o services
echo Patching...
python "%bin%patch.py" -a "%bin%apk" -s services
echo Packaging^(1/2^)...
java -Xmx800m -jar "%bin%smali.jar" a -o classes.dex services
echo Packaging^(2/2^)...
jar -cvf services-p.jar classes.dex
exit /b
)
goto :common
:sdk26
:sdk27
if exist work_dir\odex\services.vdex (
cd work_dir\odex
echo Extracting services.vdex...
"%bin%vdexExtractor" -f --ignore-crc-error -v 2 -i services.vdex
cd ..
java -Xmx800m -jar "%bin%baksmali.jar" d odex\services_classes.dex -o services
echo Patching...
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
echo Packaging^(1/2^)...
java -Xmx800m -jar "%bin%smali.jar" a -o classes.dex services
echo Packaging^(2/2^)...
jar -cvf services-p.jar classes.dex
exit /b
)
goto :common
:sdk28
if exist work_dir\odex\services.vdex (
cd work_dir\odex
echo Extracting services.vdex...
"%bin%vdexExtractor" -f --ignore-crc-error -v 2 -i services.vdex
cd "%bin%"
flinux compact_dex_converter_linux_32 work_dir\odex\services_classes.cdex
cd work_dir
java -Xmx800m -jar "%bin%baksmali.jar" d odex\services_classes.cdex.new -o services
echo Patching...
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
echo Packaging^(1/2^)...
java -Xmx800m -jar "%bin%smali.jar" a -o classes.dex services
echo Packaging^(2/2^)...
jar -cvf services-p.jar classes.dex
exit /b
)
goto :common
:common
if exist work_dir\odex\services.odex (
cd work_dir
echo Extracting services.odex...
java -Xmx800m -jar "%bin%baksmali.jar" x -d odex odex\services.odex -o services
echo Patching...
if "%sdk%"=="26" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else if "%sdk%"=="27" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else if "%sdk%"=="28" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else (
python "%bin%patch.py" -a "%bin%apk" -s services
)
echo Packaging^(1/2^)...
java -Xmx800m -jar "%bin%smali.jar" a -o classes.dex services
echo Packaging^(2/2^)...
jar -cvf services-p.jar classes.dex
exit /b
)
if exist work_dir\services.jar (
cd work_dir
echo Extracting service.jar...
java -Xmx800m -jar "%bin%baksmali.jar" d services.jar -o services
echo Patching...
if "%sdk%"=="26" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else if "%sdk%"=="27" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else if "%sdk%"=="28" (
python "%bin%patch_oreo.py" -a "%bin%apk_oreo" -s services
) else (
python "%bin%patch.py" -a "%bin%apk" -s services
)
echo Packaging^(1/2^)...
java -Xmx800m -jar "%bin%smali.jar" a -o classes.dex services
echo Packaging^(2/2^)...
jar -cvf services-p.jar classes.dex
exit /b
)