code wiki / _hdl_build / nx_pe_compile_win_game.nx

nx_pe_compile_win_game.nx source

↩ module page · 34 lines · 1682 B

1// nx_pe_compile_win_game.nx -- GAME-GUI wrapper: wraps the compiled nishi_game payload (/tmp/nxgame.s, 2// a UNIQUE .s path per the zombie-nxwin.s corrupt-exe lesson) into a native Windows PE at 3// _offc/nishi_game.exe. Thin variant: imports nx_pe_compile_win_gui's PROVEN machinery (gi_assemble + 4// gi_emit_pe + the user32/gdi32 FFI import table) verbatim -- only the in/out paths differ, so the 5// browser's _offc/nishi.exe is never touched. license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_pe_compile_win_gui.nx" 8 9func main() -> i64 { 10 let lenbox: *i64 = sys_mmap(16) as *i64 11 let src: *u8 = sys_read_file("/tmp/nxgame.s" as *u8, lenbox) 12 if (src as i64) == 0 { return 1 } 13 let n: i64 = lenbox[0] 14 if n <= 0 { return 2 } 15 let code: *u8 = sys_mmap(GI_CODE_CAP) 16 let off: *i64 = sys_mmap(16 * 8) as *i64 17 var z: i64 = 0 18 while z < 8 { off[z] = 0 - 1; z = z + 1 } 19 let code_len: i64 = gi_assemble(src, n, code, GI_CODE_CAP, off) 20 if code_len < 0 { return 3 } 21 if off[0] < 0 { return 4 } 22 let span: i64 = GI_STUB_LEN + code_len + GI_THUNK_SLACK 23 let text_fsz: i64 = gi_align(span, 0x200) 24 let rva_idata: i64 = 0x1000 + gi_align(span, 0x1000) 25 let file_size: i64 = GI_FOFF_TEXT + text_fsz + GI_IDATA_FSZ 26 let buf: *u8 = sys_mmap(file_size) 27 let rc: i64 = gi_emit_pe(buf, code, code_len, off, text_fsz, rva_idata) 28 if rc != NX_PE_OK { return 5 } 29 let outp: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nishi_game.exe" as *u8 30 if nx_pe_write_to_file(outp, buf, file_size) != NX_PE_OK { return 70 } 31 let msg: *u8 = "[substrate] Nishi GAME window PE written\n" as *u8 32 sys_write(1, msg, 41) 33 return 0 34}