hitcounter
dpointer
Tuesday, February 22, 2005
 
I/O Port Access under Windows NT/2000/XP

Under DOS, you are free: you can directly access whatever hardware input/output ports you want to use. But with a real 32-bit operating system like Microsoft Windows NT family (this includes Windows 2000 and Windows XP), not longer you have such a wonderful freedom. Most of the time, you need to communicate with a device driver which then translates your commands and dispatches them properly to the device itself.

If you are stuck with legacy hardware, for which you would never ever find the corresponding device driver and/or you hesitate to waste your time and brain on writing one, a cheap solution exists: UserPort, which is "... a simple kernel mode driver for Windows NT/2000/XP that will give programs access to I/O ports..". Sounds perfect, right?

All you have to do is simple. Just grab UserPort.zip from the above mentioned link then extract it. Copy the file userport.sys to your Windows driver folder(e.g. c:\Windows\System32\Drivers). Then run userport.exe from where you can ranges of port addresses that you want to access directly. Click the Start button and you're done (though sometimes you need to restart the system).

Now this kind of prehistoric code will work even under Windows XP:

void outportb(unsigned int portid, unsigned char value)
{
  __asm mov edx,portid
  __asm mov al,value
  __asm out dx,al
}

void myfunction()
{
  char somevalue = 0x14;
  char anothervalue = 0x03;
  outportb( CARD_BASE_ADDRESS, somevalue );
  outportb( CARD_BASE_ADDRESS+1, anothervalue );
}

Comments:
Good to know this exists. Thanks :)
 
Post a Comment

<< Home

Powered by Blogger