Difference between revisions of "Lua:enumModules"

From Cheat Engine
Jump to navigation Jump to search
(Related Functions)
m (Added CodeBox Template.)
 
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' enumModules(''ProcessID'' OPTIONAL)
+
{{CodeBox|'''function''' enumModules(''ProcessID'' OPTIONAL) ''':''' table}}
  
Returns a table containing information about each module in the current process, or the specified process id Each entry is a table with fields.
+
Returns a table containing information about each module in the current process, or in the specified `ProcessID`. 
 +
Each entry is a table with the following fields:
 +
 
 +
* '''Name''' — String containing the module name 
 +
* '''Address''' — Integer representing the base address where the module is loaded 
 +
* '''Is64Bit''' — Boolean; '''true''' if the module is 64-bit 
 +
* '''PathToFile''' — String containing the file path of the module 
  
 
=== 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
Line 12: Line 17:
 
|-
 
|-
 
|ProcessID
 
|ProcessID
|integer
+
|Integer
|The process id to use insted of current process
+
|Optional. The process ID to enumerate modules from. Defaults to the currently opened process.
 
|}
 
|}
  
 +
=== Example ===
 +
<pre>
 +
local mods = enumModules()
 +
for i, mod in ipairs(mods) do
 +
  print(string.format("%s: 0x%X - %d bytes (%s)", mod.Name, mod.Address, mod.Size or 0, mod.Is64Bit and "x64" or "x86"))
 +
end
 +
 +
-- Output:
 +
--[[
 +
cheatengine-x86_64-SSE4-AVX2.exe: 0x400000 - 0 bytes (x64)
 +
ntdll.dll: 0x7FF8CF150000 - 0 bytes (x64)
 +
KERNEL32.DLL: 0x7FF8CE660000 - 0 bytes (x64)
 +
KERNELBASE.dll: 0x7FF8CC860000 - 0 bytes (x64)
 +
apphelp.dll: 0x7FF8C9CA0000 - 0 bytes (x64)
 +
oleaut32.dll: 0x7FF8CE1B0000 - 0 bytes (x64)
 +
msvcp_win.dll: 0x7FF8CCDB0000 - 0 bytes (x64)
 +
]]
 +
</pre>
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
=== Related Functions ===
+
{{Process}}
* [[Lua:getCommonModuleList|getCommonModuleList]]
 
* [[Lua:inModule|inModule]]
 
* [[Lua:inSystemModule|inSystemModule]]
 
* [[Lua:createProcess|createProcess]]
 
* [[Lua:openProcess|openProcess]]
 
* [[Lua:getForegroundProcess|getForegroundProcess]]
 
* [[Lua:getOpenedProcessID|getOpenedProcessID]]
 
* [[Lua:getProcessIDFromProcessName|getProcessIDFromProcessName]]
 
* [[Lua:pause|pause]]
 
* [[Lua:unpause|unpause]]
 
* [[Lua:targetIs64Bit|targetIs64Bit]]
 
* [[Lua:getAddress|getAddress]]
 
* [[Lua:getNameFromAddress|getNameFromAddress]]
 

Latest revision as of 00:57, 5 December 2025

<> Function

function enumModules(ProcessID OPTIONAL) : table

Returns a table containing information about each module in the current process, or in the specified `ProcessID`. Each entry is a table with the following fields:

  • Name — String containing the module name
  • Address — Integer representing the base address where the module is loaded
  • Is64Bit — Boolean; true if the module is 64-bit
  • PathToFile — String containing the file path of the module

Function Parameters[edit]

Parameter Type Description
ProcessID Integer Optional. The process ID to enumerate modules from. Defaults to the currently opened process.

Example[edit]

local mods = enumModules()
for i, mod in ipairs(mods) do
  print(string.format("%s: 0x%X - %d bytes (%s)", mod.Name, mod.Address, mod.Size or 0, mod.Is64Bit and "x64" or "x86"))
end

-- Output:
--[[
cheatengine-x86_64-SSE4-AVX2.exe: 0x400000 - 0 bytes (x64) 
ntdll.dll: 0x7FF8CF150000 - 0 bytes (x64) 
KERNEL32.DLL: 0x7FF8CE660000 - 0 bytes (x64) 
KERNELBASE.dll: 0x7FF8CC860000 - 0 bytes (x64) 
apphelp.dll: 0x7FF8C9CA0000 - 0 bytes (x64) 
oleaut32.dll: 0x7FF8CE1B0000 - 0 bytes (x64) 
msvcp_win.dll: 0x7FF8CCDB0000 - 0 bytes (x64) 
]]

See also[edit]

Lua
Script Engine

Related Functions[edit]

createProcess
openProcess
onOpenProcess
getForegroundProcess
getOpenedProcessID
getProcessIDFromProcessName
openFileAsProcess
saveOpenedFile
setPointerSize
setAssemblerMode
getProcesslist
getWindowlist
pause
unpause
targetIs64Bit
enumModules
closeRemoteHandle