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 Cheat Engine Auto Assembler 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: Thu Mar 02, 2017 1:14 am    Post subject: I2 Cheat Engine Auto Assembler Script Template Generator This post has 3 review(s) Reply with quote


I2 CE Auto Assembler Script Template Generator



A CEA file template system and memory record creator.



Version: 1.0.3



Forked Version of:

"customAOBInjectionTemplates.lua":
Author: mgr.inz.Player
http://forum.cheatengine.org/viewtopic.php?t=588038
"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!

And what can I say about Cheat Engine, countless hours of good times because it exists (freely).

Link: http://www.mediafire.com/file/h6h17nvt188o1ea/pluginI2CEAutoAssemblerScriptTemplateGenerator.lua

The Doc String.
Code:

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

I2 Cheat Engine Auto Assembler Script Template Generator.
    And memory record creator.
   
    Version: 1.0.3

    Author: Matt - TheyCallMeTim13 - MattI2.com

    Forked Version of:
        "customAOBInjectionTemplates.lua":
            Author: mgr.inz.Player
        "Custom Lua Script Templates.lua":
            Author: predprey


    Features:
        - A Lot of Settings, see doc string below.

        - 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.

            - Allows for template tables to have memory records generated along with the template script.

                - Memory record string settings are parsed for template keys.

            - Template table structure sets the menu item structure created.

        - Generic place holder key replacement though standard input forms.

        - A Standard header can be set for use in templates.

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

        - Set the amount of data collected and put in injection information.


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


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



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



    Install / Setup Method 1:
        - Put file in CE autorun folder.

    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 I2CEAASTG = require 'pluginI2CEAutoAssemblerScriptTemplateGenerator'
            ---- You could rename the file if you go this route.
            I2CEAASTG.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.

        InjectionInfoCount      : integer - The number of lines before and after injection point in injection info.
                                    i.e.: 10 will generate 21 lines of disassembler output.
                                            10 before (addresses less then injection address)
                                            1 injection point
                                            10 after (addresses greater then injection address)

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

        AOBSignatureMin         : integer - The minimum number of bytes for AOB signatures.
        AOBSignatureScanMax     : integer - The maximum number of instruction lines to read for a unique AOB signature.

        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).
        NopASM                  : string - ASM for nops.
                                    i.e.: 'nop' or 'Nop' or 'nop //// No Operation'
                    * There is a separate template key for nops as data bytes. (i.e.: 'db 90 90 90')



    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.

        GetAddress                  : boolean - Set to true to be prompted for an address.
                    * Address is pulled from disassembler view form selection. So this is a formality.

        IsFullHook                  : boolean - Set to true to have no less then 5 bytes for a full jump.

        GetHookName                 : boolean - Set to true to be prompted for a hook name.
                    * All template hook keys will be empty strings if not set to true.
        HookTag                     : string - The tag to use for prompts.
                                        i.e.: 'Hook', 'Hack', 'Cheat', 'Exploit', or what have you.
        AppendHookTag               : boolean - Set to true to have the hook tag appended to the hook name.
                                                    Unless the hook tag is already in the hook name.
        FixInputData                : boolean - Set to true to fix sloppy input data.
                    * Only affects hook name.
                    * Title cases and removes spaces from input.

        GetAOBSignature             : boolean - Set to true to have an aob signature generated.

        Memory Records:             : table - Table of settings for generating template memory records
                                                to add to cheat table.
                    * See: 'Template Memory Records'

        MemoryRecordsIncludeScript  : boolean - Set to true for prompt to say memory records include script.

        NopPaddingLeft              : string - The leading padding for nops lines.
                                        i.e.: '\t\t'
        OriginalCodePaddingLeft     : string - The leading padding for the original code lines.
                                        i.e.: '\t\t'

        LineEnd                     : string - The line end string. (i.e.: '\n' or '\r\n')
        LineComment                 : string - The line comment string. (i.e.: '////' or '//')
        InjectionInfoCommentType    : integer:CommentTypes : The injection info comment type.

        Example Table:
            Templates = {
                Name = 'I2CEATemplates',
                SectionDisplayString = 'I2 CEA Templates',
                SectionName = 'miI2CEATemplatesSection',
                {
                    DisplayString = 'Address Injection',
                    GetAddress = true,
                    GetHookName = true,
                    HookTag = 'Cheat',
                    AppendHookTag = true,
                    TemplateString = I2_TEMPLATE_ADDRESS_INJECTION,
                    MemoryRecordsIncludeScript = true,
                    MemoryRecords = {
                        {
                            Description = '${HookName}  ()->',
                            Type = vtAutoAssembler,
                            Color = Colors.Teal,
                        },
                        {
                            Description = '_[==  ${HookName}  ==]_',
                            IsGroupHeader = true,
                            MemoryRecords = {
                                {
                                    Description = 'inj${HookNameParsed}',
                                    Address = 'inj${HookNameParsed}',
                                    Color = Colors.Red,
                                    Type = vtByteArray,
                                    Aob = {
                                        Size = 0,
                                    },
                                    ShowAsHex = true,
                                },
                            },
                        }, 
                    },
                },
            }



    Template Memory Records:  Table of settings for memory record generating.
        ID                          : integer - Unique ID
        Description                 : string - The description of the memory record
        Address                     : string - The interpretable address string.
        OffsetCount                 : integer - The number of offsets. Set to 0 for a normal address
        Offset[]                    : array - integer - Array to access each offset
        OffsetText[]                : array - string - Array to access each offset using the interpretable text style

        Type                        : ValueType - The variable type of this record. See vtByte to vtCustom
**                  *** Set to 'pointer' for a type value of vtQword or vtDword based on pointer size.
                            i.e.: Type = 'POINTER',

        *  If the type is vtString then the following properties are available:
            String                  : table - Table with key value pairs.
                Size                : integer - Number of characters in the string
                Unicode             : boolean

        *  If the type is vtBinary then the following properties are available
            Binary                  : table - Table with key value pairs.
                Startbit            : integer - First bit to start reading from
                Size                : integer - Number of bits

        *  If the type is vtByteArray then the following properties are available
            Aob                     : table - Table with key value pairs.
                Size                : integer - Number of bytes

        Script                      : String - If the type is vtAutoAssembler this will contain the auto assembler script
**              *** If the type is vtAutoAssembler and no script is set the parsed template will be used.

        CustomTypeName              : string - If the type is vtCustomType this will contain the name of the CustomType

        Value                       : string - The value in string form.
        Active                      : boolean - Set to true to activate/freeze, false to deactivate/unfreeze
        Color                       : integer
        ShowAsHex                   : boolean - Self explanatory
        ShowAsSigned                : boolean - Self explanatory
        AllowIncrease               : boolean - Allow value increasing, unfreeze will reset it to false
        AllowDecrease               : boolean - Allow value decreasing, unfreeze will reset it to false
        Collapsed                   : boolean - Set to true to collapse this record or false to expand it.
                                                Use expand/collapse methods for recursive operations.

        HotkeyCount                 : integer - Number of hot-keys attached to this memory record
        Hotkey[]                    : array - Array to index the hot-keys

        DontSave                    : boolean - Don't save this memoryrecord and it's children

        OnActivate                  : function(memoryrecord, before, currentstate)
                                        : boolean - The function to call when the memoryrecord will change
                                            (or changed) Active to true. If before is true, not returning true
                                            will cause the activation to stop.
        OnDeactivate                : function(memoryrecord, before, currentstate)
                                        : boolean - The function to call when the memoryrecord will change
                                            (or changed) Active to false. If before is true, not returning true
                                            will cause the deactivation to stop.
        OnDestroy                   : function()
                                        : Called when the memoryrecord is destroyed.

        Example Table:
            MemoryRecords = {
                {
                    Description = '_[==  ${HookName}  ==]_',
                    IsGroupHeader = true,
                    MemoryRecords = {
                        {
                            Description = 'inj${HookNameParsed}',
                            Address = 'inj${HookNameParsed}',
                            Color = Colors.Red,
                            Type = vtByteArray,
                            Aob = {
                                Size = 0,
                            },
                            ShowAsHex = true,
                        },
                    },
                },
                {
                    Description = 'flg${HookNameParsed}IsAssembled',
                    Address = 'flg${HookNameParsed}IsAssembled',
                    Color = Colors.Olive,
                    Type = vtByte,
                    DropDownList = {
                        Text = '0:Not Assembled\n1:Assembled\n',
                    },
                    DropDownReadOnly = true, ---- Disallow manual user input
                    DropDownDescriptionOnly = true, ---- Only show the description part
                    DisplayAsDropDownListItem = true, ---- Make the record display values like the dropdownlist
                },
                {
                    Description = 'inj${HookNameParsed}',
                    Address = 'inj${HookNameParsed}',
                    Color = Colors.Red,
                    Type = vtByteArray,
                    Aob = {
                        Size = 0,
                    },
                    ShowAsHex = true,
                },
            }



    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.

        HookTag                 - The hook tag word.
                                        i.e.: 'Hook', 'Hack', 'Cheat', 'Exploit', or what have you.
        HookName                - The, human readable, hook name.
                                        i.e.: 'Ammo DEC Hook', or 'Ammo DEC'
        HookNameBase            - The hook name with out the hook tag appended.
                    * Even if 'AppendHookTag' is set to 'true'.
                    * If 'AppendHookTag' is set to 'false' it will be the same as 'HookName'.
        HookNameParsed          - The, machine readable, hook name.
                                        i.e.: 'AmmoDECHook', or 'AmmoDEC'
        HookNameParsedBase          - The parsed hook name with out the hook tag appended.
                    * Even if 'AppendHookTag' is set to 'true'.
                    * If 'AppendHookTag' is set to 'false' it will be the same as 'HookNameParsed'.

        AOBBytes                - AOB byte signature string.
        AOBMessage              - Used if more then one match was found.
                    ** Adds a new line character if there is a message.
                                    i.e.: '\n// Matches Found: 25'

        OriginalCode            - The original code (pulled from disassembler view form)
        OriginalBytes           - The original bytes (pulled from disassembler view form)
        InstNOPS                - Nops matching the original number of bytes.
        InstNOP90S              - Nops, in data byte format, matching the original number of bytes.
                                    i.e.: 'db 90 90 90'
        NOPS                    - Used if nops are needed.
        NOP90S                  - Used if nops are needed.

        InjectionInfo           - The injection information collected (the commented out disassembler output).

        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_



    Templates:
        Key Format:
            ${TemplateKey}

        Example:
            ${Header}
            define(bytes, ${OriginalBytes})
            define(address, ${Address})
            ////
            //// ------------------------------ ENABLE ------------------------------
            [ENABLE]
            assert(address, bytes)
            ////
            //// ---------- Injection Point ----------
            address:
                ${InstNOPS}
            ////
            //// ------------------------------ DISABLE ------------------------------
            [DISABLE]
            ////
            //// ---------- Injection Point ----------
            address:
                db bytes
            ${InjectionInfo}



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


        CEA Files:
            - The standard CEA format with templates keys, caption add menu section will be determinate by
                file name and directory.
                    i.e.: 'some_template.cea'  ->  'Some Template' - (Templates Menu)
                    i.e.: 'some_section\some_template.cea'  ->  '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'
                GetAddress = true
                GetHookName = true
                GetAOBSignature = true
            [TEMPLATE]
                [ENABLE]
                    {$lua}
                    print('I Have The Power!!')
                [DISABLE]
                    {$lua}
                    print('Op, its gone.')



    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
            I2CEAASTG_AUTO_LOAD                     - AutoLoad
            I2CEAASTG_TEMPLATES_DIRECTORY           - TemplatesDirectory
            I2CEAASTG_NOP_ASM                       - NopASM
            I2CEAASTG_TEMPLATE_MARKER_LINE          - TemplateMarkerLine
            I2CEAASTG_HEADER                        - TemplateHeader
        Global Variables (Overridden by Template Options):
            [[ global                               - template option ]]
            I2CEAASTG_HOOK_TAG                      - HookTag
            I2CEAASTG_NOP_PADDING_LEFT              - NopPaddingLeft
            I2CEAASTG_ORIGINAL_CODE_PADDING_LEFT    - OriginalCodePaddingLeft
            I2CEAASTG_LINE_END                      - LineEnd
            I2CEAASTG_LINE_COMMENT                  - LineComment
            I2CEAASTG_INJ_INFO_COMMENT_TYPE         - InjectionInfoCommentType
       


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



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



So this template header:
Code:

{
    Process         : ${ProcessName}  -  ${ModuleBitSize}
    Module          : ${Module}  -  ${ModuleSize}
    Game Title      : ${GameTitle}
    Game Version    : ${GameVersion}
    CE Version      : ${CEVersion}
    Script Version  : 0.0.1
    Date            : ${Date}
    Author          : ${Author}
    Name            : ${HookNameParsed}

    ${HookName}
}



With this template:
Code:

${Header}

define(bytes, ${OriginalBytes})
define(address, ${Address})

globalAlloc(flg${HookNameParsed}IsAssembled, 0x1)



////
//// ------------------------------ ENABLE ------------------------------
[ENABLE]
aobScan${ModuleStr}(aob${HookNameParsed}${ModuleDecl}, ${AOBBytes})${AOBMessage}
registerSymbol(aob${HookNameParsed})
define(inj${HookNameParsed}, aob${HookNameParsed}+0)
assert(inj${HookNameParsed}, bytes)
registerSymbol(inj${HookNameParsed})

alloc(mem${HookNameParsed}, 0x400${ModuleDecl})
registerSymbol(mem${HookNameParsed})
label(mrk${HookNameParsed}MemSTART)
registerSymbol(mrk${HookNameParsed}MemSTART)
label(mrk${HookNameParsed}MemEND)
registerSymbol(mrk${HookNameParsed}MemEND)

label(ptr${HookNameParsed})
registerSymbol(ptr${HookNameParsed})


label(n_code)
label(o_code)
label(exit)
label(return)

mem${HookNameParsed}:
    padding 16

    ptr${HookNameParsed}:
        ${PointerDefault}

    padding 16
    mrk${HookNameParsed}MemSTART:

    n_code:
        //mov [ptr${HookNameParsed}],${BaseAddressRegistry}

    o_code:
${OriginalCode}

    exit:
        jmp return
    mrk${HookNameParsed}MemEND:



////
//// ---------- Injection Point ----------
inj${HookNameParsed}:
    jmp n_code${NOPS}
    return:



flg${HookNameParsed}IsAssembled:
    db 01



////
//// ------------------------------ DISABLE ------------------------------
[DISABLE]
////
//// ---------- Injection Point ----------
inj${HookNameParsed}:
    db bytes


flg${HookNameParsed}IsAssembled:
    db 00


unregisterSymbol(aob${HookNameParsed})
unregisterSymbol(inj${HookNameParsed})

unregisterSymbol(ptr${HookNameParsed})

dealloc(mem${HookNameParsed})
unregisterSymbol(mem${HookNameParsed})
unregisterSymbol(mrk${HookNameParsed}MemSTART)
unregisterSymbol(mrk${HookNameParsed}MemEND)

${InjectionInfo}





Will output a script like this:
Code:
{
    Process         : Tutorial-x86_64.exe  -  (x64)
    Module          : Tutorial-x86_64.exe  -  00000000002D4000
    Game Title      : Cheat Engine Tutorial
    Game Version    : 3.3
    CE Version      : 6.6
    Script Version  : 0.0.1
    Date            : 03/02/17
    Author          : TheyCallMeTim13
    Name            : ExampleHook

    Example Hook
}


define(bytes, 48 8D 64 24 D8)
define(address, Tutorial-x86_64.exe+16450)

globalAlloc(flgExampleHookIsAssembled, 0x1)



////
//// ------------------------------ ENABLE ------------------------------
[ENABLE]
aobScanModule(aobExampleHook, Tutorial-x86_64.exe, 48 8D 64 24 D8 C6 05 14 34 18 00 00)
registerSymbol(aobExampleHook)
define(injExampleHook, aobExampleHook+0)
assert(injExampleHook, bytes)
registerSymbol(injExampleHook)

alloc(memExampleHook, 0x400, Tutorial-x86_64.exe)
registerSymbol(memExampleHook)
label(mrkExampleHookMemSTART)
registerSymbol(mrkExampleHookMemSTART)
label(mrkExampleHookMemEND)
registerSymbol(mrkExampleHookMemEND)

label(ptrExampleHook)
registerSymbol(ptrExampleHook)


label(n_code)
label(o_code)
label(exit)
label(return)

memExampleHook:
    padding 16

    ptrExampleHook:
        dq 0

    padding 16
    mrkExampleHookMemSTART:

    n_code:
        //mov [ptrExampleHook],rsp

    o_code:
        lea rsp,[rsp-28]

    exit:
        jmp return
    mrkExampleHookMemEND:



////
//// ---------- Injection Point ----------
injExampleHook:
    jmp n_code
    return:



flgExampleHookIsAssembled:
    db 01



////
//// ------------------------------ DISABLE ------------------------------
[DISABLE]
////
//// ---------- Injection Point ----------
injExampleHook:
    db bytes


flgExampleHookIsAssembled:
    db 00


unregisterSymbol(aobExampleHook)
unregisterSymbol(injExampleHook)

unregisterSymbol(ptrExampleHook)

dealloc(memExampleHook)
unregisterSymbol(memExampleHook)
unregisterSymbol(mrkExampleHookMemSTART)
unregisterSymbol(mrkExampleHookMemEND)

{
//// Injection Point: Tutorial-x86_64.exe+16450  -  0000000100016450
//// Process: Tutorial-x86_64.exe  -  0000000100000000
//// Module: Tutorial-x86_64.exe  -  0000000100000000
Tutorial-x86_64.exe+1641F:  FF D0                       -  call rax                           
Tutorial-x86_64.exe+16421:  41 83 C5 01                 -  add r13d,01                       
Tutorial-x86_64.exe+16425:  49 8B 46 38                 -  mov rax,[r14+38]                   
Tutorial-x86_64.exe+16429:  8B 00                       -  mov eax,[rax]                     
Tutorial-x86_64.exe+1642B:  44 39 E8                    -  cmp eax,r13d                       
Tutorial-x86_64.exe+1642E:  0F87 7CFFFFFF               -  ja 1000163B0                       
Tutorial-x86_64.exe+16434:  8B 54 24 50                 -  mov edx,[rsp+50]                   
Tutorial-x86_64.exe+16438:  89 D0                       -  mov eax,edx                       
Tutorial-x86_64.exe+1643A:  90                          -  nop                               
Tutorial-x86_64.exe+1643B:  48 8D 64 24 60              -  lea rsp,[rsp+60]                   
Tutorial-x86_64.exe+16440:  41 5F                       -  pop r15                           
Tutorial-x86_64.exe+16442:  41 5E                       -  pop r14                           
Tutorial-x86_64.exe+16444:  41 5D                       -  pop r13                           
Tutorial-x86_64.exe+16446:  41 5C                       -  pop r12                           
Tutorial-x86_64.exe+16448:  5E                          -  pop rsi                           
Tutorial-x86_64.exe+16449:  5F                          -  pop rdi                           
Tutorial-x86_64.exe+1644A:  5B                          -  pop rbx                           
Tutorial-x86_64.exe+1644B:  C3                          -  ret                               
Tutorial-x86_64.exe+1644C:  00 00                       -  add [rax],al                       
Tutorial-x86_64.exe+1644E:  00 00                       -  add [rax],al                       
////  INJECTING START  ----------------------------------------------------------
Tutorial-x86_64.exe+16450:  48 8D 64 24 D8              -  lea rsp,[rsp-28]                   
////  INJECTING END  ----------------------------------------------------------
Tutorial-x86_64.exe+16455:  C6 05 14341800 00           -  mov byte ptr [100199870],00       
Tutorial-x86_64.exe+1645C:  48 8D 05 AD1B2B00           -  lea rax,[1002C8010]                [00000000]
Tutorial-x86_64.exe+16463:  48 8D 05 961B2B00           -  lea rax,[1002C8000]                [00015980]
Tutorial-x86_64.exe+1646A:  48 8D 05 AF3F1800           -  lea rax,[10019A420]                [00000000]
Tutorial-x86_64.exe+16471:  E8 8AF6FFFF                 -  call 100015B00                     
Tutorial-x86_64.exe+16476:  90                          -  nop                               
Tutorial-x86_64.exe+16477:  48 8D 64 24 28              -  lea rsp,[rsp+28]                   
Tutorial-x86_64.exe+1647C:  C3                          -  ret                               
Tutorial-x86_64.exe+1647D:  00 00                       -  add [rax],al                       
Tutorial-x86_64.exe+1647F:  00 53 48                    -  add [rbx+48],dl                   
Tutorial-x86_64.exe+16482:  8D 64 24 E0                 -  lea esp,[rsp-20]                   
Tutorial-x86_64.exe+16486:  48 B9 0000000000000000      -  mov rcx,0000000000000000           
Tutorial-x86_64.exe+16490:  E8 2BACFEFF                 -  call 1000010C0                     [->kernel32.GetModuleHandleA]
Tutorial-x86_64.exe+16495:  48 89 C3                    -  mov rbx,rax                       
Tutorial-x86_64.exe+16498:  48 B9 0000000000000000      -  mov rcx,0000000000000000           
Tutorial-x86_64.exe+164A2:  E8 19ACFEFF                 -  call 1000010C0                     [->kernel32.GetModuleHandleA]
Tutorial-x86_64.exe+164A7:  48 63 40 3C                 -  movsxd  rax,dword ptr [rax+3C]     
Tutorial-x86_64.exe+164AB:  48 8D 04 03                 -  lea rax,[rbx+rax]                 
Tutorial-x86_64.exe+164AF:  48 8B 40 60                 -  mov rax,[rax+60]                   
Tutorial-x86_64.exe+164B3:  90                          -  nop                               
//// Template: I2CEA_AOBFullInjection
//// Generated with: I2 Cheat Engine Auto Assembler Script Template Generator
//// Code Happy, Code Freely, Be Awesome.
}



And this memory record table:
Code:

{
    Description = '${HookName}  ()->',
    Type = vtAutoAssembler,
    Color = Colors.Teal,
},
{
    Description = '_[==  ${HookName}  ==]_',
    IsGroupHeader = true,
    MemoryRecords = {
        {
            Description = 'flg${HookNameParsed}IsAssembled',
            Address = 'flg${HookNameParsed}IsAssembled',
            Color = Colors.Olive,
            Type = vtByte,
            DropDownList = {
                Text = '0:Not Assembled\n1:Assembled\n',
            },
            DropDownReadOnly = true, ---- Disallow manual user input
            DropDownDescriptionOnly = true, ---- Only show the description part
            DisplayAsDropDownListItem = true, ---- Make the record display values like the dropdownlist
        },
        {
            Description = 'inj${HookNameParsed}',
            Address = 'inj${HookNameParsed}',
            Color = Colors.Red,
            Type = vtByteArray,
            Aob = {
                Size = 0,
            },
            ShowAsHex = true,
        },
        {
            Description = 'mem${HookNameParsed}',
            Address = 'mem${HookNameParsed}',
            Color = Colors.Green,
            Type = vtByteArray,
            Aob = {
                Size = 0,
            },
            ShowAsHex = true,
            MemoryRecords = {
                {
                    Description = 'mrk${HookNameParsed}MemSTART',
                    Address = 'mrk${HookNameParsed}MemSTART',
                    Color = Colors.Green,
                    Type = vtByteArray,
                    Aob = {
                        Size = 0,
                    },
                    ShowAsHex = true,
                },
                {
                    Description = 'mrk${HookNameParsed}MemEND',
                    Address = 'mrk${HookNameParsed}MemEND',
                    Color = Colors.Green,
                    Type = vtByteArray,
                    Aob = {
                        Size = 0,
                    },
                    ShowAsHex = true,
                },
            },
        },
        {
            Description = '------------------------------------------------------------', 
            Color = Colors.Silver,
            IsGroupHeader = true,
        },
        {
            Description = 'ptr${HookNameParsed}',
            Address = 'ptr${HookNameParsed}',
            Color = Colors.Grey,
            Type = 'pointer',
            ShowAsHex = true,
        },
        {
            Description = '${HookNameParsedBase}  ()->',
            Type = vtAutoAssembler,
            Color = Colors.Teal,
            Script = "[ENABLE]\n{$lua}\nprint('I Have The Power!!')\n[DISABLE]\n{$lua}\nprint('Op. Its gone.')\n",
        },
    },
}





Will create memory records like this:
Code:

<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>53</ID>
      <Description>"Test Hook  ()-&gt;"</Description>
      <LastState/>
      <Color>808000</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{
    Process         : Tutorial-x86_64.exe  -  (x64)
    Module          : Tutorial-x86_64.exe  -  00000000002D4000
    Game Title      : Cheat Engine Tutorial
    Game Version    : 3.3
    CE Version      : 6.6
    Script Version  : 0.0.1
    Date            : 03/02/17
    Author          : TheyCallMeTim13
    Name            : TestHook

    Test Hook
}


define(bytes, 48 8D 64 24 D8)
define(address, Tutorial-x86_64.exe+16450)

globalAlloc(flgTestHookIsAssembled, 0x1)


////
//// ------------------------------ ENABLE ------------------------------
[ENABLE]
define(injTestHook, address+0)
assert(injTestHook, bytes)
registerSymbol(injTestHook)

alloc(memTestHook, 0x400, Tutorial-x86_64.exe)
registerSymbol(memTestHook)
label(mrkTestHookMemSTART)
registerSymbol(mrkTestHookMemSTART)
label(mrkTestHookMemEND)
registerSymbol(mrkTestHookMemEND)

label(ptrTestHook)
registerSymbol(ptrTestHook)


label(n_code)
label(o_code)
label(exit)
label(return)

memTestHook:
    padding 16

    ptrTestHook:
        dq 0

    padding 16
    mrkTestHookMemSTART:

    n_code:
        //mov [ptrTestHook],rsp

    o_code:
        lea rsp,[rsp-28]

    exit:
        jmp return
    mrkTestHookMemEND:



//// BaseAddressOffset: -28
//// ---------- Injection Point ----------
injTestHook:
    jmp n_code${NOPS}
    return:



flgTestHookIsAssembled:
    db 01



////
//// ------------------------------ DISABLE ------------------------------
[DISABLE]
////
//// ---------- Injection Point ----------
injTestHook:
    db bytes


flgTestHookIsAssembled:
    db 00


unregisterSymbol(injTestHook)

unregisterSymbol(ptrTestHook)

dealloc(memTestHook)
unregisterSymbol(memTestHook)
unregisterSymbol(mrkTestHookMemSTART)
unregisterSymbol(mrkTestHookMemEND)

{
//// Injection Point: Tutorial-x86_64.exe+16450  -  0000000100016450
//// Process: Tutorial-x86_64.exe  -  0000000100000000
//// Module: Tutorial-x86_64.exe  -  0000000100000000
Tutorial-x86_64.exe+1641F:  FF D0                       -  call rax                           
Tutorial-x86_64.exe+16421:  41 83 C5 01                 -  add r13d,01                       
Tutorial-x86_64.exe+16425:  49 8B 46 38                 -  mov rax,[r14+38]                   
Tutorial-x86_64.exe+16429:  8B 00                       -  mov eax,[rax]                     
Tutorial-x86_64.exe+1642B:  44 39 E8                    -  cmp eax,r13d                       
Tutorial-x86_64.exe+1642E:  0F87 7CFFFFFF               -  ja 1000163B0                       
Tutorial-x86_64.exe+16434:  8B 54 24 50                 -  mov edx,[rsp+50]                   
Tutorial-x86_64.exe+16438:  89 D0                       -  mov eax,edx                       
Tutorial-x86_64.exe+1643A:  90                          -  nop                               
Tutorial-x86_64.exe+1643B:  48 8D 64 24 60              -  lea rsp,[rsp+60]                   
Tutorial-x86_64.exe+16440:  41 5F                       -  pop r15                           
Tutorial-x86_64.exe+16442:  41 5E                       -  pop r14                           
Tutorial-x86_64.exe+16444:  41 5D                       -  pop r13                           
Tutorial-x86_64.exe+16446:  41 5C                       -  pop r12                           
Tutorial-x86_64.exe+16448:  5E                          -  pop rsi                           
Tutorial-x86_64.exe+16449:  5F                          -  pop rdi                           
Tutorial-x86_64.exe+1644A:  5B                          -  pop rbx                           
Tutorial-x86_64.exe+1644B:  C3                          -  ret                               
Tutorial-x86_64.exe+1644C:  00 00                       -  add [rax],al                       
Tutorial-x86_64.exe+1644E:  00 00                       -  add [rax],al                       
////  INJECTING START  ----------------------------------------------------------
Tutorial-x86_64.exe+16450:  48 8D 64 24 D8              -  lea rsp,[rsp-28]                   
////  INJECTING END  ----------------------------------------------------------
Tutorial-x86_64.exe+16455:  C6 05 14341800 00           -  mov byte ptr [100199870],00       
Tutorial-x86_64.exe+1645C:  48 8D 05 AD1B2B00           -  lea rax,[1002C8010]                [00000000]
Tutorial-x86_64.exe+16463:  48 8D 05 961B2B00           -  lea rax,[1002C8000]                [00015980]
Tutorial-x86_64.exe+1646A:  48 8D 05 AF3F1800           -  lea rax,[10019A420]                [00000000]
Tutorial-x86_64.exe+16471:  E8 8AF6FFFF                 -  call 100015B00                     
Tutorial-x86_64.exe+16476:  90                          -  nop                               
Tutorial-x86_64.exe+16477:  48 8D 64 24 28              -  lea rsp,[rsp+28]                   
Tutorial-x86_64.exe+1647C:  C3                          -  ret                               
Tutorial-x86_64.exe+1647D:  00 00                       -  add [rax],al                       
Tutorial-x86_64.exe+1647F:  00 53 48                    -  add [rbx+48],dl                   
Tutorial-x86_64.exe+16482:  8D 64 24 E0                 -  lea esp,[rsp-20]                   
Tutorial-x86_64.exe+16486:  48 B9 0000000000000000      -  mov rcx,0000000000000000           
Tutorial-x86_64.exe+16490:  E8 2BACFEFF                 -  call 1000010C0                     [-&gt;kernel32.GetModuleHandleA]
Tutorial-x86_64.exe+16495:  48 89 C3                    -  mov rbx,rax                       
Tutorial-x86_64.exe+16498:  48 B9 0000000000000000      -  mov rcx,0000000000000000           
Tutorial-x86_64.exe+164A2:  E8 19ACFEFF                 -  call 1000010C0                     [-&gt;kernel32.GetModuleHandleA]
Tutorial-x86_64.exe+164A7:  48 63 40 3C                 -  movsxd  rax,dword ptr [rax+3C]     
Tutorial-x86_64.exe+164AB:  48 8D 04 03                 -  lea rax,[rbx+rax]                 
Tutorial-x86_64.exe+164AF:  48 8B 40 60                 -  mov rax,[rax+60]                   
Tutorial-x86_64.exe+164B3:  90                          -  nop                               
//// Template: I2CEA_AddressFullInjection
//// Generated with: I2 Cheat Engine Auto Assembler Script Template Generator
//// Code Happy, Code Freely, Be Awesome.
}


</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>54</ID>
      <Description>"_[==  Test Hook  ===================================================================================]_"</Description>
      <LastState Value="" RealAddress="00000000"/>
      <GroupHeader>1</GroupHeader>
      <CheatEntries>
        <CheatEntry>
          <ID>55</ID>
          <Description>"flgTestHookIsAssembled"</Description>
          <DropDownList ReadOnly="1" DescriptionOnly="1" DisplayValueAsItem="1">0:Not Assembled
1:Assembled
</DropDownList>
          <Color>008080</Color>
          <VariableType>Byte</VariableType>
          <Address>flgTestHookIsAssembled</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>56</ID>
          <Description>"injTestHook"</Description>
          <LastState Value="" RealAddress="00000000"/>
          <ShowAsHex>1</ShowAsHex>
          <Color>0000FF</Color>
          <VariableType>Array of byte</VariableType>
          <ByteLength>0</ByteLength>
          <Address>injTestHook</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>57</ID>
          <Description>"memTestHook"</Description>
          <LastState Value="" RealAddress="00000000"/>
          <ShowAsHex>1</ShowAsHex>
          <Color>008000</Color>
          <VariableType>Array of byte</VariableType>
          <ByteLength>0</ByteLength>
          <Address>memTestHook</Address>
          <CheatEntries>
            <CheatEntry>
              <ID>58</ID>
              <Description>"mrkTestHookMemSTART"</Description>
              <LastState Value="" RealAddress="00000000"/>
              <ShowAsHex>1</ShowAsHex>
              <Color>008000</Color>
              <VariableType>Array of byte</VariableType>
              <ByteLength>0</ByteLength>
              <Address>mrkTestHookMemSTART</Address>
            </CheatEntry>
            <CheatEntry>
              <ID>59</ID>
              <Description>"mrkTestHookMemEND"</Description>
              <LastState Value="" RealAddress="00000000"/>
              <ShowAsHex>1</ShowAsHex>
              <Color>008000</Color>
              <VariableType>Array of byte</VariableType>
              <ByteLength>0</ByteLength>
              <Address>mrkTestHookMemEND</Address>
            </CheatEntry>
          </CheatEntries>
        </CheatEntry>
        <CheatEntry>
          <ID>60</ID>
          <Description>"---------------------------------------------------------------------------------------------------------"</Description>
          <LastState Value="" RealAddress="00000000"/>
          <Color>C0C0C0</Color>
          <GroupHeader>1</GroupHeader>
        </CheatEntry>
        <CheatEntry>
          <ID>61</ID>
          <Description>"ptrTestHook"</Description>
          <ShowAsHex>1</ShowAsHex>
          <Color>808080</Color>
          <VariableType>8 Bytes</VariableType>
          <Address>ptrTestHook</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
</CheatTable>





    Update 1.0.3:
  • fixed CE Trainer menu error.




Link: http://www.mediafire.com/file/h6h17nvt188o1ea/pluginI2CEAutoAssemblerScriptTemplateGenerator.lua

_________________
- Code Happy, Code Freely, Be Awesome.


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

Joined: 10 Apr 2015
Posts: 425

PostPosted: Wed Mar 08, 2017 10:36 pm    Post subject: Reply with quote

If make a CE trainer and then save the trainer as a CETRAINER,
when run the trainer give error as below :

Quote:
Error:...torun\pluginI2CEAutoAssemblerScriptTemplateGenerator.lua:2815: attempt to index a nil value (field 'Menu')


Please fix

Regards
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 4

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

PostPosted: Thu Mar 09, 2017 2:50 am    Post subject: Reply with quote

I updated the file with a fix that you can redownload with the link.

or you can add this before line 2815
Code:

if mainForm.Menu == nil then return end


So edit this:
Code:

local menuItems = mainForm.Menu.Items   -- line 2815


To this:
Code:

if mainForm.Menu == nil then return end   -- line 2815
local menuItems = mainForm.Menu.Items


Let me know if it doesn't work, should have put that in in the first place.

_________________
- Code Happy, Code Freely, Be Awesome.
Back to top
View user's profile Send private message
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

PostPosted: Fri Mar 10, 2017 6:22 am    Post subject: Reply with quote

Since CE server is down again, can't reply. Already tested update script. It's work good now.
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