forked from Bin4ry/deejayeye-modder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunMe.bat
159 lines (159 loc) · 4.77 KB
/
RunMe.bat
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
cd /d %~dp0
set /p ver=<version.txt
set title=%~n0
TITLE %title%
for /f "tokens=1,* delims=. " %%F in ('dir /b patches\*.patch') do (
set "newvar=%%F"
set %newvar%_choice=,Yes,No,
call:setPersist "!newvar!=Yes"
)
set "p_out=patches_out"
set "d_out=decompile_out"
set "a_out=_NEW_APK"
rd /S /Q %p_out% >nul 2>&1
rd /S /Q %d_out% >nul 2>&1
rd /S /Q %a_out% >nul 2>&1
set pCounter=1
for /f "tokens=1,* delims=. " %%F in ('dir /b patches\*.patch') do (
set "newvar=%%F"
set %newvar%_choice=,Yes,No,
call:setPersist "!newvar!=No"
)
:menuLOOP
echo.
echo.-:=========================[ DeeJayEYE Patcher v%ver% ]==========================:-
echo. Options:
for /f "tokens=1,* delims=. " %%X in ('dir /b patches\*.patch') do (
set "newvar=%%X"
echo. [!pCounter!] '!%%X!' %%X
REM [!%newvar%_choice:~1,-1!] speshul
set patch!pCounter!=%%X
set /a pCounter=!pCounter!+1
)
color 08
call:sleep 1
color 07
set pCounter=1
echo.
echo. Help:
echo. [R]eadme
echo. [D]escriptions
echo.
echo. Execute:
echo. [P]atch apk
set choice=
echo.&set /p choice=-: [ENTER] choices: ||(
GOTO:EOF
)
cls
echo %choice%| findstr /r "^[1-9][0-9]*$">nul
if %errorlevel% equ 0 (
echo.&call:menu_PM
) else echo.&call:menu_%choice%
GOTO:menuLOOP
:menu_PM
call:getNextInList !patch%choice%! "!%newvar%_choice!"
cls
GOTO:EOF
:menu_R - View readme
more Readme.md
cls
GOTO:EOF
:menu_D - View patch descriptions
more Patch-Descriptions.txt
cls
GOTO:EOF
:menu_P - Start Patching
md %a_out%
md %p_out%
echo -: Converting patches...
rename "patches\origin" origin.patch
for /f "tokens=*" %%f in ('dir /b patches\*.patch') do (
copy patches\%%f %p_out%\%%f.copy >nul
TYPE "%p_out%\%%f.copy" | MORE /P > "%p_out%\%%f"
del /f /q %p_out%\%%f.copy
)
rename "patches\origin.patch" origin
echo -: Decompiling original apk...
IF EXIST PutApkHere\orig.apk (
java -jar tools\apktool.jar d -o %d_out% PutApkHere\orig.apk
) ELSE (
echo -:
echo -: FATAL ERROR '\PutApkHere\orig.apk' NOT FOUND
echo -:
pause
exit
)
cd %d_out%
..\tools\patch -l -s -p1 -N -r - < ..\%p_out%\origin.patch
for /f "tokens=1,* delims=. " %%f in ('dir /b ..\%p_out%\*.patch') do (
if /i "!%%f:~0,1!"=="Y" (
echo -: Applying %%f patch...
..\tools\patch -l -s -p1 -N -r - < ..\%p_out%\%%f.patch
if "%%f"=="removeOnlinefunction" (
echo -: Supporting with so.bspatch...
..\tools\bspatch lib\armeabi-v7a\libSDKRelativeJNI.so lib\armeabi-v7a\libSDKRelativeJNI-n.so ..\patches\so.bspatch
del /f /q "lib\armeabi-v7a\libSDKRelativeJNI.so"
rename "lib\armeabi-v7a\libSDKRelativeJNI-n.so" libSDKRelativeJNI.so
)
)
)
REM nothing
REM here
cd ..
echo -: Rebuilding apk...
java -jar tools\apktool.jar b -o %a_out%\mod.apk %d_out%
echo -: Signing with testkey...
java -jar tools\sign.jar %a_out%\mod.apk
del /f /q %a_out%\mod.apk
move %a_out%\mod.s.apk %a_out%\mod-%ver%.apk >nul
echo -: Cleaning up...
rd /S /Q %d_out%
rd /S /Q %p_out%
echo -: "Have fun and stay safe!"
pause
exit
GOTO:EOF
::-----------------------------------------------------------
:: helpers here
::-----------------------------------------------------------
:sleep -– waits some seconds before returning
:: -- %~1 – in, number of seconds to wait
FOR /l %%a in (%~1,-1,1) do (ping -n 2 -w 1 127.0.0.1>NUL)
GOTO:EOF
:setPersist -- to be called to initialize persistent variables
:: -- %*: set command arguments
set %*
GOTO:EOF
:getPersistentVars -- returns a comma separated list of persistent variables
:: -- %~1: reference to return variable
SETLOCAL
set retlist=
set parse=findstr /i /c:"call:setPersist" "%~f0%"^|find /v "ButNotThisLine"
for /f "tokens=2 delims== " %%a in ('"%parse%"') do (set retlist=!retlist!%%a,)
( ENDLOCAL & REM RETURN VALUES
IF "%~1" NEQ "" SET %~1=%retlist%
)
GOTO:EOF
:getNextInList -- return next value in list
:: -- %~1 - in/out ref to current value, returns new value
:: -- %~2 - in choice list, must start with delimiter which must not be '@'
SETLOCAL
set lst=%~2& rem.-- get the choice list
if "%lst:~0,1%" NEQ "%lst:~-1%" echo.ERROR Choice list must start and end with the delimiter&GOTO:EOF
set dlm=%lst:~-1%& rem.-- extract the delimiter used
set old=!%~1!& rem.-- get the current value
set fst=&for /f "delims=%dlm%" %%a in ("%lst%") do set fst=%%a&rem.--get the first entry
rem.-- replace the current value with a @, append the first value
set lll=!lst:%dlm%%old%%dlm%=%dlm%@%dlm%!%fst%%dlm%
rem.-- get the string after the @
for /f "tokens=2 delims=@" %%a in ("%lll%") do set lll=%%a
rem.-- extract the next value
for /f "delims=%dlm%" %%a in ("%lll%") do set new=%%a
( ENDLOCAL & REM RETURN VALUES
IF "%~1" NEQ "" (SET %~1=%new%) ELSE (echo.%new%)
)
GOTO:EOF