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 


How create a new section to Autoassemble?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sat Aug 21, 2021 4:25 pm    Post subject: How create a new section to Autoassemble? Reply with quote

Hi everyone, i find a way to use FASM to write assembly code in memory, but at this point i want to implement my own "section" within Autoassemble motor, like as {$lua}, {$asm}, but named {$fasm}.

I would need catch the actual address being writted.

Any idea about how implement this?

Also, thanks DaSpamer, i was helped by u and i forgeted thank you.


Last edited by _Iuri on Sat Aug 21, 2021 4:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sat Aug 21, 2021 4:41 pm    Post subject: Reply with quote

For that, you would have to modify the source code but I see no reason why the fasm instructions wouldn't work under the {$ASM} directive.
Back to top
View user's profile Send private message
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sat Aug 21, 2021 4:54 pm    Post subject: Reply with quote

Thanks for your response, Indeed, Autoassemble motor can parse FASM syntax without problems, but, the difference is that with FASM i can use Macros that will make my life much happier

Also, i having a lot of problems with Autoassemble, a few times stops working, others times the syntax check of the script will be succeded, but it won't activate... making the fixing a lot more complicated.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sat Aug 21, 2021 4:57 pm    Post subject: Reply with quote

If you right-click on the problematic script it will give some error information as to why the script failed.

Zanzer, another member here has a quick-and-dirty solution for macros:
Code:

{$lua}
local macro=[[
  push 1500
  fild [esp]
  add esp,4
]]
{$asm}
[ENABLE]
alloc(newmem,$1000)
newmem:
{$lua}
return macro
{$asm}
registersymbol(newmem)

[DISABLE]
dealloc(newmem)
unregistersymbol(newmem)
Back to top
View user's profile Send private message
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sat Aug 21, 2021 5:12 pm    Post subject: Reply with quote

I know how use Autoassemble, with x64 process that (Autoassemble) might fail without error notification, specifically and, for example, when you move a value to a register.

Code:

mov rdi,qword ptr[GameMotor.dll+01F] // For example


This code doesn't have problems, but it will no work. I have this problem with a script for Realm Of The Mad God.

It need to be fixed, replacing by:

Code:

mov rdi,GameMotor.dll+01F
mov rdi,qword ptr[rdi]


Also, i do not want use Lua to make Assembly macros, the code will get dirty
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sat Aug 21, 2021 5:58 pm    Post subject: Reply with quote

I wasn't implying that you are insufficiently educated with AutoAssembler. I only wished to help find a solution to your problem. If my help is not warranted then I shall save my time.

You can use something like this to store a pointer.
Code:

alloc(ptr,8)
alloc(script,$100)
label(ptr)

script:
 mov rdi,[ptr]

ptr:
 readmem("GameMotor.dll"+01F, 8)


One other thing, encapsulate GameMotor.dll within quotes ("GameMotor.dll"+01F) and see if it makes any difference to your original script.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sat Aug 21, 2021 6:47 pm    Post subject: Reply with quote

_Iuri wrote:
Code:
mov rdi,qword ptr[GameMotor.dll+01F]
This code doesn't have problems
It does if GameMotor.dll+01F isn't within 2GB of the next instruction (see RIP-relative addressing). You don't need qword ptr either- it's implied with the 64-bit destination register.

There are better but more complicated ways of using Lua to implement macros. See Lua functions registerAutoAssemblerCommand and/or registerAutoAssemblerPrologue.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sun Aug 22, 2021 7:52 am    Post subject: Reply with quote

LeFiXER sorry, i didn't mean to be rude, i just wanted show you a tipical problem that i had with Autoassemble, it was not my intention to speak badly to you

ParkourPenguin, That was an example with a fake address, the Autoassemble script was generated with a default template... but doesn't works on ENABLE section, but does under DISABLE section

Code:

[ENABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,qword ptr[GameMotor.dll+01F] // Fake example instruction, DOESN'T WORKS

[DISABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,qword ptr[GameMotor.dll+01F] // Fake example instruction, WORKS


Fix:
Code:

[ENABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,GameMotor.dll+01F
    mov rdi,qword ptr[rdi] // Fake example instruction, will work

[DISABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,qword ptr[GameMotor.dll+01F] // Fake example instruction, WORKS


Also, the main problem is that i need create a new section to Autoassemble for explode the characteristics of FASM within CheatEngine

If i can implement this we may create Autoassemblers scripts with "Medium Level" syntax.

Code:

[ENABLE]
GameMotor.dll+1F1F1F1F:
{$fasm}
    mov rdi,QWORD[GameMotor.dll+1F]
    .if rdi > 33
        invoke MessageBoxA,0,"Hello World","Title",0
    .else
        invoke ExitProcess,0
    .endif
{$asm}
[DISABLE]
...
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Sun Aug 22, 2021 9:00 am    Post subject: Reply with quote

I am unsure of the viability of this given that Cheat Engine doesn't interface with winAPI (at least to my knowledge, I could be wrong and should someone know of this then please let me know).
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25806
Location: The netherlands

PostPosted: Sun Aug 22, 2021 10:31 am    Post subject: Reply with quote

to answer the first question

with registerAutoAssemblerPrologue you can add a scanner for {$fasm} blocks and replace them with the bytecode that fasm returns (use db xx xx xx xx xx)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sun Aug 22, 2021 11:25 am    Post subject: Reply with quote

Dark Byte, thanks for your answer, i thinked that too, but at least i need pick up the actual address being writted by Autoassemble, can i get it with registerAutoAssemblerPrologue function?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sun Aug 22, 2021 11:30 am    Post subject: Reply with quote

_Iuri wrote:
...but doesn't works on ENABLE section, but does under DISABLE section
Code:
[ENABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,qword ptr[GameMotor.dll+01F] // Fake example instruction, DOESN'T WORKS

[DISABLE]
GameMotor.dll+1F1F1F1F: // Fake example address...
    mov rdi,qword ptr[GameMotor.dll+01F] // Fake example instruction, WORKS

I can't replicate that behaviour:
Code:
[ENABLE]
Tutorial-x86_64.exe+1AE068:   // random address
  mov rdi,qword ptr[Tutorial-x86_64.exe+01F]
 
[DISABLE]
Tutorial-x86_64.exe+1AE068:
  mov rdi,qword ptr[Tutorial-x86_64.exe+01F]
This assembles fine when both enabling and disabling the script.
Please provide a minimal working example with the 64-bit CE tutorial ("Tutorial-x86_64.exe").

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25806
Location: The netherlands

PostPosted: Sun Aug 22, 2021 12:06 pm    Post subject: Reply with quote

use registerAutoAssemblerPrologue in combination of registerAssembler.

Scan for the fasm block, and write it in a global table

then replace the whole {$fasm} block with fasmimplementation_#### or something like that with the requested parameters. e.g fasmimplementation(id,newmem,param1)

then in your registerAssembler hook check if the instruction starts with fasmimplementation( , and if so, parse the rest. ID as lookup in the global fasmimplementation table, and newmem and param1 for the values

then with that info create your bytes and return a bytetable

Note though that during phase 1 the parameters are given high and low addresses to determine the minimum size needed to allocate for this block so keep that in mind (it's going to give bogus addresses the first few times)

to get you on the way, here's an example script of registerAssembler:
Code:

if example then
  unregisterAssembler(example)
  example=nil
end

example=registerAssembler(function(address, instruction)
  printf("address=%x instruction=%s", address, instruction)
  if instruction=='wtf' then
    return {0x90}
  end
end)

(also notice that it doesn't have to be a valid intel AA syntax , it could just as well be ---{myline}--- <param1,param2,param3>

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
_Iuri
Newbie cheater
Reputation: 0

Joined: 08 Jul 2021
Posts: 13

PostPosted: Sun Aug 22, 2021 12:44 pm    Post subject: Reply with quote

Oh, so smart, i will try that, thanks!
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 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