Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

543 lines
20 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM SCP_WPAFiles.CMD - SCP (Secure Code Processor) Windows Product Activation bits every build
  4. REM
  5. REM Script Owner : CaglarG (Windows)
  6. REM SCP tool (VSP.exe) Owner : MariuszJ (MSR)
  7. REM
  8. REM
  9. REM Copyright (c) Microsoft Corporation. All rights reserved.
  10. REM
  11. REM ------------------------------------------------------------------
  12. if defined _CPCMAGIC goto CPCBegin
  13. perl -x "%~f0" %*
  14. goto :EOF
  15. #!perl
  16. use strict;
  17. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  18. use lib $ENV{RAZZLETOOLPATH};
  19. use PbuildEnv;
  20. use ParseArgs;
  21. sub Usage { print<<USAGE; exit(1) }
  22. SCP_WPAFiles
  23. Obfuscates WPA code on system binaries (x86 only)
  24. USAGE
  25. parseargs('?' => \&Usage);
  26. # *** NEXT FEW LINES ARE TEMPLATE ***
  27. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  28. __END__
  29. :CPCBegin
  30. set _CPCMAGIC=
  31. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  32. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  33. REM
  34. REM
  35. :CheckArchitecture
  36. REM
  37. REM Only SCP files for X86 builds for now. We don't have any code in Win64
  38. REM
  39. if /i "%_BuildArch%" == "x86" goto PreSCP
  40. :NoSCP
  41. REM
  42. REM SCP is needed only on x86 platforms, because WPA files do not exist on 64 bit.
  43. REM However this may change in the future.
  44. REM
  45. REM NOTE NOTE NOTE: If this changes, update SwapInOriginalFiles.cmd
  46. REM
  47. call logmsg.cmd "SCP can only run on x86..."
  48. goto end
  49. REM
  50. REM Pseudecode of this script;
  51. REM Create PreBBT, PostBBT, SCPTemp and SCPed subdirectories under %_NTPostBld%\SCP_WPA directory
  52. REM For each dpcdll version in different directories
  53. REM set FILE_ALREADYSCPed to zero
  54. REM Create a subdirectory called %_NTPostBld%\SCP_WPA\%SKUDirs%
  55. REM IF prebbt version of the file exists THEN (i.e. file is bbtized)
  56. REM
  57. REM IF binary is not SCPed THEN
  58. REM copy it to %_NTPostBld%\SCP_WPA\prebbt directory
  59. REM ELSE
  60. REM do nothing
  61. REM Rename scpconfig_XYZ_bbt.ini file to scpconfig.XYZ.ini
  62. REM
  63. REM ELSE /* i.e. File is not bbtized */
  64. REM IF binary is not SCPed THEN
  65. REM copy it to %_NTPostBld%\SCP_WPA\postbbt directory
  66. REM ELSE
  67. REM increment FILE_ALREADYSCPed by 1
  68. REM Rename scpconfig_XYZ_NObbt.ini file to scpconfig.XYZ.ini
  69. REM
  70. REM IF FILE_ALREADYSCPed == 0
  71. REM Run MSR tool to SCP the binary
  72. REM IF file is NOT SCPED THEN
  73. REM Save scpwebdebug log file to another name
  74. REM Goto WPAERROR
  75. REM ELSE
  76. REM Save scpwebdebug log file to another name
  77. REM Save copy of SCPed binary and pdb to %_NTPostBld%\SCP_WPA\SCPed directory
  78. REM
  79. REM Binplace the binary
  80. REM Strip the symbols
  81. REM
  82. REM ELSE
  83. REM Do nothing
  84. REM
  85. REM
  86. REM For non-version specific WPA binaries (e.g. licwmi, licdll, winlogon);
  87. REM
  88. REM set FILE_ALREADYSCPed to zero
  89. REM IF prebbt version of the file exists THEN (i.e. file is bbtized)
  90. REM
  91. REM IF binary is not SCPed THEN
  92. REM copy it to %_NTPostBld%\SCP_WPA\prebbt directory
  93. REM ELSE
  94. REM do nothing
  95. REM Rename scpconfig_XYZ_BBT.ini file to scpconfig.XYZ.ini
  96. REM
  97. REM ELSE /* i.e. File is not bbtized */
  98. REM IF binary is not SCPed THEN
  99. REM copy it to %_NTPostBld%\SCP_WPA\postbbt directory
  100. REM ELSE
  101. REM increment FILE_ALREADYSCPed by 1
  102. REM Rename scpconfig_XYZ_NOBBT.ini file to scpconfig.XYZ.ini
  103. REM
  104. REM IF FILE_ALREADYSCPed == 0
  105. REM Run MSR tool to SCP the binary
  106. REM IF file is NOT SCPED THEN
  107. REM Save scpwebdebug log file to another name
  108. REM Goto WPAERROR
  109. REM ELSE
  110. REM Save scpwebdebug log file to another name
  111. REM Save copy of SCPed binary and pdb to %_NTPostBld%\SCP_WPA\SCPed directory
  112. REM
  113. REM Strip the symbols <--- These steps are different in dpcdll above
  114. REM Binplace the binary <--- These steps are different in dpcdll above
  115. REM
  116. REM ELSE
  117. REM Do nothing
  118. REM
  119. REM
  120. :PreSCP
  121. REM
  122. REM Initializations, Pre-SCP work
  123. REM
  124. REM
  125. REM Set path for VSP21 and other files required for SCP
  126. REM
  127. set PATH=%PATH%;%_NTPostBld%\SCP_WPA\PreBBT;%_NTPostBld%\SCP_WPA\PostBBT
  128. REM
  129. REM Wade Lamble provided the paths
  130. REM
  131. set WPAPreBBTFileDir=%_NTPostBld%\pre-bbt
  132. set WPAPreBBTPDBFileDir=%_NTPostBld%\pre-bbt\pdbs
  133. call logmsg.cmd "Checking SCP_WPA directory..."
  134. if not exist %_NTPostBld%\SCP_WPA (
  135. call logmsg.cmd "WARNING: %_NTPostBld%\SCP_WPA does not exist. Make sure you ran bz in ds\security\licensing\vsp directory"
  136. goto end
  137. )
  138. call logmsg.cmd "Creating SCP directories..."
  139. call ExecuteCmd.cmd "if not exist %_NTPostBld%\SCP_WPA\PreBBT md %_NTPostBld%\SCP_WPA\PreBBT"
  140. if "!errorlevel!" == "1" goto WPAError
  141. call ExecuteCmd.cmd "if not exist %_NTPostBld%\SCP_WPA\PostBBT md %_NTPostBld%\SCP_WPA\PostBBT"
  142. if "!errorlevel!" == "1" goto WPAError
  143. call ExecuteCmd.cmd "if not exist %_NTPostBld%\SCP_WPA\SCPTemp md %_NTPostBld%\SCP_WPA\SCPTemp"
  144. if "!errorlevel!" == "1" goto WPAError
  145. call ExecuteCmd.cmd "if not exist %_NTPostBld%\SCP_WPA\SCPed md %_NTPostBld%\SCP_WPA\SCPed"
  146. if "!errorlevel!" == "1" goto WPAError
  147. pushd %_NTPostBld%\SCP_WPA
  148. REM
  149. REM If WPA file is different between SKUs and there is select/retail difference then following section does handle
  150. REM postprocess.
  151. REM
  152. set SKUDependentDlls=dpcdll
  153. set SKUDirs=. perinf srvinf select.wpa.wksinf select.wpa.srvinf eval.wpa.wksinf mantis
  154. set SymbolDllDir=%_NTPostBld%\symbols.pri
  155. for %%a in (%SKUDirs%) do (
  156. set /a FILE_ALREADYSCPed=0
  157. call ExecuteCmd.cmd "if not exist %_NTPostBld%\SCP_WPA\SCPTemp\%%a md %_NTPostBld%\SCP_WPA\SCPTemp\%%a"
  158. if "!errorlevel!" == "1" goto WPAError
  159. if exist %WPAPreBBTFileDir%\%%a\%SKUDependentDlls%.dll (
  160. call logmsg.cmd "%SKUDependentDlls%.dll is BBTized. Copying Pre-BBT %SKUDependentDlls% file..."
  161. link -dump -headers %WPAPreBBTFileDir%\%%a\%SKUDependentDlls%.dll | findstr /i /c:"21315.20512 image version" > nul
  162. if "!errorlevel!" == "1" (
  163. call ExecuteCmd.cmd "copy %WPAPreBBTFileDir%\%%a\%SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\PreBBT /Y"
  164. if "!errorlevel!" == "1" goto WPAError
  165. call ExecuteCmd.cmd "copy %WPAPreBBTPDBFileDir%\%%a\%SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  166. if "!errorlevel!" == "1" goto WPAError
  167. ) else (
  168. call logmsg.cmd "Prebbt version of %%a\%SKUDependentDlls%.dll already SCPed, so do not overwrite un-scped copy."
  169. )
  170. call logmsg.cmd "%%a\%SKUDependentDlls%.dll is BBTized. Copying Post-BBT %%a\%SKUDependentDlls% file..."
  171. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a\%SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\SCPTemp\%%a /Y"
  172. if "!errorlevel!" == "1" goto WPAError
  173. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a\dll\%SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\SCPTemp\%%a /Y"
  174. if "!errorlevel!" == "1" goto WPAError
  175. link -dump -headers %_NTPostBld%\%%a\%SKUDependentDlls%.dll | findstr /i /c:"21315.20512 image version" > nul
  176. if "!errorlevel!" == "1" (
  177. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a\%SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\PostBBT /Y"
  178. if "!errorlevel!" == "1" goto WPAError
  179. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a\dll\%SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\PostBBT /Y"
  180. if "!errorlevel!" == "1" goto WPAError
  181. ) else (
  182. call logmsg.cmd "BBTized version of %%a\%SKUDependentDlls%.dll already SCPed, so do not overwrite un-scped copy."
  183. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  184. )
  185. call logmsg.cmd "%%a\%SKUDependentDlls%.dll is BBTized. Copying config file..."
  186. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%SKUDependentDlls%_BBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%SKUDependentDlls%.ini /Y"
  187. if "!errorlevel!" == "1" goto WPAError
  188. ) else (
  189. call logmsg.cmd "Check if %%a\%SKUDependentDlls%.dll is SCPed..."
  190. link -dump -headers %_NTPostBld%\%%a\%SKUDependentDlls%.dll | findstr /i /c:"21315.20512 image version" > nul
  191. if "!errorlevel!" == "1" (
  192. call logmsg.cmd "%%a\%SKUDependentDlls%.dll is NOT BBTized and NOT SCPed. Copying Pre-BBT %%a\%SKUDependentDlls% file..."
  193. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a\%SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\SCPTemp\%%a /Y"
  194. if "!errorlevel!" == "1" goto WPAError
  195. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a\dll\%SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\SCPTemp\%%a /Y"
  196. if "!errorlevel!" == "1" goto WPAError
  197. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a\%SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\PreBBT /Y"
  198. if "!errorlevel!" == "1" goto WPAError
  199. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a\dll\%SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  200. if "!errorlevel!" == "1" goto WPAError
  201. ) else (
  202. call logmsg.cmd "Prebbt version of %%a.dll already SCPed, so do not overwrite un-scped copy."
  203. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  204. )
  205. call logmsg.cmd "%%a\%SKUDependentDlls%.dll is NOT BBTized. Copying config file..."
  206. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%SKUDependentDlls%_NoBBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%SKUDependentDlls%.ini /Y"
  207. if "!errorlevel!" == "1" goto WPAError
  208. )
  209. if !FILE_ALREADYSCPed! EQU 0 (
  210. call logmsg.cmd "SCP'ing WPA files (%%a\%SKUDependentDlls%.dll)...."
  211. call ExecuteCmd.cmd "vsp21.exe %SKUDependentDlls%.dll /F=SCPconfig_%SKUDependentDlls%.ini > nul"
  212. if "!errorlevel!" == "1" (
  213. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a_%SKUDependentDlls%"
  214. link -dump -headers %SKUDependentDlls%.dll | findstr /i /c:"21315.20512 image version" >nul
  215. if "!errorlevel!" == "1" (
  216. goto WPAError
  217. ) else (
  218. call logmsg.cmd "WARNING: %%a\%SKUDependentDlls%.dll seems to be already SCPed."
  219. )
  220. ) else (
  221. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a_%SKUDependentDlls%"
  222. call logmsg.cmd "vsp21.exe %SKUDependentDlls%.dll /F=SCPconfig_%SKUDependentDlls%.ini succeeded."
  223. )
  224. call ExecuteCmd.cmd "copy %SKUDependentDlls%.dll %_NTPostBld%\SCP_WPA\SCPed\%SKUDependentDlls%.dll"
  225. if "!errorlevel!" == "1" goto WPAError
  226. call ExecuteCmd.cmd "copy %SKUDependentDlls%.pdb %_NTPostBld%\SCP_WPA\SCPed\%SKUDependentDlls%.pdb"
  227. if "!errorlevel!" == "1" goto WPAError
  228. %RazzleToolPath%\x86\binplace -r %_NTPostBld%\%%a -s %_NTPostBld%\symbols\%%a -n %_NTPostBld%\symbols.pri\%%a -j -xa %SKUDependentDlls%.dll
  229. if "!errorlevel!" == "1" (
  230. call errmsg.cmd "Failed to binplace %SKUDependentDlls%.dll (%%a)"
  231. goto WPAError
  232. ) else (
  233. touch %_NTPostBld%\%%a\%SKUDependentDlls%.dll
  234. )
  235. call ExecuteCmd.cmd "%RazzleToolPath%\postbuildscripts\RemoveSecretSymbols.cmd %_NTPostBld%\symbols\%%a\retail\dll\%SKUDependentDlls%.pdb %_NTPostBld%\PrivateSyms\dll\%SKUDependentDlls%.privsym"
  236. if "!errorlevel!" == "1" goto WPAError
  237. ) else (
  238. call logmsg.cmd "WARNING: %%a\%SKUDependentDlls%.dll seems to be already SCPed."
  239. )
  240. )
  241. REM
  242. REM This section handles dlls that are the same for all SKUs and product types
  243. REM
  244. set WPABinplaceFlags=%RazzleToolPath%\x86\binplace -r %_NTPostBld% -s %_NTPostBld%\symbols -n %_NTPostBld%\symbols.pri -j -xa
  245. set SKUIndependentDlls=licdll licwmi
  246. set SymbolDllDir=%_NTPostBld%\symbols.pri\retail\dll
  247. for %%a in (%SKUIndependentDlls%) do (
  248. set /a FILE_ALREADYSCPed=0
  249. if exist %WPAPreBBTFileDir%\%%a.dll (
  250. call logmsg.cmd "%%a.dll is BBTized. Copying Pre-BBT %%a file..."
  251. link -dump -headers %WPAPreBBTFileDir%\%%a.dll | findstr /i /c:"21315.20512 image version" > nul
  252. if "!errorlevel!" == "1" (
  253. call ExecuteCmd.cmd "copy %WPAPreBBTFileDir%\%%a.dll %_NTPostBld%\SCP_WPA\PreBBT /Y"
  254. if "!errorlevel!" == "1" goto WPAError
  255. call ExecuteCmd.cmd "copy %WPAPreBBTPDBFileDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  256. if "!errorlevel!" == "1" goto WPAError
  257. ) else (
  258. call logmsg.cmd "Prebbt version of %%a.dll already SCPed, so do not overwrite un-scped copy."
  259. )
  260. call logmsg.cmd "%%a.dll is BBTized. Copying Post-BBT %%a file..."
  261. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.dll %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  262. if "!errorlevel!" == "1" goto WPAError
  263. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a.pdb %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  264. if "!errorlevel!" == "1" goto WPAError
  265. link -dump -headers %_NTPostBld%\%%a.dll | findstr /i /c:"21315.20512 image version" > nul
  266. if "!errorlevel!" == "1" (
  267. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.dll %_NTPostBld%\SCP_WPA\PostBBT /Y"
  268. if "!errorlevel!" == "1" goto WPAError
  269. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PostBBT /Y"
  270. if "!errorlevel!" == "1" goto WPAError
  271. ) else ( start
  272. call logmsg.cmd "BBTized version of %%a.dll already SCPed, so do not overwrite un-scped copy."
  273. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  274. )
  275. call logmsg.cmd "%%a.dll is BBTized. Copying config file..."
  276. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%%a_BBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%%a.ini /Y"
  277. if "!errorlevel!" == "1" goto WPAError
  278. ) else (
  279. call logmsg.cmd "Check if %%a\%SKUDependentDlls%.dll is SCPed..."
  280. link -dump -headers %_NTPostBld%\%%a.dll | findstr /i /c:"21315.20512 image version" > nul
  281. if "!errorlevel!" == "1" (
  282. call logmsg.cmd "%_NTPostBld%\%%a.dll is NOT BBTized and NOT SCPed. Copying Pre-BBT %%a\%SKUDependentDlls% file..."
  283. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.dll %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  284. if "!errorlevel!" == "1" goto WPAError
  285. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a.pdb %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  286. if "!errorlevel!" == "1" goto WPAError
  287. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.dll %_NTPostBld%\SCP_WPA\PreBBT /Y"
  288. if "!errorlevel!" == "1" goto WPAError
  289. call ExecuteCmd.cmd "copy %SymbolDllDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  290. if "!errorlevel!" == "1" goto WPAError
  291. ) else (
  292. call logmsg.cmd "Prebbt version of %%a.dll already SCPed, so do not overwrite un-scped copy."
  293. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  294. )
  295. call logmsg.cmd "%%a.dll is NOT BBTized. Copying config file..."
  296. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%%a_NoBBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%%a.ini /Y"
  297. if "!errorlevel!" == "1" goto WPAError
  298. )
  299. if !FILE_ALREADYSCPed! EQU 0 (
  300. call logmsg.cmd "SCP'ing WPA files (%%a)...."
  301. call ExecuteCmd.cmd "vsp21.exe %%a.dll /F=SCPconfig_%%a.ini > nul"
  302. if "!errorlevel!" == "1" (
  303. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a"
  304. link -dump -headers %%a.dll | findstr /i /c:"21315.20512 image version" >nul
  305. if "!errorlevel!" == "1" (
  306. goto WPAError
  307. ) else (
  308. call logmsg.cmd "WARNING: %%a.dll seems to be already SCPed."
  309. )
  310. ) else (
  311. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a"
  312. call logmsg.cmd "vsp21.exe %%a.dll /F=SCPconfig_%%a.ini succeeded."
  313. )
  314. call ExecuteCmd.cmd "copy %%a.dll %_NTPostBld%\SCP_WPA\SCPed\%%a.dll"
  315. if "!errorlevel!" == "1" goto WPAError
  316. call ExecuteCmd.cmd "copy %%a.pdb %_NTPostBld%\SCP_WPA\SCPed\%%a.pdb"
  317. if "!errorlevel!" == "1" goto WPAError
  318. %WPABinplaceFlags% %%a.dll
  319. if "!errorlevel!" == "1" (
  320. call errmsg.cmd "Failed to binplace %%a.dll"
  321. goto WPAError
  322. ) else (
  323. touch %_NTPostBld%\%%a.dll
  324. )
  325. call ExecuteCmd.cmd "%RazzleToolPath%\postbuildscripts\RemoveSecretSymbols.cmd %_NTPostBld%\symbols\retail\dll\%%a.pdb %_NTPostBld%\PrivateSyms\dll\%%a.privsym"
  326. if "!errorlevel!" == "1" goto WPAError
  327. ) else (
  328. call logmsg.cmd "WARNING: %%a.dll seems to be already SCPed."
  329. )
  330. )
  331. REM
  332. REM This section handles exe's that are the same for all SKUs and product types
  333. REM
  334. set SKUIndependentExes=winlogon
  335. set SymbolExeDir=%_NTPostBld%\symbols.pri\retail\exe
  336. for %%a in (%SKUIndependentExes%) do (
  337. set /a FILE_ALREADYSCPed=0
  338. if exist %WPAPreBBTFileDir%\%%a.exe (
  339. call logmsg.cmd "%%a.exe is BBTized. Copying Pre-BBT %%a file..."
  340. link -dump -headers %WPAPreBBTFileDir%\%%a.exe | findstr /i /c:"21315.20512 image version" > nul
  341. if "!errorlevel!" == "1" (
  342. call ExecuteCmd.cmd "copy %WPAPreBBTFileDir%\%%a.exe %_NTPostBld%\SCP_WPA\PreBBT /Y"
  343. if "!errorlevel!" == "1" goto WPAError
  344. call ExecuteCmd.cmd "copy %WPAPreBBTPDBFileDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  345. if "!errorlevel!" == "1" goto WPAError
  346. ) else (
  347. call logmsg.cmd "Prebbt version of %%a.exe already SCPed, so do not overwrite un-scped copy."
  348. )
  349. call logmsg.cmd "%%a.dll is BBTized. Copying Post-BBT %%a file..."
  350. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.exe %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  351. if "!errorlevel!" == "1" goto WPAError
  352. link -dump -headers %_NTPostBld%\%%a.exe | findstr /i /c:"21315.20512 image version" > nul
  353. if "!errorlevel!" == "1" (
  354. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.exe %_NTPostBld%\SCP_WPA\PostBBT /Y"
  355. if "!errorlevel!" == "1" goto WPAError
  356. call ExecuteCmd.cmd "copy %SymbolExeDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PostBBT /Y"
  357. if "!errorlevel!" == "1" goto WPAError
  358. ) else ( start
  359. call logmsg.cmd "BBTized version of %%a.exe already SCPed, so do not overwrite un-scped copy."
  360. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  361. )
  362. call logmsg.cmd "%%a.exe is BBTized. Copying config file..."
  363. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%%a_BBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%%a.ini /Y"
  364. if "!errorlevel!" == "1" goto WPAError
  365. ) else (
  366. call logmsg.cmd "%%a.exe is NOT BBTized. Copying Pre-BBT %%a file..."
  367. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.exe %_NTPostBld%\SCP_WPA\SCPTemp /Y"
  368. if "!errorlevel!" == "1" goto WPAError
  369. link -dump -headers %_NTPostBld%\%%a.exe | findstr /i /c:"21315.20512 image version" > nul
  370. if "!errorlevel!" == "1" (
  371. call ExecuteCmd.cmd "copy %_NTPostBld%\%%a.exe %_NTPostBld%\SCP_WPA\PreBBT /Y"
  372. if "!errorlevel!" == "1" goto WPAError
  373. call ExecuteCmd.cmd "copy %SymbolExeDir%\%%a.pdb %_NTPostBld%\SCP_WPA\PreBBT /Y"
  374. if "!errorlevel!" == "1" goto WPAError
  375. ) else (
  376. call logmsg.cmd "Prebbt version of %%a.exe already SCPed, so do not overwrite un-scped copy."
  377. set /a FILE_ALREADYSCPed=!FILE_ALREADYSCPed! + 1
  378. )
  379. call logmsg.cmd "%%a.exe is NOT BBTized. Copying config file..."
  380. call ExecuteCmd.cmd "copy %_NTPostBld%\SCP_WPA\SCPconfig_%%a_NoBBT.ini %_NTPostBld%\SCP_WPA\SCPconfig_%%a.ini /Y"
  381. if "!errorlevel!" == "1" goto WPAError
  382. )
  383. if !FILE_ALREADYSCPed! EQU 0 (
  384. call logmsg.cmd "SCP'ing WPA files (%%a)...."
  385. pushd %_NTPostBld%\SCP_WPA
  386. call ExecuteCmd.cmd "vsp21.exe %%a.exe /F=SCPconfig_%%a.ini > nul"
  387. if "!errorlevel!" == "1" (
  388. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a"
  389. link -dump -headers %%a.exe | findstr /i /c:"21315.20512 image version" >nul
  390. if "!errorlevel!" == "1" (
  391. goto WPAError
  392. ) else (
  393. call logmsg.cmd "WARNING: %%a.exe seems to be already SCPed."
  394. )
  395. ) else (
  396. call ExecuteCmd.cmd "copy scpwebdebug scpwebdebug_%%a"
  397. call logmsg.cmd "vsp21.exe %%a.exe /F=SCPconfig_%%a.ini succeeded."
  398. )
  399. call ExecuteCmd.cmd "copy %%a.exe %_NTPostBld%\SCP_WPA\SCPed\%%a.exe /Y"
  400. if "!errorlevel!" == "1" goto WPAError
  401. call ExecuteCmd.cmd "copy %%a.pdb %_NTPostBld%\SCP_WPA\SCPed\%%a.pdb /Y"
  402. if "!errorlevel!" == "1" goto WPAError
  403. %WPABinplaceFlags% %%a.exe
  404. if "!errorlevel!" == "1" (
  405. call errmsg.cmd "Failed to binplace %%a.exe"
  406. goto WPAError
  407. ) else (
  408. touch %_NTPostBld%\%%a.exe
  409. )
  410. call ExecuteCmd.cmd "%RazzleToolPath%\postbuildscripts\RemoveSecretSymbols.cmd %_NTPostBld%\symbols\retail\exe\%%a.pdb %_NTPostBld%\PrivateSyms\exe\%%a.privsym"
  411. if "!errorlevel!" == "1" goto WPAError
  412. ) else (
  413. call logmsg.cmd "WARNING: %%a.exe seems to be already SCPed."
  414. )
  415. )
  416. goto WPASuccess
  417. :WPAError
  418. REM
  419. REM Do not continue processing rest of the files, fail the whole operation.
  420. REM We cannot ship partially scp'ed files.
  421. REM
  422. popd
  423. set errors=%errorlevel%
  424. call errmsg.cmd "SCPWPA FAILURE: SCP_WPAFiles script cannot continue. Please contact WPAHELP."
  425. goto end
  426. :WPASuccess
  427. REM
  428. REM If we are at this point, it means that we are successfully finished the operations.
  429. REM
  430. popd
  431. call logmsg.cmd "WPA Files are successfully SCP'ed."
  432. REM
  433. REM CAGLAR1
  434. REM
  435. :end
  436. REM Do cleanup
  437. popd