Small tree: one root struct with a few typed fields at known offsets. Keeps tests fast and deterministic (no giant PEB tree).
| 11 | // Small tree: one root struct with a few typed fields at known offsets. |
| 12 | // Keeps tests fast and deterministic (no giant PEB tree). |
| 13 | static void buildSmallTree(NodeTree& tree) { |
| 14 | tree.baseAddress = 0x1000; |
| 15 | |
| 16 | Node root; |
| 17 | root.kind = NodeKind::Struct; |
| 18 | root.structTypeName = "TestStruct"; |
| 19 | root.name = "root"; |
| 20 | root.parentId = 0; |
| 21 | root.offset = 0; |
| 22 | int ri = tree.addNode(root); |
| 23 | uint64_t rootId = tree.nodes[ri].id; |
| 24 | |
| 25 | auto field = [&](int off, NodeKind k, const char* name) { |
| 26 | Node n; |
| 27 | n.kind = k; |
| 28 | n.name = name; |
| 29 | n.parentId = rootId; |
| 30 | n.offset = off; |
| 31 | tree.addNode(n); |
| 32 | }; |
| 33 | |
| 34 | field(0, NodeKind::UInt32, "field_u32"); // 4 bytes |
| 35 | field(4, NodeKind::Float, "field_float"); // 4 bytes |
| 36 | field(8, NodeKind::UInt8, "field_u8"); // 1 byte |
| 37 | field(9, NodeKind::Padding, "pad0"); // 3 bytes padding |
| 38 | // Set padding arrayLen = 3 for 3-byte padding |
| 39 | tree.nodes.last().arrayLen = 3; |
| 40 | field(12, NodeKind::Hex32, "field_hex"); // 4 bytes |
| 41 | } |
| 42 | |
| 43 | // 64-byte buffer with recognizable pattern |
| 44 | static QByteArray makeSmallBuffer() { |