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

30 lines
995 B
C

#ifndef TDKPIN_HEAP_H
#define TDKPIN_HEAP_H
#include "tdkpin_borland_runtime.h"
enum {
BORLAND_LOCAL_HEAP_MAGIC = 0x5054,
BORLAND_LOCAL_HEAP_HEADER_BYTES = 12,
};
extern uint16_t g_borland_heap_segment_head; /* 1028:0706 */
extern uint16_t g_borland_local_heap_limit; /* 1028:0708 */
extern uint16_t g_borland_heap_segment_bytes; /* 1028:070a */
typedef struct {
uint16_t offset;
bool failed;
} BorlandLocalAllocation;
BorlandLocalAllocation borland_local_allocate_in_segment(
uint16_t selector, uint16_t aligned_bytes); /* 1020:02a6 */
void borland_local_merge_next(uint16_t selector, uint16_t block); /* 1020:0327 */
uint16_t borland_create_local_heap_segment(void); /* 1020:026a */
BorlandAllocationAttempt borland_try_get_mem(uint16_t bytes); /* 1020:01ca */
bool borland_try_free_mem(Win16FarPtr block, uint16_t bytes); /* 1020:02d7 */
uint32_t borland_heap_free_space(void); /* 1020:0167 */
uint32_t borland_heap_largest_block(void); /* 1020:0195 */
#endif