code wiki / (root) / nx_pe_compile_win_wsa.nx

nx_pe_compile_win_wsa.nx

buildroot/runtime/nx_pe_compile_win_wsa.nx

11183 B221 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind tooltopic pe
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nxasm_x86.nx nx_pe_writer.nx nx_pe_compile_win_wsa.nx

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

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nxwsa_assemble sys_mmap ↻ axc_pass axc_is_space axc_is_ident axc_apply_section axc_tok_is axc_cstr_len axc_is_space ↻ axc_is_ident ↻ axc_tok_is ↻ axc_emit_bytes axc_is_digit axc_parse_int axc_is_digit ↻ axc_parse_operand axc_is_space ↻ axc_is_ident ↻ axc_reg_num axc_tok_is ↻ axc_parse_int ↻ axc_is_digit ↻ axc_tok_is ↻ axc_emit axc_tok_is ↻ axc_alu x86_alu_imm x86_rex_w x86_modrm x86_put_u32le x86_alu_rr x86_rex_w ↻

structs

none

consts

36const NXWSA_CODE_CAP: i64 = 1048576
37const NXWSA_FILE_SIZE: i64 = 0x600
38const NXWSA_STUB_LEN: i64 = 18
39const NXWSA_THUNK_LEN: i64 = 31
40const NXWSA_TEXT_CAP: i64 = 0x200
41const NXWSA_RVA_TEXT: i64 = 0x1000
42const NXWSA_RVA_IDATA: i64 = 0x2000
43const NXWSA_FOFF_TEXT: i64 = 0x200
44const NXWSA_FOFF_IDATA:i64 = 0x400
45const NXWSA_IAT_EXIT: i64 = 0x205C
46const NXWSA_IAT_WSA: i64 = 0x206C

functions

48func nxwsa_assemble(src: *u8, n: i64, out: *u8, out_cap: i64, p_main: *i64, p_sh: *i64) -> i64
85func nxwsa_emit_pe(buf: *u8, code: *u8, code_len: i64, main_off: i64, sh_off: i64) -> i64
192func main() -> i64