Difference between revisions of "Lua:copyMemory"
Jump to navigation
Jump to search
m |
m (Syntax Highlighting.) |
||
| Line 58: | Line 58: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
local source = getAddress("game.exe") | local source = getAddress("game.exe") | ||
local copiedAddress = copyMemory(source, 1024) | local copiedAddress = copyMemory(source, 1024) | ||
| Line 67: | Line 67: | ||
print("Failed to copy memory") | print("Failed to copy memory") | ||
end | end | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local source = getAddress("game.exe") | local source = getAddress("game.exe") | ||
local destination = allocateMemory(1024) | local destination = allocateMemory(1024) | ||
| Line 78: | Line 78: | ||
print("Copied memory to: " .. string.format("%X", copiedAddress)) | print("Copied memory to: " .. string.format("%X", copiedAddress)) | ||
end | end | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local source = getAddress("game.exe") | local source = getAddress("game.exe") | ||
| Line 89: | Line 89: | ||
print("Copied memory to CE memory: " .. string.format("%X", copiedAddress)) | print("Copied memory to CE memory: " .. string.format("%X", copiedAddress)) | ||
end | end | ||
| − | </ | + | </syntaxhighlight> |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
{{Memory}} | {{Memory}} | ||
Latest revision as of 16:33, 25 June 2026
Copies memory from the given source address to the destination address.
If destinationAddress is omitted or nil, Cheat Engine will allocate a random destination address for the copy.
The Method parameter controls whether the source and destination addresses are interpreted as target process memory or Cheat Engine memory.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| sourceAddress | Integer or CEAddressString | The source address to copy memory from. |
| size | Integer | The number of bytes to copy. |
| destinationAddress | Integer or CEAddressString (semi-optional) | The destination address to copy memory to. If omitted or nil, Cheat Engine will allocate a random destination address. |
| Method | Integer (optional) | The copy method to use. If omitted or nil, method 0 is used. |
Method Values[edit]
| Value | Method | Description |
|---|---|---|
| nil or 0 | Target process to target process | Copies memory from the target process to the target process. |
| 1 | Target process to Cheat Engine memory | Copies memory from the target process to Cheat Engine memory. |
| 2 | Cheat Engine memory to target process | Copies memory from Cheat Engine memory to the target process. |
| 3 | Cheat Engine memory to Cheat Engine memory | Copies memory from Cheat Engine memory to Cheat Engine memory. |
Returns[edit]
integer or nil — The address of the copied memory on success, or nil on failure.
Examples[edit]
1 local source = getAddress("game.exe")
2 local copiedAddress = copyMemory(source, 1024)
3
4 if copiedAddress ~= nil then
5 print("Copied memory to: " .. string.format("%X", copiedAddress))
6 else
7 print("Failed to copy memory")
8 end
1 local source = getAddress("game.exe")
2 local destination = allocateMemory(1024)
3
4 local copiedAddress = copyMemory(source, 1024, destination)
5
6 if copiedAddress ~= nil then
7 print("Copied memory to: " .. string.format("%X", copiedAddress))
8 end
1 local source = getAddress("game.exe")
2
3 -- Copy memory from the target process to Cheat Engine memory
4 local copiedAddress = copyMemory(source, 1024, nil, 1)
5
6 if copiedAddress ~= nil then
7 print("Copied memory to CE memory: " .. string.format("%X", copiedAddress))
8 end