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 does not work anymore in Cheat Engine 6.6
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Thu Apr 06, 2017 5:53 am    Post subject: GetAsyncKeyState does not work anymore in Cheat Engine 6.6 Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Apr 06, 2017 8:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Thu Apr 06, 2017 12:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Apr 06, 2017 12:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Thu Apr 06, 2017 12:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Apr 06, 2017 12:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Fri Apr 07, 2017 2:43 pm    Post subject: Reply with quote

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:

Code:
add ah, 0


So the sign flag tells me exactly the status of the key, if it is pressed or not.
Then I execute:

Code:
js the_key_is_down


or

Code:
jns the_key_is_up


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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Fri Apr 07, 2017 3:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Fri Apr 07, 2017 5:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Fri Apr 07, 2017 6:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Sat Apr 08, 2017 4:55 am    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Sat Apr 08, 2017 7:36 am    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Sat Apr 08, 2017 9:22 am    Post subject: Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Sat Apr 08, 2017 9:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Erez Zrihen
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2016
Posts: 65

PostPosted: Sat Apr 08, 2017 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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