Home BDM TFTP

ParPort 2000 - Direct I/O Access from Win32 User Mode Applications to PC Parallel Port(s) under Microsoft Windows NT 4.0, Windows 2000 & Windows XP

Overview ParPort 2000 delivers the ability to access PC parallel ports from Win32 applications under Microsoft Windows NT 4.0, Windows 2000 & Windows XP. Previously, the only way would have been to write an device driver to perform the I/O on behalf of the application.

This kernel mode driver and Win32 library combination allow Win32 applications to execute IN and OUT instructions to the parallel port device hardware I/O ports.

Access is coordinated with the standard Windows parallel driver to ensure that the parallel port is only 'claimed' if no other process is currently using it. Once the port is 'claimed', other processes are blocked from using the port (assuming they also use the standard parallel port arbitration scheme).

Once the application has finished using the parallel port, it may either exit or call the 'release' API and the parallel port is free for use by any other process again.

Now, with one simple command, you can grant parallel port access to a specific application.

The program RUNAPP.EXE comes with the ParPort 2000 and can be run to allow another application the Parallel Port.

To run a 32bit app use this command:

RUNAPP <Parallel Port#> <Application>

To run a 16bit DOS app use this command:

RUNAPP <Parallel Port#> command.com /c <Application>

 

How it works Normally, under Windows NT / Windows 2000 / Windows XP, access is not permitted to the I/O port range of the parallel port (and most others). Executing an IN or OUT instruction causes a privileged instruction exception resulting in termination of the process.

The driver works by changing the I/O permission map (IOPM) for the process that 'claims' the indicated parallel port. Changing the IOPM, allows the process free access to the I/O port range of the parallel port hardware. It also supports additional parallel ports added using expansion cards.

 

The Details The API calls are provided in a Win32 DLL. One call is all that is required to use the direct I/O functionality. The Win32 application is linked with the supplied import library and the kernel driver is demand loaded as necessary. No tampering with the registry or rebooting is needed.

The API calls are documented here:

Include the header file for definitions and function prototypes.

#include "ParPort2k.h"

The GetParallelPortCount API returns the number of parallel ports present in the PC.

INT WINAPI GetParallelPortCount(VOID)

Return value:

The number of parallel ports present in the PC or 0 if none are present or an error occurred. For the specific error code, call the standard Win32 function GetLastError().

The GetParallelPortInfo API returns information about the a particular indicated parallel port, such as the physical I/O port address and number of I/O port addresses spanned by the hardware device.

BOOL WINAPI GetParallelPortInfo(
  DWORD        dwPort,
  PPARLLIOINFO pinfo)

Arguments:

dwPort specifies the parallel port for which information should be returned
pinfo specifies the address of a PARLLIOINFO structure defined below. The member dwParllIoInfoSize should be initialized on entry to size(PARLLIOINFO).

Return value:

TRUE if the function returns the port information or FALSE if the port does not exist or an error occurs. For the specific error code, call the standard Win32 function GetLastError().

typedef struct {
  // size of structure
  DWORD dwParllIoInfoSize;
  // address of parallel port
  DWORD dwPortAddress;
  // span of parallel port
  DWORD dwPortSpan;
} PARLLIOINFO, *PPARLLIOINFO;

The ClaimParallelPort API attempts to allocate the specified parallel port from the standard Windows NT parallel driver. A timeout may be specified to wait for the port to become free if already allocated. Additionally, either no wait may be specified or wait indefinitely.

BOOL WINAPI ClaimParallelPort(
  DWORD dwPort,
  DWORD dwTimeout)

Arguments:

dwPort specifies the parallel port to be claimed
dwTimeout specifies in milliseconds how long to wait for the parallel port if already owned by another process or INFINITE to wait indefinitely or 0 not to wait at all.

Return value:

TRUE if the function succeeds in claiming the parallel port specified or FALSE if it is in use or an error occurs. For the specific error code call the standard Win32 function GetLastError().

The ReleaseParallelPort API frees the parallel port for use by another process. Direct I/O should not be performed after this function is called. If this function is not called, the application will own the parallel port until the application exits or is terminated.

BOOL WINAPI ReleaseParallelPort(
  DWORD dwPort)

Arguments:

dwPort specifies the parallel port to release

Return value:

TRUE if the function succeeds in releasing the parallel port specified or FALSE if the function fails or the process doesn't own the parallel port. For the specific error code call the standard Win32 function GetLastError().

The EnableIOPortRange API allows an application to read/write to a range of I/O addresses. Specifing the start I/O address and the span enables access to the given I/O ports.

BOOL WINAPI EnableIOPortRange(
  HANDLE hReserved,
  DWORD  dwIOStart,
  DWORD  dwIOSpan)

Arguments:

hReserved reserved parameter must be set to 0.
dwIOStart specifies the starting address to enable access for
dwIOSpan specifies the span of address to enable access for

Return value:

TRUE if the function succeeds in enabling I/O access to the ports specified or FALSE if the function fails. For the specific error code call the standard Win32 function GetLastError().

For Visual Basic users six functions are provided for input and output as follows:

VOID WINAPI OutByte(
  DWORD dwAdrs,
  INT   nByte)

VOID WINAPI OutWord(
  DWORD dwAdrs,
  INT   nWord)

VOID WINAPI OutDWord(
  DWORD dwAdrs,
  INT   nDWord)

INT WINAPI InByte(
  DWORD dwAdrs)

INT WINAPI InWord(
  DWORD dwAdrs)

INT WINAPI InDWord(
  DWORD dwAdrs)

I/O Timing I/O instructions executing in user mode (ring 3) will take longer than executing in kernel mode (ring 0). It is however, dependent upon the processor, but the number of clocks taken is generally two to three times that of comparable real-mode (i.e. MS-DOS) execution. Having said that, it is significantly quicker than calling down to a kernel mode driver for each IN / OUT instruction as some other NT I/O drivers require.

 

Installation ParPort 2000 developer edition consists of a header file ParPort2k.h containing definitions and function prototypes, a Microsoft Visual C++ 6.0 compatible import library ParPort2k.lib to be linked with the application and some example test programs. Both C and Visual Basic examples are supplied.

ParPort 2000 runtime edition consists of two files, a kernel mode driver ParPort2k.sys and a dynamic link library, ParPort2k.dll. These files should be distributed with the application.

The driver may either be loaded on-demand or may be loaded when the system boots. If the driver is loaded on-demand, the user running the application must have NT administrator rights.

If it is envisaged that the user running the program will not have NT administrator rights, the driver can be installed to load at boot. NT administrator rights are still needed during setup, but once completed the driver can be used by non administrative users.

A setup program is provided to create the necessary registry entries to load the driver at boot. It can be run in quiet mode so that it can be called from the application setup program or in interactive mode.

If the driver will be loaded on-demand, the application setup program can copy the files into the application directory.

Running the command setup /h show the setup program options.

To perform a quiet mode installation from another setup program, run the following command setup /q.This will copy ParPort2k.sys to the system32\drivers directory and ParPort2k.dll to the system32 directory and make the necessary registry entries to load the driver on boot.

Alternatively, use the setup program in interactive mode as shown below.

 

 

Windows 95/98 Support Under Microsoft Windows 95/98 direct port I/O is allowed to certain I/O address ranges out of the box. The parallel ports are one such range. When running under Windows 95/98, the library ParPort2k.dll skips the calls to the kernel driver allowing the same code base and file set to be shipped for both Windows NT and Windows 95/98. The bios is used to find the number of parallel ports installed and the addresses of those ports. Two additional dll's, ParllI32.dll & ParllI16.dll, are provided to look up the parallel port information in the bios segment. Additionally, PPort2k.vxd, is provided to allow cooperating applications coordinated access to the parallel ports.
Price and Availability  
Developer Edition $59.95USD
Runtime Edition Licenses
1 - 10 users $19.95USD each
11 - 50 users $14.95USD each
51 - 100 users $9.95USD each

Unlimited distribution license is $995USD.

On-line payment with PayPal

Order here

For further information please email sales@zeecube.com

Please email support questions to support@zeecube.com

 

License Agreements Click here to read the development license agreement.
Click here to read the run-time license agreement.
Last updated March 10th 2002

Hit Counter

Valid HTML 4.01!