> ## Documentation Index
> Fetch the complete documentation index at: https://lua.starline.one/llms.txt
> Use this file to discover all available pages before exploring further.

# Pointer

> Read and write native memory through typed pointer accessors.

Typed reads and writes at an address. `Pointer(addr)`.

```lua theme={"dark"}
local addr = cheat.FindPattern("client.dll", "...")
local p    = Pointer(addr + 0x30)
local hp   = p:i32()          -- read
p:i32(100)                    -- write
```

## Fields

```lua theme={"dark"}
p.address   -- the address as a number
```

Read-only. Use arithmetic to make a new `Pointer`.

## Arithmetic

|          |                                             |
| -------- | ------------------------------------------- |
| `p + n`  | new `Pointer` offset by `n` bytes           |
| `p - n`  | same, other direction                       |
| `p - q`  | byte distance between two pointers (number) |
| `p == q` | address equality                            |

## Read / Write

One method per width. No arg reads, one arg writes.

| Method               | Type                                                                                     |
| -------------------- | ---------------------------------------------------------------------------------------- |
| `p:i8()`, `p:u8()`   | 8-bit int, signed / unsigned                                                             |
| `p:i16()`, `p:u16()` | 16-bit                                                                                   |
| `p:i32()`, `p:u32()` | 32-bit                                                                                   |
| `p:i64()`, `p:u64()` | 64-bit (>2^53 loses precision through Lua's number)                                      |
| `p:f32()`, `p:f64()` | float / double                                                                           |
| `p:bool()`           | one byte, non-zero                                                                       |
| `p:ptr()`            | pointer-sized read, returns a new `Pointer`; write accepts a `Pointer` or address number |
| `p:string([max])`    | null-terminated string, capped at `max` bytes (default 16384)                            |

```lua theme={"dark"}
p:f32(3.14)
local addr = (Pointer(base):ptr() + 0x10):i32()
local name = Pointer(pName):string(64)
```

<Warning>
  Protected memory access errors with `access denied`. Unmapped addresses can crash the game. Prefer [`entity.*`](/entity) for schema fields.
</Warning>
