Difference between revisions of "Lua:fullAccess"
Jump to navigation
Jump to search
m (moved fullAccess to Lua:fullAccess) |
(Major overhaul of the post.) |
||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' fullAccess('' | + | {{CodeBox|'''function''' fullAccess(''address'', ''size'') ''':''' void}} |
| − | Changes the protection of a block | + | Changes the protection of a memory block to writable and executable. |
| − | === Function Parameters === | + | This is useful when a memory region needs to be modified or used for executable code. |
| − | {|width="85%" cellpadding="10 | + | |
| + | ===Function Parameters=== | ||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
!style="width: 80%;background-color:white;" align="left"|Description | !style="width: 80%;background-color:white;" align="left"|Description | ||
|- | |- | ||
| − | | | + | |address |
| − | | | + | |Integer / String |
| − | |The address | + | |The start address of the memory block whose protection should be changed. |
|- | |- | ||
| − | | | + | |size |
|Integer | |Integer | ||
| − | |The size of the block | + | |The size, in bytes, of the memory block. |
|} | |} | ||
| + | ===Returns=== | ||
| + | This function does not return a value. | ||
| + | |||
| + | ===Examples=== | ||
| + | |||
| + | ====Make a memory region writable and executable==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local address = getAddress("game.exe+1234") | ||
| + | local size = 4096 | ||
| + | fullAccess(address, size) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use fullAccess before writing bytes==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local address = getAddress("game.exe+1234") | ||
| + | |||
| + | fullAccess(address, 16) | ||
| + | |||
| + | writeBytes(address, 0x90, 0x90, 0x90, 0x90) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use fullAccess with a symbol==== | ||
| + | <syntaxhighlight lang="lua" line highlight="1"> | ||
| + | fullAccess("SomeSymbol", 32) | ||
| + | |||
| + | writeInteger("SomeSymbol", 100) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Make allocated memory executable==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local cave = allocateMemory(1024) | ||
| + | |||
| + | fullAccess(cave, 1024) | ||
| + | |||
| + | writeBytes(cave, 0xC3) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Protect a region before assembling code==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local address = getAddress("game.exe+5000") | ||
| + | |||
| + | fullAccess(address, 128) | ||
| + | |||
| + | autoAssemble([[ | ||
| + | game.exe+5000: | ||
| + | nop | ||
| + | nop | ||
| + | ]]) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Guard against unresolved addresses==== | ||
| + | <syntaxhighlight lang="lua" line highlight="4"> | ||
| + | local address = getAddressSafe("OptionalSymbol") | ||
| + | |||
| + | if address ~= nil then | ||
| + | fullAccess(address, 64) | ||
| + | else | ||
| + | print("Address could not be resolved") | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use with a calculated address range==== | ||
| + | <syntaxhighlight lang="lua" line highlight="5"> | ||
| + | local base = getAddress("game.exe") | ||
| + | local offset = 0x1234 | ||
| + | local size = 0x100 | ||
| + | |||
| + | fullAccess(base + offset, size) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | {{LuaSeeAlso}} | ||
| − | + | {{Memory}} | |
| − | |||
| − | |||
Latest revision as of 00:31, 27 June 2026
Changes the protection of a memory block to writable and executable.
This is useful when a memory region needs to be modified or used for executable code.
Contents
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| address | Integer / String | The start address of the memory block whose protection should be changed. |
| size | Integer | The size, in bytes, of the memory block. |
Returns[edit]
This function does not return a value.
Examples[edit]
Make a memory region writable and executable[edit]
1 local address = getAddress("game.exe+1234")
2 local size = 4096
3 fullAccess(address, size)
Use fullAccess before writing bytes[edit]
1 local address = getAddress("game.exe+1234")
2
3 fullAccess(address, 16)
4
5 writeBytes(address, 0x90, 0x90, 0x90, 0x90)
Use fullAccess with a symbol[edit]
1 fullAccess("SomeSymbol", 32)
2
3 writeInteger("SomeSymbol", 100)
Make allocated memory executable[edit]
1 local cave = allocateMemory(1024)
2
3 fullAccess(cave, 1024)
4
5 writeBytes(cave, 0xC3)
Protect a region before assembling code[edit]
1 local address = getAddress("game.exe+5000")
2
3 fullAccess(address, 128)
4
5 autoAssemble([[
6 game.exe+5000:
7 nop
8 nop
9 ]])
Guard against unresolved addresses[edit]
1 local address = getAddressSafe("OptionalSymbol")
2
3 if address ~= nil then
4 fullAccess(address, 64)
5 else
6 print("Address could not be resolved")
7 end
Use with a calculated address range[edit]
1 local base = getAddress("game.exe")
2 local offset = 0x1234
3 local size = 0x100
4
5 fullAccess(base + offset, size)