Files
tdkpin/original/reconstructed/tdkpin_window_lifecycle.c
T
ddidderr 8b99e9607c feat(reconstruction): complete binary-backed C recovery
Replace the partial mechanics transcriptions with a separate, readable C11
reconstruction of the complete Win16 image while preserving the original raw
Ghidra export as immutable evidence. Cover all ordinary and overlapping entry
points, Borland runtime behavior, Win16 imports, segmented data, callbacks,
resources, indirect control flow, physics, rendering, persistence, and
startup/shutdown lifecycles.

Add deterministic extraction and audit tooling plus address-linked ledgers for
functions, imports, DGROUP ranges and objects, relocations, resources, and
callbacks. The final gate records zero raw, partial, restored, unknown,
blocked, or unclassified required units. Keep the semantic-fidelity boundary
explicit: the portable C is not claimed to reproduce a byte-identical Borland
NE build.

Add strict focused harnesses for every reconstructed C unit, exact resource
round-trip checks, and a 16-bit Borland Real48 reference probe. No Rust source
or Cargo metadata is changed in this phase.

Test Plan:
- `bash original/tools/test_reconstructed_c.sh` -- passed
- `bash original/tools/probe_real48_reference.sh` -- passed bit-for-bit
- `python3 original/tools/audit_reconstruction.py --require-complete` -- passed
- `git diff --cached --check` -- passed
- `git diff HEAD -- '*.rs' Cargo.toml Cargo.lock` -- empty
2026-08-23 16:41:17 +02:00

72 lines
2.3 KiB
C

/* Derived ObjectWindows window destruction chains used by TDKPIN. */
#include "tdkpin_window_lifecycle.h"
#include "tdkpin_strings.h"
enum {
WINDOW_TITLE_OFFSET = 0x1d,
WINDOW_ATTACHED_OBJECT_OFFSET = 0x3b,
OVERLAY_PEER_OFFSET = 0x41,
DGROUP_OVERLAY_BITMAP = 0x0867,
};
static void write_far(
Win16FarPtr object, uint16_t offset, Win16FarPtr value)
{
win16_write_u32(object, offset, value);
}
/*
* 1018:121b — destroy TWindow-owned title and attached object before chaining
* into TObjectWindow and the caller's hidden ownership cleanup.
*/
void object_windows_window_destruct(
Win16FarPtr window, uint16_t vmt)
{
borland_far_strdispose(
win16_read_far_pointer(window, WINDOW_TITLE_OFFSET));
Win16FarPtr attached =
win16_read_far_pointer(window, WINDOW_ATTACHED_OBJECT_OFFSET);
if (attached != 0) {
borland_dispose_object(attached);
write_far(window, WINDOW_ATTACHED_OBJECT_OFFSET, 0);
}
object_windows_object_destruct(window, 0);
BorlandObjectCallFrame frame = {window, vmt};
borland_finish_object_destructor(&frame, 0);
}
/*
* 1000:5ba6 — delete DAT-993 overlay bitmap, break the reciprocal +41 peer
* links, then run the ordinary TWindow and derived Borland destructor exits.
*/
void tdkpin_overlay_window_destruct(
Win16FarPtr window, uint16_t vmt)
{
HBITMAP16 bitmap = win16_read_u16(
win16_dgroup_pointer(DGROUP_OVERLAY_BITMAP));
(void)DeleteObject16(bitmap);
Win16FarPtr peer = win16_read_far_pointer(window, OVERLAY_PEER_OFFSET);
write_far(peer, OVERLAY_PEER_OFFSET, 0);
write_far(window, OVERLAY_PEER_OFFSET, 0);
object_windows_window_destruct(window, 0);
BorlandObjectCallFrame frame = {window, vmt};
borland_finish_object_destructor(&frame, 0);
}
/* 1000:60e7 — reciprocal board peer uses its +45 field for this window. */
void tdkpin_board_window_destruct(
Win16FarPtr window, uint16_t vmt)
{
Win16FarPtr peer = win16_read_far_pointer(window, OVERLAY_PEER_OFFSET);
write_far(peer, 0x45, 0);
write_far(window, OVERLAY_PEER_OFFSET, 0);
HBITMAP16 bitmap = win16_read_u16(
win16_dgroup_pointer(DGROUP_OVERLAY_BITMAP));
(void)DeleteObject16(bitmap);
object_windows_window_destruct(window, 0);
BorlandObjectCallFrame frame = {window, vmt};
borland_finish_object_destructor(&frame, 0);
}