MFG Unlocker as an F1 option: downloaded and loaded at start when on

F1, MFG UNLOCKER (MOD, RTX 20/30), off by default. When it is on, the
launcher fetches MFG Unlocker v1.7.2 from its author's GitHub release
into %LOCALAPPDATA%\victory\mfg-unlocker. The zip and MFGUnlocker.dll
are both checked against the SHA-256 the author published
(scripts\get-mfg-unlocker.ps1). victory.exe then loads the DLL under
its own name before the device is made or Streamline is loaded, so
nothing is renamed or put beside the game.

- RTX 20 and 30 cards with DLSS on are asked once at the first start
  (default No), unless the choice was made or a mod DLL is already
  beside victory.exe.
- `victory get-mfg` fetches it by hand.
- The menu explains the item while it is picked.
- The log records the load.
- README updated.

The download and the mod itself are not tested here (RTX 50 only). The
load path was tested with a Windows DLL in its place: loaded before
Streamline, game ran normally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
trustno1-coderandClaude Opus 5.5 committed 2026-11-27 10:59:16 -08:00
1 parent 10862a6d87
commit 0cef07e9d7
6 files changed
+268 -9

No files matched your search

+13 -6
View File
@@ -72,12 +72,19 @@
(a mark is kept in `%LOCALAPPDATA%\victory\warmed`). (a mark is kept in `%LOCALAPPDATA%\victory\warmed`).
- RTX 20 and 30 cards can try DLSS frame generation with the - RTX 20 and 30 cards can try DLSS frame generation with the
[MFG Unlocker](https://github.com/dashdogy/MFG-Unlocker) mod (not ours, and [MFG Unlocker](https://github.com/dashdogy/MFG-Unlocker) mod (not ours, and
not tested with this fork, which was only run on an RTX 50). Download it from not tested with this fork, which was only run on an RTX 50). It is an option,
its own releases, rename `MFGUnlocker.dll` to `winmm.dll` and put it beside off by default: **F1, MFG UNLOCKER, ON**, then restart. On, the next start
`victory.exe`. victory.exe loads `winmm.dll`, so Windows starts the mod with it. downloads it by itself from the mod's own GitHub release (v1.7.2, about 5 MB,
The start's notice then says "UNLOCKED BY A MOD" and the log names the DLL. If checked against the SHA-256 its author published) into
the game crashes or frame generation fails, delete that `winmm.dll`. FSR 3 `%LOCALAPPDATA%\victory\mfg-unlocker`, and every start loads it. Nothing is
frame generation (2x) is the supported way on those cards. renamed or copied. On an RTX 20 or 30 the first start also asks once (No unless
you type y). `victory.exe get-mfg` downloads it by hand. The mod writes its own
`RTXMFG-...` logs and settings beside `victory.exe`, and Backspace opens its
menu. The start's notice says "UNLOCKED BY A MOD" and the log says it was
loaded. If the game crashes or frame generation fails, turn it off in F1 (or
add `VICTORY_MFG_UNLOCKER=` to `%LOCALAPPDATA%\victory\victory-settings.txt`).
FSR 3 frame generation (2x) is the supported way on those cards. A
`winmm.dll` copy of the mod beside `victory.exe` still works too.
**In the game** **In the game**
+10
View File
@@ -188,6 +188,12 @@ enum Command {
/// does it by itself where it is needed. /// does it by itself where it is needed.
#[cfg(windows)] #[cfg(windows)]
GetD3d12, GetD3d12,
/// Fetch MFG Unlocker (someone else's mod, github.com/dashdogy/MFG-Unlocker,
/// about 5 MB): DLSS frame generation on RTX 20 and 30 cards, which NVIDIA
/// does not support. `play` loads it with F1's MFG UNLOCKER on, and fetches
/// it by itself then.
#[cfg(windows)]
GetMfg,
/// Print the highest shader model the default GPU runs here (`play` /// Print the highest shader model the default GPU runs here (`play`
/// asks it in a process of its own). /// asks it in a process of its own).
#[cfg(windows)] #[cfg(windows)]
@@ -274,6 +280,8 @@ fn main() -> Result<()> {
play::preload(&ready.exe); play::preload(&ready.exe);
} }
victory_core::logging::init("info"); victory_core::logging::init("info");
// F1's MFG UNLOCKER: the mod, before the layer makes its device or loads Streamline.
play::load_mfg();
let console = if ready.series_s { Console::SeriesS } else { Console::SeriesX }; let console = if ready.series_s { Console::SeriesS } else { Console::SeriesX };
run::run(&ready.exe, Unimplemented::Trap, false, true, console) run::run(&ready.exe, Unimplemented::Trap, false, true, console)
}); });
@@ -343,6 +351,8 @@ fn main() -> Result<()> {
#[cfg(windows)] #[cfg(windows)]
Command::GetD3d12 => play::get_d3d12(), Command::GetD3d12 => play::get_d3d12(),
#[cfg(windows)] #[cfg(windows)]
Command::GetMfg => play::get_mfg(),
#[cfg(windows)]
Command::ShaderModel => { Command::ShaderModel => {
let model = victory_hle::streamline::highest_shader_model(); let model = victory_hle::streamline::highest_shader_model();
if let Some(core) = victory_hle::streamline::d3d12_core_path() { if let Some(core) = victory_hle::streamline::d3d12_core_path() {
+146 -1
View File
@@ -21,6 +21,13 @@
//! no shader model 6.6 (Windows 10's own stops at 6.5), Microsoft's newer //! no shader model 6.6 (Windows 10's own stops at 6.5), Microsoft's newer
//! runtime, `D3D12\D3D12Core.dll` from Microsoft's NuGet package, after asking //! runtime, `D3D12\D3D12Core.dll` from Microsoft's NuGet package, after asking
//! (`victory get-d3d12`). Windows loads it only from there (main.rs). //! (`victory get-d3d12`). Windows loads it only from there (main.rs).
//!
//! MFG Unlocker, someone else's mod that unlocks DLSS Frame Generation on RTX
//! 20 and 30 cards, is an option (F1, MFG UNLOCKER; off by default, asked once
//! on such a card): on, it is fetched from its author's GitHub release into
//! `%LOCALAPPDATA%\victory\mfg-unlocker` and loaded by this program at the
//! start (`victory get-mfg` fetches it by hand). It writes its own logs and
//! settings beside the program.
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::{IsTerminal, Write}; use std::io::{IsTerminal, Write};
@@ -482,6 +489,120 @@ fn offer_fsr(card: &str) {
} }
} }
/// `scripts\get-mfg-unlocker.ps1`, run by Windows PowerShell.
const FETCH_MFG: &str = include_str!("../../../scripts/get-mfg-unlocker.ps1");
/// The mod's DLL, under its own name: loaded by this program (main.rs, [`load_mfg`]), not by
/// Windows in place of one of its own, so nothing is renamed or put beside the game.
const MFG_DLL: &str = "MFGUnlocker.dll";
/// Where `victory get-mfg` puts MFG Unlocker.
fn mfg_home() -> Result<PathBuf> {
Ok(home()?.join("mfg-unlocker"))
}
/// A GeForce RTX of the 20 or 30 series ("NVIDIA GeForce RTX 3080", "... RTX 2060 SUPER"): DLSS
/// runs, DLSS Frame Generation only with MFG Unlocker.
fn older_rtx(name: &str) -> bool {
let name = name.to_ascii_uppercase();
let Some(at) = name.find("RTX") else { return false };
let model: String = name[at + 3..].trim_start().chars().take_while(char::is_ascii_digit).collect();
model.len() == 4 && (model.starts_with("20") || model.starts_with("30"))
}
/// Runs the fetcher: MFG Unlocker from its author's GitHub release into `to`.
fn fetch_mfg(to: &Path) -> Result<()> {
std::fs::create_dir_all(to).with_context(|| format!("creating {}", to.display()))?;
let script = to.join("get-mfg-unlocker.ps1");
std::fs::write(&script, FETCH_MFG).with_context(|| format!("writing {}", script.display()))?;
let status = std::process::Command::new("powershell.exe")
.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-File"])
.arg(&script)
.arg("-To")
.arg(to)
.status()
.context("starting Windows PowerShell")?;
let _ = std::fs::remove_file(&script);
anyhow::ensure!(
status.success() && to.join(MFG_DLL).is_file(),
"MFG Unlocker did not arrive (see above); the game runs without it"
);
Ok(())
}
/// `victory get-mfg`: fetches it (F1's MFG UNLOCKER turns it on).
pub(crate) fn get_mfg() -> Result<()> {
let to = mfg_home()?;
let _ = std::fs::remove_file(to.join("declined"));
fetch_mfg(&to)?;
println!("Turn it on in the game: F1, MFG UNLOCKER, ON (or `victory play --set VICTORY_MFG_UNLOCKER=1`).");
Ok(())
}
/// Asks once, on an RTX 20 or 30 card, whether to turn MFG Unlocker on. No is the default: it is
/// someone else's mod, NVIDIA does not support what it does, and it was not tested here.
/// `true`: turned on (saved in `menu_file`, as the F1 menu would).
fn offer_mfg(card: &str, menu_file: &Path) -> bool {
let Ok(to) = mfg_home() else { return false };
let declined = to.join("declined");
if declined.exists() || !std::io::stdin().is_terminal() {
return false;
}
println!("This card ({card}) runs DLSS, but NVIDIA's DLSS frame generation only on RTX 40 and later.");
println!("MFG Unlocker, someone else's mod (github.com/dashdogy/MFG-Unlocker, MIT licence, about 5 MB),");
println!("unlocks it on RTX 20 and 30 cards. NVIDIA does not support that, and it was not tested with");
println!("this game. On, it is downloaded now and at every start loaded by victory.exe; F1, MFG UNLOCKER");
println!("turns it off again. Off, the game uses AMD's FSR 3 frame generation (2x) on this card.");
print!("Turn MFG Unlocker on? [y/N] ");
let _ = std::io::stdout().flush();
let mut answer = String::new();
let _ = std::io::stdin().read_line(&mut answer);
let _ = std::fs::create_dir_all(&to);
if !answer.trim().to_ascii_lowercase().starts_with('y') {
let _ = std::fs::write(&declined, "asked once; F1, MFG UNLOCKER turns it on\r\n");
println!("Left off. F1, MFG UNLOCKER turns it on later.");
return false;
}
let mut text = std::fs::read_to_string(menu_file).unwrap_or_default();
if !text.is_empty() && !text.ends_with('\n') {
text.push_str("\r\n");
}
text.push_str("VICTORY_MFG_UNLOCKER=1\r\n");
if let Err(e) = std::fs::write(menu_file, text) {
println!("Could not save the choice ({e}); on for this start only.");
}
true
}
/// With MFG Unlocker on: the DLL, fetched first where it is missing (no question: turning it on
/// was the choice). `None`: not there (the reason said).
fn mfg_dll() -> Option<PathBuf> {
let to = mfg_home().ok()?;
let dll = to.join(MFG_DLL);
if !dll.is_file() {
println!("MFG UNLOCKER is on and not on this PC yet: downloading it.");
if let Err(e) = fetch_mfg(&to) {
println!("{e:#}");
return None;
}
}
Some(dll)
}
/// Loads MFG Unlocker (`VICTORY_MFG_UNLOCKER_DLL`, set by [`prepare`] with the option on) into
/// this process, before the layer makes its device or loads Streamline: it wraps NVIDIA's frame
/// generation from there, as it would loaded by Windows in place of `winmm.dll`. It writes its
/// own logs and settings (`RTXMFG-...`) beside the program; Backspace opens its menu.
pub(crate) fn load_mfg() {
let Some(dll) = std::env::var_os("VICTORY_MFG_UNLOCKER_DLL").filter(|v| !v.is_empty()).map(PathBuf::from) else {
return;
};
match victory_hle::streamline::load_mod("MFG Unlocker (F1, MFG UNLOCKER)", &dll) {
Ok(()) => println!("MFG Unlocker loaded ({}). Backspace opens its menu.", dll.display()),
Err(code) => println!("MFG Unlocker did not load (Windows error {code}): running without it."),
}
}
/// `D3D12` beside this program: where Windows looks for Microsoft's newer /// `D3D12` beside this program: where Windows looks for Microsoft's newer
/// Direct3D 12 runtime (main.rs's `D3D12SDKPath`). /// Direct3D 12 runtime (main.rs's `D3D12SDKPath`).
fn d3d12_dir() -> Result<PathBuf> { fn d3d12_dir() -> Result<PathBuf> {
@@ -667,6 +788,23 @@ pub(crate) fn prepare(o: &Play) -> Result<Ready> {
s.insert("VICTORY_FIDELITYFX_DIR".to_owned(), dir.to_string_lossy().into_owned()); s.insert("VICTORY_FIDELITYFX_DIR".to_owned(), dir.to_string_lossy().into_owned());
} }
} }
// MFG Unlocker (F1, MFG UNLOCKER): DLSS frame generation on RTX 20 and 30 cards. Asked once
// on such a card with DLSS on, where the choice was never made and no mod DLL is beside us.
let mods = mod_dlls(&here);
if s.contains_key("VICTORY_DLSS")
&& !menu.iter().any(|(k, _)| k == "VICTORY_MFG_UNLOCKER")
&& !s.contains_key("VICTORY_MFG_UNLOCKER")
&& mods.is_empty()
&& let Some(card) = victory_hle::streamline::adapter_name().filter(|c| older_rtx(c))
&& offer_mfg(&card, &menu_file)
{
s.insert("VICTORY_MFG_UNLOCKER".to_owned(), "1".to_owned());
}
if s.get("VICTORY_MFG_UNLOCKER").is_some_and(|v| v == "1")
&& let Some(dll) = mfg_dll()
{
s.insert("VICTORY_MFG_UNLOCKER_DLL".to_owned(), dll.to_string_lossy().into_owned());
}
// The first start of this victory.exe (no mark for its bytes yet): the game plays a little // The first start of this victory.exe (no mark for its bytes yet): the game plays a little
// and starts again by itself (crates\victory-gpu\src\host\menu.rs, `warmup`), since a new // and starts again by itself (crates\victory-gpu\src\host\menu.rs, `warmup`), since a new
// exe's first run stays at about 14 fps. `--set VICTORY_WARMUP_RESTART=0`: not done. // exe's first run stays at about 14 fps. `--set VICTORY_WARMUP_RESTART=0`: not done.
@@ -690,7 +828,6 @@ pub(crate) fn prepare(o: &Play) -> Result<Ready> {
let log = log_file(&home.join("logs"))?; let log = log_file(&home.join("logs"))?;
let console = if series_s { "series-s" } else { "series-x" }; let console = if series_s { "series-s" } else { "series-x" };
let line: Vec<String> = s.iter().map(|(k, v)| format!("{k}={v}")).collect(); let line: Vec<String> = s.iter().map(|(k, v)| format!("{k}={v}")).collect();
let mods = mod_dlls(&here);
let mods_line = if mods.is_empty() { let mods_line = if mods.is_empty() {
String::new() String::new()
} else { } else {
@@ -839,6 +976,14 @@ mod tests {
assert!(!fg("AMD Radeon RX 7900 XTX") && !fg("Intel(R) Arc(TM) A770 Graphics") && !fg("")); assert!(!fg("AMD Radeon RX 7900 XTX") && !fg("Intel(R) Arc(TM) A770 Graphics") && !fg(""));
} }
/// MFG Unlocker is offered only to RTX 20 and 30 cards.
#[test]
fn cards_offered_mfg_unlocker() {
assert!(older_rtx("NVIDIA GeForce RTX 3080 Ti") && older_rtx("NVIDIA GeForce RTX 2060 SUPER") && older_rtx("NVIDIA GeForce RTX 3050 Laptop GPU"));
assert!(!older_rtx("NVIDIA GeForce RTX 5070") && !older_rtx("NVIDIA GeForce RTX 4090") && !older_rtx("NVIDIA GeForce GTX 1080"));
assert!(!older_rtx("NVIDIA RTX A2000") && !older_rtx("AMD Radeon RX 7900 XTX") && !older_rtx(""));
}
#[test] #[test]
fn stamps_are_dates() { fn stamps_are_dates() {
assert_eq!(stamp(0), "19700101-000000"); assert_eq!(stamp(0), "19700101-000000");
+21 -2
View File
@@ -49,6 +49,13 @@ const ABOUT_PRELOAD: [&str; 3] = [
"TAKES A WHILE: MAYBE A LONG TIME, DEPENDING ON HARDWARE.", "TAKES A WHILE: MAYBE A LONG TIME, DEPENDING ON HARDWARE.",
"A LATER UPDATE OF THIS BUILD MAY NEED A NEW PRELOAD.", "A LATER UPDATE OF THIS BUILD MAY NEED A NEW PRELOAD.",
]; ];
/// The setting that turns MFG Unlocker on, and what is said of it while it is picked.
const MFG: &str = "VICTORY_MFG_UNLOCKER";
const ABOUT_MFG: [&str; 3] = [
"A MOD, NOT OURS: DLSS FRAME GEN ON RTX 20 AND 30 CARDS.",
"ON: DOWNLOADED FROM ITS GITHUB AT THE NEXT START, THEN RUN.",
"NVIDIA DOES NOT SUPPORT IT. IF THE GAME FAILS, TURN IT OFF.",
];
/// The note after the first Enter on it: the second one does it. /// The note after the first Enter on it: the second one does it.
const CONFIRM_PRELOAD: &str = "ENTER AGAIN: SAVE, CLOSE THE GAME AND PRELOAD"; const CONFIRM_PRELOAD: &str = "ENTER AGAIN: SAVE, CLOSE THE GAME AND PRELOAD";
/// The last line of the box: where this build comes from. /// The last line of the box: where this build comes from.
@@ -77,6 +84,8 @@ const ITEMS: &[Item] = &[
Item { var: "VICTORY_MENU_FRAMEGEN", label: "FRAME GENERATION", values: &[("0", "OFF"), ("2", "2X"), ("3", "3X"), ("4", "4X"), ("5", "5X"), ("6", "6X (MOST)")], live: false }, Item { var: "VICTORY_MENU_FRAMEGEN", label: "FRAME GENERATION", values: &[("0", "OFF"), ("2", "2X"), ("3", "3X"), ("4", "4X"), ("5", "5X"), ("6", "6X (MOST)")], live: false },
// DLSS Frame Generation where it runs (RTX 40 and later), else AMD's FSR 3 (2X only). // DLSS Frame Generation where it runs (RTX 40 and later), else AMD's FSR 3 (2X only).
Item { var: "VICTORY_MENU_FG_TYPE", label: "FRAME GEN TYPE", values: &[("auto", "AUTO"), ("dlss", "DLSS"), ("fsr", "FSR 3 (OLDER CARDS)")], live: false }, Item { var: "VICTORY_MENU_FG_TYPE", label: "FRAME GEN TYPE", values: &[("auto", "AUTO"), ("dlss", "DLSS"), ("fsr", "FSR 3 (OLDER CARDS)")], live: false },
// Someone else's mod (apps\victory\src\play.rs): downloaded at the next start, then loaded.
Item { var: MFG, label: "MFG UNLOCKER (MOD, RTX 20/30)", values: UNSET_ON, live: false },
Item { var: "VICTORY_MENU_FPS", label: "FRAME RATE CAP", values: &[("1000", "NONE"), ("120", "120"), ("60", "60"), ("30", "30 (THE GAME)")], live: false }, Item { var: "VICTORY_MENU_FPS", label: "FRAME RATE CAP", values: &[("1000", "NONE"), ("120", "120"), ("60", "60"), ("30", "30 (THE GAME)")], live: false },
Item { var: "VICTORY_FPS_LINE", label: "FPS AT THE TOP", values: &[("1", "ON"), ("0", "OFF")], live: true }, Item { var: "VICTORY_FPS_LINE", label: "FPS AT THE TOP", values: &[("1", "ON"), ("0", "OFF")], live: true },
Item { var: "VICTORY_PANEL", label: "STATS PANEL (F3)", values: &[("0", "OFF"), ("1", "ON")], live: true }, Item { var: "VICTORY_PANEL", label: "STATS PANEL (F3)", values: &[("0", "OFF"), ("1", "ON")], live: true },
@@ -396,7 +405,13 @@ impl Menu {
out.push(String::new()); out.push(String::new());
} }
out.push(String::new()); out.push(String::new());
let about = if self.at == ITEMS.len() + PRELOAD { ABOUT_PRELOAD } else { [""; 3] }; let about = if self.at == ITEMS.len() + PRELOAD {
ABOUT_PRELOAD
} else if ITEMS.get(self.at).is_some_and(|i| i.var == MFG) {
ABOUT_MFG
} else {
[""; 3]
};
out.extend(about.iter().map(|l| (*l).to_owned())); out.extend(about.iter().map(|l| (*l).to_owned()));
out.push(if self.note.is_empty() { "* = CHANGED: APPLIES AT THE NEXT START UNLESS LIVE".to_owned() } else { self.note.clone() }); out.push(if self.note.is_empty() { "* = CHANGED: APPLIES AT THE NEXT START UNLESS LIVE".to_owned() } else { self.note.clone() });
out.push(REPO.to_owned()); out.push(REPO.to_owned());
@@ -699,10 +714,12 @@ mod tests {
let n = lines.len(); let n = lines.len();
assert!(lines[n - 2].starts_with("* = CHANGED") || lines[n - 2] == note, "{}", lines[n - 2]); assert!(lines[n - 2].starts_with("* = CHANGED") || lines[n - 2] == note, "{}", lines[n - 2]);
assert_eq!(lines[n - 1], REPO); assert_eq!(lines[n - 1], REPO);
// What a preload costs is said while it is picked, and only then. // What a preload costs, and what MFG Unlocker is, is said while it is picked, and only then.
let about = &lines[n - 5..n - 2]; let about = &lines[n - 5..n - 2];
if at == ITEMS.len() + PRELOAD { if at == ITEMS.len() + PRELOAD {
assert_eq!(about, ABOUT_PRELOAD); assert_eq!(about, ABOUT_PRELOAD);
} else if at < ITEMS.len() && ITEMS[at].var == MFG {
assert_eq!(about, ABOUT_MFG);
} else { } else {
assert!(about.iter().all(String::is_empty), "{about:?}"); assert!(about.iter().all(String::is_empty), "{about:?}");
} }
@@ -710,6 +727,8 @@ mod tests {
} }
assert_eq!(ACTIONS[PRELOAD], "PRELOAD SHADERS (RESTARTS THE GAME)"); assert_eq!(ACTIONS[PRELOAD], "PRELOAD SHADERS (RESTARTS THE GAME)");
assert!(CONFIRM_PRELOAD.len() <= COLUMNS as usize); assert!(CONFIRM_PRELOAD.len() <= COLUMNS as usize);
assert!(ABOUT_MFG.iter().all(|l| l.len() <= COLUMNS as usize));
assert_eq!(ITEMS.iter().filter(|i| i.var == MFG).count(), 1);
} }
#[test] #[test]
+21
View File
@@ -711,6 +711,27 @@ pub fn d3d12_core_path() -> Option<PathBuf> {
} }
} }
/// Loads a mod's DLL into this process for good, logged as `what` (MFG Unlocker: it wraps
/// NVIDIA's frame generation, so it is loaded before a device is made or Streamline loaded).
/// `Err`: Windows' error code.
pub fn load_mod(what: &str, path: &Path) -> Result<(), u32> {
use windows_sys::Win32::Foundation::GetLastError;
use windows_sys::Win32::System::LibraryLoader::LoadLibraryW;
let name = wide(path);
// SAFETY: a NUL-terminated path; the module stays loaded for the life of the process.
let (module, code) = unsafe {
let module = LoadLibraryW(name.as_ptr());
(module, if module.is_null() { GetLastError() } else { 0 })
};
if module.is_null() {
tracing::warn!(dll = %path.display(), code, "{what}: did not load");
Err(code)
} else {
tracing::info!(dll = %path.display(), "{what}: loaded");
Ok(())
}
}
/// The Authenticode signature of `path` (NVIDIA signs its DLLs), checked /// The Authenticode signature of `path` (NVIDIA signs its DLLs), checked
/// without going online. /// without going online.
fn verify_signature(path: &Path) -> Result<(), String> { fn verify_signature(path: &Path) -> Result<(), String> {
+57
View File
@@ -0,0 +1,57 @@
# Fetches MFG Unlocker (github.com/dashdogy/MFG-Unlocker, someone else's MIT-licensed mod, about 5 MB) into
# %LOCALAPPDATA%\victory\mfg-unlocker, or the folder -To names. It lets DLSS Frame Generation run on GeForce
# RTX 20 and 30 cards, which NVIDIA does not support. victory.exe loads it only with the F1 menu's MFG UNLOCKER
# on (VICTORY_MFG_UNLOCKER=1); nothing is renamed or put beside the game. It is not part of this repository and
# was not tested by this fork. Its release v1.7.2 is pinned: the zip and the DLL in it are checked against the
# SHA-256 the mod's author published with that release (SHA256SUMS.txt), and nothing else is kept.
param(
[string]$To = ''
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$dir = if ($To) { $To } else { Join-Path $env:LOCALAPPDATA 'victory\mfg-unlocker' }
$version = '1.7.2'
# From the release's SHA256SUMS.txt (also GitHub's own digest of the zip).
$package = 'E002D624E3E7BA5CEDAB7211043C096FE8F555C30FF43500235A0686C7893F22'
$module = 'A9B1C01727FA72763BEF8F604E44EC165CE1C98272DE00719572B766A11CF28F'
$url = "https://github.com/dashdogy/MFG-Unlocker/releases/download/v$version/MFGUnlocker-v$version.zip"
$target = Join-Path $dir 'MFGUnlocker.dll'
if ((Test-Path $target) -and (Get-FileHash $target -Algorithm SHA256).Hash -eq $module) {
Write-Host "MFG Unlocker $version is already in $dir"
exit 0
}
Write-Host "MFG Unlocker $version (someone else's mod), from github.com/dashdogy/MFG-Unlocker (about 5 MB):"
New-Item -ItemType Directory -Force $dir | Out-Null
$part = Join-Path $dir "MFGUnlocker-v$version.zip.part"
try {
if (Get-Command curl.exe -ErrorAction SilentlyContinue) {
& curl.exe --location --fail --silent --show-error --progress-bar --output $part $url
if ($LASTEXITCODE -ne 0) { throw "could not get $url" }
} else {
Invoke-WebRequest -Uri $url -OutFile $part -UseBasicParsing
}
$hash = (Get-FileHash $part -Algorithm SHA256).Hash
if ($hash -ne $package) { throw "the zip is not the v$version release (SHA-256 $hash); not kept" }
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [IO.Compression.ZipFile]::OpenRead($part)
try {
$entry = $zip.Entries | Where-Object Name -eq 'MFGUnlocker.dll' | Select-Object -First 1
if (-not $entry) { throw 'the zip has no MFGUnlocker.dll' }
$dll = "$target.part"
[IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $dll, $true)
# Its licence and notices (Intel's XeSS data in it is under Intel's licence), kept beside it.
foreach ($name in 'LICENSE', 'LICENSE.txt', 'NOTICE.md', 'NOTICE.txt', 'README.md', 'README.txt') {
$doc = $zip.Entries | Where-Object Name -eq $name | Select-Object -First 1
if ($doc) { [IO.Compression.ZipFileExtensions]::ExtractToFile($doc, (Join-Path $dir $name), $true) }
}
} finally { $zip.Dispose() }
$hash = (Get-FileHash $dll -Algorithm SHA256).Hash
if ($hash -ne $module) { Remove-Item $dll -Force; throw "MFGUnlocker.dll is not the v$version file (SHA-256 $hash); not kept" }
Move-Item $dll $target -Force
} finally {
Remove-Item $part -Force -ErrorAction SilentlyContinue
}
Write-Host (' MFGUnlocker.dll {0:N1} MB, v{1}, checked against the published SHA-256' -f ((Get-Item $target).Length / 1MB), $version)
Write-Host " in $dir (its licence and notices beside it)"