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 to change two remote instructions at the same time

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

Joined: 10 Mar 2019
Posts: 20

PostPosted: Wed Nov 02, 2022 3:26 pm    Post subject: How to change two remote instructions at the same time Reply with quote

Hello,
I have an instruction that writes a value which I'd like to transfer to another instruction, which sits far away from the first (source) instruction.

I'm trying to
1) Park the source value to my own allocated memory.
2) Copy the source value back to the source instruction, so that it keeps functioning.
3) Copy the source value to the target instruction to enable some new functionality

Source instruction at "inputinterface.dll"+2F365
Code:

movsd xmm0,[rax+000004F0]
movsd [rsp+70],xmm0 >>>> My injection point


Target instruction at "inputinterface.dll"+46E79
Code:

movsd xmm0,[rsp+48]
movsd [rax+000004F0],xmm0


I want the value meant for [rsp+70] to end up in [rsp+70] and in [rsp+48]
I've written a basic AOB injection which does 1) and 2), but I'm clueless as to how I can tackle the last part. Is a second injection in the same script possible? Or can I access the value of myYawSource in a child script of this one?

Code:

ENABLE]
aobscanmodule(MyGoPro,inputinterface.dll,F2 0F 11 44 24 70 B8 20 00 00 00) // should be unique
alloc(newmem,$1000,"inputinterface.dll"+2F365) //allocates 1,000 bytes of memory at inputinterface.dll
alloc(myYawSource,8)
label(return)
registersymbol(MyGoPro)

newmem:
       movsd [myYawSource],xmm0 //Copies df from xmm0 register to my allocated address
       movsd xmm1,[myYawSource] //Copies from my allocated address to xmm1
       movsd [rsp+70],xmm1 //This restores the original functionality of the source instruction
       jmp return

MyGoPro:
  jmp newmem
  nop
return:

[DISABLE]

MyGoPro:
db F2 0F 11 44 24 70 B8 20 00 00 00

unregistersymbol(MyGoPro)
dealloc(newmem)


As always, any help would be greatly appreciated.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Wed Nov 02, 2022 4:51 pm    Post subject: Reply with quote

Use registersymbol to make the symbol `myYawSource` accessible in the other script. The other script should be made a child as it can't be enabled if `myYawSource` doesn't exist. Use options like "hide children when disabled", "disabling this script disables children", maybe others.

globalalloc is another option (memory is leaked once, safer than deallocating shared memory)

If the other injection point is too far away, you may not be able to use RIP-relative addressing to access myYawSource directly. There is a MOV instruction that takes the RAX register and a value at a 64-bit memory offset (prefix/opcode REX.W + A1) that should let you use `mov rax,[myYawSource]` / `mov [rsp+48],rax`

Maybe also include a bool to verify myYawSource has been initialized if a zero value isn't good for [rsp+48]

_________________
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
Trisolaris
Newbie cheater
Reputation: 0

Joined: 10 Mar 2019
Posts: 20

PostPosted: Thu Nov 03, 2022 5:45 am    Post subject: Reply with quote

Awesome! I'll try that out ASAP.
Many thanks @ ParkourPenguin

What is the best way of finding my own allocated memory?
Currently, I either scan for the AoB containing my new code or
I enter the address displayed at the jump in the disassembler
manually, and find my own values further downstream.
Is there a way to search for myYawSource directly?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Nov 03, 2022 5:47 am    Post subject: Reply with quote

Quote:

Use registersymbol to make the symbol `myYawSource` accessible in the other script. The other script should be made a child as it can't be enabled if `myYawSource` doesn't exist. Use options like "hide children when disabled", "disabling this script disables children", maybe others.

_________________
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
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Thu Nov 03, 2022 5:29 pm    Post subject: Reply with quote

You're overthinking this. Use registersymbol / unregistersymbol on `myYawSource` the same way you do for `MyGoPro`. Then you can simply use `myYawSource` in any other script.
_________________
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
Trisolaris
Newbie cheater
Reputation: 0

Joined: 10 Mar 2019
Posts: 20

PostPosted: Sat Nov 05, 2022 3:31 am    Post subject: Reply with quote

Thanks @Dark Byte & @ParkourPenguin!

Out of curiosity: will the registered symbol be visible to other scripts outside of CE? I recon that would be a great way to interact with my CE scripts. I could e.g. control variables by manipulating ["myCERegisteredSymbol" + offset] directly. As an alternative, I could AoB-scan for the code in newmem (I can add bytes further downstream to make the AoB unique if needed) and work with that.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Sat Nov 05, 2022 1:57 pm    Post subject: Reply with quote

You'd need some form of IPC (inter process communication) to communicate data between processes.

If you're trying to make your own program to do something, it's probably better to just do everything yourself and not rely on some janky hybrid setup with CE.

Doing everything in CE is also an option. CE's Lua API is good for most things- you can make your own GUI and stuff.

_________________
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
Trisolaris
Newbie cheater
Reputation: 0

Joined: 10 Mar 2019
Posts: 20

PostPosted: Wed Nov 09, 2022 2:44 pm    Post subject: Reply with quote

Guys, it worked! Very Happy Cool
My first code injection! Parent and child script work like a charm. Many thanks @ParkourPenguin and @Dark Byte, I learn so much from you guys!

Now I can check whether I can access my allocated memory from outside, but that's all nice to have. The important stuff is there Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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