<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3AcopyMemory</id>
	<title>Lua:copyMemory - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cheatengine.org/index.php?action=history&amp;feed=atom&amp;title=Lua%3AcopyMemory"/>
	<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:copyMemory&amp;action=history"/>
	<updated>2026-06-22T04:21:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.cheatengine.org/index.php?title=Lua:copyMemory&amp;diff=7958&amp;oldid=prev</id>
		<title>Leunsel: Created page with &quot;Category:Lua {{CodeBox|'''function''' copyMemory(''sourceAddress'', ''size'', ''destinationAddress'', ''Method'') ''':''' integer or nil}}  Copies memory from the given so...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.cheatengine.org/index.php?title=Lua:copyMemory&amp;diff=7958&amp;oldid=prev"/>
		<updated>2026-06-21T09:09:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Category:Lua&quot; title=&quot;Category:Lua&quot;&gt;Category:Lua&lt;/a&gt; {{CodeBox|&amp;#039;&amp;#039;&amp;#039;function&amp;#039;&amp;#039;&amp;#039; copyMemory(&amp;#039;&amp;#039;sourceAddress&amp;#039;&amp;#039;, &amp;#039;&amp;#039;size&amp;#039;&amp;#039;, &amp;#039;&amp;#039;destinationAddress&amp;#039;&amp;#039;, &amp;#039;&amp;#039;Method&amp;#039;&amp;#039;) &amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039; integer or nil}}  Copies memory from the given so...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Lua]]&lt;br /&gt;
{{CodeBox|'''function''' copyMemory(''sourceAddress'', ''size'', ''destinationAddress'', ''Method'') ''':''' integer or nil}}&lt;br /&gt;
&lt;br /&gt;
Copies memory from the given source address to the destination address.&lt;br /&gt;
&lt;br /&gt;
If ''destinationAddress'' is omitted or nil, Cheat Engine will allocate a random destination address for the copy.&lt;br /&gt;
&lt;br /&gt;
The ''Method'' parameter controls whether the source and destination addresses are interpreted as target process memory or Cheat Engine memory.&lt;br /&gt;
&lt;br /&gt;
===Function Parameters===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Parameter&lt;br /&gt;
!style=&amp;quot;width: 20%&amp;quot; align=&amp;quot;left&amp;quot;|Type&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|sourceAddress&lt;br /&gt;
|Integer or [[CEAddressString]]&lt;br /&gt;
|The source address to copy memory from.&lt;br /&gt;
|-&lt;br /&gt;
|size&lt;br /&gt;
|Integer&lt;br /&gt;
|The number of bytes to copy.&lt;br /&gt;
|-&lt;br /&gt;
|destinationAddress&lt;br /&gt;
|Integer or [[CEAddressString]] (semi-optional)&lt;br /&gt;
|The destination address to copy memory to. If omitted or nil, Cheat Engine will allocate a random destination address.&lt;br /&gt;
|-&lt;br /&gt;
|Method&lt;br /&gt;
|Integer (optional)&lt;br /&gt;
|The copy method to use. If omitted or nil, method 0 is used.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Method Values===&lt;br /&gt;
{|width=&amp;quot;85%&amp;quot; cellpadding=&amp;quot;10%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Value&lt;br /&gt;
!align=&amp;quot;left&amp;quot;|Method&lt;br /&gt;
!style=&amp;quot;width: 80%;background-color:white;&amp;quot; align=&amp;quot;left&amp;quot;|Description&lt;br /&gt;
|-&lt;br /&gt;
|nil or 0&lt;br /&gt;
|Target process to target process&lt;br /&gt;
|Copies memory from the target process to the target process.&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Target process to Cheat Engine memory&lt;br /&gt;
|Copies memory from the target process to Cheat Engine memory.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Cheat Engine memory to target process&lt;br /&gt;
|Copies memory from Cheat Engine memory to the target process.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Cheat Engine memory to Cheat Engine memory&lt;br /&gt;
|Copies memory from Cheat Engine memory to Cheat Engine memory.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
integer or nil — The address of the copied memory on success, or nil on failure.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local source = getAddress(&amp;quot;game.exe&amp;quot;)&lt;br /&gt;
local copiedAddress = copyMemory(source, 1024)&lt;br /&gt;
&lt;br /&gt;
if copiedAddress ~= nil then&lt;br /&gt;
  print(&amp;quot;Copied memory to: &amp;quot; .. string.format(&amp;quot;%X&amp;quot;, copiedAddress))&lt;br /&gt;
else&lt;br /&gt;
  print(&amp;quot;Failed to copy memory&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local source = getAddress(&amp;quot;game.exe&amp;quot;)&lt;br /&gt;
local destination = allocateMemory(1024)&lt;br /&gt;
&lt;br /&gt;
local copiedAddress = copyMemory(source, 1024, destination)&lt;br /&gt;
&lt;br /&gt;
if copiedAddress ~= nil then&lt;br /&gt;
  print(&amp;quot;Copied memory to: &amp;quot; .. string.format(&amp;quot;%X&amp;quot;, copiedAddress))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local source = getAddress(&amp;quot;game.exe&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Copy memory from the target process to Cheat Engine memory&lt;br /&gt;
local copiedAddress = copyMemory(source, 1024, nil, 1)&lt;br /&gt;
&lt;br /&gt;
if copiedAddress ~= nil then&lt;br /&gt;
  print(&amp;quot;Copied memory to CE memory: &amp;quot; .. string.format(&amp;quot;%X&amp;quot;, copiedAddress))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{LuaSeeAlso}}&lt;/div&gt;</summary>
		<author><name>Leunsel</name></author>
		
	</entry>
</feed>