@echo off
title UEFI BIOS Updater v1.8.10 21.10.2014
pushd %~dp0
set sds=Modules\sata
set sdv=Modules\vga
set sdl=Modules\lan
set sda=Modules\amd
set mmt=start /min /wait mmtool bios.bin
set mmtt=start /min /wait mmtool temp\bios.tmp
set mmt1=start /min /wait mmtool bios.bin /e A062CF1F-8473-4AA3-8793-600BC4FFE9A8 csmcore
set mmt2=start /min /wait mmtool bios.bin /e 9F3A0016-AE55-4288-829D-D22FD344C347 csmcore

set bios=bios.bin
set csm=1

set ilo=OROM 1.5.61
set ile=EFI 6.4.13
set rlo=OROM 2.60
set rle=EFI 2.029
set alo=OROM 2.0.6.6/2.1.1.5
set blo=OROM 16.2.1
set ble=EFI 16.2.2

set amda4=3.2.1.0
set amda7=3.2.1.0
set amdr=3.3.1540.19
set amdru=1.0.0.49
set amdxpt2of10=6.1.3-00035
set amdxpt2ef10=6.1.3-00035
set amdxpt2of50=6.1.3-00035
set amdxpt2ef50=6.1.3-00035

set mrv1=1.0.0.1038
set mrv2=1.0.0.0034
set mrv3=1.0.0.0034
set mrv4=1.0.0.1020
set mrva=1.1.0.1015
set mrvr=1.1.0.1015

set verosib=findver "     OROM VBIOS Sandy/IvyBridge - " 245642542053 79 FF 4 2 csmcore
set verohsw=findver "     OROM VBIOS Haswell         - " 245642542048 79 FF 4 2 csmcore
set veroast=findver "     OROM VBIOS ASPEED          - " 004153542047505500 9 00 7 2 csmcore
set veroamd=findver "     OROM VBIOS AMD             - " 41544F4D42494F53424B 18 00 22 2 csmcore
set verosata=findver "     OROM IRST SATA             - " 496E74656C2852292052617069642053746F7261676520546563686E6F6C6F6779202D204F7074696F6E20524F4D 49 0A 12 2 csmcore
set verosatae=findver "     OROM IRSTe SATA            - " 496E74656C2852292052617069642053746F7261676520546563686E6F6C6F677920656E7465727072697365202D2053415441204F7074696F6E20524F4D 65 0A 12 2 csmcore
set verossata=findver "     OROM IRSTe sSATA           - " 496E74656C2852292052617069642053746F7261676520546563686E6F6C6F677920656E7465727072697365202D207353415441204F7074696F6E20524F4D 66 0A 12 2 csmcore
set veroscu=findver "     OROM IRSTe SCU             - " 496E74656C2852292052617069642053746F7261676520546563686E6F6C6F677920656E7465727072697365202D20534355204F7074696F6E20524F4D 64 0A 12 2 csmcore

set verfagesaam3=findver "     EFI AMD AGESA OrochiPI     - " 4147455341204F726F6368695049 15 20 8 1 temp\agesa.tmp
set verfagesafmr=findver "     EFI AMD AGESA RichlandPI   - " 4147455341526963686C616E645049 22 20 8 1 temp\agesa.tmp
set verfagesafml=findver "     EFI AMD AGESA LlanoPI      - " 4147455341204C6C616E6F5049 15 20 8 1 temp\agesa.tmp
set verfagesafmt=findver "     EFI AMD AGESA TrinyPI      - " 4147455341205472696E795049 15 20 8 1 temp\agesa.tmp
set verfagesafmk=findver "     EFI AMD AGESA KaveriPI     - " 41474553414B61766572695049 22 20 8 1 temp\agesa.tmp
set verfagesafmb=findver "     EFI AMD AGESA KabiniPI     - " 41474553414B6162696E695049 22 20 8 1 temp\agesa.tmp
set verfagesafmo=findver "     EFI AMD AGESA OntaroPI     - " 4147455341204F6E7461726F5049 15 20 8 1 temp\agesa.tmp
set verfagesafm2=findver "     EFI AMD AGESA Ontar2PI     - " 4147455341204F6E746172325049 15 20 8 1 temp\agesa.tmp

set veroasm=findver "     OROM Asmedia 106X          - " 41736D65646961203130365820534154412F5041544120436F6E74726F6C6C6572 38 00 6 1 csmcore
set verojmb=findver "     OROM JMicron JMB36x        - " 504349204578707265737320746F2053415441494920484F535420436F6E74726F6C6C657220524F4D 43 00 8 1 csmcore
set verolani=findver "     OROM Intel PXE             - " 496E74656C28522920426F6F74204167656E74204745 24 00 7 1 csmcore
set verolanr=findver "     OROM Realtek PXE           - " 5265616C74656B2050434965204742452046616D696C7920436F6E74726F6C6C657220536572696573 43 20 9 1 csmcore
set verolanq=findver "     OROM QCM-Atheros PXE       - " 504349452045746865726E657420436F6E74726F6C6C6572 26 28 8 2 csmcore
set verolanb=findver "     OROM Broadcom PXE          - " 42726F6164636F6D20554E4449205058452D322E31 23 00 7 1 csmcore

if not exist drvver.exe (
	echo ! DrvVer not found !
	pause
	exit
)
if not exist findver.exe (
	echo ! FindVer not found !
	pause
	exit
)
if not exist hexfind.exe (
	echo ! HexFind not found !
	pause
	exit
)
if not exist mmtool.exe (
	echo ! MMTOOL v 4.50.0023 not found !
	pause
	exit
)

for /f "tokens=*" %%b in ('dir *.CAP *.ROM *.F?? *.BS? *.0?? *.1?? *.2?? *.3?? *.4?? *.5?? *.6?? *.7?? *.8?? *.9?? *.??1 *.??2 *.??3 bios.bin /b') do (
 	echo %%b
	if /I %%b==bios.bin (
		goto rise
	) else (
	 	if /I exist bios.bin del /f /q bios.bin
	 	ren "%%b" bios.bin
		goto rise
	)
)

setlocal
for /f "usebackq delims=" %%i in (
	`@"%systemroot%\system32\mshta.exe" "about:<FORM><INPUT type='file' name='qq'></FORM><script>document.forms[0].elements[0].click();var F=document.forms[0].elements[0].value;try {new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(F)};catch (e){};close();</script>" ^
	1^|more`
) do copy "%%i" "%~dp0"\bios.bin>nul
if not exist bios.bin goto err
endlocal

:rise
hexfind 2F7C71AE421A2B4F886178B79CA07E07 bios.bin>nul && %mmt% /e AE717C2F-1A42-4F2B-8861-78B79CA07E07 bios.tmp && set bios=bios.tmp


:mn
hexfind 1FCF62A07384A34A8793600BC4FFE9A8 %bios%>nul || hexfind 1FCF62A07384A34A8793600BC4FFE9A8 bios.bin>nul
if not errorlevel 1 %mmt1% && hexfind 5553422053746F72616765 csmcore>nul || echo CSMCORE not present! Plarforn Aptio 5 or non-UEFI BIOS not support. && pause && goto exit2
hexfind 0055AA csmcore>nul || %mmt2% && set csm=0 && set mmt1=%mmt2%

cls
set lanir=0
set lanie=0
set lanrr=0
set lanre=0
set lanar=0
set lanae=0
set lanbr=0
set lanbe=0
set m1=0
set m2=0
set m4=0
set m5=0
set m6=0
set m7=0
rem set m8=8
set s=0
set sa=0
set se=0
set arom=0
set aefi=0
set axpt=0
set vi=0
set vas=0
set vam=0
set me=0
set s1150=0
set s1155=0
set s2011=0
set asus=0

hexfind 4153555342 %bios%>nul && set asus=1 && echo Platform ASUS

if exist temp (del /f /q temp\*.*) else (md temp)
echo Scanning BIOS... Please wait...

rem CPU
copy /y bios.bin temp\bios.tmp>nul
hexfind 728508177F37EF448F4EB09FFF46A070 temp\bios.tmp>nul
if not errorlevel 1 (
	:d0cpu
	%mmtt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpuffs.tmp
	hexfind 00F8FFFFFFFFFFFFFFFF temp\cpuffs.tmp>nul
	if not errorlevel 1 (%mmtt% /d 17088572-377F-44EF-8F4E-B09FFF46A070 && goto d0cpu)
)
if exist temp\cpuffs.tmp (
	hexfind 01000000C3060300 temp\cpuffs.tmp>nul && set m7=7 && set s1150=1 && set pcpu=Haswell/Broadwell && echo Platform Socket 1150 - Haswell/Broadwell
	hexfind 01000000A7060200 temp\cpuffs.tmp>nul && set m7=7 && set s1155=1 && set pcpu=SandyBridge/IvyBridge && echo Platform Socket 1155 - SandyBridge
	hexfind 01000000A9060300 temp\cpuffs.tmp>nul && set m7=7 && set s1155=1 && set pcpu=SandyBridge/IvyBridge && echo Platform Socket 1155 - IvyBridge
	hexfind 01000000D7060200 temp\cpuffs.tmp>nul && set m7=7 && set s2011=1 && set pcpu=SandyBridge-E/IvyBridge-E && echo Platform Socket 2011 - SandyBridge-E
	hexfind 01000000E4060300 temp\cpuffs.tmp>nul && set m7=7 && set s2011=1 && set pcpu=SandyBridge-E/IvyBridge-E && echo Platform Socket 2011 - IvyBridge-E
	hexfind 0100000050060400 temp\cpuffs.tmp>nul && set m7=7 && set s1150=1 && echo Platform Haswell Mobile
	hexfind 0100000051060400 temp\cpuffs.tmp>nul && set m7=7 && set s1150=1 && echo Platform Haswell Mobile
	hexfind 0100000061060400 temp\cpuffs.tmp>nul && set m7=7 && set s1150=1 && echo Platform Haswell Mobile
)

if %m7%==7 goto mi
if %m7%==1 goto mi
rem GOP AMD
hexfind DFABDC486DCE5C46B832FD1BD169F3EA %bios%>nul || hexfind DFABDC486DCE5C46B832FD1BD169F3EA bios.bin>nul
if not errorlevel 1 %mmt% /e 48DCABDF-CE6D-465C-B832-FD1BD169F3EA temp\GopAMD.tmp && hexfind 41004D004400200047004F0050 temp\GopAMD.tmp>nul && set vam=1 && echo Found EFI GOP Driver GUID 48DCABDF- || del temp\GopAMD.tmp
hexfind DEE0FF74ECDCBF49910D1B476A851EAF %bios%>nul || hexfind DEE0FF74ECDCBF49910D1B476A851EAF bios.bin>nul
if not errorlevel 1 %mmt% /e 74FFE0DE-DCEC-49BF-910D-1B476A851EAF temp\VBIOS74.tmp && hexfind 41544F4D42494F53424B temp\VBIOS74.tmp>nul && echo Found ROM AMD VBIOS in ffs GUID 74FFE0DE- || del temp\VBIOS74.tmp
hexfind DEE0FF84ECDCBF49910D1B476A851EAF %bios%>nul || hexfind DEE0FF84ECDCBF49910D1B476A851EAF bios.bin>nul
if not errorlevel 1 %mmt% /e 84FFE0DE-DCEC-49BF-910D-1B476A851EAF temp\VBIOS84.tmp && hexfind 41544F4D42494F53424B temp\VBIOS84.tmp>nul && echo Found ROM AMD VBIOS in ffs GUID 84FFE0DE- || del temp\VBIOS84.tmp

rem AMD AGESA
hexfind FFAF5069E36EDD11AD8B0800200C9A66 %bios%>nul || hexfind FFAF5069E36EDD11AD8B0800200C9A66 bios.bin>nul
if not errorlevel 1 %mmt% /e 6950AFFF-6EE3-11DD-AD8B-0800200C9A66 temp\Agesa.tmp && echo Found AGESA  GUID 6950AFFF-

rem AMD SATA
hexfind 1DC8D59B6C092546A08B405F78FE0CFC %bios%>nul || hexfind 1DC8D59B6C092546A08B405F78FE0CFC bios.bin>nul
if not errorlevel 1 set s=2 && %mmt% /e 9BD5C81D-096C-4625-A08B-405F78FE0CFC temp\miscFC.tmp && echo Found ROM AMD RAID MISC.SIG GUID 9BD5C81D-...-FC
hexfind 1DC8D59B6C092546A08B405F78FE0CFD %bios%>nul || hexfind 1DC8D59B6C092546A08B405F78FE0CFD bios.bin>nul
if not errorlevel 1 set s=2 && %mmt% /e 9BD5C81D-096C-4625-A08B-405F78FE0CFD temp\miscFD.tmp && echo Found ROM AMD RAID MISC.SIG GUID 9BD5C81D-...-FD

hexfind 82B368C450450949AD572496141B3F4A %bios%>nul || hexfind 82B368C450450949AD572496141B3F4A bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e C468B382-4550-4909-AD57-2496141B3F4A temp\raidx64.tmp && set aefi=1 && echo Found EFI AMD RAIDx64 GUID C468B382-
hexfind 22E316094037CE31AD62BD172CECCA36 %bios%>nul || hexfind 22E316094037CE31AD62BD172CECCA36 bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 0916E322-3740-31CE-AD62-BD172CECCA36 temp\raidutil.tmp && set aefi=1 && echo Found EFI AMD RAID Utility GUID 0916E322-
hexfind C4CC6701F7D0214FA3EF9E64B7CDCE8B %bios%>nul || hexfind C4CC6701F7D0214FA3EF9E64B7CDCE8B bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 0167CCC4-D0F7-4F21-A3EF-9E64B7CDCE8B temp\ScsiBus.tmp && set aefi=1 && echo Found EFI AMD SCSI Bus GUID 0167CCC4-
hexfind 22E3660A4037CE4CAD62BD172CECCA35 %bios%>nul || hexfind 22E3660A4037CE4CAD62BD172CECCA35 bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 0A66E322-3740-4CCE-AD62-BD172CECCA35 temp\ScsiDisk.tmp && set aefi=1 && echo Found EFI AMD SCSI Disk GUID 0A66E322-
hexfind 22E316094037CE4CAD62BD172CECCA35 %bios%>nul || hexfind 22E316094037CE4CAD62BD172CECCA35 bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 0916E322-3740-4CCE-AD62-BD172CECCA35 temp\HiiDatabase.tmp && set aefi=1 && echo Found EFI AMD Hii Database.ffs GUID 0916E322-
hexfind 185C9650652FA9419961BA889EA978D9 %bios%>nul || hexfind 185C9650652FA9419961BA889EA978D9 bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 50965C18-2F65-41A9-9961-BA889EA978D9 temp\RAIDxpt2f10e.tmp && set axpt=1 && echo Found EFI AMD RAIDXpert2 F10 GUID 50965C18-
hexfind DECEF65CED0D13409196F429DE361937 %bios%>nul || hexfind DECEF65CED0D13409196F429DE361937 bios.bin>nul
if not errorlevel 1 set s=2 && set sa=1 && %mmt% /e 5CF6CEDE-0DED-4013-9196-F429DE361937 temp\RAIDxpt2f50e.tmp && set axpt=1 && echo Found EFI AMD RAIDXpert2 F50 GUID 5CF6CEDE-

set amdahci=0
echo Extract OROM
hexfind  000210AA55 csmcore>nul && %mmt% /e /l temp\55aa.tmp 1002 55aa && hexfind 5043495202109143 temp\55aa.tmp>nul && set amdahci=4391 && set arom=1
hexfind  0002109143 csmcore>nul && %mmt% /e /l temp\4391.tmp 1002 4391 && hexfind 5043495202109143 temp\4391.tmp>nul && set amdahci=4391 && set arom=1
hexfind  0002109243 csmcore>nul && %mmt% /e /l temp\4392.tmp 1002 4392 && set arom=1
hexfind  0002109343 csmcore>nul && %mmt% /e /l temp\4393.tmp 1002 4393 && set arom=1
hexfind  002210AA5500 csmcore>nul && %mmt% /e /l temp\55aa.tmp 1022 55aa && hexfind 5043495222100178 temp\55aa.tmp>nul && set amdahci=7801 && set arom=1
hexfind  002210017800 csmcore>nul && %mmt% /e /l temp\7801.tmp 1022 7801 && hexfind 5043495222100178 temp\7801.tmp>nul && set amdahci=7801 && set arom=1
hexfind  0022100278 csmcore>nul && %mmt% /e /l temp\7802.tmp 1022 7802 && set arom=1
hexfind  0022100378 csmcore>nul && %mmt% /e /l temp\7803.tmp 1022 7803 && set arom=1
hexfind  0022100388 csmcore>nul && %mmt% /e /l temp\RAIDxpt2f10o.tmp 1022 8803 && set axpt=1
hexfind  0022100488 csmcore>nul && %mmt% /e /l temp\RAIDxpt2f50o.tmp 1022 8804 && set axpt=1

goto ma

:mi
rem GOP Intel
hexfind C8EB598D5EB80E40970A1F995D1DB91E %bios%>nul || hexfind C8EB598D5EB80E40970A1F995D1DB91E bios.bin>nul
if not errorlevel 1 %mmt% /e 8D59EBC8-B85E-400E-970A-1F995D1DB91E temp\GopSan.tmp && hexfind 49006E00740065006C00 temp\GopSan.tmp>nul && set vi=1 && echo Found EFI GOP Driver GUID 8D59EBC8- || del temp\GopSan.tmp
hexfind E683BA5B27F0A74CBFD016358CC9E123 %bios%>nul || hexfind E683BA5B27F0A74CBFD016358CC9E123 bios.bin>nul
if not errorlevel 1 %mmt% /e 5BBA83E6-F027-4CA7-BFD0-16358CC9E123 temp\GopHas.tmp && hexfind 49006E00740065006C00 temp\GopHas.tmp>nul && set vi=1 && echo Found EFI GOP Driver GUID 5BBA83E6- || del temp\GopHas.tmp
hexfind CCC28A874353F246B56351F89DAF56BA %bios%>nul || hexfind CCC28A874353F246B56351F89DAF56BA bios.bin>nul
if not errorlevel 1 %mmt% /e 878AC2CC-5343-46F2-B563-51F89DAF56BA temp\vbtffs.tmp && hexfind 245642542048 temp\vbtffs.tmp>nul && echo Found VBT Intel Haswell/Broadwell GUID 878AC2CC- || del temp\vbtffs.tmp

rem GOP ASPEED
hexfind E683BA5B27F0A74CBFD016358CC9E123 %bios%>nul || hexfind E683BA5B27F0A74CBFD016358CC9E123 bios.bin>nul
if not errorlevel 1 %mmt% /e 5BBA83E6-F027-4CA7-BFD0-16358CC9E123 temp\GopAST.tmp && hexfind 00410053005000450045004400 temp\GopAST.tmp>nul && set vas=1 && echo Found EFI GOP ASPEED Driver GUID 5BBA83E6- || del  temp\GopAST.tmp
hexfind 2000031AFF2F csmcore>nul && %mmt% /e /l temp\gopromast.tmp 1A03 2FFF

rem Intel SATA
hexfind 94D3C890044E9C43BA552D8CFCB414ED %bios%>nul || hexfind 94D3C890044E9C43BA552D8CFCB414ED bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 90C8D394-4E04-439C-BA55-2D8CFCB414ED temp\satadrv90.tmp && echo Found EFI IRST GUID 90C8D394-
hexfind C1D9B4911C1424488D023C298E36EB3F %bios%>nul || hexfind C1D9B4911C1424488D023C298E36EB3F bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 91B4D9C1-141C-4824-8D02-3C298E36EB3F temp\satadrv91.tmp && echo Found EFI IRST GUID 91B4D9C1-
hexfind B3A7A043921EEF42A46DDDC03E52CB5C %bios%>nul || hexfind B3A7A043921EEF42A46DDDC03E52CB5C bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 43A0A7B3-1E92-42EF-A46D-DDC03E52CB5C temp\satadrv43.tmp && echo Found EFI IRST GUID 43A0A7B3-
hexfind C4B8A04360110217A46DDDC03E52CB5C %bios%>nul || hexfind C4B8A04360110217A46DDDC03E52CB5C bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 43A0B8C4-1160-1702-A46D-DDC03E52CB5C temp\satadrv43c.tmp && echo Found EFI IRST GUID 43A0B8C4-
hexfind 3542408B463A2F449EE83A765E1E2A64 %bios%>nul || hexfind 3542408B463A2F449EE83A765E1E2A64 bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 8B404235-3A46-442F-9EE8-3A765E1E2A64 temp\satadrv8b.tmp && echo Found EFI IRST GUID 8B404235-
hexfind 56F3B25B4A110541A5B29A9741DCD365 %bios%>nul || hexfind 56F3B25B4A110541A5B29A9741DCD365 bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 5BB2F356-114A-4105-A5B2-9A9741DCD365 temp\satadrv5b.tmp && echo Found EFI IRST GUID 5BB2F356-
hexfind 3D8DFB85A46118459ACF76FCAE169568 %bios%>nul || hexfind 3D8DFB85A46118459ACF76FCAE169568 bios.bin>nul
if not errorlevel 1 set s=1 && set se=1 && %mmt% /e 85FB8D3D-61A4-4518-9ACF-76FCAE169568 temp\scudrv85.tmp && echo Found EFI IRST SCU GUID 85FB8D3D-
hexfind 496E74656C2852292052414944 csmcore>nul && set s=1
if %csm%==1 hexfind  008680AA55 csmcore>nul && %mmt% /e /l temp\55aa.tmp 8086 55aa

rem LAN Intel
hexfind 20F753496D00F541990D0AC7742ABB60 %bios%>nul || hexfind 20F753496D00F541990D0AC7742ABB60 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AC7742ABB60 temp\lani49.tmp && hexfind 49006E00740065006C002000500052004F00 temp\lani49.tmp>nul && set lanie=1 && echo Found EFI Intel UNDI GUID 4953F720- || del temp\lani49.tmp
hexfind A49A9810036AFF48AF9AEB2A38F34611 %bios%>nul || hexfind A49A9810036AFF48AF9AEB2A38F34611 bios.bin>nul
if not errorlevel 1 %mmt% /e 10989AA4-6A03-48FF-AF9A-EB2A38F34611 temp\lani10.tmp && hexfind 49006E00740065006C002000500052004F00 temp\lani10.tmp>nul && set lanie=1 && echo Found EFI Intel UNDI GUID 10989AA4- || del temp\lani10.tmp
hexfind 20F753496D00F541990D0AA8853BCC71 %bios%>nul || hexfind 20F753496D00F541990D0AA8853BCC71 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AA8853BCC71 temp\lani49m.tmp && hexfind 49006E00740065006C002000500052004F00 temp\lani49m.tmp>nul && set lanie=1 && echo Found EFI Intel UNDI GUID 4953F720- || del temp\lani49m.tmp
hexfind F2B3221B513168448AF3590650EEAD22 %bios%>nul || hexfind F2B3221B513168448AF3590650EEAD22 bios.bin>nul
if not errorlevel 1 %mmt% /e 1B22B3F2-3151-4468-8AF3-590650EEAD22 temp\lani1b.tmp && hexfind 49006E00740065006C002000500052004F00 temp\lani1b.tmp>nul && set lanie=1 && echo Found EFI Intel UNDI GUID 1B22B3F2- || del temp\lani1b.tmp

:ma
rem LAN Realtek
hexfind AA04AA2EED5E274CB9EE26916EC25A8F %bios%>nul || hexfind AA04AA2EED5E274CB9EE26916EC25A8F bios.bin>nul
if not errorlevel 1 %mmt% /e 2EAA04AA-5EED-4C27-B9EE-26916EC25A8F temp\lanr2e.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr2e.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 2EAA04AA- || del temp\lanr2e.tmp
hexfind 34E25128FD201E4D9041DCB8F3025CAE %bios%>nul || hexfind 34E25128FD201E4D9041DCB8F3025CAE bios.bin>nul
if not errorlevel 1 %mmt% /e 2851E234-20FD-4D1E-9041-DCB8F3025CAE temp\lanr28.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr28.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 2851E234- || del temp\lanr28.tmp
hexfind 20F753496D00F541990D0AC7742ABB60 %bios%>nul || hexfind 20F753496D00F541990D0AC7742ABB60 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AC7742ABB60 temp\lanr4960.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr4960.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 4953F720- || del temp\lanr4960.tmp 
hexfind 20F753496D00F541990D0AA8853BCC71 %bios%>nul  || hexfind 20F753496D00F541990D0AA8853BCC71 %bios%>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AA8853BCC71 temp\lanr4971.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr4971.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 4953F720- || del temp\lanr4971.tmp
hexfind 20F753496D00F541990D0AC7742AAAB0 %bios%>nul || hexfind 20F753496D00F541990D0AC7742AAAB0 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AC7742AAAB0 temp\lanr49b0.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr49b0.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 4953F720- || del temp\lanr49b0.tmp
hexfind ADFC53EB7130AB4B980C6E4A379255F3 %bios%>nul || hexfind ADFC53EB7130AB4B980C6E4A379255F3 bios.bin>nul
if not errorlevel 1 %mmt% /e EB53FCAD-3071-4BAB-980C-6E4A379255F3 temp\lanreb.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanreb.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID EB53FCAD- || del temp\lanreb.tmp
hexfind 30004D5AB69DE111A8B00800200C9A66 %bios%>nul || hexfind 30004D5AB69DE111A8B00800200C9A66 bios.bin>nul
if not errorlevel 1 %mmt% /e 5A4D0030-9DB6-11E1-A8B0-0800200C9A66 temp\lanr5a.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr5a.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 5A4D0030- || del temp\lanr5a.tmp
hexfind 784E9950D5182141914416C370A16192 %bios%>nul || hexfind 784E9950D5182141914416C370A16192 bios.bin>nul
if not errorlevel 1 %mmt% /e 50994E78-18D5-4121-9144-16C370A16192 temp\lanr50.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr50.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 50994E78- || del temp\lanr50.tmp
hexfind 8472A37CA028074E9D05240A10787968 %bios%>nul || hexfind 8472A37CA028074E9D05240A10787968 bios.bin>nul
if not errorlevel 1 %mmt% /e 7CA37284-28A0-4E07-9D05-240A10787968 temp\lanr7c.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr7c.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 7CA37284- || del temp\lanr7c.tmp
hexfind 0ED5CB828AD1A846B14B4D206B33183F %bios%>nul || hexfind 0ED5CB828AD1A846B14B4D206B33183F bios.bin>nul
if not errorlevel 1 %mmt% /e 82CBD50E-D18A-46A8-B14B-4D206B33183F temp\lanr82.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr82.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 82CBD50E- || del temp\lanr82.tmp
hexfind EBCB535EE1C49343B8FB7267A118CB1E %bios%>nul || hexfind EBCB535EE1C49343B8FB7267A118CB1E bios.bin>nul
if not errorlevel 1 %mmt% /e 5E53CBEB-C4E1-4393-B8FB-7267A118CB1E temp\lanr5e.tmp && hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 temp\lanr5e.tmp>nul && set lanre=1 && echo Found EFI Realtek UNDI GUID 5E53CBEB- || del temp\lanr5e.tmp

rem LAN Broadcom
hexfind 90614FDFB842A94CBA517A801B565F08 %bios%>nul || hexfind 90614FDFB842A94CBA517A801B565F08 bios.bin>nul 
if not errorlevel 1 %mmt% /e DF4F6190-42B8-4CA9-BA51-7A801B565F08 temp\lanbdf.tmp && hexfind 4E006500740058007400720065006D0065002000470069006700610062 temp\lanbdf.tmp>nul && set lanbe=1 && echo Found EFI Broadcom NetXtreme UNDI GUID DF4F6190- || del temp\lanbdf.tmp
hexfind 784E9950D5182141914416C370A16192 %bios%>nul || hexfind 784E9950D5182141914416C370A16192 bios.bin>nul
if not errorlevel 1 %mmt% /e 50994E78-18D5-4121-9144-16C370A16192 temp\lanb50.tmp && hexfind 4E006500740058007400720065006D0065002000470069006700610062 temp\lanb50.tmp>nul && set lanbe=1 && echo Found EFI Broadcom NetXtreme UNDI GUID 50994E78- || del temp\lanb50.tmp

rem SATA_MaRV
hexfind 8D893143B8CC0841898CA5CC81442B28 %bios%>nul || hexfind 8D893143B8CC0841898CA5CC81442B28 bios.bin>nul
if not errorlevel 1 %mmt% /e 4331898D-CCB8-4108-898C-A5CC81442B28 temp\mrv43.tmp && hexfind 4D0061007200760065006C006C0020004300680061006E006E0065006C temp\mrv43.tmp>nul && set me=1 && echo Found EFI Marvell GUID 4331898D- || del temp\mrv43.tmp
hexfind D71C8FA2643B5F4E992DC8F69CBBFD84 %bios%>nul || hexfind D71C8FA2643B5F4E992DC8F69CBBFD84 bios.bin>nul
if not errorlevel 1 %mmt% /e A28F1CD7-3B64-4E5F-992D-C8F69CBBFD84 temp\mrva2.tmp && hexfind 4D0061007200760065006C006C0020004300680061006E006E0065006C temp\mrva2.tmp>nul && set me=1 && echo Found EFI Marvell GUID A28F1CD7- || del temp\mrva2.tmp
hexfind 20F753496D00F541990D0AC7742ABB61 %bios%>nul || hexfind 20F753496D00F541990D0AC7742ABB61 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AC7742ABB61 temp\mrv491.tmp && hexfind 4D0061007200760065006C006C0020004300680061006E006E0065006C temp\mrv491.tmp>nul && set me=1 && echo Found EFI Marvell GUID 4953F720-...1 || del temp\mrv491.tmp
hexfind 20F753496D00F541990D0AC7742ABB62 %bios%>nul || hexfind 20F753496D00F541990D0AC7742ABB62 bios.bin>nul
if not errorlevel 1 %mmt% /e 4953F720-006D-41F5-990D-0AC7742ABB62 temp\mrv492.tmp && hexfind 4D0061007200760065006C006C0020004300680061006E006E0065006C temp\mrv492.tmp>nul && set me=1 && echo Found EFI Marvell GUID 4953F720-...2 || del temp\mrv492.tmp

:mn1
cls
set enter=
echo.
echo		Select option for update
echo.
if %s%==1 (
	set m1=11
	echo 1 Intel RST(e^) OROM and EFI SataDriver
	call :irstd
	if %se%==0 echo      EFI IRST RAUD 	        - Not present
)

if %s%==2 (
 	set m1=12
	echo 1 AMD OROM and EFI Nodules
	call :amdd
	if %sa%==0 echo      EFI AMD RAID 	        - Not present
)

if %vi%==1 goto vb1
hexfind 535647412042494F53 csmcore>nul
if not errorlevel 1 (
	:vb1
	set m2=21
	echo 2 Intel OROM VBIOS and EFI GOP Driver
	call :videod
	if %vi%==0 echo      EFI GOP Driver		- Not present
)

if %vas%==1 goto vb2
hexfind 41535045454420546563686E6F6C6F6779 csmcore>nul
if not errorlevel 1 (
	:vb2
	findver "  ASPEED OROM VBIOS and EFI GOP Driver " C3415354 1 20 20 1 csmcore
	%veroast%
	if %vas%==0 (echo      EFI GOP Driver		- Not present) else (drvver temp\GopAST.tmp)
)

if %vam%==1 set m2=22 && goto vb3
hexfind 41544F4D42494F53424B csmcore>nul
if not errorlevel 1 (
	:vb3
	echo 2 AMD OROM VBIOS and EFI GOP Driver
	%veroamd%
	if exist temp\vbios*.tmp for /f "tokens=*" %%b in ('dir temp\vbios*.tmp /b') do findver "     OROM-in-FFS VBIOS AMD      - " 41544F4D42494F53424B 18 00 22 1 temp\%%b
	if %vam%==1 (drvver temp\gopamd.tmp) else (echo      EFI GOP Driver		- Not present)
)

echo 3 LAN OROM PXE and EFI UNDI - Intel, Realtek, BCM, QCA
%verolani% && set lanir=1
call :inlver
if %lanie%==0 hexfind 49006E00740065006C002000500052004F00 %bios%>nul && echo    Found EFI Intel UNDI - GUID Unknown. Please contact me.

%verolanr% && set lanrr=1
call :rtkver
if %lanre%==0 hexfind 5200650061006C00740065006B002000450074006800650072006E0065007400 %bios%>nul && echo      Found EFI Realtek UNDI - GUID Unknown. Please contact me.

%verolanq% && set lanar=1

%verolanb% && set lanbr=1
call :bcmver

hexfind 41736D656469612031303658 csmcore>nul
if not errorlevel 1 (
	set m4=4
	echo 4 AsMedia SATA Option ROM
	%veroasm%
)
if %me%==1 goto mm1
hexfind 4D617276656C6C2038385345 csmcore>nul
if not errorlevel 1 (
	:mm1
	set m5=5 
	echo 5 Marvell SATA Option ROM and EFI
	call :mrvlver
)

hexfind 4A4D6963726F6E csmcore>nul
if not errorlevel 1 (
	set m6=6
	echo 6 JMicron SATA Option ROM
	%verojmb%
)

if %m7%==7 (
	echo 7 Update Intel CPU MicroCode %pcpu%
	if %s1155%==1 drvver temp\cpuffs.tmp
	if %s1150%==1 drvver temp\cpuffs.tmp
)

if exist temp\agesa.tmp (echo   AMD AGESA CPU Support) && %verfagesaam3% || %verfagesafmr% || %verfagesafml% || %verfagesafmt% || %verfagesafmk% || %verfagesafmb% || %verfagesafm2% || %verfagesafmo%

echo 9 Look the Version of all UBU modules in VerDID.txt
echo 0 Exit
echo Press ENTER - Re-Scanning ALL EFI modules.

echo.
set /p enter=Enter number:
if not defined enter goto mn
if %enter%==1 if %m1%==11 goto isata
if %enter%==1 if %m1%==12 goto asata
if %enter%==2 if %m2%==21 goto video
if %enter%==2 if %m2%==22 goto videa
if %enter%==3 goto lan
if %enter%==4 if %m4%==4 goto asm
if %enter%==5 if %m5%==5 goto marv
if %enter%==6 if %m6%==6 goto jmb
if %enter%==7 if %m7%==7 goto cpu
if %enter%==9 goto view
if %enter%==0 goto exit
goto mn1

:isata
:rst
set ec=
set rome=0
hexfind 52617069642053746F7261676520546563686E6F6C6F6779202D csmcore>nul || set rome=1
if exist temp\satadrv90.tmp hexfind 52005300540065002000 temp\satadrv90.tmp>nul || set rome=0
if exist temp\satadrv91.tmp hexfind 52005300540065002000 temp\satadrv91.tmp>nul || set rome=0
if %rome%==1 goto rste

echo.
echo 	Intel RST OROM and EFI SataDriver
echo.
echo 1 - Update to v11.6.0.1702
echo 2 - Update to v12.9.0.2006
echo 3 - Update to v13.5.0.2118
hexfind 656E7465727072697365202D2053415441 csmcore>nul && echo 9 - Goto Update IRSTe/SCU
if %s1155%==1 echo T - IRST TRIM-in-RAID0 Addon for Intel 6-Series motherboards
echo 0 - Exit to Main Menu
echo.
:rst1
set /p ec= Enter number:
if not defined ec goto rst1
if %ec%==1 (
	set v=Modules\irst\11_6
	goto prcs
)
if %ec%==2 (
	set v=Modules\irst\12_9
	goto prcs
)
if %ec%==3 (
	set v=Modules\irst\13_5
	goto prcs
)
if %s2011%==1 if %ec%==9 goto rste
if %s1155%==1 if /I %ec%==t goto sata_trim
if %ec%==0 goto mn1
goto rst1

:sata_trim
set ec=
echo.
echo 	Intel RST OROM and EFI SataDriver
echo 	TRIM-in-RAID0 For Intel 6-Series motherboards
echo.
echo 1 - Update to v11.2.0.1527 TRIM-in-RAID0 (OROM only)
echo 2 - Update to v11.6.0.1702 TRIM-in-RAID0
echo 3 - Update to v12.7.0.1936 TRIM-in-RAID0
echo 4 - Update to v12.9.0.2006 TRIM-in-RAID0
echo 0 - Exit to Main Menu
echo.
:rstt
set /p ec= Enter number:
if not defined ec goto rstt
if %ec%==1 (
	set v=Modules\irst\TRIM6\11_2
	goto oprom
)
if %ec%==2 (
	set v=Modules\irst\TRIM6\11_6
	goto prcs
)
if %ec%==3 (
	set v=Modules\irst\TRIM6\12_7
	goto prcs
)
if %ec%==4 (
	set v=Modules\irst\TRIM6\12_9
	goto prcs
)
if %ec%==0 goto mn1
goto rstt

:prcs
set brend=Intel SataDriver
if exist temp\satadrv90.tmp set ftmp=temp\satadrv90.tmp && set eguid=90C8D394 && set guid=90C8D394-4E04-439C-BA55-2D8CFCB414ED && set ffs=%v%\satadriver90.ffs && call :ffsu
if exist temp\satadrv91.tmp set ftmp=temp\satadrv91.tmp && set eguid=91B4D9C1 && set guid=91B4D9C1-141C-4824-8D02-3C298E36EB3F && set ffs=%v%\satadriver91.ffs && call :ffsu
if exist temp\satadrv43c.tmp set ftmp=temp\satadrv43c.tmp && set eguid=43A0B8C4 && set guid=43A0B8C4-1160-1702-A46D-DDC03E52CB5C && set ffs=%v%\satadriver43.ffs  && call :ffsu
:oprom
set brend=Intel RST
(hexfind 0086802228 csmcore>nul || hexfind A086802228 csmcore>nul) && set did=2822 && set romf=%v%\sataorom.bin 8086 2822 && call :romu
(hexfind 0086802a28 csmcore>nul || hexfind A086802a28 csmcore>nul) && set did=282a && set romf=%v%\sataorom.bin 8086 282a && call :romu
if exist temp\55aa.tmp hexfind 5043495286802228 temp\55aa.tmp>nul && set did=55aa && set romf=%v%\sataorom.bin 8086 55aa && call :romu
hexfind 656E7465727072697365202D2053415441 csmcore>nul && goto rste || goto sataend

:rste
set ec=
echo.
echo 	Intel RSTe OROM and EFI SataDriver
echo.
echo 1 - Update to v3.8.0.1029
echo 2 - Update to v4.1.0.1026
hexfind 4153555342 %bios%>nul && hexfind B3A7A043921EEF42A46DDDC03E52CB5C %bios%>nul && echo 3 - Update to v3.8.0.1029 OROM + v12.9.0.2006 EFI
hexfind 4153555342 %bios%>nul && hexfind B3A7A043921EEF42A46DDDC03E52CB5C %bios%>nul && echo 4 - Update to v3.8.0.1029 OROM + v13.5.0.2118 EFI
hexfind 4153555342 %bios%>nul && hexfind B3A7A043921EEF42A46DDDC03E52CB5C %bios%>nul && echo 5 - Update to v4.1.0.1026 OROM + v12.9.0.2006 EFI
hexfind 4153555342 %bios%>nul && hexfind B3A7A043921EEF42A46DDDC03E52CB5C %bios%>nul && echo 6 - Update to v4.1.0.1026 OROM + v13.5.0.2118 EFI

echo 0 - Skip
echo.
:rste1
set /p ec= Enter number:
if not defined ec goto rste1
if %ec%==1 (
	set v=Modules\irst\3_8
	goto prcse
)
if %ec%==2 (
	set v=Modules\irst\4_1
	goto prcse
)
if %ec%==3 (
	set v=Modules\irst\3_8
	set ffs=Modules\irst\12_9\satadriver43_x79.ffs
	goto x79
)
if %ec%==4 (
	set v=Modules\irst\3_8
	set ffs=Modules\irst\13_5\satadriver43_x79.ffs
	goto x79
)
if %ec%==5 (
	set v=Modules\irst\4_1
	set ffs=Modules\irst\12_9\satadriver43_x79.ffs
	goto x79
)
if %ec%==6 (
	set v=Modules\irst\4_1
	set ffs=Modules\irst\13_5\satadriver43_x79.ffs
	goto x79
)

if %ec%==0 goto sataend
goto rste1

:prcse
set brend=Intel SataDriver
if exist temp\satadrv91.tmp set ftmp=temp\satadrv91.tmp && set eguid=91B4D9C1 && set guid=91B4D9C1-141C-4824-8D02-3C298E36EB3F && set ffs=%v%\satadriver_91.ffs && call :ffsu
if exist temp\satadrv43.tmp set ftmp=temp\satadrv43.tmp && set eguid=43A0A7B3 && set guid=43A0A7B3-1E92-42EF-A46D-DDC03E52CB5C && set ffs=%v%\satadriver_43.ffs && call :ffsu
set brend=Intel SCUDriver
if exist temp\scudrv85.tmp set ftmp=temp\scudrv85.tmp && set eguid=85FB8D3D && set guid=85FB8D3D-61A4-4518-9ACF-76FCAE169568 && set ffs=%v%\scudriver_85.ffs && call :ffsu
set brend=Intel RSTe
(hexfind 0086802628 csmcore>nul || hexfind A086802628 csmcore>nul) && set did=2826 && set romf=%v%\sataorom.bin 8086 2826 && call :romu
set brend=Intel RSTe SCU
(hexfind 008680681D csmcore>nul || hexfind A08680681D csmcore>nul) && set did=1d68 && set romf=%v%\scuorom.bin 8086 1d68 && call :romu
(hexfind 008680691D csmcore>nul || hexfind A08680691D csmcore>nul) && set did=1d69 && set romf=%v%\scuorom.bin 8086 1d69 && call :romu
goto sataend

:x79
set brend=Intel SataDriver
hexfind 4153555342 %bios%>nul && if exist temp\satadrv43.tmp set ftmp=temp\satadrv43.tmp && set eguid=43A0A7B3 && set guid=43A0A7B3-1E92-42EF-A46D-DDC03E52CB5C && call :ffsu
set brend=Intel RSTe
(hexfind 0086802628 csmcore>nul || hexfind A086802628 csmcore>nul) && set did=2826 && set romf=%v%\sataorom.bin 8086 2826 && call :romu
:sataend
echo.
%mmt1%
call :irstd
pause
goto mn1

:asata
:as
set ec=
echo.
echo 	AMD OROM and EFI Nodules
echo.
if %arom%==1 if %amdahci%==0 echo 1 - Update to v%amdr% RAID OROM
if %arom%==1 if %amdahci%==4391 echo 1 - Update to v%amda4% AHCI / v%amdr% RAID OROM
if %arom%==1 if %amdahci%==7801 echo 1 - Update to v%amda7% AHCI / v%amdr% RAID OROM

if %aefi%==1 echo 2 - Update to v%amdru% RAID and Utilites EFI
if %axpt%==1 echo 3 - Update to v%amdxpt2of10% / v%amdxpt2of50% RAIDXpert2 F10/F50 OROM
if %axpt%==1 echo 4 - Update to v%amdxpt2ef10% / v%amdxpt2ef50% RAIDXpert2 F10/F50 EFI
echo 5 - Update all modules
echo 0 - Exit Main Menu
echo.
:as1
set /p ec= Enter number:
if not defined ec goto as1

if %arom%==1 if %ec%==1 goto samd
if %aefi%==1 if %ec%==2 goto samde
if %axpt%==1 if %ec%==3 goto samdxo
if %axpt%==1 if %ec%==4 goto samdxe
if %ec%==5 goto samd
if %ec%==0 goto mn1
goto as1

:samd
if %asus%==0 (
	set miscfc=4392_FC.ffs
	set miscfd=4393_FD.ffs
) else (
	set miscfc=4393_FC.ffs
	set miscfd=4392_FD.ffs
)
set FC4392=0
set FD4393=0
set FC7802=0
set FD7803=0

set brend=AND AHCI
if exist temp\55aa.tmp hexfind 5043495202109143 temp\55aa.tmp>nul && set did=4391 && set romf=%sda%\4391a.bin 1002 55AA && call :romu && %mmt% /e /l temp\55aa.tmp 1002 55AA
if exist temp\4391.tmp hexfind 5043495202109143 temp\4391.tmp>nul && set did=4391 && set romf=%sda%\4391a.bin 1002 4391 && call :romu && %mmt% /e /l temp\4391.tmp 1002 4391
if exist temp\55aa.tmp hexfind 5043495222100178 temp\55aa.tmp>nul && set did=7801 && set romf=%sda%\7801a.bin 1022 55AA && call :romu && %mmt% /e /l temp\55aa.tmp 1022 55AA
if exist temp\7801.tmp hexfind 5043495222100178 temp\7801.tmp>nul && set did=7801 && set romf=%sda%\7801a.bin 1022 7801 && call :romu && %mmt% /e /l temp\7801.tmp 1022 7801

set brend=AND RAID
if exist temp\4392.tmp hexfind 5043495202109243 temp\4392.tmp>nul && set FC4392=1 && set did=4392 && set romf=%sda%\4392r.bin 1002 4392 && call :romu && %mmt% /e /l temp\4392.tmp 1002 4392
if exist temp\4393.tmp hexfind 5043495202109343 temp\4393.tmp>nul && set FD4393=1 && set did=4393 && set romf=%sda%\4393r.bin 1002 4393 && call :romu && %mmt% /e /l temp\4393.tmp 1002 4393

set brend=AND MISC %miscfc%
if exist temp\miscFC.tmp if %FC4392%==1 set ftmp=temp\miscFC.tmp && set eguid=9BD5C81D-...-FC && set guid=9BD5C81D-096C-4625-A08B-405F78FE0CFC && set ffs=%sda%\ffs\%miscfc% && call :ffsu
set brend=AND MISC %miscfd%
if exist temp\miscFD.tmp if %FD4393%==1 set ftmp=temp\miscFD.tmp && set eguid=9BD5C81D-...-FD && set guid=9BD5C81D-096C-4625-A08B-405F78FE0CFD && set ffs=%sda%\ffs\%miscfd% && call :ffsu

set brend=AND RAID
if exist temp\7802.tmp hexfind 5043495222100278 temp\7802.tmp>nul && set FC7802=1 && set did=7802 && set romf=%sda%\7802r.bin 1022 7802 && call :romu && %mmt% /e /l temp\7802.tmp 1022 7802
if exist temp\7803.tmp hexfind 5043495222100378 temp\7803.tmp>nul && set FD7803=1 && set did=7803 && set romf=%sda%\7803r.bin 1022 7803 && call :romu && %mmt% /e /l temp\7803.tmp 1022 7803

set brend=AND MISC for 7802
if exist temp\miscFC.tmp if %FC7802%==1 set ftmp=temp\miscFC.tmp && set eguid=9BD5C81D-...-FC && set guid=9BD5C81D-096C-4625-A08B-405F78FE0CFC && set ffs=%sda%\ffs\7802_FC.ffs && call :ffsu
set brend=AND MISC for 7803
if exist temp\miscFD.tmp if %FD7803%==1 set ftmp=temp\miscFD.tmp && set eguid=9BD5C81D-...-FD && set guid=9BD5C81D-096C-4625-A08B-405F78FE0CFD && set ffs=%sda%\ffs\7803_FD.ffs && call :ffsu
if %ec%==1 goto samdend

:samde
set brend=AMD RAIDx64
if exist temp\raidx64.tmp set ftmp=temp\raidx64.tmp && set eguid=C468B382- && set guid=C468B382-4550-4909-AD57-2496141B3F4A && set ffs=%sda%\ffs\RaidX64.ffs && call :ffsu
set brend=AMD RAID Setup
if exist temp\raidutil.tmp set ftmp=temp\raidutil.tmp && set eguid=0916E322- && set guid=0916E322-3740-31CE-AD62-BD172CECCA36 && set ffs=%sda%\ffs\RaidSetup.ffs && call :ffsu
set brend=AMD SCSI Bus
if exist temp\ScsiBus.tmp set ftmp=temp\ScsiBus.tmp && set eguid=0167CCC4- && set guid=0167CCC4-D0F7-4F21-A3EF-9E64B7CDCE8B && set ffs=%sda%\ffs\ScsiBus.ffs && call :ffsu
set brend=AMD SCSI Disk
if exist temp\ScsiDisk.tmp set ftmp=temp\ScsiDisk.tmp && set eguid=0A66E322- && set guid=0A66E322-3740-4CCE-AD62-BD172CECCA35 && set ffs=%sda%\ffs\ScsiDisk.ffs && call :ffsu
set brend=AMD Hii Database
if exist temp\HiiDatabase.tmp set ftmp=temp\HiiDatabase.tmp && set eguid=0916E322- && set guid=0916E322-3740-4CCE-AD62-BD172CECCA35 && set ffs=%sda%\ffs\HiiDatabase.ffs && call :ffsu
if %ec%==2 goto samdend

:samdxo
set brend=AMD RAIDXpert2 10
if exist temp\RAIDxpt2f10o.tmp set did=8803 && set romf=%sda%\raid_f10.bin 1022 8803 && call :romu && %mmt% /e /l temp\RAIDxpt2f10o.tmp 1022 8803
set brend=AMD RAIDXpert2 F50
if exist temp\RAIDxpt2f50o.tmp set did=8804 && set romf=%sda%\raid_f50.bin 1022 8804 && call :romu && %mmt% /e /l temp\RAIDxpt2f50o.tmp 1022 8804
if %ec%==3 goto samdend

:samdxe
set brend=AMD RAIDXpert2 F10
if exist temp\RAIDxpt2f10e.tmp set ftmp=temp\RAIDxpt2f10e.tmp && set eguid=50965C18- && set guid=50965C18-2F65-41A9-9961-BA889EA978D9 && set ffs=%sda%\ffs\raid_f10.ffs && call :ffsu
set brend=AMD RAIDXpert2 F50
if exist temp\RAIDxpt2f50e.tmp set ftmp=temp\RAIDxpt2f50e.tmp && set eguid=5CF6CEDE- && set guid=5CF6CEDE-0DED-4013-9196-F429DE361937 && set ffs=%sda%\ffs\raid_f50.ffs && call :ffsu

:samdend
echo.
call :amdd
pause
goto mn1

:video
if %s1150%==1 goto has
:is
set ec=
echo.
echo 	Intel OROM VBIOS and EFI GOP Driver
echo.
if %vi%==1 set outve=and v2.0.1024/v3.0.1027 EFI GOP Drivers
echo 1 - Update to v2170 OROM %outve%
if %vi%==1 echo 2 - Update to v2.0.1024/v3.0.1027 EFI GOP Drivers ONLY
echo 0 - Exit Main Menu
echo.
:is1
set /p ec= Enter number:
if not defined ec goto is1
if %ec%==0 goto mn1
if %ec%==1 (
	set vb=%sdv%\2170.bin
	goto v1
)
if %ec%==2 if %vi%==1 goto gop
goto is1

:v1
set brend=Intel VGA BIOS SandyBridge/IvyBridge
hexfind 0086800201 csmcore>nul && set did=102 && set romf=%vb% 8086 102 && call :romu
hexfind 0086806201 csmcore>nul && set did=162 && set romf=%vb% 8086 162 && call :romu
:gop
set brend=Intel GOP Driver IvyBridge
if exist temp\GopHas.tmp set ftmp=temp\GopHas.tmp && set eguid=5BBA83E6 && set guid=5BBA83E6-F027-4CA7-BFD0-16358CC9E123 && set ffs=%sdv%\gop\GopIVB.ffs && call :ffsu
set brend=Intel GOP Driver SandyBridge
if exist temp\GopSan.tmp set ftmp=temp\GopSan.tmp && set eguid=8D59EBC8 && set guid=8D59EBC8-B85E-400E-970A-1F995D1DB91E && set ffs=%sdv%\gop\GopSNB.ffs && call :ffsu
goto endvid

:has
if exist Modules\vbios.dat for /f "tokens=*" %%a in ('findver "v" 245642542048 79 FF 4 1 Modules\vbios.dat') do set vbios=%%a
set ec=
echo.
echo 	Intel OROM VBIOS and EFI GOP Driver
echo.
echo 1 - Update to v5.0.1037 EFI Haswell GOP Driver ONLY
echo 2 - Update to v5.5.1024 EFI Broadwell GOP Driver ONLY
if exist Modules\vbios.dat echo 3 - Update to %vbios% OROM and v5.0.1037 EFI GOP Driver
if exist Modules\vbios.dat echo 4 - Update to %vbios% OROM and v5.5.1024 EFI GOP Driver
echo 0 - Exit to Main Menu
echo.
:has1
set /p ec= Enter number:
if not defined ec goto has1
if %ec%==1 set gop=%sdv%\gop\GopHSW.ffs && goto gop1
if %ec%==2 set gop=%sdv%\gop\GopBDW.ffs && goto gop1
if exist Modules\vbios.dat if %ec%==3 set gop=%sdv%\gop\GopHSW.ffs && goto v2
if exist Modules\vbios.dat if %ec%==4 set gop=%sdv%\gop\GopBDW.ffs && goto v2
if %ec%==0 goto mn1
goto has1

:v2
set vb=Modules\vbios.dat
set brend=Intel VGA BIOS Haswell/Broadwell
hexfind 0086800204 csmcore>nul && set did=402 && set romf=%vb% 8086 402 && call :romu
hexfind 0086801204 csmcore>nul && set did=412 && set romf=%vb% 8086 412 && call :romu
hexfind 008680020c csmcore>nul && set did=c02 && set romf=%vb% 8086 c02 && call :romu
hexfind 008680120c csmcore>nul && set did=c12 && set romf=%vb% 8086 c12 && call :romu

:gop1
set brend=Intel GOP Driver Haswell/Broadwell
if exist temp\GopHas.tmp set ftmp=temp\GopHas.tmp && set eguid=5BBA83E6 && set guid=5BBA83E6-F027-4CA7-BFD0-16358CC9E123 && set ffs=%gop% && call :ffsu
set brend=Intel VBT Haswell/Broadwell
set vb=Modules\vbt.ffs
if exist Modules\vbt.ffs if exist temp\vbtffs.tmp set ftmp=temp\vbtffs.tmp && set eguid=878AC2CC && set guid=878AC2CC-5343-46F2-B563-51F89DAF56BA && set ffs=%vb% && call :ffsu

:endvid
echo.
%mmt1%
call :videod
pause
goto mn1

:videa
set ec=
echo.
echo 	AND EFI GOP Driver
echo.
echo 1 - Update to v1.54.0.0.0 EFI GOP Driver
echo 0 - Exit to Main Menu
echo.
:amdgop1
set /p ec= Enter number:
if not defined ec goto amdgop1
if %ec%==1 set gop=%sdv%\gop\GopAMD.ffs && goto gop4
if %ec%==0 goto mn1
goto amdgop1

:gop4
set brend=AMD GOP Driver
if exist temp\Gopamd.tmp set ftmp=temp\Gopamd.tmp && set eguid=48DCABDF- && set guid=48DCABDF-CE6D-465C-B832-FD1BD169F3EA && set ffs=%gop% && call :ffsu

echo.
drvver temp\gopamd.tmp
pause
goto mn1

:lan
:lm
set ec=
echo.
echo 	LAN OROM PXE and EFI UNDI  Intel, Realtek, BCM, QCA
echo.
echo 1 - Update ALL LAN OROM and EFI:
if %lanir%==1 if %lanie%==1 echo     Intel LAN %ilo% %ile%
if %lanir%==1 if %lanie%==0 echo     Intel LAN %ilo%
if %lanir%==0 if %lanie%==1 echo     Intel LAN %ile%
if %lanrr%==1 if %lanre%==1 echo     Realtek LAN %rlo% %rle% 
if %lanrr%==1 if %lanre%==0 echo     Realtek LAN %rlo% 
if %lanrr%==0 if %lanre%==1 echo     Realtek LAN %rle%
if %lanar%==1 if %lanae%==0 echo     QCM-Atheros LAN %alo%
if %lanbr%==1 if %lanbe%==1 echo     Broadcom LAN %blo% %ble%
if %lanbr%==1 if %lanbe%==0 echo     Broadcom LAN %blo%
if %lanbr%==0 if %lanbe%==1 echo     Broadcom LAN %ble%
echo 0 - Exit Main Menu
echo.
:lm1
set /p ec= Enter number:
if not defined ec goto lm1
if %ec%==0 goto mn1
if %ec%==1 goto lans
goto lm1

:lans
set brend=Intel UNDI
if exist temp\lani49.tmp set ftmp=temp\lani49.tmp && set eguid=4953F720 && set guid=4953F720-006D-41F5-990D-0AC7742ABB60 && set ffs=%sdl%\ffs\IntelGigabitLanX64_49.ffs && call :ffsu
if exist temp\lani10.tmp set ftmp=temp\lani10.tmp && set eguid=10989AA4 && set guid=10989AA4-6A03-48FF-AF9A-EB2A38F34611 && set ffs=%sdl%\ffs\IntelGigabitLanX64_10.ffs && call :ffsu
if exist temp\lani49m.tmp set ftmp=temp\lani49m.tmp && set eguid=4953F720 && set guid=4953F720-006D-41F5-990D-0AA8853BCC71 && set ffs=%sdl%\ffs\IntelGigabitLanX64_49m.ffs && call :ffsu
if exist temp\lani1b.tmp set ftmp=temp\lani1b.tmp && set eguid=1B22B3F2 && set guid=1B22B3F2-3151-4468-8AF3-590650EEAD22 && set ffs=%sdl%\ffs\IntelGigabitLanX64_1B.ffs && call :ffsu
set brend=Intel LAN PXE
hexfind 008680d310 csmcore>nul && set did=10d3 && set romf=%sdl%\intpxe10d3.lom 8086 10d3 && call :romu
hexfind 0086800215 csmcore>nul && set did=1502 && set romf=%sdl%\intpxe1502.lom 8086 1502 && call :romu
hexfind 0086800315 csmcore>nul && set did=1503 && set romf=%sdl%\intpxe1503.lom 8086 1503 && call :romu
hexfind 0086803315 csmcore>nul && set did=1533 && set romf=%sdl%\intpxe1533.lom 8086 1533 && call :romu
hexfind 0086800c15 csmcore>nul && set did=150c && set romf=%sdl%\intpxe150c.lom 8086 150c && call :romu
hexfind 0086803a15 csmcore>nul && set did=153a && set romf=%sdl%\intpxe153a.lom 8086 153a && call :romu
hexfind 0086803b15 csmcore>nul && set did=153b && set romf=%sdl%\intpxe153b.lom 8086 153b && call :romu
hexfind 008680a015 csmcore>nul && set did=15a0 && set romf=%sdl%\intpxe15a0.lom 8086 15a0 && call :romu
hexfind 008680a115 csmcore>nul && set did=15a1 && set romf=%sdl%\intpxe15a1.lom 8086 15a1 && call :romu

:rtk
set brend=Realtek UNDI
if exist temp\lanr2e.tmp set ftmp=temp\lanr2e.tmp && set eguid=2EAA04AA && set guid=2EAA04AA-5EED-4C27-B9EE-26916EC25A8F && set ffs=%sdl%\ffs\RtkUndiDxeX64_2e.ffs && call :ffsu
if exist temp\lanr28.tmp set ftmp=temp\lanr28.tmp && set eguid=2851E234 && set guid=2851E234-20FD-4D1E-9041-DCB8F3025CAE && set ffs=%sdl%\ffs\RtkUndiDxeX64_28.ffs && call :ffsu
if exist temp\lanr4960.tmp set ftmp=temp\lanr4960.tmp && set eguid=4953F720 && set guid=4953F720-006D-41F5-990D-0AC7742ABB60 && set ffs=%sdl%\ffs\RtkUndiDxeX64_49.ffs && call :ffsu
if exist temp\lanr4971.tmp set ftmp=temp\lanr4971.tmp && set eguid=4953F720 && set guid=4953F720-006D-41F5-990D-0AA8853BCC71 && set ffs=%sdl%\ffs\RtkUndiDxeX64_49m.ffs && call :ffsu
if exist temp\lanr49b0.tmp set ftmp=temp\lanr49b0.tmp && set eguid=4953F720 && set guid=4953F720-006D-41F5-990D-0AC7742AAAB0 && set ffs=%sdl%\ffs\RtkUndiDxeX64_49e.ffs && call :ffsu
if exist temp\lanreb.tmp set ftmp=temp\lanreb.tmp && set eguid=EB53FCAD && set guid=EB53FCAD-3071-4BAB-980C-6E4A379255F3 && set ffs=%sdl%\ffs\RtkUndiDxeX64_eb.ffs && call :ffsu
if exist temp\lanr50.tmp set ftmp=temp\lanr50.tmp && set eguid=50994E78 && set guid=50994E78-18D5-4121-9144-16C370A16192 && set ffs=%sdl%\ffs\RtkUndiDxeX64_50.ffs && call :ffsu
if exist temp\lanr5a.tmp set ftmp=temp\lanr5a.tmp && set eguid=5A4D0030 && set guid=5A4D0030-9DB6-11E1-A8B0-0800200C9A66 && set ffs=%sdl%\ffs\RtkUndiDxeX64_5a.ffs && call :ffsu
if exist temp\lanr5e.tmp set ftmp=temp\lanr5e.tmp && set eguid=5E53CBEB && set guid=5E53CBEB-C4E1-4393-B8FB-7267A118CB1E && set ffs=%sdl%\ffs\RtkUndiDxeX64_5e.ffs && call :ffsu
if exist temp\lanr7c.tmp set ftmp=temp\lanr7c.tmp && set eguid=7CA37284 && set guid=7CA37284-28A0-4E07-9D05-240A10787968 && set ffs=%sdl%\ffs\RtkUndiDxeX64_7c.ffs && call :ffsu
if exist temp\lanr82.tmp set ftmp=temp\lanr82.tmp && set eguid=82CBD50E && set guid=82CBD50E-D18A-46A8-B14B-4D206B33183F && set ffs=%sdl%\ffs\RtkUndiDxeX64_82.ffs && call :ffsu

set brend=Realtek LAN PXE
hexfind 00EC10AA55 csmcore>nul && set did=55AA && set romf=%sdl%\rtkpxe8168.lom 10ec 55aa && call :romu
hexfind 00ec106881 csmcore>nul || hexfind a0ec106881 csmcore>nul
if not errorlevel 1 (
	set did=8168
	hexfind 5265616C74656B2050434965204742452046616D696C7920436F6E74726F6C6C657220536572696573204D4C4944 csmcore>nul
	if not errorlevel 1 (
		set romf=%sdl%\rtkrpl8168.lom 10ec 8168
		call :romu
	) else (
		set romf=%sdl%\rtkpxe8168.lom 10ec 8168
		call :romu
	)
)

hexfind 00ec106981 csmcore>nul || hexfind a0ec106981 csmcore>nul
if not errorlevel 1 (
	set did=8169
	hexfind 5265616C74656B2050434965204742452046616D696C7920436F6E74726F6C6C657220536572696573204D4C4944 csmcore>nul
	if not errorlevel 1 (
		set romf=%sdl%\rtkrpl8169.lom 10ec 8169
		call :romu
	) else (
		set romf=%sdl%\rtkpxe8169.lom 10ec 8169
		call :romu
	)	
)


:qcmath
set brend=QCM-Atheros LAN PXE
hexfind 0069198310  csmcore>nul && set did=1083 && set romf=%sdl%\athpxe1083.lom 1969 1083 && call :romu
hexfind 0069199110  csmcore>nul && set did=1091 && set romf=%sdl%\athpxe1091.lom 1969 1091 && call :romu
hexfind 006919a110  csmcore>nul && set did=10a1 && set romf=%sdl%\athpxe1091.lom 1969 10a1 && call :romu
hexfind 00691991e0  csmcore>nul && set did=e091 && set romf=%sdl%\athpxee091.lom 1969 e091 && call :romu

:bcm
set brend=Broadcom NetXtreme UNDI
if exist temp\lanbdf.tmp set ftmp=temp\lanbdf.tmp && set eguid=DF4F6190 && set guid=DF4F6190-42B8-4CA9-BA51-7A801B565F08 && set ffs=%sdl%\ffs\b57undix64_df.ffs && call :ffsu
if exist temp\lanb50.tmp set ftmp=temp\lanb50.tmp && set eguid=50994E78 && set guid=50994E78-18D5-4121-9144-16C370A16192 && set ffs=%sdl%\ffs\b57undix64_50.ffs && call :ffsu
set brend=Broadcom NetXtreme LAN PXE
hexfind 00e414b116 csmcore>nul && set did=16b1 && set romf=%sdl%\bcmpxe16b1.lom 14e4 16b1 && call :romu
hexfind 00e4149916 csmcore>nul && set did=16b1 && set romf=%sdl%\bcmpxe1699.lom 14e4 1699 && call :romu

echo.
%mmt1%
%verolani% && set lanir=1
call :inlver

%verolanr% && set lanrr=1
call :rtkver

%verolanq% && set lanar=1

%verolanb% && set lanbr=1
call :bcmver

pause
goto mn1

:asm
set ec=
echo.
echo 	AsMedia SATA Option ROM
echo.
echo 1 - Update to v0.954 for ASM1061 chip
echo 2 - Update to v3.70  for ASM1062 chip and later
echo 0 - Exit to Main Menu
echo.
:asm1
set /p ec= Enter number:
if not defined ec goto asm1
if %ec%==1 set asmbin=asmed0954.bin && goto asms
if %ec%==2 set asmbin=asmed370.bin && goto asms
if %ec%==0 goto mn1
goto asm1
:asms
set brend=ASMedia 106x SATA/PATA
(hexfind 00211b1106 csmcore>nul || hexfind A0211b1106 csmcore>nul) && set did=611 && set romf=%sds%\%asmbin% 1b21 611 && call :romu
(hexfind 00211b1206 csmcore>nul || hexfind A0211b1206 csmcore>nul) && set did=612 && set romf=%sds%\%asmbin% 1b21 612 && call :romu
(hexfind 00211b1306 csmcore>nul || hexfind A0211b1306 csmcore>nul) && set did=613 && set romf=%sds%\%asmbin% 1b21 613 && call :romu

echo.
%mmt1%
%veroasm%
pause
goto mn1

:marv
set ec=
set mvv=
echo.
if %me%==1 (echo 	Marvell SATA Option ROM and EFI) else (echo 	Marvell SATA Option ROM)
echo.
echo 1 - Update OROM Marvell
hexfind 504349524b1b2091 csmcore>nul && echo     OROM Marvell 88SE9120 - %mrv1%
hexfind 504349524b1ba091 csmcore>nul && echo     OROM Marvell 88SE91a0 - %mrv1% 
hexfind 504349524b1b2391 csmcore>nul && echo     OROM Marvell 88SE9123 - %mrv1%
hexfind 504349524b1ba391 csmcore>nul && echo     OROM Marvell 88SE91a3 - %mrv1%
hexfind 504349524b1b7291 csmcore>nul && echo     OROM Marvell 88SE9172 - %mrv2%
hexfind 504349524b1b7a91 csmcore>nul && echo     OROM Marvell 88SE917a - %mrv2%
hexfind 504349524b1b8291 csmcore>nul && echo     OROM Marvell 88SE9182 - %mrv2%
hexfind 504349524b1b8a91 csmcore>nul && echo     OROM Marvell 88SE918a - %mrv2%
hexfind 504349524b1b2891 csmcore>nul && echo     OROM Marvell 88SE9128 - %mrv1%
hexfind 504349524b1b9291 csmcore>nul && echo     OROM Marvell 88SE9192 - %mrv3%
hexfind 504349524b1ba291 csmcore>nul && echo     OROM Marvell 88SE91a2 - %mrv3%
hexfind 504349524b1b3091 csmcore>nul && echo     OROM Marvell 88SE9130 - %mrv1%
hexfind 004b1b309200 csmcore>nul && hexfind 504349524b1b3092 csmcore>nul && echo     OROM Marvell 88SE9230 - %mrv4%
if exist temp\mrv*.tmp (
for /f "tokens=*" %%b in ('dir temp\mrv*.tmp /b') do hexfind 4D415256454C4C2052616964 temp\%%b>nul && (echo     EFI Marvell SATA RAID - %mrvr%) || (echo     EFI Marvell SATA AHCI - %mrva%)
)

echo 0 - Exit Main Menu
echo.
:marv1
set /p ec= Enter number:
if not defined ec goto marv1
if %ec%==0 goto mn1
if %ec%==1 goto marvs
goto marv1

:marvs

set brend=Marvell SATA
if %me%==1 if exist temp\mrv43.tmp set ftmp=temp\mrv43.tmp && set eguid=4331898D- && set guid=4331898D-CCB8-4108-898C-A5CC81442B28 && set ffs=%sds%\ffs\marv_ahci_43.ffs && call :ffsu
if %me%==1 if exist temp\mrva2.tmp set ftmp=temp\mrva2.tmp && set eguid=A28F1CD7- && set guid=A28F1CD7-3B64-4E5F-992D-C8F69CBBFD84 && set ffs=%sds%\ffs\marv_raid_a2.ffs && call :ffsu
if %me%==1 if exist temp\mrv491.tmp set ftmp=temp\mrv491.tmp && set eguid=4953F720-..1 && set guid=4953F720-006D-41F5-990D-0AC7742ABB61 && set ffs=%sds%\ffs\marv_ahci_491.ffs && call :ffsu
if %me%==1 if exist temp\mrv492.tmp set ftmp=temp\mrv492.tmp && set eguid=4953F720-..2 && set guid=4953F720-006D-41F5-990D-0AC7742ABB62 && set ffs=%sds%\ffs\marv_raid_492.ffs && call :ffsu

set brend=Marvell SATA
hexfind 004b1b309200 csmcore>nul && set did=9230 && set romf=%sds%\Mrvll9230.bin 1b4b 9230 && call :romu
hexfind 004b1b2091 csmcore>nul && set did=9120 && set romf=%sds%\Mrvll9120.bin 1b4b 9120 && call :romu
hexfind 004b1ba091 csmcore>nul && set did=91a0 && set romf=%sds%\Mrvll91a0.bin 1b4b 91a0 && call :romu
hexfind 004b1b2391 csmcore>nul && set did=9123 && set romf=%sds%\Mrvll9123.bin 1b4b 9123 && call :romu
hexfind 004b1ba391 csmcore>nul && set did=91a3 && set romf=%sds%\Mrvll91a3.bin 1b4b 91a3 && call :romu
hexfind 004b1b7291 csmcore>nul && set did=9172 && set romf=%sds%\Mrvll9172.bin 1b4b 9172 && call :romu
hexfind 004b1b7a91 csmcore>nul && set did=917a && set romf=%sds%\Mrvll917a.bin 1b4b 917a && call :romu
hexfind 004b1b8291 csmcore>nul && set did=9182 && set romf=%sds%\Mrvll9182.bin 1b4b 9182 && call :romu
hexfind 004b1b8a91 csmcore>nul && set did=918a && set romf=%sds%\Mrvll918a.bin 1b4b 918a && call :romu
hexfind 004b1b2891 csmcore>nul && set did=9128 && set romf=%sds%\Mrvll9128.bin 1b4b 9128 && call :romu
hexfind 004b1b9291 csmcore>nul && set did=9192 && set romf=%sds%\Mrvll9192.bin 1b4b 9192 && call :romu
hexfind 004b1ba291 csmcore>nul && set did=91a2 && set romf=%sds%\Mrvll91a2.bin 1b4b 91a2 && call :romu
hexfind 004b1b3091 csmcore>nul && hexfind 504349524b1b3091 csmcore>nul && set did=9130 && set romf=%sds%\Mrvll9130.bin 1b4b 9130 && call :romu
hexfind 004b1b3091 csmcore>nul && hexfind 504349524b1b2891 csmcore>nul && set did=9128 && set romf=%sds%\Mrvll9128.bin 1b4b 9130 && call :romu

echo.
%mmt1%
call :mrvlver

pause
goto mn1

:jmb
set ec=
set jmb2363=0
echo.
echo 	JMicron SATA Option ROM
echo.
echo 1 - Update to v1.07.28
hexfind 007b196323 csmcore>nul && set jmb2363=1 && echo 2 - Update to v1.08.01
echo 0 - Exit to Main Menu
echo.
:jmb1
set /p ec= Enter number:
if not defined ec goto jmb1
if %ec%==0 goto mn1
if %ec%==1 set jmb362=%sds%\jmb362_7.bin && set jmb363=%sds%\jmb363_7.bin && goto jmbs
if %jmb2363%==1 if %ec%==2 set jmb362=%sds%\jmb362_7.bin && set jmb363=%sds%\jmb363_8.bin && goto jmbs
goto jmb1
:jmbs
set brend=JMicron SATA
hexfind 007b196223 csmcore>nul && set did=2362 && set romf=%jmb362% 197b 2362 && call :romu
hexfind 007b196323 csmcore>nul && set did=2363 && set romf=%jmb363% 197b 2363 && call :romu
echo.
%mmt1%
%verojmb%
pause
goto mn1

:romu
if %csm%==1 (
	<nul set /p TmpStr=* Update OROM %brend% Device ID %did%...
	%mmt% /r /l %romf%
	echo Ok!
) else (
	echo Option ROM not avaible for update
)
exit /b

:ffsu
(
<nul set /p TmpStr=* Update EFI %brend% GUID %eguid%-...
%mmt% /rc %guid% %ffs%
%mmt% /e %guid% %ftmp%
echo Ok!
exit /b
)

:cpu
if not exist Modules\cpui\Z_CPU0.ffs (
	echo ! Modules\cpui\Z_CPU0.ffs not found !
	pause
	goto mn1
)
set cpusup=0
set cvcpu="Current Version. Press ESC to close this window and continue."
set alcpu=You already have the last version of the CPU microcode. No update required.
if %s1150%==1 (
	set cpum=Haswell/Broadwell 6C3-1C
	set modcpu=Modules\cpui\LGA1150.ffs
)
if %s1155%==1 (
	set cpum=SandyBridge 6A7-29/IvyBridge 6A9-1B
	set modcpu=Modules\cpui\LGA1155.ffs
)
if %s2011%==1 (
	set cpum=SandyBridge-E and IvyBridge-E
	set modcpu=Modules\cpui\LGA2011.ffs
)

copy /y bios.bin temp\bios.tmp>nul
hexfind 2F7C71AE421A2B4F886178B79CA07E07 %bios%>nul && goto cpud1

%mmt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpuffs.tmp
hexfind 00F8FFFFFFFFFFFFFFFF temp\cpuffs.tmp>nul
if not errorlevel 1 goto cpud2 else goto cpuend

:cpud1
%mmtt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpuffs.tmp
hexfind 00F8FFFFFFFFFFFFFFFF temp\cpuffs.tmp>nul
if not errorlevel 1 (%mmtt% /d 17088572-377F-44EF-8F4E-B09FFF46A070 && goto cpud1) else goto cpuend

:cpud2
%mmtt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpuffs.tmp
hexfind 00F8FFFFFFFFFFFFFFFF temp\cpuffs.tmp>nul
if not errorlevel 1 (
	if %cpusup%==1 echo Currently not available. && goto cpugm
	%mmtt% /d 17088572-377F-44EF-8F4E-B09FFF46A070
	set cpusup=1
	goto cpud2
) else (
	goto cpuend
)

:cpugm
set sc=0
set ec=
echo.
echo 	Update Intel CPU MicroCode
echo.
echo 1 - Update CPU MicroCode %cpum%
if %s1155%==1 echo 2 - Update CPU MicroCode SandyBridge 6A7-28/IvyBridge 6A9-19 (For Overclokers)
if %s2011%==1 (
	echo 2 - Update CPU MicroCode SandyBridge-E 6D1-106, 6D2-20C, 6D3-304, 6D5-513, 6D6-619, 6D7-710
	echo 3 - Update CPU MicroCode IvyBridge-E 6E0-008, 6E2-20D, 6E3-308, 6E4-428, 6E6-600, 6E7-70D
)
echo 0 - Exit to Main Menu
echo.
:cpu1
set /p ec= Enter number:
if not defined ec goto cpu1
if %ec%==0 goto mn1
if %ec%==1 set sc=1 && goto cpus
if %s1155%==1 if %ec%==2 set modcpu=Modules\cpui\LGA1155over.ffs && goto cpus
if %s2011%==1 if %ec%==2 set modcpu=Modules\cpui\lga2011sbe.ffs && goto cpus
if %s2011%==1 if %ec%==3 set modcpu=Modules\cpui\lga2011ibe.ffs && goto cpus
goto cpu1

:cpus
:cpus1
if %cpusup%==1 (
	echo Remove "Empty" mpdule.
	%mmt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpu_zero.tmp
	%mmt% /r 17088572-377F-44EF-8F4E-B09FFF46A070 Modules\cpui\Z_CPU0.ffs
)
<nul set /p TmpStr=Update Microcode Patch...
%mmt% /r 17088572-377F-44EF-8F4E-B09FFF46A070 %modcpu%
echo Ok!
start "Result Update. Press ESC to close this window and continue." /wait mmtool bios.bin /p
if %cpusup%==1 (
	%mmt% /e 17088572-377F-44EF-8F4E-B09FFF46A070 temp\cpuffs.tmp
	echo Recovery "Empty" mpdule.
	%mmt% /r 17088572-0000-0000-0000-000000000001 temp\cpu_zero.tmp
)
goto mn1

:cpuend
if %s1150%==1 hexfind 010000001C00000014200307C3060300 temp\cpuffs.tmp>nul &&	echo %alcpu% &&	start /wait %cvcpu% mmtool temp\bios.tmp /p && goto mn1
start %cvcpu% mmtool temp\bios.tmp /p
goto cpugm

:view
cls
type modules\verdid.txt
echo.
pause
goto mn1

:err
echo !!! File BIOS not found !!!
pause>nul
exit

:exit
set ec=
echo.
if %asus%==0 goto exit1
:ubf
echo Detected BIOS Asus
hexfind 4A452A84E5758B408B1C36420E4E3F21 %bios%>nul
if not errorlevel 1 (
	echo !This BIOS contains a write protection!
	echo  For Flashing BIOS use UBF.
) else (
	echo This BIOS does not contain the write protection.
	echo  For Flashing BIOS use FTK utilites or UBF.
)
echo.
:ubf1
set /p ec=* ASUS Bios Renamer for USB BIOS Flashback UBF Y-Yes, Any key-No? :
if not defined ec goto ubf1
if /I %ec%==y (
	ren bios.bin asus.cap
	brenamer
)
:exit1
echo.
echo *********************************************************************
echo * Many thanks to CodeRush for utilites HexFind, DrvVer and FindVer. *
echo *********************************************************************
pause>nul
:exit2
if exist *.tmp del /f /q *.tmp
if exist csmcore del /f /q csmcore
if exist temp rd /s /q temp
exit

REM display version
:videod
(
%verosib%
%verohsw%
if exist temp\Gop*.tmp for /f "tokens=*" %%b in ('dir temp\Gop*.tmp /b') do drvver temp\%%b
exit /b
)

:irstd
(
%verosata%
%verosatae%
%verossata%
if exist temp\satadrv*.tmp for /f "tokens=*" %%b in ('dir temp\satadrv*.tmp /b') do drvver temp\%%b
%veroscu%
if exist temp\scudrv85.tmp drvver temp\scudrv85.tmp
exit /b
)

:amdd
(
if exist temp\4391.tmp findver "     OROM AMD AHCI 4391         - " 414D442041484349 22 00 10 1 temp\4391.tmp
if exist temp\7801.tmp findver "     OROM AMD AHCI 7801         - " 414D442041484349 22 00 10 1 temp\7801.tmp
if exist temp\55aa.tmp if %amdahci%==4391 findver "     OROM AMD AHCI 4391         - " 414D442041484349 22 00 10 1 temp\55aa.tmp
if exist temp\55aa.tmp if %amdahci%==7801 findver "     OROM AMD AHCI 7801         - " 414D442041484349 22 00 10 1 temp\55aa.tmp
if exist temp\4392.tmp findver "     OROM AMD RAID MISC 4392    - " 55AA 10 00 12 1 temp\4392.tmp
if exist temp\4393.tmp findver "     OROM AMD RAID MISC 4393    - " 55AA 10 00 12 1 temp\4393.tmp
if exist temp\7802.tmp findver "     OROM AMD RAID MISC 7802    - " 55AA 10 00 12 1 temp\7802.tmp
if exist temp\7803.tmp findver "     OROM AMD RAID MISC 7803    - " 55AA 10 00 12 1 temp\7803.tmp
if exist temp\raidx64.tmp drvver temp\raidx64.tmp
if exist temp\raidutil.tmp drvver temp\raidutil.tmp
if exist temp\RAIDxpt2f10o.tmp findver "     OROM AMD RAIDXpert2-F10    - " 5243424E42474E 8 00 12 1 temp\RAIDxpt2f10o.tmp
if exist temp\RAIDxpt2f10e.tmp findver "     EFI AMD RAIDXpert2-F10     - " 5243424E454E44 8 00 12 1 temp\RAIDxpt2f10e.tmp 
if exist temp\RAIDxpt2f50o.tmp findver "     OROM AMD RAIDXpert2-F50    - " 5243424E42474E 8 00 12 1 temp\RAIDxpt2f50o.tmp
if exist temp\RAIDxpt2f50e.tmp findver "     EFI AMD RAIDXpert2-F50     - " 5243424E454E44 8 00 12 1 temp\RAIDxpt2f50e.tmp
exit /b
)

:mrvlver
(
findver "     OROM Marvell 88SE9120      - " 504349524B1B2091 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE91a0      - " 504349524B1Ba091 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE9123      - " 504349524B1B2391 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE91a3      - " 504349524B1Ba391 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE9128      - " 504349524B1B2891 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE9130      - " 504349524B1B3091 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE9172      - " 504349524B1B7291 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE917a      - " 504349524B1B7a91 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE9182      - " 504349524B1B8291 -21 00 10 1 csmcore
findver "     OROM Marvell 88SE918a      - " 504349524B1B8a91 -21 00 10 1 csmcore
hexfind 004b1b309200 csmcore>nul && findver "     OROM Marvell 88SE9230      - " 504349524B1B3092 -21 00 10 1 csmcore
hexfind 004b1b9291 csmcore>nul && %mmt% /e /l temp\9192.tmp 1b4b 9192 && findver "     OROM Marvell 88SE9192      - " 42494F532056657273696F6E20 14 00 10 1 temp\9192.tmp
hexfind 004b1ba291 csmcore>nul && %mmt% /e /l temp\91a2.tmp 1b4b 91a2 && findver "     OROM Marvell 88SE91a2      - " 42494F532056657273696F6E20 14 00 10 1 temp\91a2.tmp
if %me%==1 if exist temp\mrv*.tmp for /f "tokens=*" %%b in ('dir temp\mrv*.tmp /b') do drvver temp\%%b
exit /b
)

:inlver
(
if exist temp\lani*.tmp for /f "tokens=*" %%b in ('dir temp\lani*.tmp /b') do drvver temp\%%b
exit /b
)

:rtkver
(
if exist temp\lanr*.tmp for /f "tokens=*" %%b in ('dir temp\lanr*.tmp /b') do drvver temp\%%b
exit /b
)

:bcmver
(
if exist temp\lanb*.tmp for /f "tokens=*" %%b in ('dir temp\lanb*.tmp /b') do drvver temp\%%b
exit /b
)
