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 


Help writing code to inject for freecam movement

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Chazza
How do I cheat?
Reputation: 0

Joined: 23 Mar 2016
Posts: 4

PostPosted: Wed Mar 23, 2016 10:24 am    Post subject: Help writing code to inject for freecam movement Reply with quote

Hi there,

I am trying to make a free camera mode for a game where the developers have explicitly locked out this functionality using a console.

I have found the base addresses (there were still thousands of results from the pointer scan but they still work correctly even if computer rebooted etc) of the following variables:

X Coordinate
Y Coordinate
Z Coordinate
Camera Vertical Rotation: [Values of approx -0.885 (looking as far down as possible) to 0.63 (looking as far up as possible)].

All values are floats

I am trying to inject code which depending on how far up/down the camera is looking, changes the value of the address containing the Z Coordinate variable, hence moving the camera up and down with mouse movement.
I am guessing this should be injected around the instruction that increases the X Coordinate when the W key is pressed, so that both horizontal and vertical movement occurs at the same time.

I have never used assembly before (only know C++) and looked at an online tutorial into AOB scanning and found the instruction which moves the new value into the X coordinate variable, but am unsure how to proceed from here.

I know you can't simply say "Copy the value of this address into this address" which is essentially what I want to do (albeit with some maths involved).

Here is the code for the instruction which changes the X coordinate when W is pressed on the keyboard:
Code:

[ENABLE]

aobscanmodule(INJECT,LifeIsStrange.exe,60 F3 0F 11 47 54 F3 0F 10 47 58 F3 0F 58 44 24 2C) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  movss [edi+54],xmm0
  jmp return

INJECT+01:
  jmp code
return:
registersymbol(INJECT)

[DISABLE]

INJECT+01:
  db F3 0F 11 47 54

unregistersymbol(INJECT)
dealloc(newmem)

I have changed the AOB so that the signature is unique, but don't know what to do next. 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: 4722

PostPosted: Wed Mar 23, 2016 2:09 pm    Post subject: Reply with quote

Check out this topic to help get started.
_________________
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
Chazza
How do I cheat?
Reputation: 0

Joined: 23 Mar 2016
Posts: 4

PostPosted: Wed Mar 23, 2016 2:24 pm    Post subject: Reply with quote

Thanks I actually stumbled upon that thread myself but couldn't really work out what was going on.

In this line:
alloc(newmem,$1000,"Darksiders2.exe"+9A4A50)

Is this just specifying the location you want the memory to be allocated? In the template code there is no third argument to alloc which I assume just means it will put it wherever it finds space which should be ok for my purposes?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4722

PostPosted: Wed Mar 23, 2016 2:32 pm    Post subject: Reply with quote

That third parameter is only relevant for 64-bit processes AFAIK. It specifies the 2GB region of memory it should allocate memory around so that it can simply use a 5-byte jmp instead of a significantly longer one.
_________________
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
Chazza
How do I cheat?
Reputation: 0

Joined: 23 Mar 2016
Posts: 4

PostPosted: Wed Mar 23, 2016 2:34 pm    Post subject: Reply with quote

Ah OK thanks, my process is 32-bit so should be fine without.

I'll see if I can cobble something together that works.

UPDATE:

OK I've got it working, it's not the best implementation but it will do.

The problem is it seems that the way the game records the direction of the camera changes from level to level.

On the level I started with, there are 4 different addresses with an offset of 04 from each other which all contained the same value between -0.885 and 0.63.

On another level from a different episode of the game (released later), there is only one address containing a value which seems to correspond to the camera's vertical direction, but this time it goes from -12743 to 8192!

I'll check the other episodes to see if they follow either of the same patterns. Makes this much harder than I first thought!

UPDATE 2:

Yep it seems only episode 1 uses the first method for the camera direction.
Episodes 2-5 all use the second method.

Guess I'll just have to have 2 different scripts, I am sure you guys could combine them no problem but I only started playing around with CheatEngine today and don't really know enough about assembly to do anything that useful.

UPDATE 3:

I was wrong, all episodes use the same method, for some reason I couldn't find the correct addresses when I did the original scans, but after scanning again I found it and it happened to be a base address which was nice!
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