This repository was archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.bat
More file actions
223 lines (191 loc) · 7.08 KB
/
patch.bat
File metadata and controls
223 lines (191 loc) · 7.08 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:top
CLS
COLOR 1F
set currentversion=v1.0.3
set header=echo RiiConnect24 IOS Patcher %currentversion% by WiiDatabase.de
mode con cols=85 lines=30
TITLE RiiConnect24 IOS Patcher %currentversion%
:check
if not exist Support\IOS31.diff goto:missing
if not exist Support\IOS80.diff goto:missing
if not exist Support\nusd.exe goto:missing
if not exist Support\sfk.exe goto:missing
if not exist Support\xdelta3.exe goto:missing
goto:start
:missing
CLS
%header%
echo.
echo.
echo ERROR: One or more support files are missing.
echo Please check the download and redownload
echo if necessary.
echo.
echo Also, do not run the patcher as an administrator.
echo.
echo Press any key to close the patcher.
pause >NUL
exit
:start
CLS
%header%
echo.
if /i "%false%" EQU "1" Support\sfk echo -spat \x20 \x20 \x20 \x20 \x20 \x20 [Red] Not a valid input, please try again.
set false=
set islatest=
echo.
echo Welcome to the RiiConnect24 IOS Patcher!
echo.
Support\sfk echo -spat \x20 \x20 \x20 \x20 \x20 \x20 [Yellow] PLEASE NOTE: This patcher will ONLY work on the Wii^^!
Support\sfk echo -spat \x20 \x20 \x20 \x20 \x20 \x20 [Yellow] Do not install these IOS on a Wii U^^!
echo.
echo Do you have System Menu 4.3 installed and want to use Wii Mail?
echo In this case, IOS80 will also be patched.
echo.
echo.
echo [Y] Yes
echo [N] No
echo [0] Exit
echo.
set /p islatest= Input:
if /i "%islatest%" EQU "Y" (set ios31=*) && (set ios80=*) && (set nof=2) && (goto:downloadios)
if /i "%islatest%" EQU "N" (set ios31=*) && (set ios80=) && (set nof=1) && (goto:downloadios)
if /i "%islatest%" EQU "0" exit
set false=1
goto:start
:downloadios
CLS
%header%
echo.
echo.
set failed=0
:setvariables
set attempt=1
if /i "%ios31%" EQU "*" goto:ios31
if /i "%ios80%" EQU "*" goto:ios80
goto:alldownloadsfinished
:: Set variables for downloads
::
:: name = Name of the WAD (will append "-patched" for patched WADs)
:: namedl = Shown name of the download
:: titleid = TitleID of the IOS from NUS
:: titleversion = TitleID of the IOS (do not leave it blank!)
:: md5 = MD5 of the download - please use NUSD 1.9 Mod, not the NUSD Command Line 0.2 from ModMii!
:: patched_md5 = MD5 of the patched WAD
:: variable = Variable of the download (which is set to "*" earlier)
:ios31
set name=IOS31
set namedl=IOS31 Latest Version
set titleid=000000010000001F
set titleversion=3608
set md5=7908ce72ed970b9610d817dd71807a84
set patched_md5=a4dfbb1c46fdd815eefbd9c463f6ed63
set variable=ios31
goto:startdownload
:ios80
set name=IOS80
set namedl=IOS80 v6944
set titleid=0000000100000050
set titleversion=6944
set md5=a845fbe6d788f3a5c65ce624096150f4
set patched_md5=2514cfb7e9c6b566d8db4fe165e711c6
set variable=ios80
goto:startdownload
:startdownload
if /i "%attempt%" EQU "4" goto:failed
if /i "%attempt%" EQU "1" Support\sfk echo -spat \x20 \x20 [Magenta] Downloading %namedl%...
if /i "%attempt%" NEQ "1" Support\sfk echo -spat \x20 \x20 [Magenta] Redownloading %namedl%...
if /i "%existsbutinvalid%" EQU "*" (set /a attempt=%attempt%-1) && (set existsbutinvalid=)
if not exist copy-to-device\%name%-patched.wad goto:notexistpatched
:: Verify MD5, if patched WAD already exists
set md5check=
support\sfk md5 -quiet -verify %patched_md5% copy-to-device\%name%-patched.wad
if errorlevel 1 (set md5check=fail) else (set md5check=pass)
if /i %md5check% EQU fail (support\sfk echo -spat \x20 \x20 [Yellow] Patched file already exists, but failed the MD5 check.) && (support\sfk echo -spat \x20 \x20 [Yellow] Deleting the file and redownloading/repatching...) && (del copy-to-device\%name%-patched.wad)
if /i %md5check% EQU pass (support\sfk echo -spat \x20 \x20 [Green] File is already patched and valid^^!) && (set %variable%=)
echo.
goto:setvariables
:notexistpatched
:: Patched WAD doesn't exist, download base WAD first
if not exist tmp mkdir tmp
if not exist tmp\%name%.wad goto:download
set md5check=
support\sfk md5 -quiet -verify %md5% tmp\%name%.wad
if errorlevel 1 set md5check=fail
IF "%md5check%"=="" (set md5check="exists") && (goto:pass)
support\sfk echo -spat \x20 \x20 [Yellow] This file already exists, but it failed the MD5 check.
support\sfk echo -spat \x20 \x20 [Yellow] The current file will be deleted and the file will be redownloaded.
echo.
set /a attempt=%attempt%+1
set existsbutinvalid=*
del tmp\%name%.wad >NUL
if exist titles\%titleid% rmdir /s /q titles\%titleid%
goto:startdownload
:download
:: Downloading base WAD
start /min/wait Support\nusd.exe %titleid% %titleversion% packwad
if exist titles\%titleid%\%titleversion%\%titleid%-NUS-v%titleversion%.wad move /y titles\%titleid%\%titleversion%\%titleid%-NUS-v%titleversion%.wad tmp\%name%.wad >NUL
if exist titles\%titleid% rd /s /q titles\%titleid%
if exist tmp\%name%.wad goto:checkdownload
support\sfk echo -spat \x20 \x20 [Yellow] The file is missing, retrying download...
echo.
set /a attempt=%attempt%+1
if exist tmp\%name%.wad del tmp\%name%.wad
goto:startdownload
:checkdownload
:: Check MD5 of the download
set md5check=
support\sfk md5 -quiet -verify %md5% tmp\%name%.wad
if errorlevel 1 set md5check=fail
IF "%md5check%"=="" (set md5check=pass) && (goto:pass)
support\sfk echo -spat \x20 \x20 [Yellow] The MD5 check failed.
support\sfk echo -spat \x20 \x20 [Yellow] The current file will be deleted and the file will be redownloaded.
echo.
set /a attempt=%attempt%+1
del tmp\%name%.wad >NUL
if exist titles\%titleid% rd /s /q titles\%titleid%
goto:startdownload
:pass
:: Base WAD already exists and passed the MD5 check or download of the base WAD finished
if /i %md5check% EQU "exists" (support\sfk echo -spat \x20 \x20 [Green] This file already exists and has passed the MD5 check^^!) else (support\sfk echo -spat \x20 \x20 [Green] Download finished^^!)
echo.
:patching
:: Patch base WADs
Support\sfk echo -spat \x20 \x20 [Magenta] Patching %namedl%...
if not exist copy-to-device mkdir copy-to-device
start /min/wait Support\xdelta3.exe -d -s tmp\%name%.wad Support\%name%.diff copy-to-device\%name%-patched.wad
if not exist copy-to-device\%name%-patched.wad goto:patchfailed
support\sfk echo -spat \x20 \x20 [Green] Patching done^^!
echo.
set %variable%=
goto:setvariables
:patchfailed
:: Patching of the base WAD failed
if /i "%attempt%" EQU "1" Support\sfk echo -spat \x20 \x20 [Red] Patching failed, skipping...
echo.
set /a failed=%failed%+1
set %variable%=
goto:setvariables
:failed
:: Download of the base WAD failed mutiple times
support\sfk echo -spat \x20 \x20 [Red] This file failed to download multiple times, skipping...
set /a failed=%failed%+1
set %variable%=
echo.
goto:setvariables
:alldownloadsfinished
:: All downloads finished
if exist titles rd /s /q titles
echo.
if /i %failed% EQU %nof% (support\sfk echo -spat \x20 \x20 [Red] All downloads failed, please check your connection!) && (goto:miniskip)
if /i %failed% GTR 0 (support\sfk echo -spat \x20 \x20 [Yellow] Finished, but with errors.) else (support\sfk echo -spat \x20 \x20 [Green] Everything finished^^!)
echo.
echo You can find the patched file(s) in the "copy-to-device" folder.
echo Install it/them with a WAD manager.
:miniskip
echo.
echo Press any key to close this patcher.
pause >NUL
exit