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 


GetAsyncKeyState Problem...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Thu Jan 22, 2015 11:08 am    Post subject: GetAsyncKeyState Problem... Reply with quote

Well, here's my code, when I enable it and press "C" on my keyboard it doesn't do anything; what did I do wrong?
Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(notpressed)

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

originalcode:
pushad
pushfd

push 'C'
    call GetAsyncKeyState
shr ax,#15
cmp ax,1
    jne notpressed
add [esi+00000098],FF

notpressed:
popfd
popad

exit:
jmp returnhere

Terraria.Player::GainExperience+97:
jmp newmem
nop
returnhere:

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
Terraria.Player::GainExperience+97:
add [esi+00000098],ebx
//Alt: db 01 9E 98 00 00 00


I followed the tutorial on that keypresstut on cheat engine's main site but it won't work.

EDIT: Turns out you have to press and hold to make it work, though I still have to make it "call" that function in the first place (kill a minion to get exp so I get the 255 value instead of "ebx"). But how do I make it so that it executes it when I press it?
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Thu Jan 22, 2015 11:22 am    Post subject: Reply with quote

You can't just call a function whenever you want. The easiest way is usually to change a conditional jump to enable/disable the execution of a certain code (eg that you never get hit or never die).

If you want to make a script that will be executed only once, it's better if you are using flags. Setting the flag to 1 will execute the code and set the flag to 0, until the user will set the flag to 1 again. Look at Recifense's scripts to see how is he using flags. Pretty much all of his scripts are using 0/1 flags.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Thu Jan 22, 2015 11:50 am    Post subject: Reply with quote

I see, makes sense...

Ok, another question; how do I find the "jump" opcode set? The bit that says ' '? Cause the jump is mapped to "space", so I was wondering if I can find that bit and just make it call my code everytime I jump.
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Thu Jan 22, 2015 1:04 pm    Post subject: Reply with quote

The reason of why you can't call and execute a random code anytime is the environment. The registers will be different, the stack will be different, etc.

What you want to do is to change your space ship into a bicycle at the speed of light. The environment is not suitable. In order to do it, you have to change the whole environment.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Thu Jan 22, 2015 3:51 pm    Post subject: Reply with quote

Alright, so, how do I search for keypresses? Do I just search for a 1 byte value for whether the player has pressed it or not? Or is there an easier way?
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Thu Jan 22, 2015 7:04 pm    Post subject: Reply with quote

It isn't guaranteed that you will find a flag like that. Eg with the API that you have used, the result is not stored anywhere, just temporarily on eax. Scanning will not find anything in that case.

But for jump, you can often find a flag which is related to the jump. Eg a flag which is 0 when you are not jumping and 1 if you are jumping. If there is double jump, it's even better, as there is probably a value to store how many times did you jump (eg 0 on ground, 1 after jump, 2 after double jump). This can help you to find functions related to jumping.

A better solution would be to store the address of the exp and add it to the cheat table, then assign a hotkey to it to increase the value with x amount when you press the defined hotkey.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Thu Jan 22, 2015 8:21 pm    Post subject: Reply with quote

Geri wrote:
It isn't guaranteed that you will find a flag like that. Eg with the API that you have used, the result is not stored anywhere, just temporarily on eax. Scanning will not find anything in that case.

But for jump, you can often find a flag which is related to the jump. Eg a flag which is 0 when you are not jumping and 1 if you are jumping. If there is double jump, it's even better, as there is probably a value to store how many times did you jump (eg 0 on ground, 1 after jump, 2 after double jump). This can help you to find functions related to jumping.


I tried it and I found something related to jump (when I nop'd it, I couldn't jump...); but when I tried to put in "call Terraria.Player::GainExperience+97" it crashed! I even tried "jmp Terraria.Player::GainExperience+97", still crashed...
so, how do I make it call that part? Or do I have to call the beginning of the function?
EDIT: I put those calls and jmp's after the original code without modifying it, so...
Code:
originalcode:
fstp dword ptr [esi+000004E0]  //original, I didn't modify this
call Terraria.Player::GainExperience+97 //I tried jmp too...


Geri wrote:

A better solution would be to store the address of the exp and add it to the cheat table, then assign a hotkey to it to increase the value with x amount when you press the defined hotkey.

Yeah, it would; though I can't do interesting things with it like I can with assembly...
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Thu Jan 22, 2015 9:44 pm    Post subject: Reply with quote

It's as I have said above. If you call a function just like that, it will not work, because you call it from a wrong environment.

When I have mentioned conditional jumps, that has absolutely nothing to do with jumping in the game. Conditional jumps are certain instructions which will decide that the code execution will jump or not when certain conditions are met. They are "branches" in the otherwise linearly executed code. Google conditional jumps for more info (it's a long topic).

Your game is crashing, because you are doing something at the wrong location. That function is just part of a big machine, it's not working on it's own and if you put that part in the wrong place, it will cause malfunction.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
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