Copyright © 2002 CanSoft
The CanIO software is a 2-file combination utility: a DLL and SYS kernel mode driver [CANIO].
The DLL can be loaded like any other DLL and the routines are outlined below. The purpose of the application is to open up port access (for example the CMOS at port 0x70) anywhere in the 64k IO space through Windows NT/2000/XP and .Net applications. Windows 95, 98, ME do not block access to these ports but the other MS operating systems do. My utility will assign rights to your application to read and write from these ports in these applications.
You load the DLL and call the AddMultiPort routine as needed. The DLL will check your OS (or you can do this yourself in your own application if you want) and if you have NT/2000/XP/.Net installed it will then call the kernel mode driver which will in turn give to your calling application the rights to read/write from the requested ports. If it is Win95/98/ME then the DLL won't call the SYS, as it won't even be installed, and will just do nothing, as your app already has rights in this environment.
Your application should detect OS and then install the CanIO. SYS driver if needed through your own install process depending upon your development language.
For testing purposes, however, there are two ways you can install the kernel mode driver:
With the instdrv.exe application, type at the command prompt: instdrv canio c:\pathtocaniosys\canio.sys The "pathtocaniosys" directory is whatever directory you have copied the CanIO.sys driver to. If you use this method, the CanIO.dll does not have to be in the same directory as the CanIO.sys file.
Everytime you load the CanIO.DLL library, it will detect the OS type installed and then if it is WinNT/2000/XP/.Net it will try to get a handle to the CanIO service (CanIO.sys). If it cannot get a handle to the CanIO service (meaning it is not installed or is not running), it will attempt to locate the CanIO.sys file and attempt to install and start the service automatically for you.
This will work if and only if you are logged into the machine with administrative privileges. Also, the CanIO. sys file MUST be in the same directory as the CanIO.dll file because that is where it will look for it. So this method actually requires that you do nothing other than making sure you have admin privileges on the machine and that the .sys file is on the same directory as the .dll.
BOOL AddMultiPort(ULONG, INT)
AddMultiPort(0x400, 2);
AddMultiPort(0x70, 1);
BOOL UnloadDrvr()
Defines | |
#define | IMPORT __declspec(dllimport) |
use function from DLL | |
#define | CANIO_API __stdcall |
CanIO dynamic-link library calling convention. | |
Functions | |
IMPORT BOOL CANIO_API | AddMultiPort (ULONG base, int length) |
provide access privilege to a range of I/O-port addresses. |
|
It's not stated in the documentation, but CanIO uses the Pascal calling convention (like WinAPI). Initially I defined CANIO_API as empty and could use the Rulbus Device Library DLL succesfully (that is without access violation exceptions). After some code changes, rulbus.dll started to give access violation exceptions. Debugging with fprintf() statements finally pointed to AddMultiPort() and I started to suspect its prototype.
Changing the empty Martin J. Moene, 4 June 2003. |
|
this function provides port access to the number of i/o-ports specified by
|