flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > [fasm2] Console Event Discovery

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 04 Apr 2024, 04:31
This console application is an exploration of fasm2/fasmg techniques to simplify common patterns by inventing syntax. This includes an extension to the MS COFF support, GLOBSTR extension for VT100/ANSI output/buildup.

This shows effective use of the modern virtual terminal interface in windows. As with most code it's messy and incomplete, with minor testing.


Description:
Filesize: 62.76 KB
Viewed: 1981 Time(s)

Screenshot 2024-04-03 221821.png


Description:
Download
Filename: conio.zip
Filesize: 9.64 KB
Downloaded: 96 Time(s)


_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup


Last edited by bitRAKE on 10 Apr 2024, 19:47; edited 1 time in total
Post 04 Apr 2024, 04:31
View user's profile Send private message Visit poster's website Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 04 Apr 2024, 07:46
Looks like a very sophisticated tool!

I have link error: [SOLVED]
Code:
C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x86\WindowsApp.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
conio.exe : fatal error LNK1120: 12 unresolved externals    


I need to use x64 Native Tools Command Prompt for VS 2022 instead of "x86" one.

It looks like ENABLE_VIRTUAL_TERMINAL_PROCESSING is not enabled. I am going to experiment with it.

Perfect, it is fun playing with your "console event discovery", I especially like the mouse wheeled event.
Post 04 Apr 2024, 07:46
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 04 Apr 2024, 08:50
In hindsight there are quite a few errors, and comment mistakes. Earlier Windows versions can link against kernel32.lib. Should work on Windows 10 version 1511 (November 2015 update) and Windows Server 2016.

For example, look at how the mouse button events work. Multiple buttons work in a strange way.
Post 04 Apr 2024, 08:50
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2024, 10:48
I updated your attachment to not include the executable file - please package only the sources whenever possible.
Post 04 Apr 2024, 10:48
View user's profile Send private message Visit poster's website Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 04 Apr 2024, 14:15
bitRAKE wrote:

For example, look at how the mouse button events work. Multiple buttons work in a strange way.


Yes, I tested, it came up "button: 1R" or "button: 12".... but mouse button is not designed to use that way, so I think should be okay.

I don't know what happens to PAUSE command to PowerShell, now it is "Press Enter to continue". Even PAUSE command in CMD does not accept key like Ctrl, Alt, Win.... (Sorry, this is more related to my "keypress" example two days ago. Razz )
Post 04 Apr 2024, 14:15
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 04 Apr 2024, 18:23
MOUSE_EVENT is just a bad design, imho. The button up event could indicate what button has been released. This isn't just about supporting a more complex usage of devices. More about not needing to cache state to respond to the event - the design assumes too much about the usage.

Some of this event handling will be deprecated in future Windows perhaps. Standard Win32 functions can be used for non-terminal UI elements - focusing the terminal on character only features.
Post 04 Apr 2024, 18:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Apr 2024, 11:46
Code:
        eval 'extrn "__imp_',`fun,'" as ',`fun,':QWORD'    
Is EVAL necessary here? The only thing that comes to mind is that it strips the function name of the namespace context, but you could also work around it by using &line& idiom in your interceptor. And this should work fine:
Code:
        extrn '__imp_' bappend `fun as fun: QWORD    
Post 06 Apr 2024, 11:46
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 06 Apr 2024, 18:32
That line goes way back - probably the first thing I tried to do in fasmg. bappend works well - I've never used it before.
Post 06 Apr 2024, 18:32
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 10 Apr 2024, 19:51
The example has been updated with the changes from the thread, as well as processing for the keyboard event. Some important oddities of working with events:
  • FOCUS_EVENT can be received AFTER event causing console to gain focus!
  • mouse wheel change is undocumented, [.MouseEvent.dwButtonState] >> 4
  • [.MouseEvent.dwControlKeyState] is documented incorrectly (partial flags compared to: [.KeyEvent.dwControlKeyState])
  • PowerShell requires a linefeed to update the prompt.
Post 10 Apr 2024, 19:51
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.