I have been doing basic NASM coding, and I wondered if it is possible to emulate a keypress using NASM. If so, how?
I’m using Ubuntu linux 10.04 and a Pentium R T4300 processer if it matters.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are several possible paths to proceed depending on what you want to do exactly. None of them are very simple (like for example in DOS) since there is no single globally accessable keyboard buffer in Linux. I don’t think it’s possible to inject events into the kernel driver for your keyboard (correct me if i’m wrong). Unless, of course, you modify the driver. You can create a virtual keyboard and configure your programs to read events from that in addition to your real one. Or if you only need it to work in a specific environment on top of Linux (for example X) you might find some usable function in it’s API.
For some scenarios on the other hand it can be very simple. If you want to automatically answer some questions in an interactive terminal application you do it like:
yes | someapplicationorecho yyny | someapplication. Obviously what was shell code and not nasm code. Translating it is left as an exercise for the reader.