fix: PCLandscape param 4 is display, not wrapper
Browse filesHooked PCLandscape__Constructor to log actual params from original:
- p4 = DDDisplay* (wrapper->display), NOT DDGameWrapper*
- Confirmed via param hook: original passes 0x03B68A18 which matches
wrapper+0x4D0 (display pointer)
PCLandscape now completes. Crash moved to SpriteRegion__Constructor
(0x57DB20), indicating progress.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/engine/ddgame.rs
CHANGED
|
@@ -760,7 +760,7 @@ unsafe fn init_graphics_and_resources(
|
|
| 760 |
|
| 761 |
let pc_ctor: unsafe extern "stdcall" fn(
|
| 762 |
*mut u8, *mut DDGame, *mut u8, // 1=this, 2=ddgame, 3=gfx_resource
|
| 763 |
-
*mut
|
| 764 |
*mut u8, u32, // 6=&landscape_byte, 7=gfx_mode
|
| 765 |
*mut u8, *mut u8, // 8=stack local, 9=coord output
|
| 766 |
*mut u8, *mut u8, // 10=&ddgame+0x777C, 11=&ddgame+0x7780
|
|
@@ -775,7 +775,7 @@ unsafe fn init_graphics_and_resources(
|
|
| 775 |
alloc,
|
| 776 |
ddgame,
|
| 777 |
gfx_resource,
|
| 778 |
-
wrapper,
|
| 779 |
gi.add(0xDAAC), // param 5
|
| 780 |
landscape_byte_buf, // param 6
|
| 781 |
(*wrapper).gfx_mode, // param 7
|
|
|
|
| 760 |
|
| 761 |
let pc_ctor: unsafe extern "stdcall" fn(
|
| 762 |
*mut u8, *mut DDGame, *mut u8, // 1=this, 2=ddgame, 3=gfx_resource
|
| 763 |
+
*mut DDDisplay, *const u8, // 4=display, 5=game_info+0xDAAC
|
| 764 |
*mut u8, u32, // 6=&landscape_byte, 7=gfx_mode
|
| 765 |
*mut u8, *mut u8, // 8=stack local, 9=coord output
|
| 766 |
*mut u8, *mut u8, // 10=&ddgame+0x777C, 11=&ddgame+0x7780
|
|
|
|
| 775 |
alloc,
|
| 776 |
ddgame,
|
| 777 |
gfx_resource,
|
| 778 |
+
(*wrapper).display, // param 4: display (NOT wrapper!)
|
| 779 |
gi.add(0xDAAC), // param 5
|
| 780 |
landscape_byte_buf, // param 6
|
| 781 |
(*wrapper).gfx_mode, // param 7
|
crates/openwa-wormkit/src/replacements/game_session.rs
CHANGED
|
@@ -302,6 +302,26 @@ unsafe fn shadow_compare_ddgame(
|
|
| 302 |
wa_free(shadow_wrapper);
|
| 303 |
}
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
pub fn install() -> Result<(), String> {
|
| 306 |
unsafe {
|
| 307 |
INIT_REPLAY_ADDR = rb(va::DDGAMEWRAPPER_INIT_REPLAY);
|
|
@@ -310,7 +330,14 @@ pub fn install() -> Result<(), String> {
|
|
| 310 |
init_constructor_addrs();
|
| 311 |
// DDGameWrapper__Constructor is fully converted β trap the original.
|
| 312 |
hook::install_trap!("DDGameWrapper__Constructor", va::CONSTRUCT_DD_GAME_WRAPPER);
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
}
|
| 315 |
Ok(())
|
| 316 |
}
|
|
|
|
| 302 |
wa_free(shadow_wrapper);
|
| 303 |
}
|
| 304 |
|
| 305 |
+
// ββ PCLandscape__Constructor param logger ββββββββββββββββββββββββββ
|
| 306 |
+
static mut PC_LANDSCAPE_TRAMPOLINE: *const () = core::ptr::null();
|
| 307 |
+
|
| 308 |
+
/// Passthrough hook: logs all 11 params, then calls original.
|
| 309 |
+
unsafe extern "stdcall" fn hook_pc_landscape_ctor(
|
| 310 |
+
p1: u32, p2: u32, p3: u32, p4: u32, p5: u32, p6: u32,
|
| 311 |
+
p7: u32, p8: u32, p9: u32, p10: u32, p11: u32,
|
| 312 |
+
) -> u32 {
|
| 313 |
+
let _ = log_line(&format!(
|
| 314 |
+
"[PCLandscape] p1=0x{:08X} p2=0x{:08X} p3=0x{:08X} p4=0x{:08X} p5=0x{:08X} p6=0x{:08X}",
|
| 315 |
+
p1, p2, p3, p4, p5, p6));
|
| 316 |
+
let _ = log_line(&format!(
|
| 317 |
+
"[PCLandscape] p7=0x{:08X} p8=0x{:08X} p9=0x{:08X} p10=0x{:08X} p11=0x{:08X}",
|
| 318 |
+
p7, p8, p9, p10, p11));
|
| 319 |
+
// Call original
|
| 320 |
+
let orig: unsafe extern "stdcall" fn(u32,u32,u32,u32,u32,u32,u32,u32,u32,u32,u32) -> u32 =
|
| 321 |
+
core::mem::transmute(PC_LANDSCAPE_TRAMPOLINE);
|
| 322 |
+
orig(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
pub fn install() -> Result<(), String> {
|
| 326 |
unsafe {
|
| 327 |
INIT_REPLAY_ADDR = rb(va::DDGAMEWRAPPER_INIT_REPLAY);
|
|
|
|
| 330 |
init_constructor_addrs();
|
| 331 |
// DDGameWrapper__Constructor is fully converted β trap the original.
|
| 332 |
hook::install_trap!("DDGameWrapper__Constructor", va::CONSTRUCT_DD_GAME_WRAPPER);
|
| 333 |
+
|
| 334 |
+
// Hook PCLandscape__Constructor to log params
|
| 335 |
+
let tramp = hook::install(
|
| 336 |
+
"PCLandscape__Constructor",
|
| 337 |
+
va::PC_LANDSCAPE_CONSTRUCTOR,
|
| 338 |
+
hook_pc_landscape_ctor as *const (),
|
| 339 |
+
)?;
|
| 340 |
+
PC_LANDSCAPE_TRAMPOLINE = tramp as *const ();
|
| 341 |
}
|
| 342 |
Ok(())
|
| 343 |
}
|