I have some Linux code that monitors our hardware by collecting temperatures, voltages, and fan speeds, from the motherboard using inb(), outb(), inl(), etc. low level i/o functions.
My challenge is to port that code over to run under Windows as a simple console app. But am puzzled in what functions Win32 (or .NET) provide that allow me permission to access direct memory mapped ports.
I don't want to code a system driver either.
My Windows tool preference is VS2008. (fyi)
Is this possible?
The default protection level for I/O ports in Windows prevents a user-mode program from using inp and out instructions on any port. Your program will die with a GPF. There are several freely available drivers around that change that protection level so that ring 3 code can access the ports. Which is okay if you're interested in killer pokes.
The canonical one is inpout32.
Most hardware locations are mapped in areas not accesible from userspace, so you are going to need a device driver that provides the desired API.
You can also check the UNIX Application Migration Guide ad MSDN.
来源:https://stackoverflow.com/questions/2607657/windows-equivalent-of-inb-outb-low-level-i-o