aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 220c39678afdbfaf1f41e31b7e26d417fb06955b
parent 8bb15991195a051024575fb64d31fe74a5bf7dbf
Author: anon <anon@example.com>
Date:   Tue, 13 Oct 2026 07:37:47 +0000

Advance translated client through window and surface initialization

Diffstat:
Mdocs/browser-porting.md | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+), 0 deletions(-)

diff --git a/docs/browser-porting.md b/docs/browser-porting.md @@ -772,3 +772,84 @@ with bounded PE/disassembly inspection. REA constructor evidence is `ev_f3344e489870c04edd133c7facf5dd39c9d80bd240a65f63ff86b6d1a2fa06e6`. Callback addresses passed as arguments must be explicit translation seeds; following only direct calls does not discover these functions. + +### Window creation and frame callbacks + +Clientr registers its window procedure at RVA `0x31b0`. It is a +four-argument stdcall thunk forwarding to RVA `0x31e0`; that handler adds +the global app object as a fifth argument. RegisterClassA success is a +nonzero class atom, as specified by +[Microsoft](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclassa). + +The initial CreateWindowExA at RVA `0x2f5d` deliberately has zero dimensions. +The following SetWindowPos uses flags 5 (`NOSIZE | NOZORDER`), so it only +moves the window. A zero-sized initial canvas does not establish a failed +preference parse; later renderer initialization must size the window. +AO verifies write access in its root using `test.txt` before continuing. + +Clientr also registers cdecl frame callbacks at RVAs `0x43f0`, `0x43f6` +and `0x43fc` through AFCM::RegisterMessageModule. These six-byte IAT-jump +thunks target AAR's timer, DDR's action-view and CCR's font-system frame +functions. They require translation seeds even though the startup helper +passes them before the frame loop starts. + +SystemParametersInfoA calls with actions `0x11` and `0x56` request screen +saver and display power-off settings. Their return values are ignored on +this startup path. A runtime without these host operations can return +BOOL false and a Win32 error; it need not change the host's global settings. +See [the API contract](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa). + +Clientr calls SetFocus at RVA `0x2c96` before applying display settings. +It treats a null return as an error and requests the exception text +`Failed to set focus to the game window.` Windows specifies that SetFocus +returns the previous focus handle, so null can also mean successful first +focus. The existing host's single window is created active; its guest focus +state must reflect that policy rather than using an unconditional null +stub or echoing every requested handle. Supporting hidden/no-activate +styles would require corresponding host activation behavior. See +[SetFocus](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setfocus). + +FFR's TextException_t::ThrowIt (RVA `0x5ef0`, throw call `0x6031`) throws +a pointer to its singleton. The first `_CxxThrowException` argument points +to a stack slot containing that pointer, not directly to the exception +object. Dereference it once before inspecting error code +12 or its +MSVC basic_string message pointer +20 and length +24. ThrowInfo resides +at FFR RVA `0xeb40`. This observation does not implement C++ unwinding. + +The windowed branch of BBR SetDisplayMode (RVA `0x2780`) sets GWL_STYLE +(-16) to `0x00ca0000`, reads GWL_EXSTYLE (-20) and GWL_STYLE, adjusts the +window rectangle, then calls MoveWindow. This is where the initial +zero-sized window obtains the configured drawable dimensions. SetWindowLongA +returns the previous value, including zero on successful replacement; +GetWindowLongA must read that same state. See +[SetWindowLongA](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga). +The canvas host has no Win32 nonclient frame, so its rectangle adjustment +preserves the requested drawable area. Native Windows caption/menu layout +is not modeled by that hook. + +ApplyDisplaySettings also invokes OOR's virtual thunks at RVAs `0x41c0` +(SetErrorHandler, vtable slot 13) and `0x41fc` (SetDisplayMode, slot 3). +They forward through imports to BBR. FFR supplies a separate cdecl +error callback at RVA `0x5ed0`; that registered callback needs its own +translation seed. + +Renderer initialization creates another DirectDraw object after adapter +enumeration. The enumeration object can still be alive. Each object needs +its own state and reference count, with its DirectDraw/DirectDraw7/Direct3D7 +interface aliases sharing that lifetime. A process-wide singleton prevents +the client from entering this observed renderer path. + +DirectDraw7 GetDeviceIdentifier receives DDDEVICEIDENTIFIER2: 1072 bytes +in the x86 SDK layout, description at +512, driver version at +1024, +device GUID at +1048 and WHQL level at +1064. The tail includes padding. +Hardware IDs and certification fields can be zero when unknown; they +must not identify a real GPU that the bridge has not queried. See +[DDDEVICEIDENTIFIER2](https://learn.microsoft.com/en-us/windows/win32/api/ddraw/ns-ddraw-dddeviceidentifier2). + +The observed windowed path creates a primary surface, queries its pixel +format, and creates a second surface before its clipper. BBR RVA `0xbb2b1` +creates the clipper, `0xbb333` binds HWND through clipper slot 8, and +`0xbb342` attaches it to the primary surface through surface slot 28. +The caller then releases its clipper reference at `0xbb34b`; the surface +must retain its own reference. Binding the window and owning this object +does not by itself implement GetClipList or arbitrary region clipping.