mirror of
https://github.com/ivall/xcl.git
synced 2026-11-24 05:14:57 +01:00
Loader: under Wine, PEB.ImageBaseAddress keeps the real main image
run_main writes the title's base into PEB.ImageBaseAddress so that GetModuleHandle(NULL) answers the title. Wine's loader looks that address up in its own module list whenever a thread starts (loader_init: get_modref(Peb->ImageBaseAddress)) and uses the result unchecked. A manually mapped image is not in that list, so the title's first thread died in ntdll with an access violation at address 0x6e. Under Wine (ntdll exports wine_get_version) the field is now left alone and a log line says so. GetModuleHandle(NULL) then answers xcl.exe there, not the title. Nothing changes on Windows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -328,7 +328,13 @@ pub fn run_main(m: &Arc<MappedModule>) -> u32 {
|
||||
};
|
||||
unsafe {
|
||||
// PEB.ImageBaseAddress → GetModuleHandle(NULL), resources with NULL module, …
|
||||
*(peb().add(0x10) as *mut usize) = m.base;
|
||||
use windows_sys::Win32::System::LibraryLoader::{GetModuleHandleA, GetProcAddress};
|
||||
let wine = GetProcAddress(GetModuleHandleA(c"ntdll.dll".as_ptr() as *const u8), c"wine_get_version".as_ptr() as *const u8).is_some();
|
||||
if wine {
|
||||
crate::xlog_info!("Wine: PEB.ImageBaseAddress left alone (its loader needs the real main image there)");
|
||||
} else {
|
||||
*(peb().add(0x10) as *mut usize) = m.base;
|
||||
}
|
||||
run_tls_callbacks(m, 1);
|
||||
}
|
||||
READY.store(true, Ordering::Release);
|
||||
|
||||
Reference in New Issue
Block a user