@echo off setlocal :top ::chdir /d "%~dp0" pushd "%~dp0" cls if not exist support cd.. set cygwin=nodosfilewarning set ModMiiDrive=%cd:~0,2% set "PATH=%SystemRoot%\system32;%SystemRoot%\system32\wbem;%SystemRoot%;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0" if exist Support\settings.bat call Support\settings.bat ::65001 was used to fix paths with special characters like é for Sneek Installer, but caused rare slowdowns for some users so reverted back to 437. Other downloads may still fail if a special character exists in the path, but work fine if using the default COPY_TO_SD relative path. chcp 437>nul ::chcp 65001>nul ::chcp 850>nul ::chcp 1252>nul ::PUSHD "%cd%" ::::PUSHD "%~dp0" ::POPD set currentversion=8.0.3 set d2x-bundled=11-beta3 set currentversioncopy=%currentversion% set agreedversion= set "WiiPy=Support\wiipy\wiipy.exe" ::let's make this easy set redtext=Red set bluetext=Blue set yellowtext=Yellow set greentext=Green set magentatext=Magenta set cyantext=Cyan set backgroundcolor=1 set whitetext=f ::-------------------CMD LINE SUPPORT---------------------- ::getting args sent to ModMii, if applicable ::"ModMii" a b c d e f g h i ::equals ::"ModMii" %1 %2 %3 %4 %5 %6 %7 %8 %9 set one= set "one=%~1" ::if not "%one%"=="" set cmdlinemode=Y \\ this check crashes if variable contains a single quote (as sometimes will happen when dragging a drive letter onto ModMii.exe, fixed below) ::instead check if ONE is defined by set (search for "one=") then set cmd line mode and remove quotes only if it exists set|findstr /I /B /C:"one=">nul IF NOT ERRORLEVEL 1 set cmdlinemode=Y if /i "%cmdlinemode%" EQU "Y" set one=%one:"=% set "two=%~2" set "three=%~3" set "four=%~4" set "five=%~5" set "six=%~6" set "seven=%~7" set "eight=%~8" set "nine=%~9" ::one-nine will change single carets (^) to double (^^) ONLY when run via EXE (i.e. when ModMii.lnk exists), fixed below if not exist Support\ModMii.lnk goto:nofix set "one=%one:^^=^%" set "two=%two:^^=^%" set "three=%three:^^=^%" set "four=%four:^^=^%" set "five=%five:^^=^%" set "six=%six:^^=^%" set "seven=%seven:^^=^%" set "eight=%eight:^^=^%" set "nine=%nine:^^=^%" :nofix if exist Support\ModMii.lnk del Support\ModMii.lnk>nul setlocal enableDelayedExpansion set cmdinput=" set "cmdinput=!cmdcmdline!" ::if ONE is a function and not a dropped file, then revert to secondary method [set cmdinput=%*] primary method only works if calling the exe, not the bat if /i "%one%" EQU "help" set cmdinput=%* if /i "%one%" EQU "O" set cmdinput=%* if /i "%one%" EQU "D" set cmdinput=%* if /i "%one%" EQU "W" set cmdinput=%* if /i "%one%" EQU "HS" set cmdinput=%* if /i "%one%" EQU "RC" set cmdinput=%* if /i "%one%" EQU "S" set cmdinput=%* if /i "%one%" EQU "SE" set cmdinput=%* if /i "%one%" EQU "U" set cmdinput=%* if /i "%one%" EQU "E" set cmdinput=%* if /i "%one%" EQU "AW" set cmdinput=%* if /i "%one%" EQU "L" set cmdinput=%* if /i "%one%" EQU "SU" set cmdinput=%* ::slash is wrong direction when launched via exe, correct it here: set "cmdinput=!cmdinput:/Support/ModMii.bat=\Support\ModMii.bat!" ::remove bat name from cmdinput, appears sometimes depending how it's launched, actually replace with " to be removed later set "cmdinput=!cmdinput:*%~f0="!" ::remove first term "C:\WINDOWS\system32\cmd.exe" ::set "cmdinput=!cmdinput:* =!" ::remove 2nd term "/c" ::set "cmdinput=!cmdinput:* =!" ::strip out unnecessary chars at start, disabled is it removed the first arg from cmdinput ::set "cmdinput=!cmdinput:*" =!" ::remove quotes set "cmdinput=!cmdinput:"=!" setlocal DISABLEDELAYEDEXPANSION ::remove leading space if applicable if "%cmdinput%"=="" goto:skipfix if /i "%cmdinput:~0,1%" EQU " " set "cmdinput=%cmdinput:~1%" :skipfix ::in some cases above method will yield "C:\Windows\System32\cmd.exe", for these fall back on secondary method if /i "%cmdinput%" NEQ "%homedrive%\Windows\System32\cmd.exe" goto:skipfix set cmdinput=%* set "cmdinput=%cmdinput:"=%" :skipfix ::echo cmdinput: "%cmdinput%" ::echo one: "%one%" ::pause ::multidrop stuff done later! NET SESSION >nul 2>&1 IF %ERRORLEVEL% EQU 0 (set adminmode=Y) else (set adminmode=N) if /i "%adminmode%" EQU "Y" goto:donecheck ::check for write access if exist "temp\test" goto:skip mkdir "temp\test" if not exist "temp\test" (goto:WriteError) else (goto:donecheck) :skip if not exist temp\test\test.txt goto:skip del temp\test\test.txt>nul if exist temp\test\test.txt (goto:WriteError) else (goto:donecheck) :skip echo test>temp\test\test.txt if exist temp\test\test.txt goto:donecheck :WriteError ::for skin mode, force screen to be visible ::support\nircmd.exe win activate ititle "ModMiiSkinCMD" ::support\nircmd.exe win trans ititle "ModMiiSkinCMD" 255 cls echo ModMii needs to be run as an Administrator if saved to this directory. echo Please either run ModMii from somewhere else like C:\ModMii or run as admin echo. echo Press any key to update shortcuts and run ModMii as administrator... pause>nul if not "%cmdinput%"=="" support\nircmd.exe shortcut "%cd%\ModMii.exe" "%temp%" "ModMii" "%cmdinput%" if "%cmdinput%"=="" support\nircmd.exe shortcut "%cd%\ModMii.exe" "%temp%" "ModMii" support\hexalter.exe "%temp%\ModMii.lnk" 0x15=0x20>nul if exist "%userprofile%\Desktop\ModMii.lnk" support\hexalter.exe "%userprofile%\Desktop\ModMii.lnk" 0x15=0x20>nul if exist "%userprofile%\Desktop\ModMii Skin.lnk" support\hexalter.exe "%userprofile%\Desktop\ModMii Skin.lnk" 0x15=0x20>nul if exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii.lnk" support\hexalter.exe "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii.lnk" 0x15=0x20>nul if exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii Skin.lnk" support\hexalter.exe "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii Skin.lnk" 0x15=0x20>nul if exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\Uninstall.lnk" support\hexalter.exe "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\Uninstall.lnk" 0x15=0x20>nul cd "%temp%" start ModMii.lnk exit :donecheck if exist "temp\test" rd /s /q "temp\test"> nul IF "%AudioOption%"=="" set AudioOption=on if "%ModMiiverbose%"=="" set ModMiiverbose=off if "%skin%"=="" set skin=Default if exist Support\settings.bat call Support\settings.bat if exist "Support\Skins\%skin%\Success.mp3" (set "Success.mp3=Support\Skins\%skin%\Success.mp3") else (set "Success.mp3=Support\Skins\Default\Success.mp3") if exist "Support\Skins\%skin%\Fail.mp3" (set "Fail.mp3=Support\Skins\%skin%\Fail.mp3") else (set "Fail.mp3=Support\Skins\Default\Fail.mp3") if exist "Support\Skins\%skin%\splash.png" (set "splash.png=Support\Skins\%skin%\splash.png") else (set "splash.png=Support\Skins\Default\splash.png") set CurrentDLNAME= call "Support\subscripts\DB.bat" if "%DRIVE%"=="" set DRIVE=COPY_TO_SD ::check if drive folder exists--if second char is ":" check if drive exists if /i "%DRIVE:~1,1%" NEQ ":" goto:skipcheck if exist Support\settings.bat support\sfk filter -spat Support\settings.bat -lsrep _"Set*Drive=%cd:_=\x5f%\\"_"Set Drive="_ -write -yes>nul if exist Support\settings.bat support\sfk filter -spat Support\settings.bat -lsrep _"Set Drive="_"Set \x22Drive="_ -write -yes>nul if exist Support\settings.bat call Support\settings.bat if /i "%DRIVE:~1,1%" NEQ ":" goto:skipcheck if exist "%DRIVE:~0,2%" (goto:skipcheck) else (set DRIVE=COPY_TO_SD) if exist Support\settings.bat support\sfk filter Support\settings.bat -ls!"Set*Drive=" -write -yes>nul echo Set "Drive=%DRIVE%">>Support\settings.bat :skipcheck if "%DRIVEU%"=="" set DRIVEU=COPY_TO_USB ::check if DRIVEU folder exists--if second char is ":" check if DRIVEU exists if /i "%DRIVEU:~1,1%" NEQ ":" goto:skipcheck ::if /i "%DRIVEU%" EQU "%cd%\COPY_TO_USB" set DRIVEU=COPY_TO_USB if exist Support\settings.bat support\sfk filter -spat Support\settings.bat -lsrep _"Set*DriveU=%cd:_=\x5f%\\"_"Set DriveU="_ -write -yes>nul if exist Support\settings.bat support\sfk filter Support\settings.bat -lsrep _"Set DriveU="_"Set \x22DriveU="_ -write -yes>nul if exist Support\settings.bat call Support\settings.bat if /i "%DriveU:~1,1%" NEQ ":" goto:skipcheck if exist "%DRIVEU:~0,2%" (goto:skipcheck) else (set DRIVEU=COPY_TO_USB) if exist Support\settings.bat support\sfk filter Support\settings.bat -ls!"Set*DriveU=" -write -yes>nul echo Set "DriveU=%DRIVEU%">>Support\settings.bat :skipcheck set d2x-beta-rev=%d2x-bundled% if exist support\d2x-beta\d2x-beta.bat call support\d2x-beta\d2x-beta.bat ::get windows version, only 8.1 and above supported effective ModMii 8.0.0 if exist "temp\temp.txt" del "temp\temp.txt">nul ver>temp\temp.txt findStr /I /C:" 8.1" "temp\temp.txt" >nul IF NOT ERRORLEVEL 1 (set winver=9) & (goto:continue) support\sfk filter -quiet "temp\temp.txt" -rep _*" "__ -rep _"."*__ -write -yes support\sfk filter -quiet "temp\temp.txt" -no-empty-lines -no-blank-lines -write -yes set /p winver= nul if exist Support\settings.bat support\sfk filter Support\settings.bat -ls!"Set LegacyCIOS=" -write -yes>nul Set LegacyCIOS=Y echo Set LegacyCIOS=Y>>Support\settings.bat ::if exist "%homedrive%\Program Files (x86)" goto:skip if exist ModMii_64bit.exe goto:skip echo. echo Downloading alternate ModMii.exe Launcher... if not exist "temp\ModMii_Launcher_2.4_32bit.zip" support\wget --no-check-certificate -t 3 "https://raw.githubusercontent.com/modmii/modmii.github.io/master/temp/ModMii_Launcher_2.4_32bit.zip" -O "temp\ModMii_Launcher_2.4_32bit.zip" -q --show-progress if not exist "temp\ModMii_Launcher_2.4_32bit.zip" (echo Download Failed, use Support\ModMii.bat, ModMii 7.0.3, or upgrade your Windows...) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:skip) support\7za x -aoa "temp\ModMii_Launcher_2.4_32bit.zip" -r ModMii_32bit.exe if not exist ModMii_32bit.exe (del "temp\ModMii_Launcher_2.4_32bit.zip">nul) & (echo Download Failed, use Support\ModMii.bat, ModMii 7.0.3, or upgrade your Windows...) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:skip) move /y ModMii.exe ModMii_64bit.exe>nul move /y ModMii_32bit.exe ModMii.exe>nul goto:skip :continue ::check for "microsoft visual c++ 2015-2022" ::if exist "%homedrive%\Program Files (x86)" (set dlname=hashmyfiles-x64.zip) else (set dlname=hashmyfiles.zip) set MVCattempt=1 :MVC if exist "temp\temp.reg" del "temp\temp.reg">nul if exist "temp\temp.txt" del "temp\temp.txt">nul if exist "%homedrive%\Program Files (x86)" START /MIN /WAIT REG EXPORT HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64 "temp\temp.reg" /Y if not exist "%homedrive%\Program Files (x86)" START /MIN /WAIT REG EXPORT HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X86 "temp\temp.reg" /Y ::if not exist temp\temp.reg (set MVCversion=0) & (goto:skip) ::cmd /a /c type "temp\temp.reg">"temp\temp.txt" ::support\sfk filter -spat -quiet "temp\temp.txt" -+"Version\x22=" -rep _"*=\x22v"__ -rep _"\x22"__ -write -yes ::set /p MVCversion= nul if exist temp\temp.reg goto:skip if /i "%MVCattempt%" EQU "2" goto:MVCfail ::missing "microsoft visual c++ 2015-2022" ::https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170&wt.mc_id=studentamb_203301#latest-microsoft-visual-c-redistributable-version if exist "%homedrive%\Program Files (x86)" set "code2=https://aka.ms/vs/17/release/vc_redist.x64.exe" & set "dlname=vc_redist.x64.exe" if not exist "%homedrive%\Program Files (x86)" set "code2=https://aka.ms/vs/17/release/vc_redist.x86.exe" & set "dlname=vc_redist.x86.exe" echo ModMii v8.0.0 and above ^& WiiPy requires Microsoft Visual C++ 2015-2022 echo. echo Downloading and launching installer... echo. support\wget --no-check-certificate -t 3 "%code2%" -O "temp\%dlname%" -q --show-progress ::delete if file is empty (if empty) >nul findstr "^" "temp\%dlname%" || del "temp\%dlname%" if exist "temp\%dlname%" goto:MVCinstall echo Download Failed, check your connection or install it manually echo. echo Some ModMii features will not work properly (i.e. NUS downloading, WAD (un)packing, building some non-d2x cIOSs, some EmuNANDs features, theme building, WAD editing, etc.) echo. echo Hit any key to use ModMii anyway pause>nul goto:skip :MVCfail echo Installation Failed, try installing it manually echo. echo Some ModMii features will not work properly (i.e. NUS downloading, WAD (un)packing, building some non-d2x cIOSs, some EmuNANDs features, theme building, WAD editing, etc.) echo. echo Hit any key to use ModMii anyway pause>nul goto:skip :MVCinstall echo Launching installer and waiting for installation to finish... echo. ::temp\%dlname% /install /passive /norestart start /wait temp\%dlname% /install /passive /norestart echo Rechecking... echo. if exist "temp\%dlname%" del "temp\%dlname%">nul SET /a MVCattempt=%MVCattempt%+1 goto:MVC :skip if exist "temp\temp.reg" del "temp\temp.reg">nul ::in case game dump is left over for interrupted deflicker process, delete it now as it could potentially be pretty large if exist "temp\witdump" rd /s /q "temp\witdump">nul if exist "temp\__channel" rd /s /q "temp\__channel"> nul if exist "temp\HBC_Transfer_" rd /s /q "temp\HBC_Transfer_">nul ::if not exist temp mkdir temp if not exist temp\DownloadQueues mkdir temp\DownloadQueues if exist Support\DownloadQueues\* move /y Support\DownloadQueues\* temp\DownloadQueues>nul if exist Support\DownloadQueues rd /s /q "Support\DownloadQueues">nul if not exist Support\More-cIOSs mkdir Support\More-cIOSs ::check for InstallForge Uninstall.exe, uninstall.dat and uninstall_l.ifl then move\rename to Support folder if not exist uninstall.dat goto:skip if exist uninstall.dat move /y uninstall.dat Support\uninstall.dat>nul if exist uninstall_l.ifl move /y uninstall_l.ifl Support\uninstall_l.ifl>nul if exist Uninstall.exe move /y Uninstall.exe Support\Uninstall2.exe>nul :skip if exist "support\subscripts\Uninstaller.exe" move /y "support\subscripts\Uninstaller.exe" Uninstall.exe>nul if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\" goto:skip if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii.lnk" support\nircmd.exe shortcut "%cd%\ModMii.exe" "~$folder.programs$\ModMii" "ModMii" if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\ModMii Skin.lnk" support\nircmd.exe shortcut "%cd%\ModMiiSkin.exe" "~$folder.programs$\ModMii" "ModMii Skin" if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\Uninstall.lnk" support\nircmd.exe shortcut "%cd%\Uninstall.exe" "~$folder.programs$\ModMii" "Uninstall" if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\Website & Help.lnk" support\nircmd.exe shortcut "https://modmii.github.io" "~$folder.programs$\ModMii" "Website & Help" if not exist "%appdata%\Microsoft\Windows\Start Menu\Programs\ModMii\Open ModMii Folder.lnk" support\nircmd.exe shortcut "%windir%\explorer.exe" "~$folder.programs$\ModMii" "Open ModMii Folder" "%cd%\" :skip set UPDATENAME=ModMii ::set UPDATENAME=ModMii_IT_ if /i "%debug%" EQU "on" goto:skip if exist Updatetemp.bat attrib -h Updatetemp.bat if exist Updatetemp.bat del Updatetemp.bat>nul :skip ::this next line will force d2x online version checks to be done once every time modmii is opened (as opposed to just once per day) if exist "temp\d2xlist*.txt" del /f /q "temp\d2xlist*.txt" ::set to Y to keep some invalid files for debug purposes (or add "set KeepInvalidOverride=Y" to settings.bat), be sure to revert afterwards if "%KeepInvalidOverride%"=="" set KeepInvalidOverride=N if /i "%LegacyCIOS%" NEQ "Y" goto:skip call Support\subscripts\dependency.bat LegacyCIOS if /i "%dependency%" EQU "F" goto:RevertOverride ::.NET Framework 3.5 check+installation call Support\subscripts\dependency.bat NETframework if /i "%dependency%" EQU "F" goto:RevertOverride goto:skip :RevertOverride echo Removing "set LegacyCIOS=Y" from settings because: if not exist Support\WadMii.exe echo - Support\WadMii.exe is missing if not exist Support\libWiiSharp.dll echo - Support\libWiiSharp.dll is missing if not exist Support\tmdedit.exe echo - Support\tmdedit.exe is missing if not exist Support\patchios.exe echo - Support\patchios.exe is missing if not exist "%windir%\Microsoft.NET\Framework\v3.5" echo - .NET Framework 3.5 not installed set LegacyCIOS= if exist Support\settings.bat support\sfk filter Support\settings.bat -ls!"Set LegacyCIOS=" -write -yes>nul @ping 127.0.0.1 -n 2 -w 1000> nul :skip ::cmd line stuff if /i "%cmdlinemode%" NEQ "Y" goto:notcmd if /i "%two%" EQU "Help" goto:specificCMDhelp if /i "%one%" EQU "O" goto:cmdlineOPTIONShelp if /i "%one%" EQU "D" goto:cmdlineDhelp if /i "%one%" EQU "W" goto:hardcodedoptions if /i "%one%" EQU "HS" goto:hardcodedoptions if /i "%one%" EQU "RC" goto:hardcodedoptions if /i "%one%" EQU "S" goto:hardcodedoptions if /i "%one%" EQU "SE" goto:hardcodedoptions if /i "%one%" EQU "U" goto:hardcodedoptions if /i "%one%" EQU "E" goto:hardcodedoptions if /i "%one%" EQU "AW" goto:hardcodedoptions if /i "%one%" EQU "L" goto:hardcodedoptions if /i "%one%" EQU "SU" goto:hardcodedoptions ::---pure drag and drop stuff below--- ::multidrop support, insert line breaks to split different dragged files arguments ::add check for multiple files by searching for more 2 or more colons ":" set "string=%cmdinput%" set /a filecount=0 setlocal EnableDelayedExpansion if defined string (set ^"strtmp=!string::=^ %= empty string =% !^") else set "strtmp=" for /F %%C in ('cmd /V /C echo(^^!strtmp^^!^| find /C /V ""') do set /A "filecount=%%C-1" setlocal DISABLEDELAYEDEXPANSION ::echo "!string!" contains %filecount% files if %filecount% LSS 2 goto:notMulti echo "%cmdinput%">temp\MultiDrop.txt support\sfk -spat filter temp\MultiDrop.txt -rep _\x22__ -rep _" A:"_"\nA:"_ -rep _" B:"_"\nB:"_ -rep _" C:"_"\nC:"_ -rep _" D:"_"\nD:"_ -rep _" E:"_"\nE:"_ -rep _" F:"_"\nF:"_ -rep _" G:"_"\nG:"_ -rep _" H:"_"\nH:"_ -rep _" I:"_"\nI:"_ -rep _" J:"_"\nJ:"_ -rep _" K:"_"\nK:"_ -rep _" L:"_"\nL:"_ -rep _" M:"_"\nM:"_ -rep _" N:"_"\nN:"_ -rep _" O:"_"\nO:"_ -rep _" P:"_"\nP:"_ -rep _" Q:"_"\nQ:"_ -rep _" R:"_"\nR:"_ -rep _" S:"_"\nS:"_ -rep _" T:"_"\nT:"_ -rep _" U:"_"\nU:"_ -rep _" V:"_"\nV:"_ -rep _" W:"_"\nW:"_ -rep _" X:"_"\nX:"_ -rep _" Y:"_"\nY:"_ -rep _" Z:"_"\nZ:"_ -rep _"^^"_"^"_ -write -yes>nul set /p testme= temp\d2xClassicCheck.txt findStr /I /X /C:"%CurDate% " "temp\d2xClassicCheck.txt" >nul IF NOT ERRORLEVEL 1 goto:proceed if exist temp\RecD2XcIOS.txt del temp\RecD2XcIOS.txt>nul support\wget --no-check-certificate "https://github.com/xflak/stats/releases/latest/download/classic.txt" -O temp\RecD2XcIOS.txt -q ::delete if file is empty (if empty) if exist "temp\RecD2XcIOS.txt" >nul findstr "^" "temp\RecD2XcIOS.txt" || del "temp\RecD2XcIOS.txt" if not exist temp\RecD2XcIOS.txt goto:proceed set /p RecD2XcIOS= nul if exist "Support\settings.bat" support\sfk filter -spat "Support\settings.bat" -ls!"set \x22RecD2XcIOS=" -write -yes>nul echo Set "RecD2XcIOS=%RecD2XcIOS%">> Support\settings.bat echo %CurDate% >temp\d2xClassicCheck.txt :proceed ::syscheck updater drag and drop if /i "%cmdinput:~-4%" EQU ".csv" (set one=SU) & (set cmdlinemodeswitchoff=Y) & (goto:hardcodedoptions) ::\bootmii.ini updater drag and drop if /i "%cmdinput:~-12%" EQU "\bootmii.ini" set "bootmiiINI=%cmdinput%" if /i "%cmdinput:~-12%" EQU "\bootmii.ini" (set one=BM) & (set cmdlinemodeswitchoff=Y) & (set MENU1=C) & (set configfile=BM) & (goto:nohardcodedoptions) if /i "%cmdinput:~-4%" NEQ ".bat" goto:notbat ::check for "- Wizard Settings -" findStr /I /C:"- Wizard Settings -" "%cmdinput%" >nul IF NOT ERRORLEVEL 1 (set cmdlinemodeswitchoff=Y) & (set one=WL) & (set LoadWizSettings=Y) & (goto:go) ::check for download queue findStr /I /C:":endofqueue" "%cmdinput%" >nul IF ERRORLEVEL 1 goto:notbat set one=L set cmdlinemodeswitchoff=Y goto:hardcodedoptions :notbat ::---------------ModMii nand tools--------------- if /i "%cmdinput:~-4%" NEQ ".bin" goto:notbin if not exist "%cmdinput%" goto:notbin if exist "%cmdinput%\" goto:notbin title ModMii nand tools ::Checking files size... for %%A in ("%cmdinput%") do set binsize=%%~zA ::echo file size: %binsize% bytes if /i "%binsize%" EQU "553649152" goto:binDrop if /i "%binsize%" EQU "553648128" goto:nandfix ::bin file is not a nand cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools echo. support\sfk echo [%bluetext%]"%cmdinput%" echo. support\sfk echo [%yellowtext%]*This file is not a Wii nand.bin backup! Filesize is %binsize% bytes (553649152 expected) echo. echo You can close this window now, or press any key to calculate the hash of this file... pause> nul goto:HashMyFiles :nandfix cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools echo. support\sfk echo [%bluetext%]"%cmdinput%" echo. support\sfk echo [%yellowtext%]Incomplete nand detected! Missing keys! echo. echo Older versions of bootmii created nand backups without embedding the Wii's keys. echo Similarly vWii nand backups made by nanddumper are created without embedded keys. echo These broken nand backups cannot be restored or used for some other purposes without fixing it first. echo. if /i "%adminmode%" EQU "N" support\sfk.exe echo [%bluetext%]To fix your nand backup, drag the keys.bin or otp.bin file for THE SAME console onto this window and press enter if /i "%adminmode%" EQU "Y" support\sfk.exe echo [%bluetext%]To fix your nand backup, enter the path to the keys.bin or otp.bin file for THE SAME console echo Note that ModMii will NOT overwrite the original file echo. support\sfk echo [%yellowtext%]Warning! Make sure you provide the keys.bin or otp.bin file for THE SAME console this nand was dumped from! echo. set nandkeys=" set /p nandkeys=Enter Selection Here: set "nandkeys=%nandkeys:"=%" ::echo nandkeys "%nandkeys%" ::echo mympath "%mympath%" if "%nandkeys%"=="" (echo You Have Entered an Incorrect Key) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:nandfix) if not exist "%nandkeys%" (echo You Have Entered an Incorrect Key) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:nandfix) If /i "%nandkeys:~-4%" NEQ ".bin" (echo This isn't a bin file, try again...) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:nandfix) :checkkey for %%A in ("%nandkeys%") do set keyssize=%%~zA ::echo file size: %keyssize% bytes if /i "%keyssize%" NEQ "1024" (echo This isn't the right filesize [1024 bytes], try again...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:nandfix) ::check for "ConsoleID" in keys file hex search hex set ERRORLEVEL= support\sfk.exe hexfind "%nandkeys%" -pat /ConsoleID/ >nul ::ERRORLEVEL 1 means "ConsoleID" found, 0 means not found ::echo ERRORLEVEL %ERRORLEVEL% IF ERRORLEVEL 1 goto:noOTPrepair call Support\subscripts\dependency.bat ShowMiiVWiiKeys if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo. ::get nandkeysfile and nandkeyspath names, i.e. get filename and get folder full path not including filename set "nandkeysfile=%nandkeys:*\=%" set "nandkeyspath=%nandkeys%" :stripnandkeysfile set "nandkeysfile=%nandkeysfile:*\=%" echo "%nandkeysfile%">temp\temp.txt findStr \\ temp\temp.txt>nul IF NOT ERRORLEVEL 1 goto:stripnandkeysfile echo set "nandkeyspath=%%nandkeyspath:%nandkeysfile%=%%">temp\temp.bat call temp\temp.bat set "nandkeyspath=%nandkeys%" echo set "nandkeyspathback=%%nandkeyspath:\%nandkeysfile%=%%">temp\temp.bat call temp\temp.bat ::echo nandkeysfile: "%nandkeysfile%" ::echo nandkeyspath: "%nandkeyspath%" ::echo nandkeyspathback: "%nandkeyspathback%" if exist "temp\keys.bin" del "temp\keys.bin">nul if exist "temp\keys.txt" del "temp\keys.txt">nul copy /y "%nandkeys%" "temp\otp.bin">nul cd temp ShowMiiVWiiKeys.exe>nul cd.. if not exist temp\keys.bin (echo ShowMiiVWiiKeys failed, exiting...) & (@ping 127.0.0.1 -n 5 -w 1000> nul) & (exit) if exist "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.bin" move /y "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.bin" "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.bin.bak">nul if exist "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.txt" move /y "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.txt" "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.txt.bak">nul move /y "temp\keys.bin" "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.bin">nul if exist "temp\keys.txt" move /y "temp\keys.txt" "%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.txt">nul if exist "temp\otp.bin" del "temp\otp.bin">nul set "nandkeys=%nandkeyspathback%\%nandkeysfile:~0,-4%-keys.bin" ::echo %nandkeys% goto:checkkey :noOTPrepair echo. support\sfk.exe echo Appending [%cyantext%]"%nandkeys%" to "%cmdinput%"... copy /b /y "%cmdinput%"+"%nandkeys%" "%cmdinput:~0,-4%-repaired%cmdinput:~-4%" echo. if not exist "%cmdinput:~0,-4%-repaired%cmdinput:~-4%" goto:notrepaired ::Checking files size... ::echo old file size: %binsize% bytes for %%A in ("%cmdinput:~0,-4%-repaired%cmdinput:~-4%") do set binsize=%%~zA ::echo new file size: %binsize% bytes if /i "%binsize%" NEQ "553649152" goto:notrepaired set "cmdinput=%cmdinput:~0,-4%-repaired%cmdinput:~-4%" support\sfk.exe echo [%greentext%]Nand successfully repaired, continuing... @ping 127.0.0.1 -n 3 -w 1000> nul goto:binDrop :notrepaired ::cleanup if exist "%cmdinput:~0,-4%-repaired%cmdinput:~-4%" del "%cmdinput:~0,-4%-repaired%cmdinput:~-4%">nul support\sfk.exe echo [%redtext%]Something went wrong, press any key to try again...) & (pause> nul) & (goto:nandfix) :binDrop set binAction=" cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools echo. echo What would you like to do with this nand file? echo. support\sfk echo [%bluetext%]"%cmdinput%" support\sfk echo [%yellowtext%]*If this isn't a Wii or vWii nand backup, you should close this window now! echo. echo E = Extract it to use as an Emulated nand echo C = Check it using nandBinCheck echo CAB = Clone A to B; use this Wii's nand.bin ("A") to build a nand for a different "B" Wii; i.e. "A" is donor echo CBA = Clone B to A; build new nand for this Wii ("A") cloned from a different "B" Wii nand.bin; i.e. "A" is recipient echo D = DefragMii; speed up your nand by defragmenting it; can also update old nand backups to avoid new bad blocks echo. set binAction=" set /p binAction=Enter Selection Here: set "binAction=%binAction:"=%" if /i "%binAction%" EQU "E" goto:nandextract if /i "%binAction%" EQU "C" goto:nandBinCheck if /i "%binAction%" EQU "CAB" goto:Punetwiin if /i "%binAction%" EQU "CBA" goto:Punetwiin if /i "%binAction%" EQU "D" goto:DefragMii echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:binDrop :nandextract cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools call Support\subscripts\dependency.bat nand-tools if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo. echo Extracting "%cmdinput%": echo. echo Please be patient, this may take a minute... echo. ::get nandfile and nandfolder names set "nandfile=%cmdinput:*\=%" set "nandfolder=%cmdinput%" :stripnandfile set "nandfile=%nandfile:*\=%" echo "%nandfile%">temp\temp.txt findStr \\ temp\temp.txt>nul IF NOT ERRORLEVEL 1 goto:stripnandfile echo set "nandfolder=%%nandfolder:\%nandfile%=%%">temp\temp.bat call temp\temp.bat ::echo nandfile: %nandfile% ::echo nandfolder: %nandfolder% set "ModMiiDir=%cd%" if /i "%binAction%" NEQ "D" goto:notDefragmii if /i "%nand1%" EQU "%nand2%" set "nandfile1=%nandfile%" if /i "%nand1%" EQU "%nand2%" set "nandfolder1=%nandfolder%" if /i "%nand1%" EQU "%nand2%" goto:skipkeys :notDefragmii cd /d "%nandfolder%" if /i "%nandfile%" EQU "nand.bin" goto:skip if exist nand.bin move /y nand.bin nand.bin.modmii.bak>nul if exist nand-key.bin move /y nand-key.bin nand-key.bin.modmii.bak>nul move /y "%nandfile%" nand.bin>nul :skip echo @echo Off>"%ModMiiDir%\temp\temp.bat" echo title nand-aes-dump-cmd>>"%ModMiiDir%\temp\temp.bat" echo cd /d "%nandfolder%">>"%ModMiiDir%\temp\temp.bat" echo "%ModMiiDir%\temp\nand-tools\nand-aes-dump.exe">>"%ModMiiDir%\temp\temp.bat" cd "%ModMiiDir%\temp" start /min temp.bat cd /d "%nandfolder%" if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul if not exist nand-key.bin @ping 127.0.0.1 -n 1 -w 1000> nul @ping 127.0.0.1 -n 2 -w 1000> nul ::nand-aes-dump.exe doesn't exit when done! if exist nand-key.bin taskkill /F /IM "nand-aes-dump.exe" /T >nul if exist nand-key.bin taskkill /F /FI "WindowTitle eq nand-aes-dump-cmd" /T >nul if exist nand-key.bin taskkill /F /FI "WindowTitle eq Administrator: nand-aes-dump-cmd" /T >nul move /y nand.bin "%nandfile%">nul if exist nand.bin.modmii.bak move /y nand.bin.modmii.bak nand.bin>nul if not exist nand-key.bin (echo unable to retrieve nand-key.bin, exiting...) & (@ping 127.0.0.1 -n 5 -w 1000> nul) & (exit) if /i "%binAction%" EQU "D" goto:%afterkeys% "%ModMiiDir%\temp\nand-tools\NAND-bin2raw.exe" "%nandfile%" "%nandfile:~0,-4%_dec.bin" "%ModMiiDir%\temp\nand-tools\zestig.exe" nand-key.bin "%nandfile:~0,-4%_dec.bin" "%nandfile:~0,-4%" if exist "%nandfile:~0,-4%_dec.bin" del /f /q "%nandfile:~0,-4%_dec.bin" if exist "nand-key.bin" del /f /q "nand-key.bin" if exist "%nandfolder%\nand-key.bin.modmii.bak" move /y "%nandfolder%\nand-key.bin.modmii.bak" "%nandfolder%\nand-key.bin">nul echo. cd /d "%ModMiiDir%" if /i "%AudioOption%" NEQ "on" goto:nosound if exist "%nandfolder%\%nandfile:~0,-4%" (start support\nircmd.exe mediaplay 3000 "%Success.mp3%") else (start support\nircmd.exe mediaplay 3000 "%Fail.mp3%") :nosound if not exist "%nandfolder%\%nandfile:~0,-4%" (echo Something went wrong, press any key to exit...) & (pause> nul) & (exit) "%ModMiiDir%\support\sfk.exe" echo [%greentext%]FINISHED! echo. echo "%nandfolder%\%nandfile%" has been extracted to: echo "%nandfolder%\%nandfile:~0,-4%" echo. "%ModMiiDir%\support\sfk.exe" echo [%bluetext%]To Open output folder and exit enter O echo. echo (To exit you can close this window or press enter) echo. set promptO=" set /p promptO=Enter Selection Here: set "promptO=%promptO:"=%" If /i "%promptO%" NEQ "O" exit if exist "%nandfolder%\%nandfile:~0,-4%" explorer "%nandfolder%\%nandfile:~0,-4%" exit :nandBinCheck call Support\subscripts\dependency.bat nandBinCheck if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo @echo Off>temp\nandBinCheck\script.bat echo title ModMii: Checking "%cmdinput%">>temp\nandBinCheck\script.bat echo cd /d "%cd%\Support" >>temp\nandBinCheck\script.bat echo sfk echo [%bluetext%]Checking "%cmdinput%">>temp\nandBinCheck\script.bat echo echo ------------------>>temp\nandBinCheck\script.bat if /i "%ModMiiverbose%" EQU "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%cmdinput%" -all>>temp\nandBinCheck\script.bat if /i "%ModMiiverbose%" NEQ "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%cmdinput%" -all -v>>temp\nandBinCheck\script.bat echo echo ------------------>>temp\nandBinCheck\script.bat echo sfk echo [%greentext%]Finished checking "%cmdinput%">>temp\nandBinCheck\script.bat echo echo ------------------>>temp\nandBinCheck\script.bat echo echo When finished reviewing checks, press any key to exit. >>temp\nandBinCheck\script.bat if /i "%AudioOption%" EQU "on" echo start nircmd.exe mediaplay 3000 "%Success.mp3:~8%">>temp\nandBinCheck\script.bat echo pause^>nul >>temp\nandBinCheck\script.bat echo exit >>temp\nandBinCheck\script.bat start temp\nandBinCheck\script.bat exit :Punetwiin set nandfolder2= cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools echo. support\sfk echo [%cyantext%]CloneMii echo. support\sfk echo [%yellowtext%]WARNING:[def] Using CloneMii\Punetwiin has some risks if the target console does not have bootmii boot2. echo Do NOT try to clone a vWii nand to a Wii or vice versa! echo Generally this is not something that should be done frequently. echo Make sure the target console's nand was dumped recently so Punetwiin is aware of all the latest bad blocks. echo. if /i "%binAction%" EQU "CAB" echo This is the selected donor Wii's nand.bin: if /i "%binAction%" EQU "CBA" echo This is the recipient\target Wii's nand.bin: echo "%cmdinput%" echo. if /i "%adminmode%" EQU "N" if /i "%binAction%" EQU "CAB" support\sfk echo [%bluetext%] Drag and drop the recipient\target Wii's nand.bin onto this window then hit Enter if /i "%adminmode%" EQU "N" if /i "%binAction%" EQU "CBA" support\sfk echo [%bluetext%] Drag and drop the donor Wii's nand.bin onto this window then hit Enter if /i "%adminmode%" EQU "Y" if /i "%binAction%" EQU "CAB" support\sfk echo [%bluetext%] Enter the path of the recipient\target Wii's nand.bin then hit Enter if /i "%adminmode%" EQU "Y" if /i "%binAction%" EQU "CBA" support\sfk echo [%bluetext%] Enter the path of the donor Wii's nand.bin then hit Enter echo. echo B = Back echo. set nandfolder2=" set /p nandfolder2=Enter Selection Here: set "nandfolder2=%nandfolder2:"=%" if "%nandfolder2%"=="" goto:badkey if /i "%nandfolder2%" NEQ "%cmdinput%" goto:notduplicate echo You cannot use the same nand @ping 127.0.0.1 -n 2 -w 1000> nul goto:Punetwiin :notduplicate if /i "%nandfolder2%" EQU "B" goto:binDrop if /i "%nandfolder2:~-4%" NEQ ".bin" goto:badkey if not exist "%nandfolder2%" goto:badkey goto:PunetwiinConfirm :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:Punetwiin :PunetwiinConfirm set PunetwiinConfirm= cls ::Add age check of nand2.bin? if /i "%binAction%" EQU "CAB" set "nand2=%nandfolder2%" if /i "%binAction%" EQU "CBA" set "nand2=%cmdinput%" dir /T:W "%nand2%">temp\temp.txt support\sfk filter -quiet temp\temp.txt -and+".bin" -rep _" *"__ -write -yes set /p nanddate= nul goto:PunetwiinConfirm :RunPunetwiin cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools if /i "%binAction%" EQU "CAB" set "nand1=%cmdinput%" if /i "%binAction%" EQU "CAB" set "nand2=%nandfolder2%" if /i "%binAction%" EQU "CBA" set "nand1=%nandfolder2%" if /i "%binAction%" EQU "CBA" set "nand2=%cmdinput%" call Support\subscripts\dependency.bat Punetwiin if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) call Support\subscripts\dependency.bat nandBinCheck if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo. echo Making preparations to run Punetwiin and clone the nand... echo Built: "%nand1:~0,-4%_Punetwiin.bin">"%nand1:~0,-4%_Punetwiin_Info.txt" echo From Donor: "%nand1%">>"%nand1:~0,-4%_Punetwiin_Info.txt" echo For Target: "%nand2%">>"%nand1:~0,-4%_Punetwiin_Info.txt" echo @echo Off>temp\Punetwiin\script.bat echo title ModMii: Cloning "%nand1%">>temp\Punetwiin\script.bat echo echo Building: "%nand1:~0,-4%_Punetwiin.bin">>temp\Punetwiin\script.bat echo echo From Donor: "%nand1%">>temp\Punetwiin\script.bat echo echo For Target: "%nand2%">>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat ::save a copy of nand2 so it doesn't overwrite the original echo echo Saving a copy of "%nand2%" to avoid overwriting the original...>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo copy /y /v "%nand2%" "%nand1:~0,-4%_incomplete.bin"^>nul>>temp\Punetwiin\script.bat echo echo Running Punetwiin...>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo "%cd%\temp\Punetwiin\punetwiin.exe" "%nand1%" "%nand1:~0,-4%_incomplete.bin" -force>>temp\Punetwiin\script.bat echo move /y "%nand1:~0,-4%_incomplete.bin" "%nand1:~0,-4%_Punetwiin.bin"^>nul>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo echo Checking "%nand1:~0,-4%_Punetwiin.bin" with nandBinCheck>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat if /i "%ModMiiverbose%" EQU "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%nand1:~0,-4%_Punetwiin.bin" -all>>temp\Punetwiin\script.bat if /i "%ModMiiverbose%" NEQ "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%nand1:~0,-4%_Punetwiin.bin" -all -v>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo cd /d "%cd%\Support" >>temp\Punetwiin\script.bat echo sfk echo [%bluetext%]FINISHED CLONING >>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo echo Built and checked: "%nand1:~0,-4%_Punetwiin.bin">>temp\Punetwiin\script.bat echo echo From Donor: "%nand1%">>temp\Punetwiin\script.bat echo echo For Target: "%nand2%">>temp\Punetwiin\script.bat echo echo Build info saved here: "%nand1:~0,-4%_Punetwiin_Info.txt">>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]YOU SHOULD REVIEW THE ABOVE OUTPUT FROM PUNETWIIN AND NANDBINCHECK BEFORE RESTORING>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]And remember that restoring this nand has some risks if the target console does not have bootmii boot2.>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]Generally this is not something that should be done frequently.>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo echo Press any key to exit.>>temp\Punetwiin\script.bat if /i "%AudioOption%" EQU "on" echo start nircmd.exe mediaplay 3000 "%Success.mp3:~8%">>temp\Punetwiin\script.bat echo pause^>nul>>temp\Punetwiin\script.bat echo exit>>temp\Punetwiin\script.bat start temp\Punetwiin\script.bat exit :DefragMii ::get date of nand dir /T:W "%cmdinput%">temp\temp.txt support\sfk filter -quiet temp\temp.txt -and+".bin" -rep _" *"__ -write -yes set /p nand0date= nul goto:Punetwiin :DefragMii2 cls support\sfk echo [%redtext%]ModMii v%currentversion% nand tools set "nand1=%cmdinput%" set "nand2=%nandfolder2%" ::confirm keys are the same if using 2 different nands if /i "%nand1%" NEQ "%nand2%" goto:getkeys ::get nandfile and nandfolder names set "nandfile=%nand1:*\=%" set "nandfolder=%nand1%" goto:stripnandfile :getkeys call Support\subscripts\dependency.bat nand-tools if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo. echo Confirming nands are for the same console... echo. ::get nandfile and nandfolder names set "nandfile=%nand1:*\=%" set "nandfolder=%nand1%" set afterkeys=stripnandfile2 goto:stripnandfile :stripnandfile2 set "nandfile1=%nandfile%" set "nandfolder1=%nandfolder%" move /y nand-key.bin "%ModMiiDir%\temp\nand-key1.bin">nul if exist "%nandfolder%\nand-key.bin.modmii.bak" move /y "%nandfolder%\nand-key.bin.modmii.bak" "%nandfolder%\nand-key.bin">nul cd /d "%ModMiiDir%" set "nandfile=%nand2:*\=%" set "nandfolder=%nand2%" set afterkeys=comparekeys goto:stripnandfile :comparekeys set "nandfile2=%nandfile%" set "nandfolder2=%nandfolder%" move /y nand-key.bin "%ModMiiDir%\temp\nand-key2.bin">nul if exist "%nandfolder%\nand-key.bin.modmii.bak" move /y "%nandfolder%\nand-key.bin.modmii.bak" "%nandfolder%\nand-key.bin">nul cd /d "%ModMiiDir%" support\sfk md5 -quiet "temp\nand-key1.bin" "temp\nand-key2.bin" if not errorlevel 1 (echo Confirmed!) & (goto:skipkeys) echo Nands are for different Wii's, try cloning the Nand instead. Exiting... @ping 127.0.0.1 -n 5 -w 1000> nul exit :skipkeys cd /d "%ModMiiDir%" if exist temp\nand-key1.bin del temp\nand-key1.bin >nul if exist temp\nand-key2.bin del temp\nand-key2.bin >nul call Support\subscripts\dependency.bat Punetwiin if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) call Support\subscripts\dependency.bat nandBinCheck if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo. echo Making preparations to run Punetwiin and defragment the nand... ::echo Built: "%nand1:~0,-4%_Defragged.bin">"%nand1:~0,-4%_Defragged_Info.txt" ::echo From Donor: "%nand1%">>"%nand1:~0,-4%_Defragged_Info.txt" ::echo For Target: "%nand2%">>"%nand1:~0,-4%_Defragged_Info.txt" echo @echo Off>temp\Punetwiin\script.bat echo title ModMii: Defragmenting "%nand1%">>temp\Punetwiin\script.bat echo echo Building: "%nand1:~0,-4%_Defragged.bin">>temp\Punetwiin\script.bat if /i "%nand1%" NEQ "%nand2%" echo echo Source: "%nand1%">>temp\Punetwiin\script.bat if /i "%nand1%" NEQ "%nand2%" echo echo Avoiding Bad Blocks from: "%nand2%">>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat ::save a copy of nand2 so it doesn't overwrite the original echo echo Saving a copy of "%nand2%" to avoid overwriting the original...>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo copy /y /v "%nand2%" "%nand1:~0,-4%_incomplete.bin"^>nul>>temp\Punetwiin\script.bat echo echo Running Punetwiin...>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo "%cd%\temp\Punetwiin\punetwiin.exe" "%nand1%" "%nand1:~0,-4%_incomplete.bin" -force>>temp\Punetwiin\script.bat echo move /y "%nand1:~0,-4%_incomplete.bin" "%nand1:~0,-4%_Defragged.bin"^>nul>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo echo Checking "%nand1:~0,-4%_Defragged.bin" with nandBinCheck>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat if /i "%ModMiiverbose%" EQU "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%nand1:~0,-4%_Defragged.bin" -all>>temp\Punetwiin\script.bat if /i "%ModMiiverbose%" NEQ "off" echo "%cd%\temp\nandBinCheck\nandBinCheck.exe" "%nand1:~0,-4%_Defragged.bin" -all -v>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo cd /d "%cd%\Support" >>temp\Punetwiin\script.bat echo sfk echo [%bluetext%]FINISHED DEFRAGGING >>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo echo Built and checked: "%nand1:~0,-4%_Defragged.bin">>temp\Punetwiin\script.bat echo echo From Donor: "%nand1%">>temp\Punetwiin\script.bat echo echo For Target: "%nand2%">>temp\Punetwiin\script.bat ::echo echo Build info saved here: "%nand1:~0,-4%_Defragged_Info.txt">>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]YOU SHOULD REVIEW THE ABOVE OUTPUT FROM PUNETWIIN AND NANDBINCHECK BEFORE RESTORING>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]And remember that restoring this nand has some risks if the target console does not have bootmii boot2.>>temp\Punetwiin\script.bat echo sfk echo [%yellowtext%]Generally this is not something that should be done frequently.>>temp\Punetwiin\script.bat echo echo ------------------>>temp\Punetwiin\script.bat echo sfk echo You can close this window now, or [%bluetext%]press any key to exit and open the output folder.>>temp\Punetwiin\script.bat if /i "%AudioOption%" EQU "on" echo start nircmd.exe mediaplay 3000 "%Success.mp3:~8%">>temp\Punetwiin\script.bat echo pause^>nul>>temp\Punetwiin\script.bat echo explorer "%nandfolder1%">>temp\Punetwiin\script.bat echo exit>>temp\Punetwiin\script.bat start temp\Punetwiin\script.bat exit :notbin ::----------wiiload zip drag and drop--------------- if /i "%cmdinput:~-4%" EQU ".zip" goto:Wiiloadzip if /i "%cmdinput:~-4%" EQU ".rar" goto:Wiiloadzip if /i "%cmdinput:~-3%" EQU ".7z" goto:Wiiloadzip goto:notWiiloadzip :Wiiloadzip set cmdinputrar= ::support\sfk echo [%redtext%]ModMii v%currentversion% if not exist "%cmdinput%" goto:notWiiloadzip ::pass, get folder to open when any key is pressed ::get binary and mympath and zip names, i.e. get filename and get folder full path not including filename set "binary=%cmdinput:*\=%" set "binarypath=%cmdinput%" :stripbinary2 set "binary=%binary:*\=%" echo "%binary%">temp\temp.txt findStr \\ temp\temp.txt>nul IF NOT ERRORLEVEL 1 goto:stripbinary2 echo set "binarypath=%%binarypath:%binary%=%%">temp\temp.bat call temp\temp.bat set "binarypath=%binarypath:~0,-1%" ::echo binary: "%binary%" ::echo binarypath: "%binarypath%" ::echo Checking archive is not too large to transmit... ::disabled filesize check, validated on receiver goto:disablesizecheck setlocal ENABLEDELAYEDEXPANSION ::check if over 25MB (I think limit is actually 20MB) set GetFileSize= support\sfk stat "!cmdinput!">"temp\tmp.txt" support\sfk filter "temp\tmp.txt" -rep _" bytes*"__ -rep _"* "__ >temp\hexdump.txt set /p GetFileSize= nul goto:HashMyFiles :not2big setlocal DISABLEDELAYEDEXPANSION :disablesizecheck :nometazip set WiiIP= if exist temp\WiiIP.txt set /p WiiIP= NUL && goto:badkey ::check for 3 periods set "string=%WiiLoadPrompt%" set /a dotcount=0 setlocal EnableDelayedExpansion if defined string (set ^"strtmp=!string:.=^ %= empty string =% !^") else set "strtmp=" for /F %%C in ('cmd /V /C echo(^^!strtmp^^!^| find /C /V ""') do set /A "dotcount=%%C-1" setlocal DISABLEDELAYEDEXPANSION ::echo "!string!" contains %dotcount% periods. if /i "%dotcount%" EQU "3" goto:pingme :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:nometazip :pingme ::check if Wii is reachable ::echo. ::echo Pinging Wii to see if reachable... ping -n 1 "%WiiLoadPrompt%"|findstr /I /C:"ms">nul IF NOT ERRORLEVEL 1 goto:Pinged support\sfk echo [%yellowtext%]Unable to reach IP %WiiLoadPrompt%, check your settings and try again... @ping 127.0.0.1 -n 2 -w 1000> nul goto:nometazip :Pinged cls set "WiiIP=%WiiLoadPrompt%" > "temp\WiiIP.txt" ECHO %WiiIP% support\sfk echo [%redtext%]ModMii v%currentversion% HBC Transfer Tool echo. if /i "%cmdinput:~-4%" NEQ ".rar" goto:notrar call Support\subscripts\dependency.bat UnRAR if /i "%dependency%" EQU "F" (echo Exiting...) & (@ping 127.0.0.1 -n 3 -w 1000> nul) & (exit) echo The HBC only accepts ZIPs, ModMii will extract the RAR contents and save a temporary ZIP copy for transmission... if exist "temp\rar" rd /s /q "temp\rar"> nul mkdir temp\rar temp\unrar.exe x -y "%cmdinput%" "temp\rar" ::check if folder is empty dir /b /s /a "temp\rar\" | findstr .>nul || rd /s /q "temp\rar"> nul if not exist "temp\rar\" (echo UnRAR failed, exiting...) & (@ping 127.0.0.1 -n 5 -w 1000> nul) & (exit) echo. ::change cmdinput to zip, but flag original set "cmdinputrar=%cmdinput%" set "cmdinput=%cmdinput:~0,-4%.zip" cd temp\rar ..\..\support\7za a "%cmdinput%" * >nul cd ..\.. if exist "temp\rar" rd /s /q "temp\rar"> nul :notrar set "HBC_Transfer=%cmdinput%" set password= set passwordcmd= ::check zip structure if "%cmdinputrar%"=="" echo If this window immediately freezes after this line the archive requires a password, press any key to continue if "%cmdinputrar%"=="" echo. support\7za l "%cmdinput%" > "%temp%\zip.txt" support\sfk filter -quiet "%temp%\zip.txt" -ls!"Listing archive:" -ls!"Path = " -write -yes ::check for password, check only works if file names are encrypted findStr /I /B "Enter password" "%temp%\zip.txt" >nul IF ERRORLEVEL 1 goto:nopassword1 ::get password from user for /f "usebackq tokens=*" %%p in (`powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"`) do set password=%%p echo. ::echo "%password%" set "passwordcmd= -p"%password%"" ::echo %passwordcmd% support\7za l "%cmdinput%"%passwordcmd% > "%temp%\zip.txt" support\sfk filter -quiet "%temp%\zip.txt" -ls!"Listing archive:" -ls!"Path = " -write -yes :nopassword1 set foundDOL= set foundELF= findStr /I /E "boot.dol" "%temp%\zip.txt" >nul IF NOT ERRORLEVEL 1 set foundDOL=Y findStr /I /E "boot.elf" "%temp%\zip.txt" >nul IF NOT ERRORLEVEL 1 set foundELF=Y if /i "%foundDOL%" EQU "Y" goto:foundbin if /i "%foundELF%" EQU "Y" goto:foundbin support\sfk echo [%yellowtext%]"%cmdinput%" does not contain a dol or an elf file echo. echo exiting... if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul if exist "temp\HBC_Transfer_" rd /s /q "temp\HBC_Transfer_">nul @ping 127.0.0.1 -n 4 -w 1000> nul exit :foundbin ::check2 for password, this check is when filenames aren't protected but extraction is if not "%password%"=="" goto:nopassword2 if exist temp\boot.dol del temp\boot.dol>nul if exist temp\boot.elf del temp\boot.elf>nul support\7za e -aoa "%cmdinput%" -o"temp" boot.dol boot.elf -r >nul if exist temp\boot.dol for /F %%A in ("temp\boot.dol") do If %%~zA equ 0 del "temp\boot.dol" if exist temp\boot.elf for /F %%A in ("temp\boot.elf") do If %%~zA equ 0 del "temp\boot.elf" if exist temp\boot.dol goto:nopassword2 if exist temp\boot.elf goto:nopassword2 ::get password from user for /f "usebackq tokens=*" %%p in (`powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"`) do set password=%%p echo. ::echo "%password%" set "passwordcmd= -p"%password%"" ::echo %passwordcmd% ::support\7za l "%cmdinput%"%passwordcmd% > "%temp%\zip.txt" ::support\sfk filter -quiet "%temp%\zip.txt" -ls!"Listing archive:" -ls!"Path = " -write -yes :nopassword2 if exist temp\boot.dol del temp\boot.dol>nul if exist temp\boot.elf del temp\boot.elf>nul findStr /I apps\ "%temp%\zip.txt" >nul IF ERRORLEVEL 1 goto:noAppsDir ::support\sfk -spat echo [%yellowtext%]"%cmdinput%" echo The selected archive file includes an "apps" directory and is not transferable in it's current state if /i "%cmdinput:~-4%" EQU ".zip" echo ModMii will create a temporary usable copy of the ZIP for transmission... if /i "%cmdinput:~-4%" NEQ ".zip" echo The HBC only accepts ZIPs, ModMii will create a temporary usable ZIP copy of the %cmdinput:~-3% if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul if exist "temp\zip" rd /s /q "temp\zip"> nul ::if not exist "temp\zip" mkdir "temp\zip" if not exist temp\zip\apps mkdir temp\zip\apps support\7za x -aoa "%cmdinput%"%passwordcmd% -o"temp\zip"> nul cd temp\zip\apps del /f /q *.* ..\..\..\support\7za a "..\..\HBC_Transfer.zip" *>nul cd ..\..\.. ::"%cmdinput%" echo. set "HBC_Transfer=%cd%\temp\HBC_Transfer.zip" ::---check for folders outside of apps folder and display yellow warning if exist rd /s /q "temp\zip\apps"> nul ::anything left in temp\zip is not getting sent, check if zip folder is empty... ::empty folder check, if not empty goto something, if empty delete it dir /A /B "temp\zip" | findstr /R ".">NUL && goto:notempty ::empty goto:letsgo :notempty ::not empty, show warning support\sfk -spat echo [%yellowtext%]Warning: this archive contains the following items that are outside of the apps folder that will NOT get transferred. support\sfk -spat echo [%yellowtext%]Files outside of /apps need to be transferred manually, the HBC won't touch those. dir /b temp\zip if exist "temp\zip" rd /s /q "temp\zip"> nul echo. goto:letsgo :noAppsDir ::need to repack without password if it has a password (and not already repacked to correct apps folder) if /i "%cmdinput:~-4%" NEQ ".zip" goto:forceRepack if "%password%"=="" goto:letsgo :forceRepack ::support\sfk -spat echo [%yellowtext%]"%cmdinput%" echo A copy of the archive without a password is needed to transfer for the HBC if /i "%cmdinput:~-4%" EQU ".zip" echo ModMii will create a temporary usable copy of the ZIP for transmission... if /i "%cmdinput:~-4%" NEQ ".zip" echo The HBC only accepts ZIPs, ModMii will create a temporary usable ZIP copy of the %cmdinput:~-3% for transmission... if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul if exist "temp\zip" rd /s /q "temp\zip"> nul if not exist "temp\zip" mkdir "temp\zip" support\7za x -aoa "%cmdinput%"%passwordcmd% -o"temp\zip"> nul cd temp\zip ..\..\support\7za a "..\HBC_Transfer.zip" *>nul cd ..\.. ::"%cmdinput%" echo. set "HBC_Transfer=%cd%\temp\HBC_Transfer.zip" :letsgo ::check if both boot.dol and boot.elf exist, if yes, rename boot.dol to bootAlt.dol if /i "%foundDOL%" NEQ "Y" goto:tinyskip if /i "%foundELF%" NEQ "Y" goto:tinyskip echo The selected archive file includes both a boot.elf and a boot.dol and is not transferable in it's current state echo ModMii will rename the dol to create a temporary usable copy of the ZIP for transmission... if exist "temp\zip" rd /s /q "temp\zip"> nul if not exist "temp\zip" mkdir "temp\zip" support\7za x -aoa "%HBC_Transfer%" -o"temp\zip"> nul if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul set dolpath= dir /b /s temp\zip\*boot.dol>temp\dolpath.txt set /p dolpath= nul if exist "%dolpath%" move /y "%dolpath%" "%dolpath:~0,-4%Alt.dol">nul cd temp\zip ..\..\support\7za a "..\HBC_Transfer.zip" * >nul cd ..\.. ::"%cmdinput%" echo. set "HBC_Transfer=%cd%\temp\HBC_Transfer.zip" :tinyskip if exist temp\wiiload.exe goto:skip if exist index.html del index.html>nul call Support\subscripts\dependency.bat wiiload if /i "%dependency%" NEQ "F" goto:skip if /i "%AudioOption%" EQU "on" start support\nircmd.exe mediaplay 3000 "%Fail.mp3%" echo Unable to download wiiload, press any key to exit... if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul if exist "temp\HBC_Transfer_" rd /s /q "temp\HBC_Transfer_">nul pause>nul exit :skip support\sfk echo Upload from archive: [%bluetext%]"%cmdinput%" support\sfk echo To IP Address: [%bluetext%]"%WiiIP%" echo. echo The following will be uploaded to the "apps" folder of the device currently loaded by the HBC (e.g. SD or USB): echo. support\7za l "%HBC_Transfer%" > "%temp%\zip.txt" support\sfk filter -quiet "%temp%\zip.txt" -cut "*" to "----" -write -yes type "%temp%\zip.txt" echo. echo Make sure you have the HBC open but that you are not inside its Home Menu, echo Then press any key to start the upload... pause>nul set "WIILOAD=tcp:%WiiIP%" echo. support\sfk echo Sending command: [%cyantext%]wiiload.exe \""%HBC_Transfer%"\" echo. echo If you have issues, before trying again, make sure you have the HBC open but that you are not inside its Home Menu, echo Double check the Wii IP address and make sure both this device and the Wii are on the same network. echo. temp\wiiload.exe "%HBC_Transfer%" echo. echo exiting... @ping 127.0.0.1 -n 3 -w 1000> nul ::delete copy if applicable if exist "temp\HBC_Transfer.zip" del "temp\HBC_Transfer.zip">nul if exist "temp\HBC_Transfer_" rd /s /q "temp\HBC_Transfer_">nul ::if cmdinputrar is not nul, cmdinput is a zip copy of the original rar and should be deleted if not "%cmdinputrar%"=="" del "%cmdinput%">nul @ping 127.0.0.1 -n 7 -w 1000> nul exit :notWiiloadzip ::----------Wad drag and drop (single files) unpack and send to wii--------------- if /i "%cmdinput:~-4%" NEQ ".wad" goto:notwad if not exist "%cmdinput%" goto:notwad if exist "%cmdinput%\" goto:notwad title ModMii WAD tools support\nircmd.exe win setsize ititle "ModMii WAD tools" 0 0 895 780 set "WadInput=%cmdinput%" call "Support\subscripts\CollectWadInfo.bat" if exist temp\WADinfo.txt del temp\WADinfo.txt>nul If /i "%wadtype%" EQU "Invalid" (echo.) & (echo This is not a valid WAD file! Press any key to exit...) & (pause>nul) & (exit) ::Detect NandLoader if %AutoDetectNL% setting is enabled, WADcontents is not GTR than 3 (so channels like Region Select & bomberman aren't attempted), and wadtype is channel or hidden if %WadContents% LEQ 1 goto:AutoDetectNLpickup if %WadContents% GTR 3 goto:AutoDetectNLpickup If /i "%wadtype%" EQU "channel" goto:AutoDetectNL If /i "%wadtype%" NEQ "hidden" goto:AutoDetectNLpickup :AutoDetectNL ::Careful editing cmdinput! ::if not "%AutoDetectNL%"=="" set "cmdinput=%WadInput%" if not "%AutoDetectNL%"=="" (set WadNandLoader=D) & (set DetectNLpickup=AutoDetectNLpickup) & (goto:NLcount) :AutoDetectNLpickup :WADdrop ::title ModMii WAD tools set SendWAD= set WiiIP= if exist temp\WiiIP.txt set /p WiiIP= temp\temp.txt support\sfk -spat filter temp\temp.txt -rep _"\x22"__ -write -yes>nul cls title ModMii Inspector Wadget support\sfk echo [%redtext%]ModMii v%currentversion% Inspector Wadget goto:WadBulkInfo :skip ::%wadtype:~0,7% to permit channel and channelsystem types If /i "%wadtype:~0,7%" EQU "channel" goto:permit If /i "%wadtype%" EQU "hidden" goto:permit If /i "%wadtype%" EQU "ios" goto:permit goto:skip :permit if /i "%SendWAD%" EQU "M" goto:modifywad :skip if %GetFileSize% GTR 8388576 goto:badkey if /i "%SendWAD%" EQU "help" (start https://www.youtube.com/embed/JSyIDx35TVo) & (goto:WADdrop) if "%WiiIP%"=="" goto:skip If /i "%SendWAD%" EQU "S" set "SendWAD=%WiiIP%" :skip ::check valid IP powershell -nologo -noprofile -Command "[ipaddress]::TryParse('%SendWAD%',[ref][ipaddress]::Loopback)" | findstr "False">NUL && goto:badkey ::check for 3 periods set "string=%SendWAD%" set /a dotcount=0 setlocal EnableDelayedExpansion if defined string (set ^"strtmp=!string:.=^ %= empty string =% !^") else set "strtmp=" for /F %%C in ('cmd /V /C echo(^^!strtmp^^!^| find /C /V ""') do set /A "dotcount=%%C-1" setlocal DISABLEDELAYEDEXPANSION ::echo "!string!" contains %dotcount% periods. if /i "%dotcount%" EQU "3" goto:pingme :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:WADdrop :pingme call Support\subscripts\dependency.bat Sharpii if /i "%dependency%" EQU "F" (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:WADdrop) ::check if Wii is reachable ::echo. ::echo Pinging Wii to see if reachable... ping -n 1 "%SendWAD%"|findstr /I /C:"ms">nul IF NOT ERRORLEVEL 1 goto:Pinged support\sfk echo [%yellowtext%]Unable to reach IP %SendWAD%, check your settings and try again... @ping 127.0.0.1 -n 2 -w 1000> nul goto:WADdrop :Pinged cls set "WiiIP=%SendWAD%" > "temp\WiiIP.txt" ECHO %WiiIP% support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Sending Wad: [%bluetext%]"%cmdinput%" support\sfk echo To IP Address: [%bluetext%]"%WiiIP%" echo. echo If you have issues make sure you have the HBC open but that you are not inside its Home Menu, echo Double check the Wii IP address and make sure both this device and the Wii are on the same network. echo. support\sfk -spat echo "Sending command: [%cyantext%]sharpii.exe SendWad -ip "%WiiIP%" -wad \x22"%cmdinput%"\x22 -ahb" echo. temp\Sharpii.exe SendWad -ip %WiiIP% -wad "%cmdinput%" -ahb echo. echo exiting... @ping 127.0.0.1 -n 5 -w 1000> nul exit :unpackwad if not exist "%cmdinput:~0,-4%" mkdir "%cmdinput:~0,-4%" set errorlevel= %WiiPy% wad unpack --skip-hash "%cmdinput%" "%cmdinput:~0,-4%">nul if /i "%errorlevel%" NEQ "0" goto:UnpackFail if not exist "%cmdinput:~0,-4%\*.tmd" goto:UnpackFail if /i "%AudioOption%" EQU "on" start support\nircmd.exe mediaplay 3000 "%Success.mp3%" echo. echo WAD unpacked to folder: "%cmdinput:~0,-4%" echo. echo exiting... if /i "%SendWAD%" EQU "O" explorer "%cmdinput:~0,-4%" @ping 127.0.0.1 -n 5 -w 1000> nul exit :UnpackFail if /i "%AudioOption%" EQU "on" start support\nircmd.exe mediaplay 3000 "%Fail.mp3%" ::empty folder check, if not empty goto something, if empty delete it dir /A /B "%cmdinput:~0,-4%" | findstr /R ".">NUL && goto:notempty rd /s /q "%cmdinput:~0,-4%"> nul :notempty echo. (echo Something went wrong, press any key to exit...) & (pause>nul) & (exit) :modifywad If /i "%wadtype%" EQU "ios" goto:modifyIOSwad :FirstRandom if not "%RandomNum%"=="" goto:notFirstRandom set "RandomNum=%random%" set "WADcopy=%cmdinput:~0,-4%-Mod%RandomNum%.wad" if exist "%WADcopy%" (set RandomNum=) & (goto:FirstRandom) :notFirstRandom if "%WADtit%"=="" goto:modifyID cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: [%cyantext%]Title[def], Title ID, IOS, DOL, AHB^|DVD, %NLtext%Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify Channel Title echo. echo If you would like to change the Title, enter a new Title now (max length is 40 chars). echo. echo To leave the Title unchanged, leave the selection blank and press Enter. echo. echo B = Back echo E = Exit echo. set WADtitle=" set /p WADtitle=Enter Selection Here: set "WADtitle=%WADtitle:"=%" if "%WADtitle%"=="" goto:modifyID if /i "%WADtitle%" EQU "B" goto:WADdrop if /i "%WADtitle%" EQU "E" exit ::title 40 chars length check if /i "%WADtitle:~40,1%" NEQ "" goto:badkey ::save copy and apply change if not exist "%WADcopy%" copy /y "%cmdinput%" "%WADcopy%">nul %WiiPy% wad edit --channel-name "%WADtitle%" "%WADcopy%" if not errorlevel 0 goto:WADfail set "WADtit=%WADtitle%" set SigningStatus=Fakesigned @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyID :badkey echo Title is greater than 40 character maximum... @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifywad :modifyID cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: %TITtext%[%cyantext%]Title ID[def], IOS, DOL, AHB^|DVD, %NLtext%Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify Channel Title ID echo. echo If you would like to change the Title ID, enter a new 4-character Title ID now. ::echo Note: letters and numbers only; cannot contain spaces or special characters. echo. echo To leave the Title ID unchanged, leave the selection blank and press Enter. echo. ::check for title ID's that cause issues on vWii https://hackmd.io/@Ingunar/43OnlyWii#Structure-and-rules (pillarboxing be resolved using priiloader system menu hack instead) ::https://github.com/DacoTaco/priiloader/blob/master/docs/HACKSLIST.md#remove-pillarboxing-completely-vwii ::pillarboxing if /i "%TitID:~0,1%" EQU "C" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "F" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "J" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "L" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "N" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "P" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "Q" goto:titleIDwarning ::Titles starting with D, R, S, T are checked for in discdb.bin- Wii Disc IDs and Disk Channels if /i "%TitID:~0,1%" EQU "D" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "R" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "T" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "S" goto:titleIDwarning ::Titles starting with E are complicated, if the second letter is I-Z or 2-7 it's checked in the vcadb.bin - Virtual Console Arcade Titles, if the second letter is A-H it's 4:3 #E[A-H]xxxx - NeoGeo Virtual Console games games, All other titles are 16:9 if /i "%TitID:~0,1%" EQU "E" goto:titleIDwarning ::Titles starting with H, W are checked for in the wwdb.bin - All Wii System Menu Channels and WiiWare Titles if /i "%TitID:~0,1%" EQU "H" goto:titleIDwarning if /i "%TitID:~0,1%" EQU "W" goto:titleIDwarning ::Titles starting with M followed by C3 are always 16:9, all others with M are 4:3 if /i "%TitID:~0,1%" EQU "M" goto:titleIDwarning ::Titles starting with X followed by A-G are 4:3, all others are checked for in the wwdb.bin - All WiiWare Demos if /i "%TitID:~0,1%" EQU "X" goto:titleIDwarning goto:skipwarning :titleIDwarning support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%redtext%]Warning![def] \x22"%TitID%"\x22 Title ID will force title checks or 4:3 aspect ratio (pillarboxing) on vWii echo UNLESS Priiloader's pillarboxing system menu hacks are enabled. To avoid this without needing echo Priiloader hacks use a new Title ID that does not begin any of these letters: support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 C,D,E,F,H,J,L,M,N,P,Q,R,S,T,W,X (e.g. B"%TitID:~1,3%") echo. :skipwarning echo B = Back echo E = Exit echo. set WADtitleID=" set /p WADtitleID=Enter Selection Here: set "WADtitleID=%WADtitleID:"=%" if "%WADtitleID%"=="" goto:modifyIOS if /i "%WADtitleID%" NEQ "B" goto:notback if "%WADtit%"=="" goto:WADdrop goto:modifywad :notback if /i "%WADtitleID%" EQU "E" exit ::title 4 chars length check if /i "%WADtitleID:~4,1%" NEQ "" goto:badkey if /i "%WADtitleID:~3,1%" EQU "" goto:badkey ::space check ::if /i "%WADtitleID:~0,1%" EQU " " goto:badkey ::if /i "%WADtitleID:~1,1%" EQU " " goto:badkey ::if /i "%WADtitleID:~2,1%" EQU " " goto:badkey ::if /i "%WADtitleID:~3,1%" EQU " " goto:badkey ::skip if same value entered if /i "%TitID%" EQU "%WADtitleID%" goto:modifyIOS ::check for title ID's that cause issues on vWii https://hackmd.io/@Ingunar/43OnlyWii#Structure-and-rules (pillarboxing be resolved using priiloader system menu hack instead) ::https://github.com/DacoTaco/priiloader/blob/master/docs/HACKSLIST.md#remove-pillarboxing-completely-vwii ::pillarboxing if /i "%WADtitleID:~0,1%" EQU "C" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "F" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "J" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "L" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "N" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "P" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "Q" goto:titleIDwarning ::Titles starting with D, R, S, T are checked for in discdb.bin- Wii Disc IDs and Disk Channels if /i "%WADtitleID:~0,1%" EQU "D" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "R" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "T" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "S" goto:titleIDwarning ::Titles starting with E are complicated, if the second letter is I-Z or 2-7 it's checked in the vcadb.bin - Virtual Console Arcade Titles, if the second letter is A-H it's 4:3 #E[A-H]xxxx - NeoGeo Virtual Console games games, All other titles are 16:9 if /i "%WADtitleID:~0,1%" EQU "E" goto:titleIDwarning ::Titles starting with H, W are checked for in the wwdb.bin - All Wii System Menu Channels and WiiWare Titles if /i "%WADtitleID:~0,1%" EQU "H" goto:titleIDwarning if /i "%WADtitleID:~0,1%" EQU "W" goto:titleIDwarning ::Titles starting with M followed by C3 are always 16:9, all others with M are 4:3 if /i "%WADtitleID:~0,1%" EQU "M" goto:titleIDwarning ::Titles starting with X followed by A-G are 4:3, all others are checked for in the wwdb.bin - All WiiWare Demos if /i "%WADtitleID:~0,1%" EQU "X" goto:titleIDwarning goto:skipwarning :titleIDwarning echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%redtext%]Warning![def] \x22%WADtitleID%\x22 Title ID will force title checks or 4:3 aspect ratio (pillarboxing) on vWii echo UNLESS Priiloader's pillarboxing system menu hacks are enabled. To avoid this without needing echo Priiloader hacks use a new Title ID that does not begin any of these letters: echo C,D,E,F,H,J,L,M,N,P,Q,R,S,T,W,X (e.g. B%WADtitleID:~1,3%) echo. :titleIDwarning2 set titleIDwarning=" set /p titleIDwarning= Do you still want to change the Title ID to "%WADtitleID%"? (Y/N): set "titleIDwarning=%titleIDwarning:"=%" if /i "%titleIDwarning%" EQU "N" goto:modifyID if /i "%titleIDwarning%" EQU "Y" goto:skipwarning echo You Have Entered an Incorrect Key echo. goto:titleIDwarning2 :skipwarning ::save copy and apply change if not exist "%WADcopy%" copy /y "%cmdinput%" "%WADcopy%">nul %WiiPy% wad edit --tid "%WADtitleID%" "%WADcopy%" if not errorlevel 0 goto:WADfail set SigningStatus=Fakesigned set "TitID=%WADtitleID%" @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyIOS :badkey echo Title ID must be 4 characters... @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyID :modifyIOS cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: %TITtext%Title ID, [%cyantext%]IOS[def], DOL, AHB^|DVD, %NLtext%Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify Channel IOS echo. echo If you would like to change the IOS used by the channel, enter it now (must be between 3-254). echo Note: The selected IOS should be installed on the Wii\vWii and capable of launching this title. echo. echo To leave the IOS unchanged, leave the selection blank and press Enter. echo. ::IOS61 Warning for vWii If /i "%iosslot%" NEQ "61" goto:skipwarning support\sfk -spat echo \x20 \x20 \x20 [%redtext%]Warning![def] IOS61 is normally not installed on vWii unless you used ModMii or System Channel Restorer. echo Keeping the IOS at 61 may prevent the channel from loading on vWii. echo Choose another IOS to avoid this issue (e.g. 58). echo. :skipwarning echo B = Back echo E = Exit echo. set WADios=" set /p WADios=Enter Selection Here: set "WADios=%WADios:"=%" if "%WADios%"=="" goto:modifyDOL if /i "%WADios%" EQU "B" goto:modifyID if /i "%WADios%" EQU "E" exit ::if not numeric goto:badkey for %%A in ("%WADios%") do (for /f "tokens=1 delims=0123456789" %%B in ("%%~A") do goto:badkey) ::Remove leading zeros for /f "tokens=* delims=0" %%A in ("%WADios%") do set "WADios=%%A" ::Set to 0 if entire input is all zeros if "%WADios%"=="" set "WADios=0" ::IOS 3-254 check ::limit user input to X# of digits if not "%WADios:~3%"=="" goto:badkey if %WADios% LSS 3 goto:badkey if %WADios% GTR 254 goto:badkey ::skip if same value entered if /i "%WADios%" EQU "%iosslot%" goto:modifyDOL ::IOS61 Warning for vWii if /i "%WADios%" NEQ "61" goto:skipwarning echo. support\sfk -spat echo \x20 \x20 \x20 [%redtext%]Warning![def] IOS61 is normally not installed on vWii unless you used ModMii or System Channel Restorer. echo Keeping the IOS at 61 may prevent the channel from loading on vWii. echo Choose another IOS to avoid this issue (e.g. 58). echo. :IOS61warning set IOS61warning=" set /p IOS61warning= Do you still want to change the IOS to 61? (Y/N): set "IOS61warning=%IOS61warning:"=%" if /i "%IOS61warning%" EQU "N" goto:modifyIOS if /i "%IOS61warning%" EQU "Y" goto:skipwarning echo You Have Entered an Incorrect Key echo. goto:IOS61warning :skipwarning ::save copy and apply change if not exist "%WADcopy%" copy /y "%cmdinput%" "%WADcopy%">nul set ERRORLEVEL= %WiiPy% wad edit --ios "%WADios%" "%WADcopy%" if not errorlevel 0 goto:WADfail set SigningStatus=Fakesigned set "iosslot=%WADios%" @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyDOL :badkey echo IOS must be between 3-254, try again... @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyIOS :modifyDOL cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: %TITtext%Title ID, IOS, [%cyantext%]DOL[def], AHB^|DVD, %NLtext%Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify Channel DOL echo. echo To change the DOL used by this channel enter the path of the new DOL or WAD to use instead. if /i "%adminmode%" EQU "N" echo Note: You can drag and drop the new DOL or WAD onto this window instead of manually typing it. echo. echo To leave the DOL unchanged, leave the selection blank and press Enter. echo. echo B = Back echo E = Exit echo. set WADdol=" set /p WADdol=Enter Selection Here: set "WADdol=%WADdol:"=%" if "%WADdol%"=="" goto:modifyAHB if /i "%WADdol%" EQU "B" goto:modifyIOS if /i "%WADdol%" EQU "E" exit if not exist "%WADdol%" goto:badkey ::if newDolNL=Y it means new dol (or dol embedded in wad) has an integrated nand loader, same goes for oldDolNL (i.e. wad that was dragged) if %WadContents% GTR 2 (set oldDolNL=N) else (set oldDolNL=Y) set newDolNL=N if /i "%WADdol:~-4%" NEQ ".wad" goto:skipWADcheck ::only accept channels and hidden channels set channelpathTEMP= if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0xE8C 0x04 "%WADdol%">temp\hexdump.txt set /p channelpathTEMP= nul goto:modifyDOL :skip ::new module count (in hex) in tmd at offset 0x1DE (len 2), or offset 0xEDE of wad (offset is 0xD00 or 3328 greater in WAD than tmd) if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0xEDE 0x02 "%WADdol%">temp\hexdump.txt set /p NewWadContents= temp\hexdump.txt set /p NewWadContents= nul support\sfk hexdump -pure -nofile -offlen 0xEE0 0x02 "%WADdol%">temp\hexdump.txt set /p NewBootIndex= nul goto:modifyDOL :continue ::if wad, unpack to get new dol if exist "temp\__channel" rd /s /q "temp\__channel"> nul mkdir "temp\__channel" %WiiPy% wad unpack --skip-hash "%WADdol%" "temp\__channel">nul ::00000003.app should not exist if exist "temp\__channel\00000003.app" (echo 00000003.app unexpected in donor WAD...) & (goto:WADfail) if not exist "temp\__channel\00000001.app" (echo 00000001.app missing in donor WAD...) & (goto:WADfail) ::if exist "temp\__channel" rd /s /q "temp\__channel"> nul If /i "%NewBootIndex%" EQU "0001" set "WADdol=temp\__channel\00000002.app" If /i "%NewBootIndex%" EQU "0002" set "WADdol=temp\__channel\00000001.app" if not exist "temp\__channel\00000002.app" set "WADdol=temp\__channel\00000001.app" If /i "%newDolNL%" EQU "Y" set "WADdol=temp\__channel\00000001.app" goto:skip :skipWADcheck if /i "%WADdol:~-4%" NEQ ".dol" goto:badkey ::.dol: check if new dol has integrated nandloader call Support\subscripts\dependency.bat ODB if /i "%dependency%" EQU "F" (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:modifyDOL) ::double check this is a NandLoader, if OpenDolBoot.exe -i output contains 0x00003400 or 0x80003400 then it's a nandloader temp\OpenDolBoot.exe -i "%WADdol%" | findstr 0x00003400>NUL && set newDolNL=Y temp\OpenDolBoot.exe -i "%WADdol%" | findstr 0x80003400>NUL && set newDolNL=Y :skip if not exist "%WADcopy%" (set "WADtemp=%cmdinput%") else (set "WADtemp=%WADcopy%") ::get boot index (at offset 0x1E0 of TMD or 0xEE0 of WAD) if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0xEE0 0x02 "%WADtemp%">temp\hexdump.txt set /p OldBootIndex= nul goto:modifyDOL :continue ::At this point if "%WADdol%" was a wad, now it's a dol ::if oldDolNL=Y and newDolNL=N, need to inject nandloader into dol If /i "%oldDolNL%" NEQ "Y" goto:skip If /i "%newDolNL%" NEQ "N" goto:skip echo. echo Old dol has integrated NandLoader but new dol does not... echo Integrating OpenDolBoot's NandLoader to new dol before adding to WAD... call Support\subscripts\dependency.bat ODB if /i "%dependency%" EQU "F" (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:modifyDOL) if exist "temp\main.dol" del "temp\main.dol">nul temp\OpenDolBoot.exe "%WADdol%" -f "temp\main.dol">nul if not errorlevel 0 goto:WADfail set "WADdol=temp\main.dol" set "WadNL=OpenDolBoot [integrated]" set newDolNL=Y :skip ::apply change to copy if not exist "%WADcopy%" copy /y "%cmdinput%" "%WADcopy%">nul ::if oldDolNL=Y and newDolNL=N impossible scenario now, as it would have already been changed to both be =Y ::if oldDolNL=N and newDolNL=Y, replace content #1 and remove content #2 ::if oldDolNL=Y and newDolNL=Y, just replace content #1 If /i "%newDolNL%" NEQ "Y" goto:skip %WiiPy% wad set -i 1 "%WADcopy%" "%WADdol%" if /i "%errorlevel%" NEQ "0" goto:WADfail If /i "%oldDolNL%" EQU "N" %WiiPy% wad remove -i 2 "%WADcopy%" if /i "%errorlevel%" NEQ "0" goto:WADfail If /i "%oldDolNL%" EQU "N" set /a WadContents=%WadContents%-1 echo Operation completed succesfully! if exist "temp\__channel" rd /s /q "temp\__channel"> nul set SigningStatus=Fakesigned ::get WAD updated size (1 of 3) %WiiPy% info "%WADcopy%">temp\WADinfo.txt ::check if file is empty, if empty it means WiiPy errored; likely with "This is not a valid WAD file!" >nul findstr "^" "temp\WADinfo.txt" || set wadtype=Invalid If /i "%wadtype%" NEQ "Invalid" goto:notInvalid support\sfk echo [%yellowtext%]This is not a valid WAD file if exist temp\WADinfo.txt del temp\WADinfo.txt>nul goto:WADfail :notInvalid ::get WAD size in bytes, megabytes and blocks support\sfk filter -quiet temp\WADinfo.txt -ls+" Installed Size: " -rep _*": "__>temp\WADinfo2.txt set /p WadBlocks= temp\WADinfo2.txt set /p GetFileSizeMB= "temp\WADinfo.txt" support\sfk filter "temp\WADinfo.txt" -rep _" bytes*"__ -rep _"* "__ >temp\WADinfo2.txt set /p GetFileSize= nul if exist temp\WADinfo2.txt del temp\WADinfo2.txt>nul ::---redetect new Nandloader if autodetect enabled--- ::if %WadContents% LEQ 1 goto:AutoDetectNLpickup3 ::if %WadContents% GTR 3 goto:AutoDetectNLpickup3 ::If /i "%wadtype%" EQU "channel" goto:AutoDetectNL3 ::If /i "%wadtype%" NEQ "hidden" goto:AutoDetectNLpickup3 :::AutoDetectNL3 set WadNL= set "cmdinputcopy=%cmdinput%" if "%AutoDetectNL%"=="" goto:AutoDetectNLpickup3 echo. echo Autodetecting new NandLoader as per settings... set WadNandLoader=D set DetectNLpickup=AutoDetectNLpickup3 ::Careful editing cmdinput! ::done above::set "cmdinputcopy=%cmdinput%" set "cmdinput=%WADcopy%" goto:NLcount :AutoDetectNLpickup3 set "cmdinput=%cmdinputcopy%" @ping 127.0.0.1 -n 1 -w 1000> nul goto:modifyAHB :skip ::if oldDolNL=N and newDolNL=N, replace correct content If /i "%OldBootIndex%" EQU "0001" %WiiPy% wad set -i 2 "%WADcopy%" "%WADdol%" If /i "%OldBootIndex%" EQU "0002" %WiiPy% wad set -i 1 "%WADcopy%" "%WADdol%" if /i "%errorlevel%" NEQ "0" goto:WADfail echo Operation completed succesfully! if exist "temp\__channel" rd /s /q "temp\__channel"> nul set SigningStatus=Fakesigned ::get WAD updated size (2 of 3) %WiiPy% info "%WADcopy%">temp\WADinfo.txt ::check if file is empty, if empty it means WiiPy errored; likely with "This is not a valid WAD file!" >nul findstr "^" "temp\WADinfo.txt" || set wadtype=Invalid If /i "%wadtype%" NEQ "Invalid" goto:notInvalid support\sfk echo [%yellowtext%]This is not a valid WAD file if exist temp\WADinfo.txt del temp\WADinfo.txt>nul goto:WADfail :notInvalid ::get WAD size in bytes, megabytes and blocks support\sfk filter -quiet temp\WADinfo.txt -ls+" Installed Size: " -rep _*": "__>temp\WADinfo2.txt set /p WadBlocks= temp\WADinfo2.txt set /p GetFileSizeMB= "temp\WADinfo.txt" support\sfk filter "temp\WADinfo.txt" -rep _" bytes*"__ -rep _"* "__ >temp\WADinfo2.txt set /p GetFileSize= nul if exist temp\WADinfo2.txt del temp\WADinfo2.txt>nul @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyAHB :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyDOL :modifyAHB cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: %TITtext%Title ID, IOS, DOL, [%cyantext%]AHB^|DVD[def], %NLtext%Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify AHB or DVD Video Access Rights echo. echo 2 = Enable both AHB (full PPC hardware) and DVD Video access rights echo A = enable AHB Access only and disable DVD Video access echo D = enable DVD Video access Only and disable AHB access echo N = None; disable both AHB and DVD Video Access for some reason echo. echo To leave AHB Access unchanged, leave the selection blank and press Enter. echo. echo B = Back echo E = Exit echo. set WadAHB=" set /p WadAHB=Enter Selection Here: set "WadAHB=%WadAHB:"=%" if not "%WadAHB%"=="" goto:notempty if "%NLtext%"=="" goto:modifyFakesign goto:modifyNandLoader :notempty if /i "%WadAHB%" EQU "B" goto:modifyDOL if /i "%WadAHB%" EQU "E" exit if /i "%WadAHB%" EQU "2" goto:continue if /i "%WadAHB%" EQU "A" goto:continue if /i "%WadAHB%" EQU "D" goto:continue if /i "%WadAHB%" EQU "N" goto:continue goto:badkey :continue ::7 6 5 4 3 2 1 0 - bits ::if position 0 = 1 then AHB Access is enabled ::if position 1 = 1 then DVD Access is enabled set "AccessRightsBinNew=%AccessRightsBin%" if /i "%WadAHB%" EQU "A" set "AccessRightsBinNew=%AccessRightsBinNew:~0,6%01" if /i "%WadAHB%" EQU "D" set "AccessRightsBinNew=%AccessRightsBinNew:~0,6%10" if /i "%WadAHB%" EQU "N" set "AccessRightsBinNew=%AccessRightsBinNew:~0,6%00" if /i "%WadAHB%" EQU "2" set "AccessRightsBinNew=%AccessRightsBinNew:~0,6%11" ::echo AccessRightsBin:"%AccessRightsBin%" ::echo AccessRightsBinNew:"%AccessRightsBinNew%" if /i "%AccessRightsBinNew%" EQU "%AccessRightsBin%" (echo No changes selected...) & (goto:NextThing) ::convert AccessRightsBinNew to hex and apply patch support\sfk num -show hex 0b%AccessRightsBinNew%>temp\hexdump.txt set /p AccessRightsHexNew= nul set ERRORLEVEL= support\sfk setbytes "%WADcopy%" 0xEDB 0x%AccessRightsHexNew% -yes>nul if not errorlevel 0 goto:WADfail set AccessRightsHex=%AccessRightsHexNew% set AccessRightsBin=%AccessRightsBinNew% If /i "%AccessRightsBin:~-1%" EQU "1" (set ahbprot=Enabled) else (set ahbprot=Disabled) ::echo AHB Access: %ahbprot% If /i "%AccessRightsBin:~-2,1%" EQU "1" (set DVDvid=Enabled) else (set DVDvid=Disabled) ::echo DVD Video Access: %DVDvid% echo Operation completed succesfully! :NextThing @ping 127.0.0.1 -n 2 -w 1000> nul if "%NLtext%"=="" goto:modifyFakesign goto:modifyNandLoader :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyAHB :WADfail ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled if "%SendWAD%"=="" (set "WadNL=Unable to detect") & (goto:%DetectNLpickup%) If /i "%droptype%" EQU "folder" (support\sfk echo [%redtext%]Something went wrong, skipping...) & (set /a wads2error=%wads2error%+1) & (goto:%EOF%) if /i "%AudioOption%" EQU "on" start support\nircmd.exe mediaplay 3000 "%Fail.mp3%" echo Something went wrong, exiting... if exist "temp\__channel" rd /s /q "temp\__channel"> nul @ping 127.0.0.1 -n 5 -w 1000> nul exit :modifyNandLoader set DetectNLpickup=modifyNandLoader cls support\sfk echo [%redtext%]ModMii v%currentversion% WAD tools echo. support\sfk echo Modify Channel WAD: %TITtext%Title ID, IOS, DOL, AHB^|DVD, [%cyantext%]NandLoader[def], Fakesign, %DFtext%Visibility echo. support\sfk.exe echo Input : [%bluetext%]"%cmdinput%" support\sfk.exe echo Output: [%bluetext%]"%cmdinput:~0,-4%[%redtext%]-Mod%RandomNum%[%bluetext%].wad" echo. ::set "WADinfo=%cmdinput%" ::if exist "%WADcopy%" set "WADinfo=%WADcopy%" call "Support\subscripts\DisplayWadInfo.bat" echo. support\sfk -spat echo \x20 \x20 \x20 \x20 \x20 [%cyantext%]Modify NandLoader echo. echo To leave NandLoader unchanged, leave the selection blank and press Enter. :modifyNandLoader2 If /i "%droptype%" NEQ "folder" goto:notfolder cls support\sfk echo [%redtext%]ModMii v%currentversion% Bulk WAD NandLoader Updater echo. echo What NandLoader you would like to inject into this folder of WADs? echo. support\sfk.exe echo [%bluetext%]"%wadpath%" echo. echo Note: Inapplicable channels will be skipped. echo Changes will be applied to copies of the original WADs. :notfolder echo. echo If a channel fails to launch, changing its NandLoader may get it working. echo * OpenDolBoot ^& OpenHBC should work on both Wii and vWii echo * Tiny vWii only works with vWii echo * All other NandLoaders only work on the Wii echo. echo O = OpenDolBoot [Integrated] NandLoader (Recommended) echo C = Choose another NandLoader If /i "%droptype%" EQU "folder" goto:tinyskip ::when detecting NL, checks are also done for visible channels to see if a minimalist banner is installed if "%WadNL%"=="" echo D = Detect which NandLoader is currently used if "%AutoDetectNL%"=="" echo D+ = Detect NandLoader now and immediately when opening applicable Channel WADs if not "%AutoDetectNL%"=="" echo D+ = Disable automatic NandLoader detection when opening applicable Channel WADs :tinyskip echo B = Back echo E = Exit echo. set WadNandLoader=" set /p WadNandLoader=Enter Selection Here: set "WadNandLoader=%WadNandLoader:"=%" if "%WadNandLoader%"=="" goto:modifyFakesign if /i "%WadNandLoader%" NEQ "B" goto:notback If /i "%droptype%" EQU "folder" goto:wadfolder2 goto:modifyAHB :notback if /i "%WadNandLoader%" EQU "E" exit ::if /i "%WadNandLoader%" NEQ "Y" goto:badkey ::Detect NandLoader, start by building bin files for all external NandLoaders (if not already done), then unpack unpack channel to temp\__channel get data and return to :DetectNandLoader set "cmdinputcopy=%cmdinput%" If /i "%droptype%" EQU "folder" goto:AfterDetection ::enable AutoDetectNL (D+) if not already enabled, and detect if not already detected if not "%AutoDetectNL%"=="" goto:skip if /i "%WadNandLoader%" NEQ "D+" goto:skip Set AutoDetectNL=Y echo Set AutoDetectNL=Y>>Support\settings.bat if not "%WadNL%"=="" goto:modifyNandLoader set WadNandLoader=D goto:skip2 :skip ::disable AutoDetectNL (D+) if enabled (if previously enabled then already detected) if "%AutoDetectNL%"=="" goto:skip2 if /i "%WadNandLoader%" NEQ "D+" goto:skip2 Set AutoDetectNL= if exist Support\settings.bat support\sfk filter Support\settings.bat -ls!"Set AutoDetectNL=" -write -yes>nul goto:modifyNandLoader :skip2 set "cmdinputcopy=%cmdinput%" if not "%WadNL%"=="" goto:AfterDetection if exist "%WADcopy%" set "cmdinput=%WADcopy%" ::::set already::set DetectNLpickup=modifyNandLoader if /i "%WadNandLoader%" EQU "D" goto:NLcount :DetectNandLoader if /i "%WadNandLoader%" NEQ "D" goto:AfterDetection temp\OpenDolBoot.exe -i "temp\__channel\%NANDloadLoc%" >"temp\NandLoader.nfo" support\sfk filter "temp\NandLoader.nfo" -cut "*" to "Sections" -+"0x00003400" -+"0x80003400" >"temp\tmp.txt" ::del "temp\NandLoader.nfo">nul ::0x09 is tab support\sfk filter -spat "temp\tmp.txt" -rep _"*offset*0x"__ -rep _"\x09*"__ -rep _" *"__ >"temp\offset.txt" set offset= set /p offset= <"temp\offset.txt" support\sfk filter -spat "temp\tmp.txt" -rep _"*size*0x"__ -rep _"\x09*"__ -rep _" *"__ >"temp\size.txt" set size= set /p size= <"temp\size.txt" ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled if "%SendWAD%"=="" goto:tinyskip if "%offset%"=="" (echo Unable to detect NandLoader...) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:modifyNandLoader) if "%size%"=="" (echo Unable to detect NandLoader...) & (@ping 127.0.0.1 -n 2 -w 1000> nul) & (goto:modifyNandLoader) :tinyskip if "%offset%"=="" (set "WadNL=Unable to detect") & (goto:%DetectNLpickup%) if "%size%"=="" (set "WadNL=Unable to detect") & (goto:%DetectNLpickup%) ::Check for ODB magicword (0xC4951034) at %offset%+4 len4 set magicword= if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0x%offset% 0x08 "temp\__channel\%NANDloadLoc%">temp\hexdump.txt set /p magicword= nul if exist "temp\NandLoader.md5" del "temp\NandLoader.md5">nul if exist "temp\NandLoaders.md5" del "temp\NandLoaders.md5">nul support\sfk hexdump -nofile -offlen 0x%offset% 0x%size% "temp\__channel\%NANDloadLoc%" +hextobin "temp\NandLoader.bin">nul ::nul out entrypoint ::temp\OpenDolBoot.exe -i "temp\__channel\%NANDloadLoc%" >"temp\NandLoader.nfo" support\sfk filter -quiet "temp\NandLoader.nfo" -cut "*" to "Sections" -!"0x00003400" -!"0x80003400" -write -yes ::0x09 is tab support\sfk filter -quiet -spat "temp\NandLoader.nfo" -rep _"*address*0x"__ -rep _"\x09*"__ -rep _" *"__ -write -yes set address= set /p address= <"temp\NandLoader.nfo" del "temp\NandLoader.nfo">nul ::echo address %address% set entrypoint=00000000 ::xhexfind instead of sfk hexfind to use wildcards i.e. [2 bytes] support\sfk xhexfind "temp\NandLoader.bin" -text "/\x%address:~0,2%\x%address:~2,2%[2 bytes]\x%address:~4,2%\x%address:~6,2%/">"temp\NandLoader.nfo" ::count number of matches \ hits to confirm just 1 set hits= find /C "hit at offset" < "temp\NandLoader.nfo">"temp\hits.txt" set /p hits= <"temp\hits.txt" del "temp\hits.txt">nul ::echo %hits% hits ::instead of going to :wadfail going to :skipnul2 if something fails, just means we can't detect, no need to exit if /i "%hits%" NEQ "1" goto:skipnul2 ::get offset support\sfk filter -quiet "temp\NandLoader.nfo" -+"hit at offset 0x" -rep _"*hit at offset 0x"__ -rep _" *"__ -write -yes set /p BinOffset= <"temp\NandLoader.nfo" ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2%>nul if not errorlevel 0 goto:skipnul2 support\sfk calc -hex 0x%BinOffset%+0x4>"temp\NandLoader.nfo" set /p BinOffset= <"temp\NandLoader.nfo" set BinOffset=%BinOffset:~2% del "temp\NandLoader.nfo">nul ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2%>nul if not errorlevel 0 goto:skipnul2 :skipnul2 ::hashcheck "temp\NandLoader.bin" against "Support\NandLoaders\*.nul" to detect, also check if integrated or not support\sfk md5 "temp\NandLoader.bin">"temp\NandLoader.md5" if exist "temp\NandLoader.bin" del "temp\NandLoader.bin">nul set /p md5= <"temp\NandLoader.md5" support\sfk select "Support\NandLoaders" .nul +md5>"temp\NandLoaders.md5" support\sfk filter -quiet "temp\NandLoaders.md5" -+"%md5%" -rep _*Support\NandLoaders\__ -rep _.nul__ -write -yes>nul ::delete if file is empty >nul findstr "^" "temp\NandLoaders.md5" || del "temp\NandLoaders.md5" if exist "temp\NandLoaders.md5" set /p WadNL= <"temp\NandLoaders.md5" if not exist "temp\NandLoaders.md5" set WadNL=Unknown :intVSext if not exist "temp\__channel\00000002.app" set WadNL=%WadNL% [Integrated] if exist "temp\__channel\00000002.app" set WadNL=%WadNL% [External] ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled if "%SendWAD%"=="" goto:%DetectNLpickup% ::if not "%AutoDetectNL%"=="" goto:%DetectNLpickup% if /i "%SendWAD%" EQU "I" goto:%DetectNLpickup% echo NandLoader: %WadNL% @ping 127.0.0.1 -n 2 -w 1000> nul ::DetectNLpickup=modifyNandLoader if launched from this screen directly goto:%DetectNLpickup% ::goto:modifyNandLoader :AfterDetection set "cmdinput=%cmdinputcopy%" if /i "%WadNandLoader%" EQU "O" goto:nextstep2 if /i "%WadNandLoader%" NEQ "C" goto:notClassicNandLoader echo. echo Choose from one of the following NandLoader options: echo. :NLcount call Support\subscripts\dependency.bat ODB ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled if "%SendWAD%"=="" goto:tinyskip if /i "%dependency%" EQU "F" (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:modifyNandLoader) :tinyskip if /i "%dependency%" EQU "F" (echo NandLoader: Unable to detect without OpenDolBoot) & (goto:%DetectNLpickup%) set /a NLcount=0 dir /b /a-d "Support\NandLoaders\*.bin">temp\NandLoaders.txt dir /b /a-d "Support\NandLoaders\*.app">>temp\NandLoaders.txt support\sfk filter "temp\NandLoaders.txt" -lerep _.app__ -lerep _.bin__ -write -yes>nul support\sfk filter "temp\NandLoaders.txt" -unique -no-empty-lines -no-blank-lines -write -yes>nul ::Loop through the following once for EACH line in *.txt for /F "tokens=*" %%A in (temp\NandLoaders.txt) do call :processNLlist %%A goto:nextstep :processNLlist set NL=%* set /a NLcount=%NLcount%+1 if /i "%WadNandLoader%" NEQ "D" echo %NLcount% = %NL% if exist "temp\NandLoader.nfo" del "temp\NandLoader.nfo">nul ::strip out just nandloader bin if exist "Support\NandLoaders\%NL%.bin" goto:skiptrim if not exist "Support\NandLoaders\%NL%.app" goto:skiptrim temp\OpenDolBoot.exe -i "Support\NandLoaders\%NL%.app" >"temp\NandLoader.nfo" support\sfk filter "temp\NandLoader.nfo" -cut "*" to "Sections" -+"0x00003400" -+"0x80003400" >"temp\tmp.txt" ::0x09 is tab support\sfk filter -spat "temp\tmp.txt" -rep _"*offset*0x"__ -rep _"\x09*"__ -rep _" *"__ >"temp\offset.txt" set offset= set /p offset= <"temp\offset.txt" support\sfk filter -spat "temp\tmp.txt" -rep _"*size*0x"__ -rep _"\x09*"__ -rep _" *"__ >"temp\size.txt" set size= set /p size= <"temp\size.txt" if "%offset%"=="" (echo Warning! %NL%.app does not appear to be a NandLoader...) & (goto:skiptrim) if "%size%"=="" (echo Warning! %NL%.app does not appear to be a NandLoader...) & (goto:skiptrim) support\sfk hexdump -nofile -offlen 0x%offset% 0x%size% "Support\NandLoaders\%NL%.app" +hextobin "Support\NandLoaders\%NL%.bin">nul :skiptrim ::create *.nul files for detection purposes ::For improved nand detection, need to null out entrypoint of mem address in current wad bin and copies of base nandloader bins before comparing hashes, double check that only 1 replacement is made if exist "Support\NandLoaders\%NL%.nul" goto:skipnul if not exist "Support\NandLoaders\%NL%.bin" goto:skipnul ::2) analyze nandloader.app for the non-NandLoader text section (i.e. ODB -i %NANDloadLoc%: the one without 0x00003400 or 0x80003400) to get its mem address (old entrypoint) ::if no *.app to retrieve address from (e.g. maybe OpenHBC.bin), try typical addresses (80004000 & later 81330000) ::marcan.bin, taiko.bin & waninkoko.bin is jumping to 0x81330000, majority are jumping to 0x80004000 set address= if not exist "Support\NandLoaders\%NL%.app" (set address=80004000) & (goto:step3b) temp\OpenDolBoot.exe -i "Support\NandLoaders\%NL%.app" >"temp\NandLoader.nfo" support\sfk filter -quiet "temp\NandLoader.nfo" -cut "*" to "Sections" -!"0x00003400" -!"0x80003400" -write -yes ::0x09 is tab support\sfk filter -quiet -spat "temp\NandLoader.nfo" -rep _"*address*0x"__ -rep _"\x09*"__ -rep _" *"__ -write -yes set address= set /p address= <"temp\NandLoader.nfo" del "temp\NandLoader.nfo">nul ::echo address %address% :step3b ::3) save a copy of nandloader.bin and edit\replace with nul entrypoint set entrypoint=00000000 ::mem address in the nandloader bin is usually preceeding by 0x3C60 and separated in the middle by 0x6063, i.e. if it's 0x8133000 search and replace 0x3C60****6063**** with 0x3C60%xxxx%6063%xxxx%; however comex is different (3863 instead of 6063), and OpenDol boot has no separators at all but ODB.exe handles that anyway ::search for %address% with any 2 bytes in the middle to get offset(s) copy /y "Support\NandLoaders\%NL%.bin" "temp\NandLoader.bin">nul ::xhexfind instead of sfk hexfind to use wildcards i.e. [2 bytes] support\sfk xhexfind "temp\NandLoader.bin" -text "/\x%address:~0,2%\x%address:~2,2%[2 bytes]\x%address:~4,2%\x%address:~6,2%/">"temp\NandLoader.nfo" ::count number of matches \ hits to confirm just 1 set hits= find /C "hit at offset" < "temp\NandLoader.nfo">"temp\hits.txt" set /p hits= <"temp\hits.txt" del "temp\hits.txt">nul ::echo %hits% hits ::instead of going to :wadfail going to :skipnul if something fails, just means we can't detect, no need to exit if /i "%hits%" EQU "1" goto:skip if /i "%address%" EQU "81330000" goto:skipnul ::try again if not exist "Support\NandLoaders\%NL%.app" (set address=81330000) & (goto:step3b) goto:skipnul :skip ::get offset support\sfk filter -quiet "temp\NandLoader.nfo" -+"hit at offset 0x" -rep _"*hit at offset 0x"__ -rep _" *"__ -write -yes set /p BinOffset= <"temp\NandLoader.nfo" ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2%>nul if not errorlevel 0 goto:skipnul support\sfk calc -hex 0x%BinOffset%+0x4>"temp\NandLoader.nfo" set /p BinOffset= <"temp\NandLoader.nfo" set BinOffset=%BinOffset:~2% del "temp\NandLoader.nfo">nul ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2%>nul if not errorlevel 0 goto:skipnul move /y "temp\NandLoader.bin" "Support\NandLoaders\%NL%.nul">nul :skipnul goto:EOF :nextstep if /i "%WadNandLoader%" NEQ "D" goto:NotDetect if exist "temp\__channel" rd /s /q "temp\__channel"> nul mkdir "temp\__channel" %WiiPy% wad unpack --skip-hash "%cmdinput%" "temp\__channel">nul goto:unpack2temp :NotDetect echo. echo B = Back \ Cancel echo. echo Additional NandLoaders can be added to ModMii by saving app or bin files here: echo "%cd%\Support\NandLoaders" echo. set ClassicNLChoice=" set /p ClassicNLChoice=Enter Selection Here: set "ClassicNLChoice=%ClassicNLChoice:"=%" if "%ClassicNLChoice%"=="" goto:badkey if /i "%ClassicNLChoice%" EQU "B" goto:modifyNandLoader ::if not numeric goto:badkey for %%A in ("%ClassicNLChoice%") do (for /f "tokens=1 delims=0123456789" %%B in ("%%~A") do goto:badkey) ::Remove leading zeros for /f "tokens=* delims=0" %%A in ("%ClassicNLChoice%") do set "ClassicNLChoice=%%A" ::Set to 0 if entire input is all zeros if "%ClassicNLChoice%"=="" set "ClassicNLChoice=0" if %ClassicNLChoice% GTR %NLcount% goto:badkey if %ClassicNLChoice% LEQ 0 goto:badkey set /a NLcount=0 ::Loop through the following once for EACH line in *.txt for /F "tokens=*" %%A in (temp\NandLoaders.txt) do call :processNLlist2 %%A goto:badkey :processNLlist2 set NL=%* set /a NLcount=%NLcount%+1 if /i "%NLcount%" EQU "%ClassicNLChoice%" goto:nextstep2 goto:EOF :nextstep2 call Support\subscripts\dependency.bat ODB if /i "%dependency%" EQU "F" (@ping 127.0.0.1 -n 3 -w 1000> nul) & (goto:modifyNandLoader) ::if not .app then no external support if not exist "Support\NandLoaders\%NL%.app" (set IntegrateNL=Y) & (goto:skipQ) if /i "%WadNandLoader%" EQU "O" goto:ConfirmedNL ::double check this is a NandLoader, if OpenDolBoot.exe -i output contains 0x00003400 or 0x80003400 then it's a nandloader temp\OpenDolBoot.exe -i "Support\NandLoaders\%NL%.app" | findstr 0x00003400>NUL && goto:ConfirmedNL temp\OpenDolBoot.exe -i "Support\NandLoaders\%NL%.app" | findstr 0x80003400>NUL && goto:ConfirmedNL echo The selected option is not a NandLoader, I won't delete it but it should not be in the Support\NandLoaders folder... @ping 127.0.0.1 -n 5 -w 1000> nul goto:modifyNandLoader :ConfirmedNL If /i "%droptype%" NEQ "folder" goto:skipQ if /i "%WadNandLoader%" EQU "O" (set IntegrateNL=Y) & (goto:skipQ) if not exist "Support\NandLoaders\%NL%.bin" (set IntegrateNL=N) & (goto:skipQ) echo. echo Would you like to integrate\merge the NandLoader with the main dol of each WAD? (Y/N): echo. echo If you say no, ModMii will keep the NandLoader position the same as the source WAD. echo i.e. If source WAD NandLoader is integrated it will stay integrated, if separate it will stay separate. echo. set IntegrateNL=" set /p IntegrateNL=Enter Selection Here: set "IntegrateNL=%IntegrateNL:"=%" if /i "%IntegrateNL%" EQU "Y" goto:skipQ if /i "%IntegrateNL%" EQU "N" goto:skipQ goto:badkey :skipQ If /i "%droptype%" EQU "folder" goto:BulkNandLoader :BulkNandLoaderPickup ::save copy and apply change if not exist "%WADcopy%" copy /y "%cmdinput%" "%WADcopy%">nul ::unpack WAD to temp dir if exist "temp\__channel" rd /s /q "temp\__channel"> nul mkdir "temp\__channel" %WiiPy% wad unpack --skip-hash "%WADcopy%" "temp\__channel">nul :unpack2temp ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled if "%SendWAD%"=="" goto:tinyskip if exist "temp\__channel\00000003.app" (echo 00000003.app unexpected...) & (goto:WADfail) :tinyskip if exist "temp\__channel\00000003.app" goto:WADfail if not exist "temp\__channel\00000001.app" (echo 00000001.app missing...) & (goto:WADfail) set NANDloadLoc= set MainBinLoc= ::determine if 00000001.app or 00000002.app is nandloader (note 00000002.app may be missing if already integrated) temp\OpenDolBoot.exe -i "temp\__channel\00000001.app" | findstr 0x00003400>NUL && set "NANDloadLoc=00000001.app" && set "MainBinLoc=00000002.app" temp\OpenDolBoot.exe -i "temp\__channel\00000001.app" | findstr 0x80003400>NUL && set "NANDloadLoc=00000001.app" && set "MainBinLoc=00000002.app" if not exist "temp\__channel\00000002.app" set MainBinLoc=00000001.app if exist "temp\__channel\00000002.app" temp\OpenDolBoot.exe -i "temp\__channel\00000002.app" | findstr 0x00003400>NUL && set "NANDloadLoc=00000002.app" && set "MainBinLoc=00000001.app" if exist "temp\__channel\00000002.app" temp\OpenDolBoot.exe -i "temp\__channel\00000002.app" | findstr 0x80003400>NUL && set "NANDloadLoc=00000002.app" && set "MainBinLoc=00000001.app" ::echo NANDloadLoc %NANDloadLoc% ::echo MainBinLoc %MainBinLoc% if not "%NANDloadLoc%"=="" goto:NLlocated ::If SendWAD is nul and we're here, then it means AutoDetectNL is enabled ::if "%SendWAD%"=="" goto:WADfail if "%SendWAD%"=="" (set "WadNL=Missing?!") & (goto:%DetectNLpickup%) if not exist "temp\__channel\00000001.app" (echo Unable to locate current NandLoader...) & (goto:WADfail) if exist "temp\__channel\00000002.app" (echo Unable to locate current NandLoader...) & (goto:WADfail) support\sfk echo [%yellowtext%]The WAD appears to be missing a NandLoader and broken. support\sfk echo [%yellowtext%]ModMii will try to repair it by integrating one into 00000001.app @ping 127.0.0.1 -n 2 -w 1000> nul set MainBinLoc=00000001.app set IntegrateNL=Y goto:skipQ :NLlocated if /i "%WadNandLoader%" EQU "D" goto:DetectNandLoader If /i "%droptype%" EQU "folder" goto:skipQ if /i "%WadNandLoader%" EQU "O" (set IntegrateNL=Y) & (goto:skipQ) ::if not .app then no external support if not exist "Support\NandLoaders\%NL%.app" (set IntegrateNL=Y) & (goto:skipQ) ::if 00000002.app exists prompt if users if they want to integrate NandLoader with main dol or leave separate if not exist "temp\__channel\00000002.app" (set IntegrateNL=Y) & (goto:skipQ) if not exist "Support\NandLoaders\%NL%.bin" (set IntegrateNL=N) & (goto:skipQ) echo. echo Would you like to integrate\merge the NandLoader with the main dol? (Y/N): echo If you say no, the NandLoader will be kept as a separate\external file. echo. set IntegrateNL=" set /p IntegrateNL=Enter Selection Here: set "IntegrateNL=%IntegrateNL:"=%" if /i "%IntegrateNL%" EQU "Y" goto:skipQ if /i "%IntegrateNL%" EQU "N" goto:skipQ goto:badkey :skipQ ::Update nandloader.bin address\entrypoint to align with main.dol (only for integrated NLs excluding ODB) before injecting\merging with dol, but the offsets to change differ from bin to bin if /i "%IntegrateNL%" EQU "N" goto:donestep3 if /i "%WadNandLoader%" EQU "O" goto:donestep3 ::1) analyze main.dol\app for new entrypoint with ODB.exe, or get it from dol directly at 0xE0 len 0x04 if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0xE0 0x04 "temp\__channel\%MainBinLoc%">temp\hexdump.txt set /p entrypoint= "temp\NandLoader.nfo" support\sfk filter -quiet "temp\NandLoader.nfo" -cut "*" to "Sections" -!"0x00003400" -!"0x80003400" -write -yes ::0x09 is tab support\sfk filter -quiet -spat "temp\NandLoader.nfo" -rep _"*address*0x"__ -rep _"\x09*"__ -rep _" *"__ -write -yes set address= set /p address= <"temp\NandLoader.nfo" del "temp\NandLoader.nfo">nul ::echo address %address% :step3 ::3) save a copy of nandloader.bin and edit\replace the new entrypoint from the main.dol before merging them using ODB.exe ::mem address in the nandloader bin is usually preceeding by 0x3C60 and separated in the middle by 0x6063, i.e. if it's 0x8133000 search and replace 0x3C60****6063**** with 0x3C60%xxxx%6063%xxxx%; however comex is different (3863 instead of 6063), and OpenDol boot has no separators at all but ODB.exe handles that anyway ::search for %address% with any 2 bytes in the middle to get offset(s) copy /y "Support\NandLoaders\%NL%.bin" "temp\NandLoader.bin">nul if /i "%address%" EQU "%entrypoint%" goto:donestep3 ::xhexfind instead of sfk hexfind to use wildcards i.e. [2 bytes] support\sfk xhexfind "temp\NandLoader.bin" -text "/\x%address:~0,2%\x%address:~2,2%[2 bytes]\x%address:~4,2%\x%address:~6,2%/">"temp\NandLoader.nfo" ::count number of matches \ hits to confirm just 1 set hits= find /C "hit at offset" < "temp\NandLoader.nfo">"temp\hits.txt" set /p hits= <"temp\hits.txt" del "temp\hits.txt">nul ::echo %hits% hits if /i "%hits%" EQU "1" goto:skip if /i "%address%" EQU "81330000" goto:wadfail ::try again if not exist "Support\NandLoaders\%NL%.app" (set address=81330000) & (goto:step3) goto:wadfail :skip ::get offset support\sfk filter -quiet "temp\NandLoader.nfo" -+"hit at offset 0x" -rep _"*hit at offset 0x"__ -rep _" *"__ -write -yes set /p BinOffset= <"temp\NandLoader.nfo" ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~0,2%,0x%entrypoint:~2,2%>nul if not errorlevel 0 goto:WADfail support\sfk calc -hex 0x%BinOffset%+0x4>"temp\NandLoader.nfo" set /p BinOffset= <"temp\NandLoader.nfo" set BinOffset=%BinOffset:~2% del "temp\NandLoader.nfo">nul ::echo support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2% support\hexalter.exe "temp\NandLoader.bin" 0x%BinOffset%=0x%entrypoint:~4,2%,0x%entrypoint:~6,2%>nul if not errorlevel 0 goto:WADfail ::old hex search hex replace method that only worked if all nandloaders followed this pattern: 3C60%address:~0,4%6063%address:~4,4% ::support\sfk replace "temp\NandLoader.bin" -binary /3C60%address:~0,4%6063%address:~4,4%/3C60%entrypoint:~0,4%6063%entrypoint:~4,4%/ -yes>"temp\NandLoader.nfo" ::ERRORLEVEL 1 means replacement successful ::IF not ERRORLEVEL 1 goto:wadfail ::confirm 1 change made in 1 file by finding this output "[001/1/0] temp\NandLoader.bin" ::findStr /I /C:"[001/1/0] temp\NandLoader.bin" "temp\NandLoader.nfo" >nul ::ERRORLEVEL 1 means not found ::IF ERRORLEVEL 1 goto:wadfail :donestep3 ::get tmd name dir /b /a-d "temp\__channel\*.tmd">"temp\__tmd.txt" set /p tmd= <"temp\__tmd.txt" del "temp\__tmd.txt">nul if /i "%IntegrateNL%" EQU "N" copy /y "Support\NandLoaders\%NL%.app" "temp\__channel\%NANDloadLoc%">nul if /i "%IntegrateNL%" NEQ "Y" goto:skip set errorlevel= if /i "%WadNandLoader%" EQU "O" temp\OpenDolBoot.exe "temp\__channel\%MainBinLoc%" -f "temp\__channel\main.app">nul if /i "%WadNandLoader%" NEQ "O" temp\OpenDolBoot.exe "temp\__channel\%MainBinLoc%" -f -n "temp\NandLoader.bin" "temp\__channel\main.app">nul if not errorlevel 0 goto:WADfail move /y temp\__channel\main.app temp\__channel\00000001.app>nul ::echo Remove ID 2 from tmd only if exists and we are integrating, then delete ::if exist "temp\__channel\00000002.app" support\TMdedit.exe -e "temp\__channel\%tmd%" -delID 2 -q if exist "temp\__channel\00000002.app" %WiiPy% tmd remove -i 2 "temp\__channel\%tmd%" ::Set boot index to 1 in tmd when integrating (in case position changed) if exist "temp\__channel\00000002.app" support\sfk setbytes "temp\__channel\%tmd%" 0x1E0 0x0001 -yes>nul if exist "temp\__channel\00000002.app" (del "temp\__channel\00000002.app">nul) & (set /a WadContents=%WadContents%-1) :skip ::echo Removing ID 0 and 1 from tmd (2 already removed if applicable) - no longer necessary given WiiPy updates hashes automatically during repacking ::support\TMdedit.exe -e "temp\__channel\%tmd%" -delID 0 -q ::support\TMdedit.exe -e "temp\__channel\%tmd%" -delID 1 -q ::if exist "temp\__channel\00000002.app" support\TMdedit.exe -e "temp\__channel\%tmd%" -delID 2 -q ::add back ID 0 & 1 (and 2 if applicable) to tmd with updated hashes ::support\TMdedit.exe -e "temp\__channel\%tmd%" -add 0 Normal 0 "temp\__channel\00000000.app" -q ::support\TMdedit.exe -e "temp\__channel\%tmd%" -add 1 Normal 1 "temp\__channel\00000001.app" -q ::if exist "temp\__channel\00000002.app" support\TMdedit.exe -e "temp\__channel\%tmd%" -add 2 Normal 2 "temp\__channel\00000002.app" -q ::Repack! if exist "temp\__channel.wad" del "temp\__channel.wad">nul set errorlevel= %WiiPy% wad pack --fakesign "temp\__channel" "temp\__channel.wad">nul set SigningStatus=Fakesigned ::support\sharpii.exe wad -p "temp\__channel" "temp\__channel.wad" if /i "%errorlevel%" NEQ "0" goto:WADfail if not exist "temp\__channel.wad" goto:WADfail move /y "temp\__channel.wad" "%WADcopy%">nul If /i "%droptype%" EQU "folder" (support\sfk.exe echo [%greentext%]Operation completed succesfully!) & (set /a wadsSuccess=%wadsSuccess%+1) & (goto:%EOF%) echo Operation completed succesfully! ::get WAD updated size (3 of 3) %WiiPy% info "%WADcopy%">temp\WADinfo.txt ::check if file is empty, if empty it means WiiPy errored; likely with "This is not a valid WAD file!" >nul findstr "^" "temp\WADinfo.txt" || set wadtype=Invalid If /i "%wadtype%" NEQ "Invalid" goto:notInvalid support\sfk echo [%yellowtext%]This is not a valid WAD file if exist temp\WADinfo.txt del temp\WADinfo.txt>nul goto:WADfail :notInvalid ::get WAD size in bytes, megabytes and blocks support\sfk filter -quiet temp\WADinfo.txt -ls+" Installed Size: " -rep _*": "__>temp\WADinfo2.txt set /p WadBlocks= temp\WADinfo2.txt set /p GetFileSizeMB= "temp\WADinfo.txt" support\sfk filter "temp\WADinfo.txt" -rep _" bytes*"__ -rep _"* "__ >temp\WADinfo2.txt set /p GetFileSize= nul if exist temp\WADinfo2.txt del temp\WADinfo2.txt>nul @ping 127.0.0.1 -n 1 -w 1000> nul if /i "%WadNandLoader%" EQU "O" set WadNL=OpenDolBoot if /i "%WadNandLoader%" NEQ "O" set "WadNL=%NL%" if /i "%IntegrateNL%" EQU "Y" set WadNL=%WadNL% [Integrated] if /i "%IntegrateNL%" EQU "N" set WadNL=%WadNL% [External] goto:modifyFakesign :notClassicNandLoader :badkey echo You Have Entered an Incorrect Key @ping 127.0.0.1 -n 2 -w 1000> nul goto:modifyNandLoader :BulkNandLoader cls support\sfk echo [%redtext%]ModMii v%currentversion% Bulk WAD NandLoader Updater echo. ::echo wad2folder: "%wad2folder%" ::echo wadpath: "%wadpath%" ::echo wadpathback: "%wadpathback%" if /i "%IntegrateNL%" EQU "N" (set NLtype=) else (set NLtype= [Integrated]) if /i "%WadNandLoader%" EQU "O" echo NandLoader: OpenDolBoot%NLtype% if /i "%WadNandLoader%" NEQ "O" echo NandLoader: %NL%%NLtype% set wadsSkipped=0 set wadsSuccess=0 set wads2error=0 set wadnum=0 ::Loop through the following once for EACH line in *.txt, alt method without FOR command to support & ^ and ! without using setlocal ENABLEDELAYEDEXPANSION :wadnum set EOF=wadnum ::use goto:above (or goto:%EOF%) instead of goto:EOF set CurrentWAD= ::check if file is empty, if empty it means list completed and goto:continue >nul findstr "^" "temp\temp.txt" || goto:skipwadnum ::set variable equal to top line set /p CurrentWAD= "temp\temp2.txt" ::"more" limits lines to about 65535 bytes/characters and the file to about 65535 lines. Also TABs become expanded to spaces move /y temp\temp2.txt temp\temp.txt>nul set /a wadnum=%wadnum%+1 echo. echo WAD %wadnum% of %wad2count%: "%CurrentWAD%" set "cmdinput=%CurrentWAD%" if /i "%WadNandLoader%" EQU "O" set "WADcopy=%CurrentWAD:~0,-4%_OpenDolBoot.wad" if /i "%WadNandLoader%" NEQ "O" set "WADcopy=%CurrentWAD:~0,-4%_%NL%.wad" ::echo "%cmdinput%" ::echo "%WADcopy%" ::confirm if channel or hidden channel ::hidden channels will have 00010008 in tmd at offset 0x18C (len 4), or offset at 0xE8C of wad (offset is 0xD00 or 3328 greater in WAD than tmd), if converting type it may not be enough to edit tmd as Sharpii makes other changes (including 0xC1C of wad) if exist temp\hexdump.txt del temp\hexdump.txt>nul support\sfk hexdump -pure -nofile -offlen 0xE8C 0x04 "%cmdinput%">temp\hexdump.txt set /p channelpath= nul support\sfk hexdump -pure -nofile -offlen 0xEDE 0x02 "%cmdinput%">temp\hexdump.txt set /p WadContents= temp\hexdump.txt set /p WadContents=