Files
Kevin Thomas 6a9090915b Initial commit
2026-07-06 21:23:12 -04:00

66 lines
3.3 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
<style>
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
.dim{font:20px 'Courier New',monospace;fill:#888}
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
.badge{stroke:#00ff41;rx:14}
</style>
<rect class="bg" width="1200" height="800"/>
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
<text class="title" x="600" y="52" text-anchor="middle">C Structs &amp; typedef</text>
<text class="dim" x="600" y="88" text-anchor="middle">Grouping Related Data in C</text>
<!-- Left Panel: Struct Definition -->
<rect class="pnl" x="30" y="110" width="555" height="320" rx="8"/>
<text class="sub" x="50" y="145">Struct Definition</text>
<rect x="50" y="160" width="515" height="245" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="70" y="192">typedef struct {</text>
<text class="txt" x="100" y="222">i2c_hw_t *hw;</text>
<text class="txt" x="100" y="252">bool restart_on_next;</text>
<text class="cyn" x="70" y="282">} i2c_inst_t;</text>
<text class="dim" x="70" y="320">typedef creates an alias</text>
<text class="dim" x="70" y="345">so we can write: i2c_inst_t var;</text>
<text class="dim" x="70" y="370">instead of: struct { ... } var;</text>
<!-- Right Panel: Struct in Memory -->
<rect class="pnl" x="615" y="110" width="555" height="320" rx="8"/>
<text class="sub" x="635" y="145">Memory Layout</text>
<text class="dim" x="635" y="175">i2c_inst_t at 0x2000062C</text>
<rect x="635" y="190" width="515" height="70" rx="4" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
<text class="dim" x="655" y="215">Offset 0x00</text>
<text class="grn" x="820" y="215">hw</text>
<text class="amb" x="890" y="215">= 0x40098000</text>
<text class="dim" x="655" y="245">i2c_hw_t* (4 bytes)</text>
<rect x="635" y="270" width="515" height="70" rx="4" fill="#0a0a0f" stroke="#00d4ff" stroke-width="1"/>
<text class="dim" x="655" y="295">Offset 0x04</text>
<text class="cyn" x="820" y="295">restart_on_next</text>
<text class="amb" x="655" y="325">= 0x00 (false)</text>
<text class="dim" x="870" y="325">bool (1 byte)</text>
<text class="dim" x="635" y="370">Total struct size: 8 bytes</text>
<text class="dim" x="635" y="400">hw points to I2C1 registers</text>
<!-- Bottom: Forward Declaration -->
<rect class="pnl" x="30" y="445" width="1140" height="120" rx="8"/>
<text class="sub" x="50" y="480">Forward Declaration</text>
<rect x="50" y="495" width="1100" height="45" rx="4" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="70" y="524">struct i2c_inst;</text>
<text class="dim" x="310" y="524">// tells compiler: this type exists, define later</text>
<!-- Bottom: Why structs -->
<rect class="pnl" x="30" y="580" width="1140" height="100" rx="8"/>
<text class="sub" x="50" y="615">Why Structs Matter in RE</text>
<text class="txt" x="50" y="650">GDB shows raw memory -- you must recognize struct layouts</text>
<text class="dim" x="50" y="670">x/2wx 0x2000062c shows: 0x40098000 0x00000000</text>
<!-- Footer -->
</svg>