flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > A Win32 console keypress example (Updated) Goto page Previous 1, 2 |
Author |
|
MatQuasar 02 Apr 2024, 16:28
revolution wrote: This might help. Good! |
|||
02 Apr 2024, 16:28 |
|
MatQuasar 13 Apr 2024, 15:25
Another example modified from code posted by a 'fasm' Discord user.
GetKeyState API function : "Press "0" to quit" Code: format PE console include 'win32a.inc' msg db 'Key pressed',13,10 len = $ - msg msgg db 'Press 0 to quit',13,10 lenn = $ - msgg stdout dd ? entry $ invoke GetStdHandle,STD_OUTPUT_HANDLE mov [stdout],eax invoke WriteConsole,[stdout], msgg, lenn, 0, 0 mov ebx, '0' .again: invoke GetKeyState,ebx bt eax,15 jnc .again invoke WriteConsole,[stdout], msg, len, 0, 0 invoke ExitProcess,0 data import library kernel,'kernel32.dll',user32,'user32.dll' import kernel, WriteConsole,'WriteConsoleA',GetStdHandle,'GetStdHandle', ExitProcess, 'ExitProcess' import user32, GetKeyState,'GetKeyState',GetAsyncKeyState,'GetAsyncKeyState' end data |
|||
13 Apr 2024, 15:25 |
|
bitRAKE 28 Apr 2024, 09:26
MatQuasar wrote: Two undefined "db ? " added. Is it because needed by alignment , which is 32-bit? MatQuasar wrote: And what about this: Code: struct KEY_EVENT_RECORD bKeyDown dd ? wRepeatCount dw ? wVirtualKeyCode dw ? wVirtualScanCode dw ? union UnicodeChar dw ? AsciiChar db ? ends dwControlKeyState dd ? ends _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
28 Apr 2024, 09:26 |
|
bitRAKE 28 Apr 2024, 09:35
Note: revolution's structure isn't correct:
Code: struc IREVENT { virtual .MouseEvent MOUSE_EVENT_RECORD .WindowBufferSizeEvent WINDOW_BUFFER_SIZE_RECORD .MenuEvent MENU_EVENT_RECORD .FocusEvent FOCUS_EVENT_RECORD end virtual .KeyEvent KEY_EVENT_RECORD }struct IREVENT That's why I produced a comprehensive example to demonstrate the errors or validity of my understanding. |
|||
28 Apr 2024, 09:35 |
|
revolution 28 Apr 2024, 09:46
Thanks. The virtual blocks should be independent.
Code: struc IREVENT { virtual .MouseEvent MOUSE_EVENT_RECORD end virtual virtual .WindowBufferSizeEvent WINDOW_BUFFER_SIZE_RECORD end virtual virtual .MenuEvent MENU_EVENT_RECORD end virtual virtual .FocusEvent FOCUS_EVENT_RECORD end virtual .KeyEvent KEY_EVENT_RECORD }struct IREVENT |
|||
28 Apr 2024, 09:46 |
|
MatQuasar 28 Apr 2024, 10:08
bitRAKE wrote: Yeap. My example has complete console API definitions, but in this specific case the UNION contains a DWORD - which forces the alignment. Thank you so much, for confirming my doubts. I always think it is best to refer to the structure disassembled by a disassembler such as IDA Freeware. bitRAKE wrote: That's why I produced a comprehensive example to demonstrate the errors or validity of my understanding. That is a fine example although I don't understand macro. I am impressed with your "never-say-die" attitude in the console event examples (two of them). |
|||
28 Apr 2024, 10:08 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.