code wiki / _hdl_build / _pe_riffhdr.nx
_pe_riffhdr.nx source
↩ module page · 23 lines · 844 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_riffhdr_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) != 82 { return 0 - 1 }
7 if (b[off + 1] & 0xff) != 73 { return 0 - 1 }
8 if (b[off + 2] & 0xff) != 70 { return 0 - 1 }
9 if (b[off + 3] & 0xff) != 70 { return 0 - 1 }
10 off = off + 4
11 off = off + 4
12 if off > n { return 0 - 1 }
13 if off + 4 > n { return 0 - 1 }
14 if (b[off + 0] & 0xff) != 87 { return 0 - 1 }
15 if (b[off + 1] & 0xff) != 65 { return 0 - 1 }
16 if (b[off + 2] & 0xff) != 86 { return 0 - 1 }
17 if (b[off + 3] & 0xff) != 69 { return 0 - 1 }
18 off = off + 4
19 out[0] = off
20 out[1] = n - off
21 return 0
22 return 0 - 1
23}