-
Notifications
You must be signed in to change notification settings - Fork 4
/
easy-build-xinit.cmd
308 lines (263 loc) · 9.6 KB
/
easy-build-xinit.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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
@echo off
cd /d %~d0
REM
REM UAC elevation
REM I found this method to elevate the script to admin here: https://stackoverflow.com/a/12264592
REM I chose it because it is what my Windows 10 Toolbox uses, and works well!
REM
:init
setlocal DisableDelayedExpansion
set cmdInvoke=1
set winSysFolder=System32
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO.
ECHO Invoking UAC for Privilege Escalation
ECHO.
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
if '%cmdInvoke%'=='1' goto InvokeCmd
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
goto ExecElevation
:InvokeCmd
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
:ExecElevation
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
:ebinit
if NOT exist "%~d0\xbox\public\tools\easybuild.conf" goto eb-start
if exist "%~d0\xbox\public\tools\easybuild.conf" goto eb-load-config
rem if NOT exist "%~dp0\easy-build_1strun.complete" goto eb-start
rem if exist "%~dp0\easy-build_1strun.complete" goto eb-xbox-checks
:eb-load-config
set "_EBConf=%~dp0\xbox\public\tools\easybuild.conf"
set "_FIRST_RUN="
for /F "skip=1 delims=" %%i in (%_EBConf%) do if not defined _FIRST_RUN set "_FIRST_RUN=%%i"
echo First Run = %_FIRST_RUN%
echo.
set "_CPXXUPD_DONE="
for /F "skip=1 delims=" %%i in (%_EBConf%) do if not defined _CPXXUPD_DONE set "_CPXXUPD_DONE=%%i"
echo Complex = %_CPXXUPD_DONE%
echo.
goto eb-xbox-checks
:eb-start
cd /d %~dp0
Title Easy-Build Environment for Xbox
echo --------------------------------------------------------
echo Welcome to Easy-Build Environment for XBOX Original
echo.
echo -- In constant testing --
echo This script sets up the source tree and creates
echo your Razzle 'Profile'. Then will load
echo Easy-Build. Run this script to load each time.
echo.
echo This tool focuses on a source tree without COMPLEX patches..
echo Based off of the 'xbox trunk.rar' that's with 'CPXXUPD.RAR'
echo If you want to use with a different tree, check the Wiki
echo On the Github page on how.
echo.
echo --------------------------------------------------------
echo Make sure your dir structure is as follows:
echo.
echo %~d0
echo \easy-build-xinit.cmd
echo \xbox \
echo \private\
echo \public\
echo
echo.
echo Requirements:
echo - Freshly extracted source (xbox_leak_may_2020.7z/xbox trunk.rar))
echo - Layout as above and unmodified in the structure above
echo - Free space
echo - Patience
echo.
echo If you are using the VHD image, this will already be setup for you..
pause
rem echo First run complete! delete this file to show 'First Run' screen >> %~dp0\easy-build_1strun.complete
rem test settings
echo [FIRST_RUN] > %~d0\xbox\public\tools\easybuild.conf
echo 1 >> %~d0\xbox\public\tools\easybuild.conf
set _FIRST_RUN=1
goto eb-xbox-checks
:eb-xbox-checks
REM
REM
REM SIMPLE IF STATEMENTS TO CHECK IF THE SOURCE AND CPXXUPD FOLDERS ARE SET-UP
REM
REM
REM
echo Now running some checks..
echo.
if NOT exist "%~d0\xbox\private" echo Xbox Source not setup correctly&& pause&& exit
if NOT exist "%~d0\xbox\public" echo Xbox Source not setup correctly&& pause&& exit
if exist "%~d0\xbox\private" goto eb-xbox-init-check
:eb-xbox-init-check
REM
REM
REM ADD CHECK FOR ALREADY PATCHED SOURCE OR IF TO BE PATCHED
if exist "%~d0\easy-build_1strun.complete" goto remoldconfig
if NOT exist "%~d0\xbox\PRIVATE\DEVELOPR\%username%\" (goto eb-setup-cpxxupd) else (goto eb-xbox-mainmenu-init)
REM
REM
:remoldconfig
REM
REM Remove old config files if exist and switch to easybuild.conf
REM
if exist "%~d0\easy-build_1strun.complete" del "%~d0\easy-build_1strun.complete"
if exist "%~d0\xbox\public\tools\cpxxupd_done.txt" del "%~d0\xbox\public\tools\cpxxupd_done.txt"
echo [FIRST_RUN] > %~d0\xbox\public\tools\easybuild.conf
echo 1 >> %~d0\xbox\public\tools\easybuild.conf
set _FIRST_RUN=1
echo [CPXXUPD_DONE] >> %~dp0\xbox\public\tools\easybuild.conf
echo 1 >> %~dp0\xbox\public\tools\easybuild.conf
echo [BVT_ADDRESS] >> %~dp0\xbox\public\tools\easybuild.conf
echo \\tsclient\D >> %~dp0\xbox\public\tools\easybuild.conf
echo [BVT_KERNEL_ONLY] >> %~dp0\xbox\public\tools\easybuild.conf
echo 1 >> %~dp0\xbox\public\tools\easybuild.conf
echo [XBOX_DEBUG_IP] >> %~dp0\xbox\public\tools\easybuild.conf
echo 192.168.0.5 >> %~dp0\xbox\public\tools\easybuild.conf
echo [XBOX_TITLE_IP] >> %~dp0\xbox\public\tools\easybuild.conf
echo 192.168.0.3 >> %~dp0\xbox\public\tools\easybuild.conf
goto eb-xbox-mainmenu-init
:eb-setup-cpxxupd
if exist "%ebntroot%\PRIVATE\DEVELOPR\%username%\" echo Setup already complete && goto xbox-dorazzle
echo.
echo Easy-Build detected the source tree needs configuring.
echo Cleaning leftover files and creating profile..
echo.
goto eb-cpxxupd
:eb-cpxxupd
if /i "%_CPXXUPD_DONE%" == "1" goto eb-xbox-mainmenu-init
setlocal
set _location_=%~d0\xbox
REM CleanUp
del /f /q "%_location_%\private\p_build.cmd"
del /f /q "%_location_%\private\windbg.lnk"
del /s /f /q "%_location_%\copy *"
del /s /f /q "%_location_%\shortcut *"
del /s /f /q "%_location_%\public\idw\rombld.exe"
rmdir /s /q "%_location_%\private\developr\template\old"
if exist "%_location_%\public\lib-mar02\d3d8i.lib" (
copy "%_location_%\public\lib-mar02\d3d8i.lib" "%_location_%\public\lib"
)
rem Test config
echo [CPXXUPD_DONE] >> %~dp0\xbox\public\tools\easybuild.conf
echo 1 >> %~dp0\xbox\public\tools\easybuild.conf
REM Finish setup of .conf with 'default' settings.
echo [BVT_ADDRESS] >> %~dp0\xbox\public\tools\easybuild.conf
echo \\tsclient\D >> %~dp0\xbox\public\tools\easybuild.conf
echo [BVT_KERNEL_ONLY] >> %~dp0\xbox\public\tools\easybuild.conf
echo 1 >> %~dp0\xbox\public\tools\easybuild.conf
echo [XBOX_DEBUG_IP] >> %~dp0\xbox\public\tools\easybuild.conf
echo 192.168.0.5 >> %~dp0\xbox\public\tools\easybuild.conf
echo [XBOX_TITLE_IP] >> %~dp0\xbox\public\tools\easybuild.conf
echo 192.168.0.3 >> %~dp0\xbox\public\tools\easybuild.conf
endlocal
goto eb-setup-profile
:eb-setup-profile
echo.
echo Creating Razzle profile
cd /d %~d0\XBOX\PRIVATE\DEVELOPR\TEMPLATE\
goto xbox-initrazzle
REM Contents of 'xbox\private\developr\template\initrazzle.cmd' adapted for Easy-Build
:xbox-initrazzle
setlocal
set _drive_=%~d0
set _ntroot_=xbox
set _drive_=ntroot
if /i "%_drive%" == "ntroot" set _ntroot_=xbox& shift& shift
xcopy /f %~d0\xbox\private\developr\template %~d0\xbox\private\developr\%username%\
cd /d %~d0\xbox\private\developr\%username%
move cuep-sample.pri cuep.pri
move setenvp-sample.cmd setenvp.cmd
move setchkp-sample.cmd setchkp.cmd
move setfrep-sample.cmd setfrep.cmd
move tools-sample.ini tools.ini
set _ntdrive=%_drive_%
set _ntbindir=%_drive_%\%_ntroot_%
endlocal
echo Loading Razzle
goto eb-xbox-mainmenu-init
:eb-xbox-mainmenu-init
cd /d %~d0\XBOX\PRIVATE\DEVELOPR\%username%\
goto xbox-dorazzle
REM Contents of 'xbox\private\developr\%username%\dorazzle.cmd' adapted for Easy-Build
rem fixed the invalid paths to 'idw' and 'mstools'
:xbox-dorazzle
REM
REM Set _NTDrive
REM
set _NTDrive=%~d0
REM
REM Set _NTRoot
REM
set _NTRoot=\xbox
REM
REM Support Win64
REM
if /i "%1" == "WIN64" (
set _NTWIN64=1
shift
)
REM
REM Add MSTOOLS, IDW and PUBLIC\TOOLS to the path if not in system directory.
REM
if exist "%_NTDrive%%_NTRoot%\public\mstools" (
set "MSTOOLS_DIR=%_NTDrive%%_NTRoot%\public\mstools"
set "PATH=%PATH%;%_NTDrive%%_NTRoot%\public\mstools"
)
if exist "%_NTDrive%%_NTRoot%\public\idw" (
set "IDW_DIR=%_NTDrive%%_NTRoot%\public\idw"
set "PATH=%PATH%;%_NTDrive%%_NTRoot%\public\idw"
)
if exist "%_NTDrive%%_NTRoot%\public\tools" (
set "PATH=%PATH%;%_NTDrive%%_NTRoot%\public\tools"
)
REM This adds the Barnabus Repack's BIOSpack to the PATH variable so it can be called easy
if exist "%_NTDrive%%_NTRoot%\public\idw\biospack" set "PATH=%PATH%;%_NTDrive%%_NTRoot%\public\idw\biospack"
goto ebhandover
:ebhandover
rem
rem
cls
echo.
echo Razzle will now start.
echo.
echo Please type "easybuild" without quotes or type:
echo.
echo - easybuild free //For FREE Devkit build
echo - easybuild free xm3 //For FREE Retail build
echo - easybuild chk //For CHK DevKit Build
echo - easybuild chk xm3 //For CHK Retail Build
echo.
echo NOTE: You need to build FREE before CHK. CHK is UNTESTED
echo with the latest patches in the repo
echo.
echo NOTE: Easy-Build will always set the default build to:
echo FREE NODEVKIT if no options specified
echo.
pause
goto INVOKEIT
:INVOKEIT
REM
REM Invoke RAZZLE.CMD, which does the real work of setting up the Razzle window.
REM
if /i "%PROCESSOR_ARCHITECTURE%" == "AMD64" set PROCESSOR_ARCHITECTURE=x86
cls
cmd.exe /k "%_NTDrive%%_NTRoot%\public\tools\razzle.cmd %~d0 NTROOT \XBOX SETFRE"