Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


I2 CE Lua Script Template Generator

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions
View previous topic :: View next topic  
Author Message
TheyCallMeTim13
Wiki Contributor
Reputation: 4

Joined: 24 Feb 2017
Posts: 36
Location: Right Here Buddy.

PostPosted: Fri Mar 03, 2017 10:46 pm    Post subject: I2 CE Lua Script Template Generator Reply with quote


I2 CE Lua Script Template Generator



A Lua file template system.



Version: 1.0.1



Forked Version of:

"Custom Lua Script Templates.lua":
Author: predprey
http://forum.cheatengine.org/viewtopic.php?t=595096

I feel like credit should go to the entire forum. I have been visiting for years and have learned a lot.
So to all thous who answer posts and help out in general. Thank you for being awesome!

Link: http://www.mediafire.com/file/uuzynmrvu2p261e/pluginI2CELuaScriptTemplateGenerator.lua

Basically a trimmed down version of "pluginI2CEAutoAssemblerScriptTemplateGenerator.lua" tailored for lua templates.

The Doc String.
Code:

--[====================================================================================================================[

I2 Cheat Engine Lua Script Template Generator

   Version: 1.0.1

   Author: Matt - TheyCallMeTim13 - MattI2.com

   Forked Version of:
      "Custom Lua Script Templates.lua":
         Author: predprey


   Features:
      - Allows for adding templates as tables or in a directory structure.

         - Load templates function can be called multiple time to allow for standard and game specific templates.

         - Template table structure sets the menu item structure created.

      - Generic place holder key replacement though standard input forms.

      - Gets the file version of the process's executable, for use in templates.



   For the default templates see:
      - CE Form >> Ctrl+M >> Ctrl+A >> Menu >> Templates >> I2 CEA Templates


   To add templates use:
      local TemplatesTable = {
          ...
      }
      I2CELuaScriptTemplates.loadTemplates(TemplatesTable)



   To add templates from a directory:
      I2CELuaScriptTemplates.loadTemplatesDirectory([[x:\SomeOddDirectory]])



   Install / Setup Method 1:
      - Put file in CE autorun folder, run Cheat engine.
      
   Install / Setup Method 2:
      - Put in CE lua folder (it isn't created by default).
         And in a file in the CE autorun folder import and add tables.

      Example:
         local TemplatesTable = {
             ...
         }

         local I2CELSTG = require 'pluginI2CELuaScriptTemplateGenerator'
         ---- You could rename the file if you go this route.
         I2CELSTG.loadTemplates(TemplatesTable)



   Notes:
      - Has a translation function that just returns the string back,
         I want to look into translation setup for CE / Lua.
               * See: 'TODO: Look into translation setup for CE.' / 'local function t(tanslationStr)'
               
      - For some reason when using from an address list script the script will not get added to the form's text edit.
         ** Must use memory records to have added to address list for now (still figuring this out.)
            But only happens with address list scripts.



   Settings:

      UserNameEnvKey         : string - Environment variable key for user name.
                           i.e.: 'CE_USERNAME' or 'HEYBUDDYWHATSTHENAME'
      UserName            : string - Used for overriding the system's user name from environment ('USERNAME').
               ** See 'Environment Variable Keys' to override that way.

      DateFormat            : string - Lua date format string.

      AddMainSeperator      : boolean - Set to true to have a separator added to the menu before adding
                           template menu items.

      PlaceHolderKey         : string - The Place holder key used in templates for generic replacement prompts.
               ** See: 'Template Place Holders' for more info.

      AutoLoad            : boolean - Set to false to stop auto loading of templates.
      TemplatesDirectory      : string - The templates directory to use.
**               *** Template files use a unique format, (my change to template files matched with json files for
                  settings) so this should be in a unique spot (IT CAN CLASH with other template generators
                  if in same folder).


   Template Options:  Table of settings for template generating.
      Required Options:
         DisplayString         : string - The menu display string.

      Bound Required Options: One or the other.
         *   TemplateString      : string - The template string to use.
            TemplateFile      : string - The file path of the template.
               *** Do not use multi extension files. (still figuring this one out)
                     i.e.: 'AOB_Injection.template.cea'
                  Instead try:
                     'AOB_Injection-template.cea '

      Name                  : string - The name of the template.
               *** Used in menu item creation, also in injection information and logging.

      LineEnd                  : string - The line end string. (i.e.: '\n' or '\r\n')

      Example Table:
         Templates = {
            Name = 'I2CELTemplates',
            SectionDisplayString = 'I2 Lua Templates',
            SectionName = 'miI2CELTemplatesSection',
            {
               Name = 'I2CEL_Header',
               DisplayString = 'Header',
               TemplateString = I2_TEMPLATE_HEADER,
            },
            '-----', ---- SEPERATOR
            {
               Name = 'I2CEL_Timer',
               DisplayString = 'Timer',
               TemplateString = I2_TEMPLATE_TIMER,
            },
            {
               Name = 'I2CEL_BreakPoint',
               DisplayString = 'Break Point',
               TemplateString = I2_TEMPLATE_BREAK_POINT,
            },
            {
               Name = 'I2CEL_Hotkey',
               DisplayString = 'Hot-key',
               TemplateString = I2_TEMPLATE_HOTKEY,
            },
         }



   Template Keys:
         - Keys to be used in templates and memory record strings.
            format:
               ${TemplateKey}

      ProcessName            - The process name.
      ProcessAddress         - The process address.

      Module               - The address's module, if it is in a module.
      ModuleAddress         - The address's module address, if it is in a module.
      ModuleSize            - The address's module size, if it is in a module.
      ModuleBitSize         - The address's module bit size, if it is in a module.
                           i.e.: '(x32)' or '(x64)'
      ModuleStr            - Will be set to the word 'Module' if the address is in a module.
                           * Used with aob scan.
                              i.e.: 'aobScan${ModuleStr}(...'
      ModuleDecl            - Will be set to the module name with a comma in front, if the address is in a module.
                           * Used with aob scans, and memory allocation.
                              i.e.: 'aobScan${ModuleStr}(SomeUserSymbol${ModuleDecl}, bytes)'
                              i.e.: 'alloc(SomeUserSymbol, 0x400${ModuleDecl})'

      Address               - The address, will be in module with offset format, if the address is in a module.
               * Pulled from disassembler view form selection.
      AddressHex            - The address in hex format, length is based on pointer size.

      Date               - The current date.
      Author               - The detected user name.
               *** Set global 'CE_USERNAME', or environment variable 'CE_USERNAME', to override
                        the windows user name.

      CEVersion            - Cheat Engine's version.
      PointerSize            - The processes pointer size.
                           i.e.: x32 PointerSize is 4 and x64 PointerSize is 8.
      PointerFtmStr         - The processes pointer format string. (for lua use in templates)
                           i.e.: x32 PointerFtmStr is '%08X' and x64 PointerFtmStr is '%016X'.
      PointerWordSize         - The processes pointer declaration word.
                           i.e.: x32 PointerWordSize is 'dd' and x64 PointerWordSize is 'dq'.
      PointerDefault         - The processes pointer declaration with integer 0 value.
                           i.e.: x32 PointerWordSize is 'dd 0' and x64 PointerWordSize is 'dq 0'.
      PointerDefaultFull      - The processes pointer declaration with hex 0 value.
                           i.e.: x32 PointerDefaultFull is 'dd 00000000' and
                                 x64 PointerDefaultFull is 'dq 0000000000000000'.
      GameTitle            - The game title. (See: 'Global Variables' for overriding process based value)
      GameVersion            - The game version. (See: 'Global Variables' for overriding determined value)

      BaseAddressRegistry      - Registry pulled form original code of the first line (uses lua matching).
      BaseAddressOffset      - Offset for registry pulled form original code of the first line (uses lua matching).
               * Looks for most instructions followed by brackets with a registry and offset. Kinda works!
                        i.e.: mov eax,[rsi+10]
                           BaseAddressRegistry will be 'rsi'
                           BaseAddressOffset will be '10'



   Template Place Holders:
      - User will be prompted for replacement of key words, every thing after place holder key.
         * Key words are striped of underscores and title cased before prompt.
            i.e.:
               PlaceHolder_Some_Value  ->  "Some Value"
               PlaceHolder_the_ultimate_question  ->  "The Ultimate Question"

      Key Start:
         PlaceHolder_

      Example:
         local aTimer = nil
         local aTimerInterval = ${PlaceHolder_Timer_Interval}
         local aTimerTicks = 0
         local aTimerTickMax = ${PlaceHolder_Timer_Tick_Max}
         local function aTimer_tick(timer)
            if aTimerTickMax > 0 and aTimerTicks >= aTimerTickMax then
               timer.destroy()
            end
            aTimerTicks = aTimerTicks + 1
            -- body
         end
         aTimer = createTimer(getMainForm(), false)
         aTimer.Interval = aTimerInterval
         aTimer.OnTimer = aTimer_tick
         aTimer.Enabled = true



   Templates:
      Key Format:
         ${TemplateKey}

      Example:
         local autoAttachTimer = nil
         local autoAttachTimerInterval = 100
         local autoAttachTimerTicks = 0
         local autoAttachTimerTickMax = 5000

         local function autoAttachTimer_tick(timer)
            if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
               timer.destroy()
            end
            if getProcessIDFromProcessName('${ProcessName}') ~= nil then
               timer.destroy()
               openProcess('${ProcessName}')
            end
            autoAttachTimerTicks = autoAttachTimerTicks + 1
         end

         autoAttachTimer = createTimer(getMainForm())
         autoAttachTimer.Interval = autoAttachTimerInterval
         autoAttachTimer.OnTimer = autoAttachTimer_tick



   Template Files:
      - Template files can be just a lua file or they can have a settings and template section
**         *** Must be just a lua file, or have '[SETTINGS]' then '[TEMPLATE]' section in that order.
            i.e.:
               |      Good   |      Good   |      Good   |      Bad      |
               |---------------|---------------|---------------|---------------|
               |   [SETTINGS]   |   [TEMPLATE]   |   ...         |   [TEMPLATE]   |
               |   ...         |   ...         |   ...         |   ...         |
               |   [TEMPLATE]   |   ...         |   ...         |   [SETTINGS]   |
               |   ...         |   ...         |   ...         |   ...         |
               |---------------|---------------|---------------|---------------|


      Lua Files:
         - The standard lua format with templates keys, caption add menu section will be determinate by
            file name and directory.
               i.e.: 'some_template.lua'  ->  'Some Template' - (Templates Menu)
               i.e.: 'some_section\some_template.lua'  ->  'Some Template' - 'Some Section' (miSomeSection)

      Settings:
         - Only allows basic setting (no nested settings at this point ?? json).
**         *** Settings and template section keys must be the only thing on that line.

      Template:
         - The template to use (reads to end of file).
**         *** Template and settings section keys must be the only thing on that line.

      Example:
         [SETTINGS]
            DisplayString = 'Some Template'
         [TEMPLATE]
            print('I Have The Power!!')



   Global Variables:
      GAME_TITLE         - The game title.
                  * If not set process name with out extension will be used.
                  ** Manually set in table lua files, if needed.
      GAME_VERSION      - The game version.
                  * If not set value from 'getFileVersion' on the first module will be used.
                  ** Manually set in table lua files, if needed.
      Global Variables (Overridden by Settings):
         [[ global                         - setting ]]
         CE_USERNAME                        - UserName
         I2CELSTG_AUTO_LOAD                  - AutoLoad
         I2CELSTG_TEMPLATES_DIRECTORY         - TemplatesDirectory
      Global Variables (Overridden by Template Options):
         [[ global                         - template option ]]
         I2CELSTG_LINE_END                  - LineEnd
      


   Environment Variable Keys: (Overridden by global variables)
      CE_USERNAME         - The name used for 'Author' template key.



]====================================================================================================================]--



Link: http://www.mediafire.com/file/uuzynmrvu2p261e/pluginI2CELuaScriptTemplateGenerator.lua



pluginI2CELuaScriptTemplateGenerator.lua
 Description:
I2 CE Lua Script Template Generator

Download
 Filename:  pluginI2CELuaScriptTemplateGenerator.lua
 Filesize:  43.14 KB
 Downloaded:  272 Time(s)


_________________
- Code Happy, Code Freely, Be Awesome.


Last edited by TheyCallMeTim13 on Wed Mar 15, 2017 12:30 pm; edited 5 times in total
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 15

Joined: 08 Oct 2015
Posts: 366

PostPosted: Sat Mar 04, 2017 8:52 am    Post subject: Reply with quote

you have some damn fine documentations, looks so much more professional. i'm feeling like a scriptkiddie here Embarassed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites