Difference between revisions of "Lua:allocateMemory"
Jump to navigation
Jump to search
m |
m (Syntax Highlighting.) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 29: | Line 29: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
local address = allocateMemory(1024) | local address = allocateMemory(1024) | ||
| Line 35: | Line 35: | ||
deAlloc(address) | deAlloc(address) | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local baseAddress = getAddress("game.exe") | local baseAddress = getAddress("game.exe") | ||
local address = allocateMemory(2048, baseAddress) | local address = allocateMemory(2048, baseAddress) | ||
| Line 44: | Line 44: | ||
deAlloc(address) | deAlloc(address) | ||
| − | </ | + | </syntaxhighlight> |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| + | |||
| + | {{Memory}} | ||
Latest revision as of 16:31, 25 June 2026
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)