Lua:allocateMemory

From Cheat Engine
Revision as of 16:31, 25 June 2026 by Leunsel (talk | contribs) (Syntax Highlighting.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<> Lua API Reference

function allocateMemory(size, BaseAddress, Protection) : integer

Allocates memory in the target process.

The optional BaseAddress parameter can be used to specify a preferred base address for the allocation. The optional Protection parameter can be used to specify the memory protection for the allocated region.

Function Parameters[edit]

Parameter Type Description
size Integer The number of bytes to allocate in the target process.
BaseAddress Integer or CEAddressString (optional) The preferred base address for the allocation.
Protection Integer or String (optional) The memory protection to use for the allocated region.

Returns[edit]

integer — The address of the allocated memory block.

Examples[edit]

1 local address = allocateMemory(1024)
2 
3 print("Allocated memory at: " .. string.format("%X", address))
4 
5 deAlloc(address)
1 local baseAddress = getAddress("game.exe")
2 local address = allocateMemory(2048, baseAddress)
3 
4 print("Allocated memory at: " .. string.format("%X", address))
5 
6 deAlloc(address)

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Sections / Views

Memory Mapping

Memory Copy / Compare

Memory Streams