code wiki / _hdl_build / _pe_pnghdr.nx

_pe_pnghdr.nx source

↩ module page · 21 lines · 794 B

1// AUTHORED BY THE NISHI BUILDER (pattern: STRUCT_WALK v2 magic/tailrest) -- field-table walk, no Claude logic 2import "nx_syscalls.nx" 3func _pe_pnghdr_locate(b: *u8, n: i64, out: *i64) -> i64 { 4 var off: i64 = 0 5 if off + 4 > n { return 0 - 1 } 6 if (b[off + 0] & 0xff) != 137 { return 0 - 1 } 7 if (b[off + 1] & 0xff) != 80 { return 0 - 1 } 8 if (b[off + 2] & 0xff) != 78 { return 0 - 1 } 9 if (b[off + 3] & 0xff) != 71 { return 0 - 1 } 10 off = off + 4 11 if off + 4 > n { return 0 - 1 } 12 if (b[off + 0] & 0xff) != 13 { return 0 - 1 } 13 if (b[off + 1] & 0xff) != 10 { return 0 - 1 } 14 if (b[off + 2] & 0xff) != 26 { return 0 - 1 } 15 if (b[off + 3] & 0xff) != 10 { return 0 - 1 } 16 off = off + 4 17 out[0] = off 18 out[1] = n - off 19 return 0 20 return 0 - 1 21}