flat assembler
Message board for the users of flat assembler.

Index > Windows > GetKeyState and Return Value

Author
Thread Post new topic Reply to topic
asmhardy



Joined: 22 Apr 2012
Posts: 1
asmhardy
Hello,

The GetKeyState function retrieves the status of the specified virtual key. MSDN

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646301%28v=vs.85%29.aspx

says: "If the high-order bit is 1, the key is down; otherwise, it is up ..."
Why is the contents of register EAX: 0xFFFFFF80 or 0xFFFFFF81, when the SHIFT-Key is pressed? Why isn't 0x000008000? Can anybody explain to me please.

Code:
format PE GUI 4.0
include 'win32a.inc'

; -----------------------------------------------
section '.code' code readable executable
; -----------------------------------------------

start:
       invoke Sleep,100
       invoke GetKeyState,VK_SHIFT
       cmp    eax, 0
       jnl    start
       cinvoke wsprintf,buff,wsformat,eax
       invoke MessageBoxA,0,buff,title,0
       invoke ExitProcess,0

; -----------------------------------------------
section '.data' data readable writeable
; -----------------------------------------------

buff     rb 100
title    db 'Ausgabe ...',0
wsformat db "EAX -->> %08X",0

;-------------------------------------------------
section '.idata' import data readable writeable   
;-------------------------------------------------

library kernel32,'KERNEL32.DLL',\
        user32,'USER32.DLL'

import  kernel32,\
        ExitProcess,'ExitProcess',\
        Sleep,'Sleep'

import  user32,\
        MessageBoxA,'MessageBoxA',\
        GetKeyState,'GetKeyState',\
        wsprintf,'wsprintfA'   
    



Sorry, my English is not so good ...


Last edited by asmhardy on 17 May 2012, 11:57; edited 1 time in total
Post 17 May 2012, 07:00
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
asmhardy wrote:
0x000008000


DWORD or QWORD Confused Also, note that this function returns WORD. Wink whose range is 0xFFFF
Post 17 May 2012, 10:14
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 698
Location: Adelaide
sinsi
It only returns two bits of interest, the others could be anything.
You need to test the bit with test/and/bt
Post 17 May 2012, 10:48
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.