Difference between revisions of "Lua:getModuleSize"

From Cheat Engine
Jump to navigation Jump to search
m (Reverted edits by This content is not available (Talk) to last revision by TheyCallMeTim13)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' getModuleSize(''ModuleName'') ''':''' integer
+
{{CodeBox|'''function''' getModuleSize(''modulename'') ''':''' integer}}
  
Returns the size of a given module.
+
Returns the size of the given module.
  
Tip: Use [[getAddress]] to get the base address.
+
Use getAddress with the module name to retrieve the module's base address.
  
 
+
===Function Parameters===
=== Function Parameters ===
+
{|width="85%" cellpadding="10%" 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
 
|-
 
|-
|ModuleName
+
|modulename
|string
+
|String
|The module name to get the size of
+
|The name of the module to get the size of.
 
|}
 
|}
  
 +
===Returns===
 +
integer — The size of the given module in bytes.
 +
 +
===Examples===
 +
<pre>
 +
local moduleName = "KERNEL32.dll"
 +
local moduleBase = getAddress(moduleName)
 +
local moduleSize = getModuleSize(moduleName)
  
== Examples ==
+
printf("Module base: %X", moduleBase)
Code:
+
printf("Module size: 0x%X", moduleSize)
  local procAddr = 'Tutorial-x86_64.exe'
+
</pre>
  print(string.format('%016X', getAddress(procAddr)))
 
  print(string.format('        %08X', getModuleSize(procAddr)))
 
  print(string.format('%016X', getAddress(procAddr) + getModuleSize(procAddr)))
 
Output:
 
  0000000100000000
 
          002D4000
 
  00000001002D4000
 
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
 
=== Related Functions ===
 
=== Related Functions ===

Revision as of 04:42, 21 June 2026

<> Lua API Reference

function getModuleSize(modulename) : integer

Returns the size of the given module.

Use getAddress with the module name to retrieve the module's base address.

Function Parameters

Parameter Type Description
modulename String The name of the module to get the size of.

Returns

integer — The size of the given module in bytes.

Examples

local moduleName = "KERNEL32.dll"
local moduleBase = getAddress(moduleName)
local moduleSize = getModuleSize(moduleName)

printf("Module base: %X", moduleBase)
printf("Module size: 0x%X", moduleSize)

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Related Functions