diff --git a/openfut-hook/src/connect_hook.rs b/openfut-hook/src/connect_hook.rs index 34639b7..aeff08b 100644 --- a/openfut-hook/src/connect_hook.rs +++ b/openfut-hook/src/connect_hook.rs @@ -191,7 +191,7 @@ pub unsafe extern "system" fn hooked_connect(s: usize, name: *const u8, namelen: let mut len: i32 = 4; getsockopt( s, - SOL_SOCKET as i32, + SOL_SOCKET, SO_TYPE, &mut ty as *mut i32 as *mut u8, &mut len, @@ -265,11 +265,11 @@ pub unsafe extern "system" fn hooked_wsa_connect( pub unsafe fn install_inline_connect_hook() -> bool { use windows_sys::Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress}; - let ws2 = GetModuleHandleA(b"ws2_32.dll\0".as_ptr()); + let ws2 = GetModuleHandleA(c"ws2_32.dll".as_ptr().cast()); if ws2.is_null() { return false; } - let connect_fn = match GetProcAddress(ws2, b"connect\0".as_ptr()) { + let connect_fn = match GetProcAddress(ws2, c"connect".as_ptr().cast()) { Some(f) => f as *mut u8, None => return false, }; diff --git a/openfut-hook/src/connectex_hook.rs b/openfut-hook/src/connectex_hook.rs index fa3d20f..513eaf1 100644 --- a/openfut-hook/src/connectex_hook.rs +++ b/openfut-hook/src/connectex_hook.rs @@ -152,11 +152,11 @@ pub unsafe extern "system" fn hooked_wsaioctl( pub unsafe fn install_wsaioctl_hook() -> bool { use windows_sys::Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress}; - let ws2 = GetModuleHandleA(b"ws2_32.dll\0".as_ptr()); + let ws2 = GetModuleHandleA(c"ws2_32.dll".as_ptr().cast()); if ws2.is_null() { return false; } - let fn_ptr = match GetProcAddress(ws2, b"WSAIoctl\0".as_ptr()) { + let fn_ptr = match GetProcAddress(ws2, c"WSAIoctl".as_ptr().cast()) { Some(f) => f as *mut u8, None => return false, }; diff --git a/openfut-hook/src/hooks.rs b/openfut-hook/src/hooks.rs index c9c028c..d29e19d 100644 --- a/openfut-hook/src/hooks.rs +++ b/openfut-hook/src/hooks.rs @@ -71,7 +71,7 @@ pub unsafe extern "system" fn hooked_getaddrinfo( let redirect = REDIRECT_IP .get() .map(|v| v.as_ptr()) - .unwrap_or(b"127.0.0.1\0".as_ptr()); + .unwrap_or(c"127.0.0.1".as_ptr().cast()); let real = REAL.get().copied().unwrap_or(sys_getaddrinfo); return real(redirect, service_name, hints, result); } diff --git a/openfut-hook/src/lib.rs b/openfut-hook/src/lib.rs index 0c20865..4bc448d 100644 --- a/openfut-hook/src/lib.rs +++ b/openfut-hook/src/lib.rs @@ -1,3 +1,12 @@ +// The `fifa17` feature compiles this shared crate but activates only the FIFA-17 +// injection path (fifa17.rs + sbc_*): install_hooks() routes to fifa17::install() +// and the FIFA-23 hook modules are reached solely via install_hooks_fifa23(), which +// is itself `#[cfg(not(feature = "fifa17"))]`. Those modules are therefore compiled +// but unused under `fifa17` (the linker strips them from the cdylib). Scope the +// resulting dead-code/unused-import lints to that feature so both builds stay +// `-D warnings` clean without dropping code the default (FIFA-23) build needs. +#![cfg_attr(feature = "fifa17", allow(dead_code, unused_imports))] + mod config; mod connect_hook; mod connectex_hook; @@ -54,6 +63,13 @@ pub(crate) fn flush_log() { } } +/// # Safety +/// +/// This is the DLL entry point invoked by the Windows loader; it MUST NOT be +/// called manually. `module` must be the valid `HMODULE` the loader passes for +/// this DLL. On `DLL_PROCESS_ATTACH` it installs process-wide inline detours +/// (raw memory patching), so it must run exactly once, on the loader thread, +/// before any hooked API is used. #[no_mangle] pub unsafe extern "system" fn DllMain(module: HMODULE, reason: u32, _: *mut ()) -> BOOL { if reason == DLL_PROCESS_ATTACH { @@ -73,7 +89,6 @@ unsafe fn install_hooks(module: HMODULE) { { let _ = module; fifa17::install(); - return; } #[cfg(not(feature = "fifa17"))] install_hooks_fifa23(module) diff --git a/openfut-hook/src/sbc_hook.rs b/openfut-hook/src/sbc_hook.rs index d9e3111..d9600e7 100644 --- a/openfut-hook/src/sbc_hook.rs +++ b/openfut-hook/src/sbc_hook.rs @@ -313,12 +313,12 @@ unsafe fn read_u16(ptr: usize) -> Option { /// Resolve CardsDLL's runtime base, or 0. Tries the exact loaded name; the ToolHelp /// fallback (name-contains "CardsDLL") lives in the spec — add it if EA ever renames. unsafe fn resolve_cards_base() -> usize { - let h = GetModuleHandleA(b"CardsDLL_Win64_retail.dll\0".as_ptr()); + let h = GetModuleHandleA(c"CardsDLL_Win64_retail.dll".as_ptr().cast()); if !h.is_null() { return h as usize; } // Also try the short form some tooling reports. - let h2 = GetModuleHandleA(b"CardsDLL.dll\0".as_ptr()); + let h2 = GetModuleHandleA(c"CardsDLL.dll".as_ptr().cast()); if !h2.is_null() { return h2 as usize; } diff --git a/openfut-hook/src/sbc_request_trace.rs b/openfut-hook/src/sbc_request_trace.rs index df6a951..058d4bf 100644 --- a/openfut-hook/src/sbc_request_trace.rs +++ b/openfut-hook/src/sbc_request_trace.rs @@ -367,7 +367,7 @@ unsafe fn worker() { } let mut base = 0usize; for _ in 0..600u32 { - base = GetModuleHandleA(b"CardsDLL_Win64_retail.dll\0".as_ptr()) as usize; + base = GetModuleHandleA(c"CardsDLL_Win64_retail.dll".as_ptr().cast()) as usize; if base != 0 { break; } diff --git a/openfut-hook/src/sbc_trace.rs b/openfut-hook/src/sbc_trace.rs index 35588d8..d033552 100644 --- a/openfut-hook/src/sbc_trace.rs +++ b/openfut-hook/src/sbc_trace.rs @@ -839,7 +839,7 @@ unsafe fn worker() { let _pending = CodeInstallerPending; let mut base = 0usize; for _ in 0..600u32 { - base = GetModuleHandleA(b"CardsDLL_Win64_retail.dll\0".as_ptr()) as usize; + base = GetModuleHandleA(c"CardsDLL_Win64_retail.dll".as_ptr().cast()) as usize; if base != 0 { break; } @@ -926,7 +926,7 @@ unsafe fn notifier_worker() { let _pending = CodeInstallerPending; let mut base = 0usize; for _ in 0..600u32 { - base = GetModuleHandleA(b"CardsDLL_Win64_retail.dll\0".as_ptr()) as usize; + base = GetModuleHandleA(c"CardsDLL_Win64_retail.dll".as_ptr().cast()) as usize; if base != 0 { break; } @@ -1029,7 +1029,7 @@ unsafe fn controller_register_worker() { let _pending = CodeInstallerPending; let mut base = 0usize; for _ in 0..600u32 { - base = GetModuleHandleA(b"CardsDLL_Win64_retail.dll\0".as_ptr()) as usize; + base = GetModuleHandleA(c"CardsDLL_Win64_retail.dll".as_ptr().cast()) as usize; if base != 0 { break; } diff --git a/openfut-hook/src/ssl_patch.rs b/openfut-hook/src/ssl_patch.rs index 59c3e02..892899f 100644 --- a/openfut-hook/src/ssl_patch.rs +++ b/openfut-hook/src/ssl_patch.rs @@ -67,7 +67,7 @@ fn patch_module(module: isize, scan_bytes: usize) -> bool { /// Patch ProtoSSL cert-verify in EAWebKit.dll (call when EAWebKit is loaded). pub unsafe fn patch_eawebkit_cert_verify() -> bool { - let module = GetModuleHandleA(b"EAWebKit.dll\0".as_ptr()) as isize; + let module = GetModuleHandleA(c"EAWebKit.dll".as_ptr().cast()) as isize; // EAWebKit.dll is ~22 MB patch_module(module, 24 * 1024 * 1024) } diff --git a/openfut-hook/src/transport_watch.rs b/openfut-hook/src/transport_watch.rs index a7cf2e9..93f79f4 100644 --- a/openfut-hook/src/transport_watch.rs +++ b/openfut-hook/src/transport_watch.rs @@ -152,7 +152,7 @@ pub unsafe fn note_connect(api: &str, name: *const u8, namelen: i32, s: usize) { let mut len: i32 = 4; getsockopt( s, - SOL_SOCKET as i32, + SOL_SOCKET, SO_TYPE, &mut ty as *mut i32 as *mut u8, &mut len,