nx_pe_compile_win_wsa.nx
buildroot/runtime/nx_pe_compile_win_wsa.nx
about
nx_pe_compile_win_wsa.nx -- W-NET-0: a Nishi organ initializes Winsock (2-DLL PE import table).
The network arc's foundation. Every prior organ imported ONLY kernel32; TCP sockets live in
ws2_32.dll, so a serving container needs a PE that imports from TWO DLLs. This rung proves the
2-DLL import table + the first ws2_32 call (WSAStartup) -- native, no VM. Unlocks socket/bind/
listen/accept/recv/send (W-NET-1..) toward an HTTP server organ serving Elder UI on :5173.
The keystone-linker redirects the genuine shim `nx_wsa_startup()` to a thunk that calls
ws2_32!WSAStartup. The thunk provides its OWN stack WSADATA buffer (so no allocator import needed):
nx_wsa_startup_thunk:
sub rsp, 0x228 ; 0x200 WSADATA + 0x28 shadow/align (rsp 8 mod16 -> 0x230 -> 0 mod16)
mov ecx, 0x0202 ; wVersionRequested = MAKEWORD(2,2)
lea rdx, [rsp+0x28] ; &WSADATA (above shadow)
call [rip+ws2_32!WSAStartup] ; rax = 0 on success
add rsp, 0x228 / ret
2 DLLs: kernel32 { ExitProcess } (entry-stub exit) + ws2_32 { WSAStartup }. IAT: ExitProcess 0x205C,
WSAStartup 0x206C.
NO-FALSE-GREEN: source `{ let r = nx_wsa_startup(); return r + 70 }`. WSAStartup returns 0 on
success -> exit 70. If ws2_32 failed to bind, the OS loader fails (0xC0000139, exe won't run). So
exit 70 = Winsock genuinely initialized via the 2nd-DLL import. Tamper "WSAStartup"/"ws2_32.dll" ->
0xC0000139 (proves the 2nd DLL is bound by the real OS).
PIPELINE (build WSL sovereign, run native): src.nx -> nx_compile_x86_native.elf > /tmp/nxwin.s
-> nx_sov_build_run.elf nx_pe_compile_win_wsa -> _offc/nx_win_compiled_wsa.exe -> run native.
HONEST SCOPE: WSAStartup only (Winsock init); socket/bind/listen/accept/recv/send are the next
W-NET rungs. Replicates keystone assemble (reuses axc_pass; no shared edit).
lineage_id: substrate_pe_compile_win_wsa_v1
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnxasm_x86.nxnx_pe_writer.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 36 | const NXWSA_CODE_CAP: i64 = 1048576 |
| 37 | const NXWSA_FILE_SIZE: i64 = 0x600 |
| 38 | const NXWSA_STUB_LEN: i64 = 18 |
| 39 | const NXWSA_THUNK_LEN: i64 = 31 |
| 40 | const NXWSA_TEXT_CAP: i64 = 0x200 |
| 41 | const NXWSA_RVA_TEXT: i64 = 0x1000 |
| 42 | const NXWSA_RVA_IDATA: i64 = 0x2000 |
| 43 | const NXWSA_FOFF_TEXT: i64 = 0x200 |
| 44 | const NXWSA_FOFF_IDATA:i64 = 0x400 |
| 45 | const NXWSA_IAT_EXIT: i64 = 0x205C |
| 46 | const NXWSA_IAT_WSA: i64 = 0x206C |
functions
| 48 | func nxwsa_assemble(src: *u8, n: i64, out: *u8, out_cap: i64, p_main: *i64, p_sh: *i64) -> i64 |
| 85 | func nxwsa_emit_pe(buf: *u8, code: *u8, code_len: i64, main_off: i64, sh_off: i64) -> i64 |
| 192 | func main() -> i64 |