Skip to content

Commit 185b93f

Browse files
committed
Update for ER 1.10.1, remove logging because fuck that
1 parent 1a6ecea commit 185b93f

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

Cargo.toml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "eldenring-alt-saves"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
edition = "2021"
55

66
[lib]
@@ -17,4 +17,10 @@ detour = { git = "https://github.com/veeenu/detour-rs.git", branch = "master" }
1717
version = "0.48.0"
1818
features = [
1919
"Win32_Foundation",
20-
]
20+
]
21+
22+
[profile.release]
23+
strip = true
24+
lto = true
25+
codegen-units = 1
26+
opt-level = "z"

src/lib.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const SC_SAVEGAME_EXTENSION: &str = ".co2";
1919
const SC_SAVEGAME_BACKUP_EXTENSION: &str = ".co2.bak";
2020

2121
const REGBIN_CHECK_FLAG_IBO: usize = 0x3acea92;
22-
const REGULATIONMANAGER_CONSTRUCTOR_IBO: usize = 0xdc95e0;
22+
const REGULATIONMANAGER_CONSTRUCTOR_IBO: usize = 0xdc96c0;
2323

2424
static_detour! {
2525
static CREATE_FILE_W_HOOK: unsafe extern "system" fn(PCWSTR, u32, u32, u64, u32, u32, HANDLE) -> u64;
@@ -28,16 +28,13 @@ static_detour! {
2828

2929
#[dll::entrypoint]
3030
pub fn entry(_: usize) -> bool {
31-
// Set this up anyways as it'll log panics too
32-
broadsword::logging::init("log/alt-saves.log");
3331
apply_file_hook();
3432
apply_regulation_hook();
35-
return true;
33+
true
3634
}
3735

3836
fn apply_regulation_hook() {
39-
let regulationmanager_constructor = get_module_handle("eldenring.exe".to_string())
40-
.expect("Could not locate eldenring.exe") + REGULATIONMANAGER_CONSTRUCTOR_IBO;
37+
let regulationmanager_constructor = get_main_module() + REGULATIONMANAGER_CONSTRUCTOR_IBO;
4138

4239
unsafe {
4340
REGULATIONMANAGER_CONSTRUCTOR
@@ -59,9 +56,7 @@ fn apply_regulation_hook() {
5956
// a particular hash. This check causes new save files to throw errors when the regbin has been
6057
// changed.
6158
fn patch_regbin_check() {
62-
let ptr = get_module_handle("eldenring.exe".to_string())
63-
.expect("Could not find ER base") + REGBIN_CHECK_FLAG_IBO;
64-
59+
let ptr = get_main_module() + REGBIN_CHECK_FLAG_IBO;
6560
unsafe { *(ptr as *mut u8) = 0x0 };
6661
}
6762

@@ -84,7 +79,7 @@ fn apply_file_hook() {
8479
// Doing this here to ensure the string isn't dropped until after the fn call
8580
// otherwise the string's source is dropped before the pointer is consumed.
8681
let patched_path = transform_path(path)
87-
.map(|s| HSTRING::from(s));
82+
.map(HSTRING::from);
8883

8984
let effective_path = match patched_path {
9085
None => path,
@@ -129,4 +124,11 @@ unsafe fn transform_path(path: PCWSTR) -> Option<String> {
129124
} else {
130125
None
131126
}
132-
}
127+
}
128+
129+
/// Attempts to retrieve the main module of the game
130+
pub fn get_main_module() -> usize {
131+
get_module_handle("eldenring.exe")
132+
.or_else(|_| get_module_handle("start_protected_game.exe"))
133+
.expect("Could not locate main module")
134+
}

0 commit comments

Comments
 (0)