Difference between revisions of "Lua:getInstructionSize"

From Cheat Engine
Jump to navigation Jump to search
m (Syntax Highlighting.)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
−
'''function''' getInstructionSize(''Address'') ''':''' integer
+
[[Category:Lua]]
 +
{{CodeBox|'''function''' getInstructionSize(''address'') ''':''' Integer}}
  
−
Returns the size of an instruction (basically it disassembles the instruction and returns the number of bytes for you).
+
Returns the size (in bytes) of the instruction at the given address. 
 +
Basically, it disassembles the instruction and returns how many bytes it occupies.
  
−
=== Function Parameters ===
+
===Function Parameters===
−
 
+
{|width="85%" cellpadding="5%" cellspacing="0" border="0"
−
{|width="85%" cellpadding="10%" cellpadding="5%" 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
+
|address
−
|[[CEAddressString]] or Integer
+
|Integer
−
|The address of the instruction
+
|The memory address of the instruction to analyze.
 
|}
 
|}
  
 +
===Example===
 +
<syntaxhighlight lang="lua" line>
 +
local size = getInstructionSize(0x401000)
 +
print("Instruction size:", size)
 +
</syntaxhighlight>
  
−
== See also ==
+
{{LuaSeeAlso}}
−
* [[Lua]]
 
−
* [[Help_File:Script engine|Script engine]]
 
  
−
=== Related Functions ===
+
{{Assembly}}
−
* [[disassemble]]
 
−
* [[getPreviousOpcode]]
 
−
* [[splitDisassembledString]]
 
−
* [[AOBScan]]
 
−
* [[autoAssemble]]
 
−
* [[readBytes]]
 
−
* [[readPointer]]
 
−
* [[writeBytes]]
 
−
* [[readBytesLocal]]
 
−
* [[readPointerLocal]]
 
−
* [[writeBytesLocal]]
 
−
* [[wordToByteTable]]
 
−
* [[dwordToByteTable]]
 
−
* [[qwordToByteTable]]
 
−
* [[floatToByteTable]]
 
−
* [[doubleToByteTable]]
 
−
* [[stringToByteTable]]
 
−
* [[wideStringToByteTable]]
 
−
* [[byteTableToWord]]
 
−
* [[byteTableToDword]]
 
−
* [[byteTableToQword]]
 
−
* [[byteTableToFloat]]
 
−
* [[byteTableToDouble]]
 
−
* [[byteTableToString]]
 
−
* [[byteTableToWideString]]
 

Latest revision as of 19:27, 25 June 2026

<> Lua API Reference

function getInstructionSize(address) : Integer

Returns the size (in bytes) of the instruction at the given address. Basically, it disassembles the instruction and returns how many bytes it occupies.

Function Parameters[edit]

Parameter Type Description
address Integer The memory address of the instruction to analyze.

Example[edit]

1 local size = getInstructionSize(0x401000)
2 print("Instruction size:", size)

Main Pages

Core Lua documentation entry points

◆ Lua
◆ Script Engine

Assembler and Disassembler Related Lua Functions

Auto assembler, disassembly helpers, instruction size lookup, and assembler callbacks