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 inject code on keystroke?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Tue Apr 26, 2016 4:05 pm    Post subject: How to inject code on keystroke? Reply with quote

Hello friends,

So I'm trying to create a trainer where I can adjust the FOV by pressing a keystroke.

I've found that adjusting the FOV in the game settings (adjusting slider and pressing apply) executes the following code:

mov [rcx+000027C0],eax

By changing this to:

mov [rcx+000027C0],(float)70

I fake the game into adjusting it to 70 instead of whatever value is set in the options (50-60 max ranges by default) when I hit apply in the settings.

How can I write a piece of code that executes that injection on a key press?

I suppose this would work the same as someone using a trainer to LOCK health or ammo.

Thanks fellas!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4719

PostPosted: Tue Apr 26, 2016 8:12 pm    Post subject: Reply with quote

  1. Right click on the AA script in the address list.
  2. Select "Set/Change hotkeys".
  3. You should be able to make the hotkey from there.

_________________
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
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 3:55 am    Post subject: Reply with quote

ParkourPenguin wrote:
  1. Right click on the AA script in the address list.
  2. Select "Set/Change hotkeys".
  3. You should be able to make the hotkey from there.

Not what I'm looking for. Again that would hotkey enable/disable the function to force it to 70 when clicking APPLY in the menu.

I'm looking to force that value on the fly wherever I am in game.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 4:10 am    Post subject: Reply with quote

It would work, you just have to set up your script to support it by creating a boolean trigger and assigning a hotkey to it. For example:

newmem:
cmp byte ptr [fov_enable],1
je fov_cheat
jmp originalcode

You can allocate memory for fov_enable, then set up a child script that will toggle fov_enable value to 1/0 in the enable/disable sections.

Alternatively, you can control everything inside of your script by setting up a conditional jump that checks if a particular key/button is being pressed, then execute your code only when that is happening.

However, I don't see how this would be any different than what ParkourPenguin has suggested. Perhaps you can elaborate on what it is that you are wanting to accomplish, specifically?
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:01 am    Post subject: Reply with quote

++METHOS wrote:
...

Sorry that goes right over my head, not that experienced yet with Cheat Engine Smile

So here's what I am trying to do:

The game allows to change the FOV between 50 and 60 through a slider in-game.

I've found the address that writes the FOV value as soon as I hit APPLY in the settings.

I've managed to re-route that to a 'newmem' where I force it to 70.

However that means I have to go through the menu, change it to whatever and hit apply. That is so far the only way I have found to get the game to execute the 'newmem'.

Instead what I want is to change the FOV while playing for example:

NUM 1 = FOV 70
NUM 2 = FOV 10

I have no idea how I could let 'mov [rcx+000027C0],(float)70' happen without having to go into the menu and pressing APPLY.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 11:15 am    Post subject: Reply with quote

The value that you're interested in is inside [rcx+000027C0]. Try right-clicking on the instruction inside of memory viewer and checking to see what address(es) it accesses. Change the FOV value by hitting apply. In the new window that popped up earlier, you should see your address show up. Add it to your cheat table. Click 'stop' and close the new window. Right-click on the address in your cheat table to see what is accessing it. If an instruction pops up that is constantly accessing the address, then you can use that for your injection point. If not, you'll have to find a better injection point or just use a pointer.

Once you have done that, you can determine how to proceed.
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:25 am    Post subject: Reply with quote

++METHOS wrote:
The value that you're interested in is inside [rcx+000027C0]. Try right-clicking on the instruction inside of memory viewer and checking to see what address(es) it accesses. Change the FOV value by hitting apply. In the new window that popped up earlier, you should see your address show up. Add it to your cheat table. Click 'stop' and close the new window. Right-click on the address in your cheat table to see what is accessing it. If an instruction pops up that is constantly accessing the address, then you can use that for your injection point. If not, you'll have to find a better injection point or just use a pointer.

Once you have done that, you can determine how to proceed.


I've already done all that now I'm going in circles.

In this imgur picture you can see the memory address in the main window and the instruction that consitantly accesses the address.

i DOT imgur DOT com SLASH ZcWfwCi.png

Can you perhaps explain to me than how I proceed?

EDIT: So that instruction is the one that is triggered when I hit apply in the menu.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 11:28 am    Post subject: Reply with quote

If that instruction is actually accessing the address constantly, and not accessing any other addresses, then you can use that for your injection point.

Let CE build the script for you using Auto Assemble with AOB Injection template.

Once you have your script, add it to your table. Setting it up to do what you want will be easy at that point.
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:31 am    Post subject: Reply with quote

So I've already done the Auto Assembler script as well, I'll try and link that here for you also.

Main Window with new Script:

IMGUR HRr56p3.png

The script:

Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048,"EliteDangerous64.exe"+70B9E1)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

mov [rcx+000027C0],(float)70

originalcode:
//mov [rcx+000027C0],eax

exit:
jmp returnhere

"EliteDangerous64.exe"+70B9E1:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"EliteDangerous64.exe"+70B9E1:
mov [rcx+000027C0],eax
//Alt: db 89 81 C0 27 00 00


The problem with that script is obviously that it's only triggered when hitting APPLY in the settings window (and it does work) not when I hit a hot key.

There's the question Smile
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 11:33 am    Post subject: Reply with quote

Like I said already......

You have to use an instruction that is constantly accessing the address.

When you change the value of the address in your cheat table, does it change the FOV in-game?


Last edited by ++METHOS on Wed Apr 27, 2016 11:34 am; edited 1 time in total
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:34 am    Post subject: Reply with quote

You've been a wonderful help METHOS thank you so much. I suppose I'm doing things right but this instruction is just the wrong one to use.

I would have no idea how to find an instruction that is constantly adjusting the FOV (I don't think there is one) but that will be my new task then Smile
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 11:35 am    Post subject: Reply with quote

If changing the value in your cheat table changes the FOV in-game, in real time, then do as I explained above and right-click on it to see what is 'accessing' it (not what is writing to it). In the new debugger window that pops up, if there is an instruction that populates the list and is constantly accessing the address, you can use that one.
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:38 am    Post subject: Reply with quote

Ah, that's new. Yes I've just checked what is accessing it and I do get multiple different instructions.

They all come up with this instruction:

movss xmm0,[rax+08]

I tried changing one of those with:

mov [rcx+000027C0],(float)70

But the game then crashed, let me fiddle with this. Any easier way for us to communicate? You're being an amazing help and I really appreciate it.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 27, 2016 11:42 am    Post subject: Reply with quote

The game is probably crashing because the instructions are accessing multiple addresses. You can check this by right-click on the empty, white space inside the debugger window that pops up (when you right-click the address to see what is accessing it), and check to see if found opcodes are accessing other addresses. You will see extra numbers populate in the count column that will be between 1 and 8. If any of them say 1, and are constantly accessing the address, then you can use that. If not, you'll need to incorporate a filter or find a different instruction to use (e.g. an instruction that handles one of the other offsets/addresses inside that same data structure).
Back to top
View user's profile Send private message
Liquidious
How do I cheat?
Reputation: 0

Joined: 26 Apr 2016
Posts: 8

PostPosted: Wed Apr 27, 2016 11:47 am    Post subject: Reply with quote

They are all saying (1) but so far I have tried the first and second one, they both crashed the game.

IMGUR aaMqM2t.png

Am I OK to keep using:

mov [rcx+000027C0],(float)70

EDIT: So they are all crashing the game if I use the original code, but maybe that's wrong:

Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048,"EliteDangerous64.exe"+E7B275)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

mov [rcx+000027C0],(float)70

originalcode:
//movss xmm0,[rax+08]

exit:
jmp returnhere

"EliteDangerous64.exe"+E7B275:
jmp newmem
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"EliteDangerous64.exe"+E7B275:
movss xmm0,[rax+08]
//Alt: db CC 0F 10 40 08
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
Goto page 1, 2  Next
Page 1 of 2

 
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