> For the complete documentation index, see [llms.txt](https://0x29a.gitbook.io/0x29a-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0x29a.gitbook.io/0x29a-docs/memory-and-analysis/pe.md).

# pe

**analysis · global: `pe`**

Parsing of the PE (Portable Executable) format for a module already loaded in memory — no disk access.

### `pe.valid(base) -> bool`

Checks whether `base` points at a valid PE header (`MZ`/`PE`).

### `pe.info(base) -> info | nil`

```lua
{
    is64        = true,
    timestamp   = 1699999999,
    entry_rva   = 0x1000,
    entry_addr  = base + 0x1000,
    subsystem   = 2,
    image_size  = 0x500000,
}
```

### `pe.sections(base) -> [section]`

```lua
{ name, rva, addr, virtual_size, raw_size, exec, write, read }
```

`exec`/`write`/`read` are booleans derived from the section's characteristics.

### `pe.exports(base) -> [export]`

```lua
{ name, ordinal, rva, addr, forwarded, forward_to }
```

`forwarded = true` when the export just redirects to another module (`forward_to` gives the target, e.g. `"KERNEL32.HeapAlloc"`).

### `pe.export_addr(base, name) -> addr | nil`

Shortcut to resolve a single export by name without building the whole list.

```lua
local addr = pe.export_addr(mem.module("kernel32.dll").base, "CreateFileW")
```

### `pe.imports(base) -> [{module, functions}]`

Each `functions[i]` is `{name, hint, iat_addr}` — `iat_addr` is the address in the Import Address Table, useful for IAT hooking.

### `pe.runtime_functions(base) -> [{addr, size, begin_rva, end_rva}]`

Reads the `.pdata` table (x64 unwind info) — gives function boundaries without needing disassembly heuristics, as long as the binary isn't stripped.

***

See the global helpers [`exports(mod, fn)`](/0x29a-docs/globals/helpers.md#exports-modname-fn) and [`sections(mod)`](/0x29a-docs/globals/helpers.md#sections-modname) for versions that already print formatted output.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://0x29a.gitbook.io/0x29a-docs/memory-and-analysis/pe.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
