/// Reads openfut.cfg from the same directory as this DLL. /// /// The file contains a single line: the IP the hook should redirect EA /// hostnames to, e.g. "192.168.1.10" or "127.0.0.1". /// Falls back to 127.0.0.1 if the file is missing or unreadable. use windows_sys::Win32::System::LibraryLoader::GetModuleFileNameA; pub fn read_redirect_ip(module: windows_sys::Win32::Foundation::HMODULE) -> String { if let Some(cfg_path) = config_path(module) { if let Ok(content) = std::fs::read_to_string(&cfg_path) { let ip = content.trim().to_string(); if !ip.is_empty() { return ip; } } } "127.0.0.1".to_string() } fn config_path(module: windows_sys::Win32::Foundation::HMODULE) -> Option { let mut buf = vec![0u8; 512]; let len = unsafe { GetModuleFileNameA(module, buf.as_mut_ptr(), buf.len() as u32) }; if len == 0 { return None; } let path = std::ffi::CStr::from_bytes_until_nul(&buf[..len as usize + 1]) .ok()? .to_str() .ok()?; let dll_path = std::path::Path::new(path); Some(dll_path.parent()?.join("openfut.cfg")) }