Files
tdkpin/original/reconstructed/tdkpin_borland_runtime.h
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

63 lines
2.4 KiB
C

#ifndef TDKPIN_BORLAND_RUNTIME_H
#define TDKPIN_BORLAND_RUNTIME_H
#include "tdkpin_segmented.h"
#include <stdatomic.h>
Win16FarPtr borland_get_mem(uint16_t bytes); /* 1020:012d */
Win16FarPtr borland_global_allocate(uint16_t bytes); /* 1020:0222 */
void borland_free_mem(Win16FarPtr block, uint16_t bytes); /* 1020:0147 */
void borland_fill_bytes(
Win16FarPtr destination, uint16_t count, uint8_t value); /* 1020:16c9 */
void borland_move_bytes(
Win16FarPtr destination,
Win16FarPtr source,
uint16_t count); /* 1020:16a5 */
void borland_copy_typed_record(
uint16_t descriptor_field_offset,
Win16FarPtr destination,
Win16FarPtr source); /* 1020:046c */
_Noreturn void borland_runtime_exit(uint16_t status); /* 1020:0061 */
_Noreturn void borland_runtime_error(uint16_t code); /* 1020:005d */
void borland_run_exit_procedures(void); /* 1020:00d2 */
extern Win16FarPtr g_borland_exit_proc; /* 1028:0712/0714 */
extern uint16_t g_borland_error_offset; /* 1028:0718 */
extern uint16_t g_borland_error_segment; /* 1028:071a */
extern uint16_t g_borland_heap_reserve_bytes; /* 1028:06f4 */
extern Win16FarPtr g_borland_heap_reserve; /* 1028:06f6/06f8 */
extern uint8_t g_borland_heap_reserve_disabled; /* 1028:06fa */
extern Win16FarPtr g_borland_heap_error_handler; /* 1028:070e/0710 */
extern uint16_t g_borland_global_alloc_flags; /* 1028:070c */
bool borland_heap_reserve_is_unallocated(void); /* 1008:2de0 */
void borland_ensure_heap_reserve(void); /* 1008:2dff */
uint16_t borland_release_heap_reserve_on_oom(uint16_t requested_bytes); /* 1008:2e22 */
void borland_initialize_heap_reserve(void); /* 1008:2e76 */
extern _Atomic uint16_t g_borland_io_result; /* 1028:071e */
_Static_assert(sizeof(g_borland_io_result) == 2, "Borland IOResult width drift");
uint16_t borland_take_io_result(void); /* 1020:0388 */
void borland_require_io_success(void); /* 1020:038f */
typedef struct {
int32_t minimum;
int32_t maximum;
} BorlandInt32Range;
void borland_check_int32_range(
int32_t value, const BorlandInt32Range *range); /* 1020:039d */
_Noreturn void borland_runtime_error_215(void); /* 1020:03c5 */
typedef struct {
Win16FarPtr block;
bool failed;
} BorlandAllocationAttempt;
BorlandAllocationAttempt borland_try_get_mem(uint16_t bytes); /* 1020:01ca */
bool borland_try_free_mem(Win16FarPtr block, uint16_t bytes); /* 1020:02d7 */
#endif