View previous topic :: View next topic |
Author |
Message |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Thu Apr 06, 2017 5:53 am Post subject: GetAsyncKeyState does not work anymore in Cheat Engine 6.6 |
|
|
GetAsyncKeyState always returns 0, even though my applications, written in masm32 and C, are running as administrator, as long as my focus is on one of the Cheat Engine 6.6 windows. That's it. I am going back to using Cheat Engine 6.5 again as always, until you correct this issue/problem.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Thu Apr 06, 2017 8:44 am Post subject: |
|
|
Works fine for me using the CE Tutorial (32-bit).
Code: | [ENABLE]
alloc(newmem,2048)
label(terminate)
label(returnValue)
registersymbol(terminate)
registersymbol(returnValue)
createthread(newmem)
newmem:
push #50
call kernel32.Sleep
push 43 // VK_C // <- The part you care about
call user32.GetAsyncKeyState // <
mov [returnValue],ax // <
cmp byte ptr[terminate],0
je newmem
pop eax
push 8000
push 0
push newmem
push eax
jmp kernel32.VirtualFree
terminate:
db 0
returnValue:
dd 0
[DISABLE]
terminate:
db 1
unregistersymbol(terminate)
unregistersymbol(returnValue) |
The value at returnValue is 0 when c is not pressed, and it's either 0x8000 or 0x8001 when it is pressed.
It's likely a problem on your end.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Thu Apr 06, 2017 12:04 pm Post subject: |
|
|
Do you suggest me to read Cheat Engine memory, to know when a key is down, rather than invoking GetAsyncKeyState directly? Or I just didn't understand your answer and need explanation.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Thu Apr 06, 2017 12:07 pm Post subject: |
|
|
I'm telling you that it isn't a problem with CE and you're likely doing something wrong.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Thu Apr 06, 2017 12:51 pm Post subject: |
|
|
Quote: | you're likely doing something wrong. |
Assume that this is true, but if so then I need to know what I am doing wrong exactly?
List all, or at least the most common reasons that cause GetAsyncKeyState to not working properly.
It will be difficult for me to find this out myself, because in Cheat Engine 6.5, GetAsyncKeyState does work, so why am I doing something wrong? It seems that there is something wrong in the change from version 6.5 to 6.6 of Cheat Engine.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Thu Apr 06, 2017 12:55 pm Post subject: |
|
|
It's kind of hard for anyone to help you if you don't tell us what you're doing.
See the remarks section of this webpage if you're only checking the least significant bit.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Fri Apr 07, 2017 2:43 pm Post subject: |
|
|
ParkourPenguin wrote: | It's kind of hard for anyone to help you if you don't tell us what you're doing.
See the remarks section of this webpage if you're only checking the least significant bit. |
I am using the sign flag to check the most significant bit. I mean that after I invoke GetAsyncKeyState, I execute the instruction:
So the sign flag tells me exactly the status of the key, if it is pressed or not.
Then I execute:
or
This trick is working. If my focus is not on one of the cheat engine windows, it really works. When I do focus one of the cheat engine windows, it seems that js is equivalent to jmp, and jns is equivalent to nop.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Fri Apr 07, 2017 3:32 pm Post subject: |
|
|
Again, it works perfectly fine for me.
Code: | push 43 // VK_C
call user32.GetAsyncKeyState
add ah,0 |
The sign flag is 1 when the key is pressed, and it's 0 when the key is not pressed. It works regardless if focus is on one of CE's windows or on the target window.
If I can't reproduce it, the only thing I can logically assume is that it's user error.
What process are you targeting? Does this also happen with other targets? Are you absolutely certain CE 6.5 worked and CE 6.6 didn't? Do you have other software (e.g. antiviruses) that could be interfering? Did the example I previously posted work for you, or did it produce the same behavior?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Fri Apr 07, 2017 5:52 pm Post subject: |
|
|
I am using invoke, not push and call instructions.
Quote: | Are you absolutely certain CE 6.5 worked and CE 6.6 didn't? |
Yes, I am certain that the program works in cheat engine 6.5, but not in cheat engine 6.6. If I am running my program normally, i.e. not as administrator, then even in cheat engine 6.5, GetAsyncKeyState doesn't work.
Quote: | what process are you targeting? |
Does this matter? I am targeting LEGO Racers (old game), but I don't think that it is the cause to make GetAsyncKeyState to malfunctioning.
I think that I must see the changes between ce 6.5 and ce 6.6 and the differences between them. The developer did something new in ce 6.6 that makes GetAsyncKeyState not working, something about privileges and rights.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Fri Apr 07, 2017 6:55 pm Post subject: |
|
|
There is no "invoke" pseudoinstruction in CE. If you're not using CE, why are you blaming it? What are you using CE for? What are you trying to do?
Regardless, I wrote a small program in C and it works perfectly fine with GetAsyncKeyState even if CE has focus, so I still can't replicate the problem.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Sat Apr 08, 2017 4:55 am Post subject: |
|
|
ParkourPenguin wrote: | There is no "invoke" pseudoinstruction in CE. If you're not using CE, why are you blaming it? What are you using CE for? What are you trying to do?
Regardless, I wrote a small program in C and it works perfectly fine with GetAsyncKeyState even if CE has focus, so I still can't replicate the problem. |
I am not using cheat engine pseudoinstruction, but a program that I wrote in masm32, not in C, but still I am surprised that for you it is working and for me it doesn't. Can you please post for me the code of your program written in C please?
I want to see what did you do in there exactly.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Sat Apr 08, 2017 7:36 am Post subject: |
|
|
Code: | #include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
while ((GetAsyncKeyState(0x58) & 0x8000) == 0) // VK_X exits program
{
printf("isPressed:\t%d\r\n", (GetAsyncKeyState(0x43) & 0x8000) != 0); // VK_C is used to print
Sleep(1000);
}
return 0;
}
// compiled with:
// gcc test.c -std=c11 -Wall -o test.exe |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Sat Apr 08, 2017 9:22 am Post subject: |
|
|
ParkourPenguin wrote: | Code: | #include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
while ((GetAsyncKeyState(0x58) & 0x8000) == 0) // VK_X exits program
{
printf("isPressed:\t%d\r\n", (GetAsyncKeyState(0x43) & 0x8000) != 0); // VK_C is used to print
Sleep(1000);
}
return 0;
}
// compiled with:
// gcc test.c -std=c11 -Wall -o test.exe |
|
Are you running test.exe as administrator? Does your program really quit when you press X while focusing CE 6.6? I don't think that for me using the and logic operation rather than the sign flag will make a difference at all.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Sat Apr 08, 2017 9:29 am Post subject: |
|
|
Doesn't matter if I run it as admin or not- it works either way regardless of whatever window has focus.
As I said before, yes it does work for me. Obviously the thread isn't running while it's sleeping, so make sure you hold down the X key for at least a second.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Erez Zrihen Advanced Cheater
Reputation: 0
Joined: 26 Feb 2016 Posts: 65
|
Posted: Sat Apr 08, 2017 10:09 am Post subject: |
|
|
ParkourPenguin wrote: | Doesn't matter if I run it as admin or not- it works either way regardless of whatever window has focus.
As I said before, yes it does work for me. Obviously the thread isn't running while it's sleeping, so make sure you hold down the X key for at least a second. |
In my code, I don't invoke the Sleep procedure/function at all or I do, but for very short amount of time, i.e. no longer than 100 milliseconds, so in CE 6.5 when my program runs as administrator, just pressing down the Ctrl+C keys for a very short moment immediately opens the clipboard to copy it's data to the program's memory and then closes it and then clears the console output buffer and prints the new data from memory by invoking printf. I am so surprised that GetAsyncKeyState works for you even though your program doesn't run as administrator. If I run my program not as administrator, GetAsyncKeyState fails even in CE 6.5. No way that we have different Cheat Engines. Now I think that it is something in the operating system, or the way I launch cheat engine.
|
|
Back to top |
|
 |
|