@@ -19,7 +19,7 @@ const SC_SAVEGAME_EXTENSION: &str = ".co2";
19
19
const SC_SAVEGAME_BACKUP_EXTENSION : & str = ".co2.bak" ;
20
20
21
21
const REGBIN_CHECK_FLAG_IBO : usize = 0x3acea92 ;
22
- const REGULATIONMANAGER_CONSTRUCTOR_IBO : usize = 0xdc95e0 ;
22
+ const REGULATIONMANAGER_CONSTRUCTOR_IBO : usize = 0xdc96c0 ;
23
23
24
24
static_detour ! {
25
25
static CREATE_FILE_W_HOOK : unsafe extern "system" fn ( PCWSTR , u32 , u32 , u64 , u32 , u32 , HANDLE ) -> u64 ;
@@ -28,16 +28,13 @@ static_detour! {
28
28
29
29
#[ dll:: entrypoint]
30
30
pub fn entry ( _: usize ) -> bool {
31
- // Set this up anyways as it'll log panics too
32
- broadsword:: logging:: init ( "log/alt-saves.log" ) ;
33
31
apply_file_hook ( ) ;
34
32
apply_regulation_hook ( ) ;
35
- return true ;
33
+ true
36
34
}
37
35
38
36
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 ;
41
38
42
39
unsafe {
43
40
REGULATIONMANAGER_CONSTRUCTOR
@@ -59,9 +56,7 @@ fn apply_regulation_hook() {
59
56
// a particular hash. This check causes new save files to throw errors when the regbin has been
60
57
// changed.
61
58
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 ;
65
60
unsafe { * ( ptr as * mut u8 ) = 0x0 } ;
66
61
}
67
62
@@ -84,7 +79,7 @@ fn apply_file_hook() {
84
79
// Doing this here to ensure the string isn't dropped until after the fn call
85
80
// otherwise the string's source is dropped before the pointer is consumed.
86
81
let patched_path = transform_path ( path)
87
- . map ( |s| HSTRING :: from ( s ) ) ;
82
+ . map ( HSTRING :: from) ;
88
83
89
84
let effective_path = match patched_path {
90
85
None => path,
@@ -129,4 +124,11 @@ unsafe fn transform_path(path: PCWSTR) -> Option<String> {
129
124
} else {
130
125
None
131
126
}
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