Difference between revisions of "Tutorials:Auto Assembler:Example 2"

From Cheat Engine
Jump to navigation Jump to search
(Enable section)
(Replaced content with '<span style="font-size:25px;color:red">Sorry! Content not available.</span>')
Line 1: Line 1:
[[Category:Tutorial]]
+
<span style="font-size:25px;color:red">Sorry! Content not available.</span>
[[Category:Auto Assembler]]
 
{{DISPLAYTITLE:Auto Assembler - Example 2}}
 
 
 
Let's look at that the following example.
 
: Note: All numbers in the ''Auto Assembler'' are read as [https://wikipedia.org/wiki/Hexadecimal hexadecimal] format by default, use '''#''' or '''(int)''' for decimal format (base 10).
 
: Note: Values written in a 0x* notation are in [https://wikipedia.org/wiki/Hexadecimal hexadecimal] format.
 
[[File:AutoAssembler-Example-2.01.png|border]]
 
<!-- <pre>{$STRICT}
 
 
 
define(address, GAME.exe+123ABC)
 
define(bytes, 0F 2F 05 7C A4 6A FE)
 
 
 
////
 
//// ------------------------------ ENABLE ------------------------------
 
[ENABLE]
 
alloc(memSomeHook, 0x400)
 
 
 
label(fltSomeHook)
 
registerSymbol(fltSomeHook)
 
label(flgSomeHook)
 
registerSymbol(flgSomeHook)
 
label(ptrSomeHook)
 
registerSymbol(ptrSomeHook)
 
 
 
label(n_code)
 
label(o_code)
 
label(exit)
 
label(return)
 
 
 
memSomeHook:
 
    fltSomeHook:
 
        dd (float)1
 
    flgSomeHook:
 
        db 00
 
    align 10
 
    ptrSomeHook:
 
        dq 0
 
    align 10 CC
 
    n_code:
 
        mov [ptrSomeHook],rbx
 
        cmp byte ptr [flgSomeHook],0
 
        je o_code
 
        cmp byte ptr [flgSomeHook],1
 
        jne @f
 
            movss xmm0,[fltSomeHook]
 
            jmp o_code
 
        @@:
 
        mov byte ptr [flgSomeHook],0
 
    o_code:
 
        movss [rbx+10],xmm0
 
    exit:
 
        jmp return
 
 
 
 
 
////
 
//// ---------- Injection Point ----------
 
address:
 
    jmp n_code
 
    nop
 
    nop
 
    return:
 
 
 
 
 
////
 
//// ------------------------------ DISABLE ------------------------------
 
[DISABLE]
 
////
 
//// ---------- Injection Point ----------
 
address:
 
    db bytes
 
 
 
unregisterSymbol(fltSomeHook)
 
unregisterSymbol(flgSomeHook)
 
unregisterSymbol(ptrSomeHook)
 
dealloc(memSomeHook)</pre> -->
 
 
 
 
 
=== Main section ===
 
 
 
; 1. {$STRICT}
 
: When [[Auto_Assembler:STRICT|{$STRICT}]] is present in your script, Cheat Engine will not assume that an undefined symbol is a [[Auto_Assembler:label|label]], and will give you an error instead.
 
: Note that this is optional.
 
; 3. define(address, GAME.exe+123ABC)
 
: This line [[Auto_Assembler:define|define]]s or sets "address" to "GAME.exe+123ABC",
 
: i.e.: any where in this script we place "address" Cheat Engine will replace it with "GAME.exe+123ABC".
 
; 4. define(bytes, 0F 2F 05 7C A4 6A FE)
 
: This line [[Auto_Assembler:define|define]]s or sets "bytes" to "0F 2F 05 7C A4 6A FE",
 
: i.e.: any where in this script we place "bytes" Cheat Engine will replace it with "0F 2F 05 7C A4 6A FE".
 
 
 
 
 
=== Enable section ===
 
 
 
; 8. [ENABLE]
 
: This line just denotes the start of the enable section.
 
: Note: Cheat Engine table scripts require an '''enable''' and '''disable''' section.
 
; 9. alloc(memSomeHook, 0x400, address)
 
: This line [[Auto_Assembler:alloc|alloc]]ates 0x400 bytes using the symbol "memSomeHook", near the address of ''address'' (which is "GAME.exe+123ABC").
 
 
 
; 11. label(fltSomeHook)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "fltSomeHook".
 
; 12. registerSymbol(fltSomeHook)
 
: This [[Auto_Assembler:registerSymbol|registers the symbol]] "fltSomeHook" with the user symbol list.
 
: A registered symbol can be used in the disable section and else where on the table.
 
; 13. label(flgSomeHook)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "flgSomeHook".
 
; 14. registerSymbol(flgSomeHook)
 
: This [[Auto_Assembler:registerSymbol|registers the symbol]] "flgSomeHook" with the user symbol list.
 
; 15. label(ptrSomeHook)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "ptrSomeHook".
 
; 16. registerSymbol(ptrSomeHook)
 
: This [[Auto_Assembler:registerSymbol|registers the symbol]] "ptrSomeHook" with the user symbol list.
 
 
 
; 18. label(n_code)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "n_code".
 
; 19. label(o_code)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "o_code".
 
; 20. label(exit)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "exit".
 
; 21. label(return)
 
: This creates a [[Auto_Assembler:label|label]] using the symbol "return".
 
 
 
; 23. memSomeHook&#8758;
 
: This places the symbol, here it denotes to start assembling at the address of ''memSomeHook''.
 
; 24. fltSomeHook&#8758;
 
: This places the symbol, here it denotes the placement of ''fltSomeHook''.
 
; 25. dd (float)1
 
: This sets the [[Tutorials:Value_types#Value_sizes|size]] of the "fltSomeHook" as a ''data double word'' (4 bytes), with a float value of 1.
 
; 26. flgSomeHook&#8758;
 
: This places the symbol, here it denotes the placement of ''flgSomeHook''.
 
; 27. db 00
 
: This sets the [[Tutorials:Value_types#Value_sizes|size]] of the "flgSomeHook" as a ''data byte'', with a value of 0.
 
; 28. align 10
 
: This will [[Auto_Assembler:align|align]] what comes after this line, it aligns at an address ending with 0x10, with the default padding byte of 0x0.
 
; 29. ptrSomeHook&#8758;
 
: This places the symbol, here it denotes the placement of ''ptrSomeHook''.
 
; 30. dq 0
 
: This sets the [[Tutorials:Value_types#Value_sizes|size]] of the "ptrSomeHook" as a ''data quadword'' (8 bytes), with a value of 0x0.
 
: Note: ''ptrSomeHook'' will be used as a base address and in 64 bit mode 8 bytes is needed, but in 32 bit mode only 4 bytes is needed.
 
; 31. align 10 CC
 
: This will [[Auto_Assembler:align|align]] what comes after this line, it aligns at an address ending with 0x10, with a padding byte of 0xCC.
 
; 32. n_code&#8758;
 
: This places the symbol, here it denotes the placement of ''n_code'', this will be the start of the ''new code''.
 
; 33. mov [ptrSomeHook],rbx
 
: This will [[Assembler:Commands:MOV|mov]]e the value of [[Assembler#Structure|RBX]] into the ''value at the address'' (denoted by the '''[''' and ''']''') of ''ptrSomeHook''.
 
; 34. cmp byte ptr [flgSomeHook],0
 
: This [[Assembler:Commands:CMP|compares]] a byte pointer value at the address of ''flgSomeHook'' to 0x0 (as an immediate).
 
; 35. je o_code
 
: This will [[Assembler:Commands:JMP|jump]], [[Assembler:Commands:JE|if equal]] to the label ''o_code''; i.e.: if the last compare equated to being ''equal''.
 
; 36. cmp byte ptr [flgSomeHook],1
 
: This [[Assembler:Commands:CMP|compares]] a byte pointer value at the address of ''flgSomeHook'' to 0x1.
 
; 37. jne @f
 
: This will [[Assembler:Commands:JMP|jump]], [[Assembler:Commands:JNE|if not equal]] forward to the next label (denoted by the "@f", as "@b" would be for a label back); i.e.: if the last compare equated to being ''not equal''.
 
; 38. movss xmm0,[fltSomeHook]
 
: This will [[Assembler:Commands:MOV|mov]]e [[Assembler:Commands:MOVSS|a ''Scalar Single-Precision Floating-Point'']] of the ''value at the address'' of ''fltSomeHook'' into [[Assembler#Structure|XMM0]].
 
; 39. jmp o_code
 
: This will [[Assembler:Commands:JMP|jump]] to the label ''o_code''.
 
; 40. @@&#8758;
 
: This denotes a generic label, it can't be used by name is only useful with "''@f''" and "''@b''".
 
; 41. mov byte ptr [flgSomeHook],0
 
: This will [[Assembler:Commands:MOV|mov]]e a byte value of 0x0 into the ''value at the address'' of ''flgSomeHook''.
 
; 42. o_code&#8758;
 
: This places the symbol, here it denotes the placement of ''o_code'', this will be the start of the ''original code''.
 
; 43. movss [rbx+10],xmm0
 
: This will [[Assembler:Commands:MOV|mov]]e [[Assembler:Commands:MOVSS|a ''Scalar Single-Precision Floating-Point'']] of [[Assembler#Structure|XMM0]] into the ''value at the address'' of [[Assembler#Structure|RBX]] plus 0x10.
 
; 44. exit&#8758;
 
: This places the symbol, here it denotes the placement of ''exit'', this will be the start of the ''exit code'', note that the ''exit'' label is not used so it could be removed with the [[Auto_Assembler:label|label]] declaration.
 
; 45. jmp return
 
: This will [[Assembler:Commands:JMP|jump]] to the label ''return''.
 
 
 
 
 
; 50. address&#8758;
 
: This places the symbol, here it denotes to start assembling at the address of ''address'' (which is "GAME.exe+123ABC").
 
; 51. jmp n_code
 
: This will [[Assembler:Commands:JMP|jump]] to the label ''n_code''. This is the injection hook, as it hooks the code to do some thing else.
 
: Note that, in 64 bit mode, here is where the use of ''AllocateNearThisAddress'' with [[Auto_Assembler:alloc|alloc]] helps to insure a 5 byte jump.
 
; 52. nop
 
: This is a [[Assembler:Commands:NOP|NOP]] (no operation), here it is used a padding as the original instruction was more then 5 bytes
 
; 54. return&#8758;
 
: This places the symbol, here it denotes the placement of ''return'', this will be the ''return'' point.
 
 
 
=== Disable section ===
 
; 59. [DISABLE]
 
: This line just denotes the start of the disable section.
 
 
 
; 62. address&#8758;
 
: This places the symbol, here it denotes to start assembling at the address of ''address'' (which is "GAME.exe+123ABC").
 
; 63. db bytes
 
: This denotes to start assembling data bytes using the symbol ''bytes'' (which is "0F 2F 05 7C A4 6A FE").
 
 
 
; 65. unregisterSymbol(fltSomeHook)
 
: This [[Auto_Assembler:unregisterSymbol|unregisters the symbol]] "fltSomeHook" with the user symbol list.
 
; 66. unregisterSymbol(flgSomeHook)
 
: This [[Auto_Assembler:unregisterSymbol|unregisters the symbol]] "flgSomeHook" with the user symbol list.
 
; 67. unregisterSymbol(ptrSomeHook)
 
: This [[Auto_Assembler:unregisterSymbol|unregisters the symbol]] "ptrSomeHook" with the user symbol list.
 
; 68. dealloc(memSomeHook)
 
: This [[Auto_Assembler:dealloc|dealloc]]ates the memory at "memSomeHook".
 
 
 
 
 
== See also ==
 
* [[Assembler]]
 
* [[Assembler:Commands|Assembler Commands]]
 
* [[Cheat_Engine:Auto Assembler|Auto Assembler]]
 
* [[Tutorials:Auto_Assembler:Templates|Auto Assembler Templates]]
 
* [[Tutorials:Auto_Assembler:Injection_basic|Code Injection Basic]]
 
* [[Tutorials:Auto_Assembler:Injection_full|Code Injection Full]]
 

Revision as of 15:57, 16 March 2019

Sorry! Content not available.