Difference between revisions of "Lua:writeBytes"

From Cheat Engine
Jump to navigation Jump to search
m (Added CodeBox Template.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' writeBytes(''Address'', ''Byte1'', ''Byte2'', ''Byte3'', ... )
+
{{CodeBox|'''function''' writeBytes(''Address'', ''Byte1'', [''Byte2'', ...])}}
  
'''function''' writeBytes(''Address'', ''Table'' )
+
{{CodeBox|'''function''' writeBytes(''Address'', ''Table'')}}
  
Write the bytes to the given address
+
Writes bytes to the specified address in the currently opened (target) process.
 +
You can provide the bytes as separate arguments or as a table.
  
 +
===Function Parameters===
  
===Function Parameters===
+
'''writeBytes(address, byte1, [byte2, ...])'''
'''function''' writeBytes(''Address'', ''Byte1'', ''Byte2'', ''Byte3'', ... )
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="1"
 
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
Line 16: Line 17:
 
|Address
 
|Address
 
|[[CEAddressString]] or Integer
 
|[[CEAddressString]] or Integer
|The address to write to
+
|The address in the target process to write to.
 
|-
 
|-
|Byte1
+
|Byte1, Byte2, ...
 
|Integer
 
|Integer
|The first byte
+
|The bytes to write (as separate arguments).
|-
 
|Byte2
 
|Integer
 
|The second byte
 
|-
 
|...
 
|Integer
 
|All the other bytes (Max around 20)
 
 
|}
 
|}
<br>
+
 
'''function''' writeBytes(''Address'', ''Table'')
+
'''writeBytes(address, table)'''
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="1"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
Line 39: Line 32:
 
|Address
 
|Address
 
|[[CEAddressString]] or Integer
 
|[[CEAddressString]] or Integer
|The address to write to
+
|The address in the target process to write to.
 
|-
 
|-
 
|Table
 
|Table
 
|Table
 
|Table
|A table consisting of integers to be written to
+
|A table containing the bytes to write.
 
|}
 
|}
 +
 +
===Examples===
 +
<pre>
 +
-- Write 4 bytes to an address
 +
writeBytes(0x123456, 0x90, 0x90, 0x90, 0x90)
 +
 +
-- Write bytes from a table
 +
local bytes = {0xDE, 0xAD, 0xBE, 0xEF}
 +
writeBytes(0x654321, bytes)
 +
</pre>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}

Latest revision as of 23:00, 4 December 2025

<> Function

function writeBytes(Address, Byte1, [Byte2, ...])

<> Function

function writeBytes(Address, Table)

Writes bytes to the specified address in the currently opened (target) process. You can provide the bytes as separate arguments or as a table.

Function Parameters[edit]

writeBytes(address, byte1, [byte2, ...])

Parameter Type Description
Address CEAddressString or Integer The address in the target process to write to.
Byte1, Byte2, ... Integer The bytes to write (as separate arguments).

writeBytes(address, table)

Parameter Type Description
Address CEAddressString or Integer The address in the target process to write to.
Table Table A table containing the bytes to write.

Examples[edit]

-- Write 4 bytes to an address
writeBytes(0x123456, 0x90, 0x90, 0x90, 0x90)

-- Write bytes from a table
local bytes = {0xDE, 0xAD, 0xBE, 0xEF}
writeBytes(0x654321, bytes)

See also[edit]

Lua
Script Engine

Related Functions[edit]

Read Functions
readBytes
readSmallInteger
readInteger
readQword
readPointer
readFloat
readDouble
readString
Read Functions (Local Process)
readBytesLocal
readIntegerLocal
readQwordLocal
readPointerLocal
readFloatLocal
readDoubleLocal
readStringLocal
Write Functions
writeBytes
writeSmallInteger
writeInteger
writeQword
writeFloat
writeDouble
writeString
Write Functions (Local Process)
writeBytesLocal
writeIntegerLocal
writeQwordLocal
writeFloatLocal
writeDoubleLocal
writeStringLocal
Byte Table Conversions (Value → Byte Table)
wordToByteTable
dwordToByteTable
qwordToByteTable
floatToByteTable
doubleToByteTable
stringToByteTable
wideStringToByteTable
Byte Table Conversions (Byte Table → Value)
byteTableToWord
byteTableToDword
byteTableToQword
byteTableToFloat
byteTableToDouble
byteTableToString
byteTableToWideString