code wiki / _hdl_build / _pe_pnghdr_test.nx

_pe_pnghdr_test.nx source

↩ module page · 27 lines · 776 B

1// AUTHORED BY THE NISHI BUILDER (pattern: STRUCT_WALK v2 test) -- KATs computed from the table at emit time 2import "_pe_pnghdr.nx" 3import "nx_syscalls.nx" 4func main() -> i64 { 5 let b: *u8 = sys_mmap(512) 6 b[0] = 137 as u8 7 b[1] = 80 as u8 8 b[2] = 78 as u8 9 b[3] = 71 as u8 10 b[4] = 13 as u8 11 b[5] = 10 as u8 12 b[6] = 26 as u8 13 b[7] = 10 as u8 14 b[8] = 119 as u8 15 b[9] = 119 as u8 16 b[10] = 119 as u8 17 b[11] = 119 as u8 18 let out: *i64 = sys_mmap(32) as *i64 19 if _pe_pnghdr_locate(b, 12, out) == 0 { 20 if out[0] == 8 { 21 if out[1] == 4 { 22 if _pe_pnghdr_locate(b, 3, out) == 0 - 1 { 23 b[0] = (((b[0] & 0xff) + 1) & 0xff) as u8 24 if _pe_pnghdr_locate(b, 12, out) == 0 - 1 { sys_exit(0) } } } } } 25 sys_exit(1) 26 return 1 27}