code wiki / _hdl_build / _pe_odmnap.nx

_pe_odmnap.nx source

↩ module page · 21 lines · 798 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_odmnap_locate(b: *u8, n: i64, out: *i64) -> i64 { 4 var off: i64 = 0 5 if off + 2 > n { return 0 - 1 } 6 off = off + 2 + (((b[off] & 0xff) << 8) | (b[off + 1] & 0xff)) 7 if off > n { return 0 - 1 } 8 if off + 2 > n { return 0 - 1 } 9 off = off + 2 + (((b[off] & 0xff) << 8) | (b[off + 1] & 0xff)) 10 if off > n { return 0 - 1 } 11 if off + 1 > n { return 0 - 1 } 12 off = off + 1 + (b[off] & 0xff) 13 if off > n { return 0 - 1 } 14 if off + 2 > n { return 0 - 1 } 15 let tl: i64 = ((b[off] & 0xff) << 8) | (b[off + 1] & 0xff) 16 if off + 2 + tl > n { return 0 - 1 } 17 out[0] = off + 2 18 out[1] = tl 19 return 0 20 return 0 - 1 21}