Jump to content
Sign in to follow this  
holoc

Need help with sending cmd to KEYB0ARD I/O port

Recommended Posts

holoc

WinIo - This library allows direct I/O port and physical memory access under Windows 9x/NT/2000 and XP. Version 2.0 provides faster I/O port access, better memory mapping support and can be used from non-administrative accounts under Windows NT/2000 and XP.

http://www.internals.com/utilities/winio.zip

The documentation is included within the archive.

Here is the code:

If WinActivate("Untitled - Notepad") = 0 Then
    MsgBox(0,"Error", "Start the Notepad first.")
    Exit;
EndIf
Sleep(1000)

DllOpen("WinIo.dll")
DllCall("WinIo.dll", "bool", "InitializeWinIo")
Sleep(100)

; send to port 0x64 Command Byte 0xD2 (Write keyboard buffer) - Parameter written to input buffer as if received from keyboard.
DllCall("WinIo.dll", "bool", "SetPortVal", "word", 0x64, "dword", 0xD2, "byte", 1)  
Sleep(100)

; send to port 0x60 Byte 0x04 (press key 3)
DllCall("WinIo.dll", "bool", "SetPortVal", "word", 0x60, "dword", 0x04, "byte", 1)  
Sleep(100)

; send to port 0x64 Command Byte 0xD2 (Write keyboard buffer) - Parameter written to input buffer as if received from keyboard.
DllCall("WinIo.dll", "bool", "SetPortVal", "word", 0x64, "dword", 0xD2, "byte", 1)  
Sleep(100)

; send to port 0x60 Byte 0x84 (release key 3)
DllCall("WinIo.dll", "bool", "SetPortVal", "word", 0x60, "dword", 0x84, "byte", 1)

DllCall("WinIo.dll", "none", "ShutdownWinIo")
DllClose("WinIo.dll")

I have NO ERRORS, but it doesn't work. It does not send anything(checked this). What is the right syntax?

SetPortVal
This function writes a BYTE/WORD/DWORD value to an I/O port. 

bool _stdcall SetPortVal(
   WORD wPortAddr,       
   DWORD dwPortVal,      
   BYTE bSize            
);                        
Parameters
wPortAddr 
[in] I/O port address 

dwPortVal 
[in] Value to be written to the port 

bSize 
[in] Number of bytes to write. 
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.