tobey's bepinex 5 hardpatcher
an experimental F# script that hardpatches a Unity game to load BepInEx 5 plugins
this is mostly only useful for non-Steam games on macOS and Linux, e.g. Subnautica when installed with the Epic Games Launcher on macOS
YOU WILL NEED TO RUN THIS PATCH AGAIN WHENEVER THE GAME UPDATES, SO YOU SHOULD PROBABLY BOOKMARK THIS PAGE
to use, first extract the relevant BepInEx archive to the game folder (e.g. where the game's .app or .exe is located)
if you don't know where to get BepInEx from then just do a Google search for "[game name] BepInEx" to see if there is a popular BepInEx 5 pack for the game available, if not then just get the latest BepInEx 5 from their GitHub
then, open a terminal in the game folder and run the appropriate command for your operating system below (right-click to paste in terminal)
to test that it's working after the patch has completed you can simply run the game as normal, and then
check in the BepInEx folder for a file named LogOutput.log - if it exists, BepInEx is
running!
macOS/Linux
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS --no-path > /dev/null && curl -sSL https://tobey.me/mods/bepinex/hardpatcher/patch.fsx --output .tobey.patch.fsx && ~/.dotnet/dotnet fsi .tobey.patch.fsx --quiet; rm .tobey.patch.fsx
Windows
Command Prompt
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel LTS -NoPath" > nul && curl -sSL https://tobey.me/mods/bepinex/hardpatcher/patch.fsx --output .tobey.patch.fsx && %LocalAppData%\Microsoft\dotnet\dotnet fsi .tobey.patch.fsx --quiet & del /q .tobey.patch.fsx
PowerShell 5
&powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel LTS -NoPath" | Out-Null; if ($?) { Invoke-WebRequest -UseBasicParsing https://tobey.me/mods/bepinex/hardpatcher/patch.fsx -OutFile .tobey.patch.fsx; if ($?) { &$env:LocalAppData\Microsoft\dotnet\dotnet fsi .tobey.patch.fsx --quiet; Remove-Item .tobey.patch.fsx } }
PowerShell 7+
&powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel LTS -NoPath" | Out-Null && curl -sSL https://tobey.me/mods/bepinex/hardpatcher/patch.fsx --output .tobey.patch.fsx && &$env:LocalAppData\Microsoft\dotnet\dotnet fsi .tobey.patch.fsx --quiet; Remove-Item .tobey.patch.fsx
notes and caveats
trustworthiness
if you take a good look at the commands, you'll note that the first thing they do is install dotnet, which is made by Microsoft - you can verify this by visiting https://dot.net/, the root URL of the dotnet-install script it downloads and executes
dotnet is necessary for me to execute the F# script, which is the only other thing the command does
you can inspect the source code of the F# script it downloads in a nicely formatted fashion here
troubleshooting
if you run into issues using the hardpatcher, feel free to send a discord dm to toebean
explaining the issue (preferably with screenshots of the terminal output and your game folder), and i'll
reply as soon as i remember to check my message requests 😅
uninstallation
to remove the patch it is recommend to simply run a "verify game files" operation with your launcher
the file(s) the hardpatcher modify are small and redownloading them should be fast
if preferred, you can instead search for the file pattern UnityEngine*.bak from the game
folder, delete the files which have been modified by this hardpatcher (they will have the same filename
as the results of the search, but the extension .dll), and then rename the files with the
extension .bak to have the extension .dll
you can also delete the file Tobey.BepInEx.Bootstrap.dll (just search for it from the game
folder) which is downloaded and used exclusively by the hardpatcher to load BepInEx when the game starts
patch command needs to be re-run after updates or verifying game files
we advise bookmarking this page since you will need to run the patch command again any time the game is updated, or if you run a "verify game files" operation
only BepInEx plugins are supported - BepInEx patchers will not be run
packages which require BepInEx patchers to function (e.g. Subnautica and Below Zero's QModManager) are not currently supported and as a result, will not function correctly
it may be possible with additional research and experimentation to allow patchers to run before plugins are loaded, however it is unlikely that patchers which modify the game's core managed assemblies will ever be supported due to the nature of how hardpatching operates; some of these core managed assemblies will have already loaded into memory by the time we are able to execute any code meaning they cannot be altered by BepInEx patchers
patchers which change the BepInEx entry point also cannot be supported via hardpatching due to the fact that the entry point is permanently set by the hardpatcher
i make no promises as to whether BepInEx patchers will ever be supported by this hardpatcher as it will require a significant amount of work just to find out
so, if you want to use a mod package which requires BepInEx patchers to function, such as QModManager, then you will need to get the game on Steam and install BepInEx the normal way, i.e. not with this hardpatcher
license
Copyright 2023 Tobey Blaber
Permission to use, copy, modify and/or distribute this software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.