Difference between revisions of "Lua"

From Cheat Engine
Jump to navigation Jump to search
m
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
 
Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.
 
Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.
 +
 +
 +
= Variables =
 +
 +
== Globals ==
 +
* [[TrainerOrigin]]: A variable that contains the path of the trainer that launched cheat engine (Only set when launched as a trainer)
 +
* [[process]]: A variable that contains the main modulename of the currently opened process
 +
* [[MainForm]]: The main ce gui
 +
* [[AddressList]]: The address list of the main ce gui
 +
 +
== Variables ==
 +
* [[Debug Variables]]
 +
** EFLAGS
 +
** '''32/64-bit''': EAX, EBX, ECX, EDX, EDI, ESI, EBP, ESP, EIP
 +
** '''64-bit only''': RAX, RBX, RCX, RDX, RDI, RSI, RBP, RSP, RIP, R8, R9, R10, R11, R12, R13, R14, R15 : The value of the register
  
  
 
= Functions =
 
= Functions =
 
  
 
== Cheat table ==
 
== Cheat table ==
Line 11: Line 25:
 
* [[getAddressList]]: Returns the cheat table [[Addresslist]] object
 
* [[getAddressList]]: Returns the cheat table [[Addresslist]] object
 
* [[findTableFile]]: Returns a [[TableFile]] stored in the cheat table
 
* [[findTableFile]]: Returns a [[TableFile]] stored in the cheat table
 +
* [[loadTable]]: Loads a ".ct" or ".cetrainer" file or stream
 +
* [[saveTable]]: Saves the current table
 +
 +
 +
== Trainers ==
 +
* [[registerEXETrainerFeature]]: Adds a new feature to the exe trainer generator window, and calls your function when the user builds an .exe trainer
 +
* [[unregisterEXETrainerFeature]]: Unregisters the trainer feature
 +
 +
 +
== Protection ==
 +
* [[activateProtection]]: Prevents basic memory scanners from opening the cheat engine process
 +
* [[enableDRM]]: Prevents normal memory scanners from reading the Cheat Engine process (kernelmode)
 +
* [[encodeFunction]]: Converts a given function into an encoded string that you can pass on to [[decodeFunction]]
 +
* [[decodeFunction]]: Converts an encoded string back into a function
  
  
Line 21: Line 49:
  
 
== Process ==
 
== Process ==
 +
* [[createProcess]]: Creates a process with or without debugging
 
* [[openProcess]]: Causes cheat engine to open the given processname or id
 
* [[openProcess]]: Causes cheat engine to open the given processname or id
 
* [[onOpenProcess]]: Called by CE when it opens a process (userdefined)
 
* [[onOpenProcess]]: Called by CE when it opens a process (userdefined)
* [[getForegroundProcess]]: Returns the processid of the current foreground window
+
* [[getForegroundProcess]]: Returns the process ID of the process that is currently on top
 
* [[getOpenedProcessID]]: Returns the currently opened process
 
* [[getOpenedProcessID]]: Returns the currently opened process
 
* [[getProcessIDFromProcessName]]: Returns a processid
 
* [[getProcessIDFromProcessName]]: Returns a processid
Line 36: Line 65:
 
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
 
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
 
* [[enumModules]]: Returns a table containing information about each module in the current process, or the specified process ID
 
* [[enumModules]]: Returns a table containing information about each module in the current process, or the specified process ID
* [[getHandleList]]: Returns a table with all the handles in the system
 
 
* [[closeRemoteHandle]]: Closes the handle of a process
 
* [[closeRemoteHandle]]: Closes the handle of a process
* [[getForegroundProcess]]: Returns the process ID of the process that is currently on top
 
  
  
Line 48: Line 75:
 
* [[queue]]: Calls the given function from the main thread. Does not wait for the result
 
* [[queue]]: Calls the given function from the main thread. Does not wait for the result
 
* [[checkSynchronize]]: Call this from an infinite loop in the main thread when using threading and synchronize calls
 
* [[checkSynchronize]]: Call this from an infinite loop in the main thread when using threading and synchronize calls
 +
 +
 +
== Handles ==
 +
* [[getHandleList]]: Returns a table with all the handles in the system
  
  
Line 68: Line 99:
 
* [[registerAddressLookupCallback]]: Registers a function to be called when the name of an address is requested
 
* [[registerAddressLookupCallback]]: Registers a function to be called when the name of an address is requested
 
* [[unregisterAddressLookupCallback]]: Removes the callback
 
* [[unregisterAddressLookupCallback]]: Removes the callback
 +
* [[reinitializeDotNetSymbolhandler]]: Reinitializes only the DotNet part of the symbol list
  
  
Line 77: Line 109:
 
* [[mapViewOfSection]]: Maps the section to memory
 
* [[mapViewOfSection]]: Maps the section to memory
 
* [[unMapViewOfSection]]: Unmaps a section from memory
 
* [[unMapViewOfSection]]: Unmaps a section from memory
 +
* [[copyMemory]]: Copies memory from the given address to the destination address
 +
* [[allocateKernelMemory]]: Allocates a block of nonpaged memory and returns the address
 +
* [[freeKernelMemory]]: Frees the given memory region
 +
* [[mapMemory]]: Maps a specific address to the usermode context from the given PID to the given PID
 +
* [[unmapMemory]]:
  
  
Line 91: Line 128:
 
* [[readString]]: Reads a string from memory until it hits a 0-terminator. maxlength is just so you won't freeze for too long
 
* [[readString]]: Reads a string from memory until it hits a 0-terminator. maxlength is just so you won't freeze for too long
 
* [[readRegionFromFile]]: Writes the given file to a specific address
 
* [[readRegionFromFile]]: Writes the given file to a specific address
 +
 +
* [[readBytesLocal]]: See readBytes but then it's for Cheat engine's memory
 +
* [[readSmallIntegerLocal]]: Reads a 16-bit integer from the specified address in CE's memory
 +
* [[readIntegerLocal]]: Reads a 32-bit integer from the specified address in CE's memory
 +
* [[readQwordLocal]]: Reads a 64-bit integer from the specified address in CE's memory
 +
* [[readPointerLocal]]: [[ReadQwordLocal]]/[[ReadIntegerLocal]] depending on the cheat engine build
 +
* [[readFloatLocal]]: Reads a single precision floating point value from the specified address in CE's memory
 +
* [[readDoubleLocal]]: Reads a double precision floating point value from the specified address in CE's memory
 +
* [[readStringLocal]]: Reads a string from CE's memory until it hits a 0-terminator
 +
  
 
=== Writing ===
 
=== Writing ===
Line 101: Line 148:
 
* [[writeString]]: Write a string to the specified address. Returns true on success.
 
* [[writeString]]: Write a string to the specified address. Returns true on success.
 
* [[writeRegionToFile]]: Writes the given region to a file. Returns the number of bytes written.
 
* [[writeRegionToFile]]: Writes the given region to a file. Returns the number of bytes written.
 +
 +
* [[writeSmallIntegerLocal]]: Writes a 16-bit integer to the specified address in CE's memory. Returns true on success
 +
* [[writeIntegerLocal]]: Writes a 32-bit integer to the specified address in CE's memory. Returns true on success
 +
* [[writeQwordLocal]]: Writes a 64-bit integer to the specified address in CE's memory. Returns true on success
 +
* [[writeFloatLocal]]: Writes a single precision floating point to the specified address in CE's memory. Returns true on success
 +
* [[writeDoubleLocal]]: Writes a double precision floating point to the specified address in CE's memory. Returns true on success
 +
* [[writeStringLocal]]: Write a string to the specified address. Returns true on success.
 +
* [[writeBytesLocal]]: See writeBytes but then it's for Cheat Engine's memory
 +
 +
** [[readSmallInteger]], [[readInteger]], [[readSmallIntegerLocal]], [[readIntegerLocal]] can also have second boolean parameter. If true, value will be signed.
 +
 +
== Convertions ==
 +
* [[ansiToUtf8]]: Converts a string in Ansi encoding to UTF8
 +
* [[utf8ToAnsi]]: Converts a string in UTF8 encoding to Ansi
 +
* [[stringToMD5String]]: Returns an md5 hash string from the provided string
 +
* [[integerToUserData]]: Converts a given integer to a userdata variable
 +
* [[userDataToInteger]]: Converts a given userdata variable to an integer
 +
 +
=== To Byte Table ===
 +
* [[wordToByteTable]]: Converts a word to a bytetable
 +
* [[dwordToByteTable]]: Converts a dword to a bytetable
 +
* [[qwordToByteTable]]: Converts a qword to a bytetable
 +
* [[floatToByteTable]]: Converts a float to a bytetable
 +
* [[doubleToByteTable]]: Converts a double to a bytetable
 +
* [[stringToByteTable]]: Converts a string to a bytetable
 +
* [[wideStringToByteTable]]: Converts a string to a widestring and converts that to a bytetable
 +
 +
=== From Byte Table ===
 +
* [[byteTableToWord]]: Converts a bytetable to a word
 +
* [[byteTableToDword]]: Converts a bytetable to a dword
 +
* [[byteTableToQword]]: Converts a bytetable to a qword
 +
* [[byteTableToFloat]]: Converts a bytetable to a float
 +
* [[byteTableToDouble]]: Converts a bytetable to a double
 +
* [[byteTableToString]]: Converts a bytetable to a string
 +
* [[byteTableToWideString]]: Converts a bytetable to a widestring and convets that to a string
 +
 +
 +
=== Binary ===
 +
[[bOr]]: Binary Or
 +
[[bXor]]: Binary Xor
 +
[[bAnd]]: Binary And
 +
[[bShl]]: Binary shift left
 +
[[bShr]]: Binary shift right
 +
[[bNot]]: Binary not
  
  
Line 176: Line 267:
 
These functions help manage Cheat Engine itself.
 
These functions help manage Cheat Engine itself.
  
* [[getFormCount]]: Returns the total number of forms assigned to the main CE application
+
* [[getCEVersion]]: Returns a floating point value specifying the version of cheat engine
* [[getForm]]: Returns the form at the specific index
+
* [[getCheatEngineFileVersion]]: Returns the full version data of the cheat engine version. A raw integer, and a table containing major, minor, release and build
* [[getMemoryViewForm]]: Returns the first Memoryview form class object
 
* [[getMainForm]]: Returns the first Mainform class object
 
 
* [[getFreezeTimer]]: Returns the Timer object responsible for freezing values
 
* [[getFreezeTimer]]: Returns the Timer object responsible for freezing values
 
* [[getUpdateTimer]]: Returns the Timer object responsible for updating the value list
 
* [[getUpdateTimer]]: Returns the Timer object responsible for updating the value list
 
* [[getCommonModuleList]]: Returns the commonModuleList [[StringList]] object
 
* [[getCommonModuleList]]: Returns the commonModuleList [[StringList]] object
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
 
 
* [[getCheatEngineProcessID]]: Returns the processid of cheat engine
 
* [[getCheatEngineProcessID]]: Returns the processid of cheat engine
 
* [[cheatEngineIs64Bit]]: Returns true if Cheat Engine is 64-bit, false if 32-bit
 
* [[cheatEngineIs64Bit]]: Returns true if Cheat Engine is 64-bit, false if 32-bit
 
* [[closeCE]]: Closes Cheat Engine
 
* [[closeCE]]: Closes Cheat Engine
 
* [[getAutoAttachList]]: Returns the AutoAttach [[StringList]] object
 
* [[getAutoAttachList]]: Returns the AutoAttach [[StringList]] object
* [[registerFormAddNotification]]: Registers a function to be called when a form is attached to Cheat Engine's form list
 
* [[unregisterFormAddNotification]]: unregister the FormAddNotification call back
 
 
* [[connectToCEServer]]: Connects to the given host and port. On success, most commands subsequent will be handled by the server
 
* [[connectToCEServer]]: Connects to the given host and port. On success, most commands subsequent will be handled by the server
* [[unhideMainCEwindow]]: Shows the main Cheat Engine window
 
* [[hideAllCEWindows]]: Makes all normal Cheat Engine windows invisible (e.g trainer table)
 
 
* [[supportCheatEngine]]: Will show an advertising window which will help keep the development of Cheat Engine going.
 
* [[supportCheatEngine]]: Will show an advertising window which will help keep the development of Cheat Engine going.
 
* [[fuckCheatEngine]]: Removes the ad window if it was showing
 
* [[fuckCheatEngine]]: Removes the ad window if it was showing
 
* [[getCheatEngineDir]]: Returns the folder Cheat Engine (or the trainer) is located at.
 
* [[getCheatEngineDir]]: Returns the folder Cheat Engine (or the trainer) is located at.
* [[readBytesLocal]]: readBytes, but for Cheat Engine's own memory
 
* [[writeBytesLocal]]: writeBytes, but for Cheat Engine's own memory
 
 
* [[getComment]]: Gets the userdefined comment at the specified address
 
* [[getComment]]: Gets the userdefined comment at the specified address
 
* [[setComment]]: Sets a userdefined comment at the specifried address
 
* [[setComment]]: Sets a userdefined comment at the specifried address
Line 203: Line 285:
 
* [[setHeader]]: Sets the userdefined header at the specified address
 
* [[setHeader]]: Sets the userdefined header at the specified address
 
* [[registerBinUtil]]: Registers a binutils toolset with Cheat Engine
 
* [[registerBinUtil]]: Registers a binutils toolset with Cheat Engine
 +
* [[reloadSettingsFromRegistry]]: This will cause cheat engine to reload the settings from the registry and apply them
 +
* [[loadPlugin]]: Loads the given plugin
 +
* [[getSettings]]: Returns a settings object
  
 +
=== Forms ===
 +
* [[getFormCount]]: Returns the total number of forms assigned to the main CE application
 +
* [[getForm]]: Returns the form at the specific index
 +
* [[getMemoryViewForm]]: Returns the first Memoryview form class object
 +
* [[getMainForm]]: Returns the first Mainform class object
 +
* [[getSettingsForm]]: Returns the main settings form
 +
* [[getLuaEngine]]: Returns the lua engine form object (Creates it if needed)* [[unhideMainCEwindow]]: Shows the main Cheat Engine window
 +
* [[hideAllCEWindows]]: Makes all normal Cheat Engine windows invisible (e.g trainer table)
 +
* [[registerFormAddNotification]]: Registers a function to be called when a form is attached to Cheat Engine's form list
 +
* [[unregisterFormAddNotification]]: unregister the FormAddNotification call back
  
 
=== Messages ===
 
=== Messages ===
Line 209: Line 304:
 
* [[messageDialog]]: Pops up a message box
 
* [[messageDialog]]: Pops up a message box
 
* [[outputDebugString]]: Outputs a message using the windows OutputDebugString message
 
* [[outputDebugString]]: Outputs a message using the windows OutputDebugString message
 +
* [[processMessages]]: Lets the main eventhandler process the new messages (allows for new button clicks)
  
 
=== Input ===
 
=== Input ===
Line 228: Line 324:
 
* [[resetLuaState]]: This will create a new Lua state that will be used.
 
* [[resetLuaState]]: This will create a new Lua state that will be used.
 
* [[sleep]]: Pauses for the number of specified milliseconds
 
* [[sleep]]: Pauses for the number of specified milliseconds
 +
* [[createRef]]: Integer - Returns an integer reference that you can use with getRef
 +
* [[getRef]]: Returns whatever the reference points out
 +
* [[destroyRef]]: Removes the reference
  
  
Line 266: Line 365:
 
* [[registerAutoAssemblerPrologue]]: Registers a function to be called when the auto assembler is about to parse an auto assembler script
 
* [[registerAutoAssemblerPrologue]]: Registers a function to be called when the auto assembler is about to parse an auto assembler script
 
* [[unregisterAutoAssemblerPrologue]]: Unregisters an auto assembler prologue
 
* [[unregisterAutoAssemblerPrologue]]: Unregisters an auto assembler prologue
 +
* [[fullAccess]]: Changes the protection of a block of memory to writable and executable
 +
 +
 +
=== Scripts ===
 
* [[registerAutoAssemblerTemplate]]: Registers a template for the auto assembler
 
* [[registerAutoAssemblerTemplate]]: Registers a template for the auto assembler
 
* [[unregisterAutoAssemblerTemplate]]: Unregisters a template for the auto assembler
 
* [[unregisterAutoAssemblerTemplate]]: Unregisters a template for the auto assembler
Line 271: Line 374:
 
* [[generateAOBInjectionScript]]: Adds an AOB injection script to the given script
 
* [[generateAOBInjectionScript]]: Adds an AOB injection script to the given script
 
* [[generateFullInjectionScript]]: Adds a Full Injection script to the given script
 
* [[generateFullInjectionScript]]: Adds a Full Injection script to the given script
 +
* [[generateAPIHookScript]]: Generates an auto assembler script which will hook the given address when executed
  
  
Line 276: Line 380:
 
These functions manage the debugger. See ''[[Lua Debugging]]''.
 
These functions manage the debugger. See ''[[Lua Debugging]]''.
  
 +
* [[debug_isDebugging]]: Returns true if the debugger has been started
 +
* [[debug_getCurrentDebuggerInterface]]: Returns the current debuggerinterface used (1=windows, 2=VEH 3=Kernel, nil=no debugging active)
 +
* [[debug_canBreak]]: Returns true if there is a possibility the target can stop on a breakpoint. 6.4+
 +
* [[debug_isBroken]]: Returns true if the debugger is currently halted on a thread
 +
* [[debug_getBreakpointList]]: Returns a lua table containing all the breakpoint addresses
 
* [[debugProcess]]: Debugs the currently attached process
 
* [[debugProcess]]: Debugs the currently attached process
 
* [[debug_setBreakpoint]]: Sets a breakpoint of a specific size at the given address
 
* [[debug_setBreakpoint]]: Sets a breakpoint of a specific size at the given address
Line 289: Line 398:
 
* [[debug_updateGUI]]: Will refresh the userinterface to reflect the new context if the debugger was broken
 
* [[debug_updateGUI]]: Will refresh the userinterface to reflect the new context if the debugger was broken
 
* [[detachIfPossible]]: Detaches the debugger from the target process (if it was attached)
 
* [[detachIfPossible]]: Detaches the debugger from the target process (if it was attached)
 +
* [[debug_addThreadToNoBreakList]]: This will cause breakpoints on the provided thread to be ignored
 +
* [[debug_removeThreadFromNoBreakList]]: removed the threadid from the list
 +
* [[debug_getXMMPointer]]: Returns the address of the specified xmm register of the thread that is currently broken
 +
* [[debugger_onModuleLoad]]: This routine is called when a module is loaded. Only works for the windows debugger
  
  
Line 301: Line 414:
 
* [[dbk_writeMSR]]: Writes the msr using the dbk driver
 
* [[dbk_writeMSR]]: Writes the msr using the dbk driver
 
* [[dbk_executeKernelMemory]]: Executes a routine from kernelmode (e.g a routine written there with auto assembler)
 
* [[dbk_executeKernelMemory]]: Executes a routine from kernelmode (e.g a routine written there with auto assembler)
 +
* [[dbk_getCR0]]: Returns Control Register 0
 +
* [[dbk_getCR3]]: Returns Control Register 3 of the currently opened process
 +
* [[dbk_getCR4]]: Returns Control Register 4
 +
* [[dbk_getPhysicalAddress]]: Returns the physical address of the given address
 +
* [[dbk_writesIgnoreWriteProtection]]: Set to true if you do not wish to initiate copy-on-write behaviour
 +
 +
 +
== DBVM ==
 
* [[dbvm_initialize]]: Initializes the dbvm functions
 
* [[dbvm_initialize]]: Initializes the dbvm functions
 
* [[dbvm_readMSR]]: Reads the msr using dbvm (bypasses the driver)
 
* [[dbvm_readMSR]]: Reads the msr using dbvm (bypasses the driver)
 
* [[dbvm_writeMSR]]: Writes the msr using dbvm (bypasses the driver)
 
* [[dbvm_writeMSR]]: Writes the msr using dbvm (bypasses the driver)
 +
* [[dbvm_getCR4]]: Returns the real Control Register 4 state
  
  
Line 314: Line 436:
  
 
== Files ==
 
== Files ==
* [[getFileVersion]]: Returns the 64-bit file version, and a table that has split up the file version into major, minor, release and build]]
+
* [[getFileVersion]]: Returns the 64-bit file version, and a table that has split up the file version into major, minor, release and build
 +
* [[getFileList]]: Returns an indexed table with filenames
 
* [[getDirectoryList]]: Returns an indexed table with directory names
 
* [[getDirectoryList]]: Returns an indexed table with directory names
  
Line 326: Line 449:
  
 
== Miscellaneous ==
 
== Miscellaneous ==
* [[getPixel]]: Returns the rgb value of the pixel at the specific screen coordinate
 
 
* [[injectDll]]: Injects a dll
 
* [[injectDll]]: Injects a dll
* [[allocateSharedMemory]]: Creates/reuses a shared memory object
 
* [[createProcess]]: Creates a process with or without debugging
 
 
* [[shellExecute]]: Executes a given command
 
* [[shellExecute]]: Executes a given command
* [[generateAPIHookScript]]: Generates an auto assembler script which will hook the given address when executed
+
* [[executeCode]]: Executes a stdcall function with 1 parameter at the given address in the target process and wait for it to return
 +
* [[executeCodeLocal]]: Executes a stdcall function with 1 parameter at the given address in the target process
 
* [[onAPIPointerChange]]: Registers a callback when an api pointer is changed
 
* [[onAPIPointerChange]]: Registers a callback when an api pointer is changed
 
* [[setAPIPointer]]: Sets the pointer of the given api to the given address
 
* [[setAPIPointer]]: Sets the pointer of the given api to the given address
* [[encodeFunction]]: Converts a given function into an encoded string that you can pass on to [[decodeFunction]]
 
* [[decodeFunction]]: Converts an encoded string back into a function
 
 
* [[md5memory]]: Returns a md5 sum calculated from the provided memory
 
* [[md5memory]]: Returns a md5 sum calculated from the provided memory
 
* [[md5file]]: Returns a md5 sum calculated from the file
 
* [[md5file]]: Returns a md5 sum calculated from the file
 
* [[getSystemMetrics]]: Retrieves the specified system metric or system configuration setting [https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx]
 
* [[getSystemMetrics]]: Retrieves the specified system metric or system configuration setting [https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx]
 
* [[getTickCount]]: Returns the current tickcount since windows was started. Each tick is one millisecond
 
* [[getTickCount]]: Returns the current tickcount since windows was started. Each tick is one millisecond
* [[processMessages]]: Lets the main eventhandler process the new messages (allows for new button clicks)
 
* [[integerToUserData]]: Converts a given integer to a userdata variable
 
* [[userDataToInteger]]: Converts a given userdata variable to an integer
 
* [[executeCode]]: Executes a stdcall function with 1 parameter at the given address in the target process and wait for it to return
 
* [[executeCodeLocal]]: Executes a stdcall function with 1 parameter at the given address in the target process
 
 
* [[getUserRegistryEnvironmentVariable]]: Returns the environment variable stored in the user registry environment
 
* [[getUserRegistryEnvironmentVariable]]: Returns the environment variable stored in the user registry environment
 
* [[setUserRegistryEnvironmentVariable]]: Sets the environment variable stored in the user registry environment
 
* [[setUserRegistryEnvironmentVariable]]: Sets the environment variable stored in the user registry environment
 
* [[broadcastEnvironmentUpdate]]: Call this when you've changed the environment variables in the registry
 
* [[broadcastEnvironmentUpdate]]: Call this when you've changed the environment variables in the registry
* [[stringToMD5String]]: Returns an md5 hash string from the provided string
 
 
* [[getApplication]]: Returns the application object (the titlebar)
 
* [[getApplication]]: Returns the application object (the titlebar)
  
  
 
+
<!-- Left off at SQL Classes: line 2742 -->
 
= Classes =
 
= Classes =
 
Besides the above functions, Cheat Engine also implements some classes.
 
Besides the above functions, Cheat Engine also implements some classes.
  
 
* [[Addresslist]]: The addresslist class is a container for memory records
 
* [[Addresslist]]: The addresslist class is a container for memory records
 +
* [[Bitmap]]: Bitmap based Graphic object
 
* [[Brush]]: The brush class is part of the Canvas object. It's used to fill surfaces
 
* [[Brush]]: The brush class is part of the Canvas object. It's used to fill surfaces
 
* [[Button]]: The button class is a visual component in the shape of a button.
 
* [[Button]]: The button class is a visual component in the shape of a button.
 
* [[ButtonControl]]: Common ancestor of several button like objects.
 
* [[ButtonControl]]: Common ancestor of several button like objects.
* [[Canvas]]: The canvas class is a graphical class. It allows you do draw lines, pictures, and text on top of other object. Usually used in onPaint events and other graphical events  
+
* [[Canvas]]: The canvas class is a graphical class. It allows you do draw lines, pictures, and text on top of other object. Usually used in onPaint events and other graphical events
 +
* [[Calendar]]:
 +
* [[CEForm]]:
 
* [[CheatComponent]]: The cheatcomponent class is the component used in Cheat Engine 5.x trainers
 
* [[CheatComponent]]: The cheatcomponent class is the component used in Cheat Engine 5.x trainers
 
* [[CheckBox]]: The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed
 
* [[CheckBox]]: The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed
Line 368: Line 484:
 
* [[CollectionItem]]:  Basic object that is managed by a Collection class
 
* [[CollectionItem]]:  Basic object that is managed by a Collection class
 
* [[ComboBox]]: The Combobox is like an edit field with a ListBox attached to it
 
* [[ComboBox]]: The Combobox is like an edit field with a ListBox attached to it
 +
* [[CriticalSection]]:
 
* [[CustomControl]]: Base class for windowed controls which paint themselves
 
* [[CustomControl]]: Base class for windowed controls which paint themselves
 +
* [[CustomType]]: The custom type is an convertor of raw data, to a human readable interpretation.
 +
* [[D3DHOOK]]: The d3dhook functions provide a method to render graphics and text inside the game, as long as it is running in directx9, 10 or 11
 +
* [[D3DHook_FontMap]]: A fontmap is a texture that contains extra data regarding the characters
 +
* [[D3DHook_Texture]]: This class controls the texture in memory. Without a sprite to use it, it won't show
 +
* [[D3Dhook_TextContainer]]: A d3dhook_sprite class draws a piece of text on the screen based on the used fontmap
 +
* [[D3DHook_RenderObject]]: The renderobject is the abstract class used to control in what manner objects are rendered.
 +
* [[D3DHook_Sprite]]: A d3dhook_sprite class is a visible texture on the screen
 +
* [[Disassembler]]:
 
* [[Disassemblerview]]: The visual disassembler used in the memory view window
 
* [[Disassemblerview]]: The visual disassembler used in the memory view window
 +
* [[DisassemblerviewLine]]:
 +
* [[DissectCode]]:
 
* [[Edit]]: The Edit class is a visual component that lets the user type in data (Use control_getCaption to get the user input)
 
* [[Edit]]: The Edit class is a visual component that lets the user type in data (Use control_getCaption to get the user input)
 +
* [[Event]]:
 
* [[FileStream]]: The FileStream class is a Stream class that is linked to an open file on disk
 
* [[FileStream]]: The FileStream class is a Stream class that is linked to an open file on disk
 +
* [[FileDialog]]:
 +
* [[FindDialog]]:
 
* [[Font]]: Class that defines a font
 
* [[Font]]: Class that defines a font
 
* [[Form]]: Class that defines a window
 
* [[Form]]: Class that defines a window
Line 379: Line 509:
 
* [[GraphicControl]]: Class that supports simple lightweight controls that do not need the ability to accept keyboard input or contain other controls.  
 
* [[GraphicControl]]: Class that supports simple lightweight controls that do not need the ability to accept keyboard input or contain other controls.  
 
* [[GroupBox]]: The groupbox class is like a Panel, but then has a header on top
 
* [[GroupBox]]: The groupbox class is like a Panel, but then has a header on top
 +
* [[Hexadecimal]]: The visual hexadecimal object used on the memory view window
 
* [[Hexadecimalview]]: The visual hexadecimal object used on the memory view window
 
* [[Hexadecimalview]]: The visual hexadecimal object used on the memory view window
 +
* [[Icon]]:
 
* [[Image]]: The Image class is a visual component that lets you show an image
 
* [[Image]]: The Image class is a visual component that lets you show an image
 +
* [[Internet]]:
 +
* [[JpegImage]]:
 
* [[Label]]: The Label class is a visual component that lets you display text
 
* [[Label]]: The Label class is a visual component that lets you display text
 +
* [[LuaPipe]]: Abstract class that [[LuaPipeServer]] and [[LuaPipeclient]] inherit from
 +
* [[LuaPipeClient]]: Class implementing a client that connects to a pipe
 +
* [[LuaPipeServer]]: Class launching the server side of a pipe
 
* [[ListBox]]: The listbox class is a visual component with a list of selectable strings
 
* [[ListBox]]: The listbox class is a visual component with a list of selectable strings
 
* [[ListColumn]]: The listcolumn class is an implemented CollectionItem class which is used by the ListColumns class of the listview class
 
* [[ListColumn]]: The listcolumn class is an implemented CollectionItem class which is used by the ListColumns class of the listview class
Line 397: Line 534:
 
* [[MemoryStream]]: The memorystream class is a Stream class that is stored completely in memory. Because it's a stream there are multiple functions that can work with it
 
* [[MemoryStream]]: The memorystream class is a Stream class that is stored completely in memory. Because it's a stream there are multiple functions that can work with it
 
* [[Memoryview]]: The memoryview class is the Memory view window of Cheat Engine. Use this as a basis to access the objects inside this window
 
* [[Memoryview]]: The memoryview class is the Memory view window of Cheat Engine. Use this as a basis to access the objects inside this window
* [[Object]] : Most basic class. All classes inherit from this class
+
* [[MultiReadExclusiveWriteSynchronizer]]:
 +
* [[Object]]: Most basic class. All classes inherit from this class
 +
* [[PaintBox]]:
 +
* [[Pagecontrol]]: This is an object that can hold multiple pages
 
* [[Panel]]: The Panel class is like a form which can contain visual components.
 
* [[Panel]]: The Panel class is like a form which can contain visual components.
 
* [[Pen]]: The Pen class is part of the Canvas object. It's used to draw lines
 
* [[Pen]]: The Pen class is part of the Canvas object. It's used to draw lines
 
* [[Picture]]: Container for the Graphic class
 
* [[Picture]]: Container for the Graphic class
 
* [[PopupMenu]]: The menu that shows when rightclicking on an object
 
* [[PopupMenu]]: The menu that shows when rightclicking on an object
 +
* [[PortableNetworkGraphic]]:
 
* [[ProgressBar]]: The progressbar class is a visual representation for a bar that can show the current progress on something
 
* [[ProgressBar]]: The progressbar class is a visual representation for a bar that can show the current progress on something
 
* [[RadioGroup]]: The radiogroup is like a GroupBox but autopopulated using the Items(Strings object)
 
* [[RadioGroup]]: The radiogroup is like a GroupBox but autopopulated using the Items(Strings object)
 +
* [[RasterImage]]: Base class for some graphical controls
 +
* [[RIPRelativeScanner]]:
 
* [[OpenDialog]]: The OpenDialog class is used for selecting files to open.
 
* [[OpenDialog]]: The OpenDialog class is used for selecting files to open.
 
* [[SaveDialog]]: The SaveDialog class is based on the OpenDialog class but is used to select a file for saving
 
* [[SaveDialog]]: The SaveDialog class is based on the OpenDialog class but is used to select a file for saving
 +
* [[SelectDirectoryDialog]]:
 +
* [[Semaphore]]:
 +
* [[Settings]]: This class can be used to read out and set settings of cheat engine and of plugins, and store your own data
 
* [[Splitter]]: The Splitter class is a visual component that lets the user re-size neighboring components)
 
* [[Splitter]]: The Splitter class is a visual component that lets the user re-size neighboring components)
 
* [[Stringlist]]: Class that holds a list of strings
 
* [[Stringlist]]: Class that holds a list of strings
 
* [[Strings]]: Abstract class that some text based classes make use of
 
* [[Strings]]: Abstract class that some text based classes make use of
 +
* [[StringStream]]:
 +
* [[Structure]]:
 +
* [[StructureElement]]:
 +
* [[StructureFrm]]:
 +
* [[structGroup]]:
 +
* [[SymbolList]]: This class can be used to look up an address to a symbolname, and a symbolname to an address
 +
* [[TabSheet]]: Part of a page control
 
* [[TableFile]]: Tablefiles are files stored into a Cheat Table. You can access the data of such a file using this class
 
* [[TableFile]]: Tablefiles are files stored into a Cheat Table. You can access the data of such a file using this class
 +
* [[Thread]]:
 
* [[Timer]]: The timer class is an non visual component that when active triggers an onTimer event every few milliseconds, based on the given interval
 
* [[Timer]]: The timer class is an non visual component that when active triggers an onTimer event every few milliseconds, based on the given interval
 
* [[ToggleBox]]: The togglebox is like a button, but can stay down. Use with the checkbox methods
 
* [[ToggleBox]]: The togglebox is like a button, but can stay down. Use with the checkbox methods
 
* [[TrackBar]]: The trackbar class is a slider you can drag arround and read/set the state
 
* [[TrackBar]]: The trackbar class is a slider you can drag arround and read/set the state
 +
* [[TreeNode]]:
 +
* [[TreeNodes]]:
 +
* [[Treeview]]:
 
* [[Wincontrol]]: Base class for controls which can contain other controls.
 
* [[Wincontrol]]: Base class for controls which can contain other controls.
 +
* [[xmplayer]]:
  
  
Line 430: Line 588:
 
* [[setProperty]] : Sets the value of a published property of a class (Won't work for method properties)
 
* [[setProperty]] : Sets the value of a published property of a class (Won't work for method properties)
 
* [[getProperty]] : Gets the value of a published property of a class (Won't work for method properties)
 
* [[getProperty]] : Gets the value of a published property of a class (Won't work for method properties)
 +
* [[setMethodProperty]]: Sets the method property to the specific function
 +
* [[getMethodProperty]]: Returns a function you can use to call the original function

Revision as of 03:30, 24 January 2018

Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.


Variables

Globals

  • TrainerOrigin: A variable that contains the path of the trainer that launched cheat engine (Only set when launched as a trainer)
  • process: A variable that contains the main modulename of the currently opened process
  • MainForm: The main ce gui
  • AddressList: The address list of the main ce gui

Variables

  • Debug Variables
    • EFLAGS
    • 32/64-bit: EAX, EBX, ECX, EDX, EDI, ESI, EBP, ESP, EIP
    • 64-bit only: RAX, RBX, RCX, RDX, RDI, RSI, RBP, RSP, RIP, R8, R9, R10, R11, R12, R13, R14, R15 : The value of the register


Functions

Cheat table

These functions help manage the cheat table.


Trainers


Protection

  • activateProtection: Prevents basic memory scanners from opening the cheat engine process
  • enableDRM: Prevents normal memory scanners from reading the Cheat Engine process (kernelmode)
  • encodeFunction: Converts a given function into an encoded string that you can pass on to decodeFunction
  • decodeFunction: Converts an encoded string back into a function


Scanning

These functions control Cheat Engine's scanning.


Process


Threads

  • getCPUCount: Returns the number of CPU's
  • getThreadlist: Fills a List object with the threadlist of the currently opened process
  • inMainThread: Returns true if the current code is running inside the main thread (6.4+)
  • synchronize: Calls the given function from the main thread. Returns the return value of the given function
  • queue: Calls the given function from the main thread. Does not wait for the result
  • checkSynchronize: Call this from an infinite loop in the main thread when using threading and synchronize calls


Handles

  • getHandleList: Returns a table with all the handles in the system


Addresses

These functions help convert between memory addresses and symbols/CEAddressStrings.


Memory


These functions read/write memory from the opened process.

Reading

  • readBytes: Returns the bytes at the given address. If ReturnAsTable is true it will return a table instead of multiple bytes
  • readSmallInteger: Reads a 16-bit integer from the specified address.
  • readInteger: Reads a 32-bit integer from the specified address.
  • readQword: Reads a 64-bit integer from the specified address.
  • readPointer: In a 64-bit target this equals readQword, in a 32-bit target readInteger().
  • readFloat: Reads a single precision floating point value from the specified address
  • readDouble: Reads a double precision floating point value from the specified address
  • readString: Reads a string from memory until it hits a 0-terminator. maxlength is just so you won't freeze for too long
  • readRegionFromFile: Writes the given file to a specific address


Writing

  • writeBytes: Write the given bytes to the given address from a table
  • writeSmallInteger: Writes a 16-bit integer to the specified address. Returns true on success.
  • writeInteger: Writes a 32-bit integer to the specified address. Returns true on success.
  • writeQword: Write a 64-bit integer to the specified address. Returns true on success.
  • writeFloat: Writes a single precision floating point to the specified address. Returns true on success.
  • writeDouble: Writes a double precision floating point to the specified address. Returns true on success.
  • writeString: Write a string to the specified address. Returns true on success.
  • writeRegionToFile: Writes the given region to a file. Returns the number of bytes written.
  • writeSmallIntegerLocal: Writes a 16-bit integer to the specified address in CE's memory. Returns true on success
  • writeIntegerLocal: Writes a 32-bit integer to the specified address in CE's memory. Returns true on success
  • writeQwordLocal: Writes a 64-bit integer to the specified address in CE's memory. Returns true on success
  • writeFloatLocal: Writes a single precision floating point to the specified address in CE's memory. Returns true on success
  • writeDoubleLocal: Writes a double precision floating point to the specified address in CE's memory. Returns true on success
  • writeStringLocal: Write a string to the specified address. Returns true on success.
  • writeBytesLocal: See writeBytes but then it's for Cheat Engine's memory

Convertions

To Byte Table

From Byte Table


Binary

bOr: Binary Or bXor: Binary Xor bAnd: Binary And bShl: Binary shift left bShr: Binary shift right bNot: Binary not


Input devices

These functions get/set keyboard/mouse input.

Game Controller

Clipboard


Screen


Sounds

xmplayer


Text to Speech


Fonts


Forms and Windows


Cheat Engine

These functions help manage Cheat Engine itself.

Forms

Messages

Input

  • inputQuery: Shows a dialog where the user can input a string. This function returns the given string, or nil on cancel (CE6.4+)

Shortcuts

  • shortCutToText: Returns the textual representation of the given shortcut value (integer) (6.4+)
  • textToShortCut: Returns an shortcut integer that the given string represents. (6.4+)
  • convertKeyComboToString: Returns a string representation of the given keys like the hot-key handler does

Speed Hack


Lua

These functions help manage Lua itself.

  • resetLuaState: This will create a new Lua state that will be used.
  • sleep: Pauses for the number of specified milliseconds
  • createRef: Integer - Returns an integer reference that you can use with getRef
  • getRef: Returns whatever the reference points out
  • destroyRef: Removes the reference


Types

These functions help structure a process's memory into datatypes.


Object-oriented

These functions determine how a Lua object fits in the class hierarchy.


Assembly

These functions help work with the x86 machine code as assembly.

  • autoAssemble: Runs the auto assembler with the given text
  • autoAssembleCheck: Checks the script for syntax errors. Returns true on succes, false with an error message on failure
  • disassemble: Disassembles the given address and returns a string in the format of "address - bytes - opcode extra"
  • splitDisassembledString: Returns 4 strings. The address, bytes, opcode and extra field
  • getInstructionSize: Returns the size of an instruction
  • getPreviousOpcode: Returns the address of the previous opcode (guess)
  • registerAssembler: Registers a function to be called when the single line assembler is invoked to convert an instruction to a list of bytes
  • unregisterAssembler: Unregisters the registered assembler


Auto Assembler


Scripts


Debugger

These functions manage the debugger. See Lua Debugging.


DBK


DBVM


Translation

  • getTranslationFolder: Returns the path of the current translation files, empty if there is no translation going on
  • loadPOFile: Loads a ".PO" file used for translation
  • translate: Returns a translation of the string, returns the same string if it can't be found
  • translateID: Returns a translation of the string ID


Files

  • getFileVersion: Returns the 64-bit file version, and a table that has split up the file version into major, minor, release and build
  • getFileList: Returns an indexed table with filenames
  • getDirectoryList: Returns an indexed table with directory names


Structures


Miscellaneous


Classes

Besides the above functions, Cheat Engine also implements some classes.

  • Addresslist: The addresslist class is a container for memory records
  • Bitmap: Bitmap based Graphic object
  • Brush: The brush class is part of the Canvas object. It's used to fill surfaces
  • Button: The button class is a visual component in the shape of a button.
  • ButtonControl: Common ancestor of several button like objects.
  • Canvas: The canvas class is a graphical class. It allows you do draw lines, pictures, and text on top of other object. Usually used in onPaint events and other graphical events
  • Calendar:
  • CEForm:
  • CheatComponent: The cheatcomponent class is the component used in Cheat Engine 5.x trainers
  • CheckBox: The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed
  • Component : Base class for all components that need owner-owned functionality.
  • Control : Base class for visible controls.
  • Collection: The Collection class is an abstract class that the ListColumns class implements (And perhaps other classes as well)
  • CollectionItem: Basic object that is managed by a Collection class
  • ComboBox: The Combobox is like an edit field with a ListBox attached to it
  • CriticalSection:
  • CustomControl: Base class for windowed controls which paint themselves
  • CustomType: The custom type is an convertor of raw data, to a human readable interpretation.
  • D3DHOOK: The d3dhook functions provide a method to render graphics and text inside the game, as long as it is running in directx9, 10 or 11
  • D3DHook_FontMap: A fontmap is a texture that contains extra data regarding the characters
  • D3DHook_Texture: This class controls the texture in memory. Without a sprite to use it, it won't show
  • D3Dhook_TextContainer: A d3dhook_sprite class draws a piece of text on the screen based on the used fontmap
  • D3DHook_RenderObject: The renderobject is the abstract class used to control in what manner objects are rendered.
  • D3DHook_Sprite: A d3dhook_sprite class is a visible texture on the screen
  • Disassembler:
  • Disassemblerview: The visual disassembler used in the memory view window
  • DisassemblerviewLine:
  • DissectCode:
  • Edit: The Edit class is a visual component that lets the user type in data (Use control_getCaption to get the user input)
  • Event:
  • FileStream: The FileStream class is a Stream class that is linked to an open file on disk
  • FileDialog:
  • FindDialog:
  • Font: Class that defines a font
  • Form: Class that defines a window
  • FoundList: The foundlist is an companion class to MemScan. It opens the current memscan's result file and provides an interface for reading out the addresses
  • GenericHotkey: Lets you register hotkeys to Cheat Engine's internal hotkey handler
  • Graphic: Base class for dealing with Graphic images (Abstract)
  • GraphicControl: Class that supports simple lightweight controls that do not need the ability to accept keyboard input or contain other controls.
  • GroupBox: The groupbox class is like a Panel, but then has a header on top
  • Hexadecimal: The visual hexadecimal object used on the memory view window
  • Hexadecimalview: The visual hexadecimal object used on the memory view window
  • Icon:
  • Image: The Image class is a visual component that lets you show an image
  • Internet:
  • JpegImage:
  • Label: The Label class is a visual component that lets you display text
  • LuaPipe: Abstract class that LuaPipeServer and LuaPipeclient inherit from
  • LuaPipeClient: Class implementing a client that connects to a pipe
  • LuaPipeServer: Class launching the server side of a pipe
  • ListBox: The listbox class is a visual component with a list of selectable strings
  • ListColumn: The listcolumn class is an implemented CollectionItem class which is used by the ListColumns class of the listview class
  • ListColumns: The ListColumns class contains the Column class objects of a ListView object
  • ListItem: The ListItem class object is an entry in a ListView
  • ListItems: The listItems class is a container for the ListItem class objects of a Listview
  • Listview: The listview class lets you have a listbox like component with resizable columns
  • MainMenu: The menu at the top of a form
  • Memo: The Memo class is a multiline edit field
  • MemScan: The memscan class is the memory scanner of Cheat engine
  • Menu: Common Class ancestor for the MainMenu and PopupMenu classes
  • MenuItem: Holds the menuitems of a Menu, PopupMenu or even another MenuItem
  • MemoryRecord: The Memoryrecord class object describes a Cheat Table's Cheat Entry.
  • MemoryRecordHotkey: The memoryRecordHotkey class object is part of a MemoryRecord class. It's used as an interface to each individual hotkey inside a Cheat Table
  • MemoryStream: The memorystream class is a Stream class that is stored completely in memory. Because it's a stream there are multiple functions that can work with it
  • Memoryview: The memoryview class is the Memory view window of Cheat Engine. Use this as a basis to access the objects inside this window
  • MultiReadExclusiveWriteSynchronizer:
  • Object: Most basic class. All classes inherit from this class
  • PaintBox:
  • Pagecontrol: This is an object that can hold multiple pages
  • Panel: The Panel class is like a form which can contain visual components.
  • Pen: The Pen class is part of the Canvas object. It's used to draw lines
  • Picture: Container for the Graphic class
  • PopupMenu: The menu that shows when rightclicking on an object
  • PortableNetworkGraphic:
  • ProgressBar: The progressbar class is a visual representation for a bar that can show the current progress on something
  • RadioGroup: The radiogroup is like a GroupBox but autopopulated using the Items(Strings object)
  • RasterImage: Base class for some graphical controls
  • RIPRelativeScanner:
  • OpenDialog: The OpenDialog class is used for selecting files to open.
  • SaveDialog: The SaveDialog class is based on the OpenDialog class but is used to select a file for saving
  • SelectDirectoryDialog:
  • Semaphore:
  • Settings: This class can be used to read out and set settings of cheat engine and of plugins, and store your own data
  • Splitter: The Splitter class is a visual component that lets the user re-size neighboring components)
  • Stringlist: Class that holds a list of strings
  • Strings: Abstract class that some text based classes make use of
  • StringStream:
  • Structure:
  • StructureElement:
  • StructureFrm:
  • structGroup:
  • SymbolList: This class can be used to look up an address to a symbolname, and a symbolname to an address
  • TabSheet: Part of a page control
  • TableFile: Tablefiles are files stored into a Cheat Table. You can access the data of such a file using this class
  • Thread:
  • Timer: The timer class is an non visual component that when active triggers an onTimer event every few milliseconds, based on the given interval
  • ToggleBox: The togglebox is like a button, but can stay down. Use with the checkbox methods
  • TrackBar: The trackbar class is a slider you can drag arround and read/set the state
  • TreeNode:
  • TreeNodes:
  • Treeview:
  • Wincontrol: Base class for controls which can contain other controls.
  • xmplayer:


Class Helper Functions

Undefined Class Property Functions

Not all properties of all classes have been explicitly exposed to lua, but if you know the name of a property of a specific class you can still access them (assuming they are declared as published in the pascal class declaration)

  • getPropertyList : Returns a StringList object containing all the published properties of the specified class
  • setProperty : Sets the value of a published property of a class (Won't work for method properties)
  • getProperty : Gets the value of a published property of a class (Won't work for method properties)
  • setMethodProperty: Sets the method property to the specific function
  • getMethodProperty: Returns a function you can use to call the original function