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
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
#include "../tdkpin_global_memory.h"
|
|
|
|
#include <assert.h>
|
|
|
|
static UINT16 g_alloc_flags;
|
|
static uint32_t g_alloc_bytes;
|
|
static HGLOBAL16 g_handle;
|
|
static Win16FarPtr g_locked_pointer;
|
|
static uint16_t g_handle_selector;
|
|
static unsigned g_unlock_sequence;
|
|
static unsigned g_free_sequence;
|
|
|
|
HGLOBAL16 GlobalAlloc16(UINT16 flags, uint32_t bytes)
|
|
{
|
|
g_alloc_flags = flags;
|
|
g_alloc_bytes = bytes;
|
|
return g_handle;
|
|
}
|
|
|
|
Win16FarPtr GlobalLock16(HGLOBAL16 allocation)
|
|
{
|
|
assert(allocation == g_handle);
|
|
return g_locked_pointer;
|
|
}
|
|
|
|
HGLOBAL16 GlobalHandle16(uint16_t selector)
|
|
{
|
|
g_handle_selector = selector;
|
|
return g_handle;
|
|
}
|
|
|
|
BOOL16 GlobalUnlock16(HGLOBAL16 allocation)
|
|
{
|
|
assert(allocation == g_handle);
|
|
g_unlock_sequence = 1;
|
|
return 0;
|
|
}
|
|
|
|
HGLOBAL16 GlobalFree16(HGLOBAL16 allocation)
|
|
{
|
|
assert(allocation == g_handle && g_unlock_sequence == 1);
|
|
g_free_sequence = 2;
|
|
return 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
g_handle = 0x1234;
|
|
g_locked_pointer = win16_make_far_pointer(0xa100, 0x0040);
|
|
Win16FarPtr block = tdkpin_global_allocate_locked(0x0042, 0x12345678u);
|
|
assert(block == g_locked_pointer);
|
|
assert(g_alloc_flags == 0x0042 && g_alloc_bytes == 0x12345678u);
|
|
|
|
tdkpin_global_unlock_and_free(
|
|
win16_make_far_pointer(0xa100, 0xbeef));
|
|
assert(g_handle_selector == 0xa100);
|
|
assert(g_unlock_sequence == 1 && g_free_sequence == 2);
|
|
return 0;
|
|
}
|