• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Access parallel port directly in NT 4 (1000 pts)

I'm writing a driver for a special device on the parallel port of the computer, does anyone have a start for me like some sample code for a kernel mode device driver enabling to access the parport through a dll function? Oh and by the way Createfile("lpt1",....) is not the way it's going to work, I need something like the good old dos inport, outport

thanks in regard of your answer
    - Raymond

btw I'm offering a 1000 points for the right answer!!! I'll first check the answers. If the information suits my needs you're the lucky winner of the jackpot!
0
rdno
Asked:
rdno
  • 12
  • 11
  • 2
1 Solution
 
jkrCommented:
See the 'Sybera Hardware Access' Kit at http://www.sybera.de/home.htm which allows direct hardware access under NT without developing your own driver. Can be downloaded for free at http://www.sybera.de/download/sha.exe 
0
 
jkrCommented:
BTW: If you really want to write your own driver, the NT DDK comes with various driver sawmples, which also contain a sample parralel port driver. The DDK can be found at http://www.microsoft.com/hwdev/ddk/
0
 
jkrCommented:
Hmmm - if yo uhave difficulties locating the parallel port driver sample, it can be found at
%BASEDIR%\src\comm\parport
after installing the DDK...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
rdnoAuthor Commented:
yeak I found it, but I'm totally new to device driver programming. I got the ddk already, do you know if it's possible to use the ddk kit from withing the VC++?
0
 
rdnoAuthor Commented:
oh and I downloaded the kit already, before you mentioned, but it has to be my own device driver, It's for a school project. Even my teacher don't know how to program the parport in NT
and can you give me the way to make an device driver installer, can it be done with installshield for Vc++ enterprice?
0
 
rdnoAuthor Commented:
do you know where the parlog.rc is located?
0
 
rdnoAuthor Commented:
damn, do I need another ddk or SDK?
0
 
rdnoAuthor Commented:
damn, do I need another ddk or SDK?
0
 
jkrCommented:
Hmm, sorry for the delay, but it's Europe here and half past midnight meanwhile ;-)

No, you need nothing else but the DDK and VC++. There's a .bat file in the %BASEDIR%\bin directory that sets the environment properly - you'll have to call it from the console window from where you run the 'build' command. (Hmm, being at home now, I don't have a DDK here, so please bear with me - I don't know the directory structure of the samples by heart...)
0
 
jkrCommented:
>>can you give me the way to make an device driver
>>installer, can it be done with installshield for Vc++
>>enterprice?

Yes, it can be done - all you need is the 'instdrv' sample, which installs a driver.  This one can be caled from your setup script in order to install the driver (maybe you'll need a wrapper DLL, so feel free to ask if so - been there, done that...)


But as this is a school project, I highly recommend using the package I mentioned earlier. I do SWDEV for my living, and I have to say that it's quite a *lot* of work to be able to write a stable driver...
0
 
jkrCommented:
Well, being back at work, I have acces to my links again ;-)

Be sure to check out

http://www.lvr.com/parport.htm#Programming

on this issue...


BTW: The parport.rc file resides in the same directory as the sample...

Oh, yes, and the environment is set up by calling

%SystemRoot%\SYSTEM32\cmd.exe /k %BASEDIR%\bin\setenv.bat %BASEDIR% free
0
 
rdnoAuthor Commented:
damn, I get only this message

C:\DDK\bin>setenv c:\ddk
Error: MSTOOLS environment variable not recognized.
       The Win32 SDK must be installed.

C:\DDK\bin>

well about the school project... it has to be my own work.. not any 3rd party software
0
 
jkrCommented:
Aaah - the problem is that this batch file is looking for the 'normal' SDK or the Platform SDK, which can be found at
http://msdn.microsoft.com/downloads/sdks/platform/default.asp

Since you're using VC++, simply locate a 'setenv.bat' file in it's directory structure and

set MSTOOLS=<path to 'setenv.bat' without filename>

but, to be honest,

set MSTOOLS=trash

will also remedy the problem ;-)
0
 
TryCommented:
.. which allows direct hardware access under NT

------------------------------------

"jkr" are you sure about this?  My entire understanding of NT is that it purposefully prevents someone from expressly doing something like this.  That's my understanding why the Hardware Abstraction Layer exist in the first place.
0
 
jkrCommented:
>>"jkr" are you sure about this?  

Of course - but I should have added 'on Intel machines'.

This package is simply a KMode driver that has a call interface which allows user mode applications to request direct port I/O and to retrieve the results.

>>My entire understanding of NT is that
>>it purposefully prevents someone from
>>expressly doing something like this

You're right - but only if 'someone' isn't a kernel mode driver ;-)

You can even have user mode code executed at Ring 0:

    case    IRP_MJ_DEVICE_CONTROL:

            // Make sure this is a valid IOCTL for us...
            if  (       IOCTL_KE_EXEC
                    !=  pIos->Parameters.DeviceIoControl.IoControlCode
                )
                {
                    ntStatus    =   STATUS_INVALID_PARAMETER;
                }
             else
                {
                    // Get the pointer to the function to call
                    VOID ( *pfnUserFuncToCall)( PULONG) =   pIrp->UserBuffer;
                    // And the argument to pass
                    PVOID   pvUserArg;

                    pvUserArg   =   pIos->Parameters.DeviceIoControl.Type3InputBuffer;

                    // Call user's function with the parameter
                    if  (   pfnUserFuncToCall)
                        {
                            DbgPrint    (   "KeExec.SYS: pfnUserFuncToCall == 0x%8.8x, arg == 0x%8.8x\n",
                                            pfnUserFuncToCall,
                                            pvUserArg
                                        );

                            ( pfnUserFuncToCall)    ( pvUserArg);

                        }

                    ntStatus    =   STATUS_SUCCESS;
                }

            break;



0
 
rdnoAuthor Commented:
Damn microsoft... i tried to download the SDK, but after 30 retries it only gave the error message file not found, I'll try to download it on a much faster connection....
0
 
rdnoAuthor Commented:
and redirect mstools to itself, it ended with:

C:\>set MSTOOLS=c:\ddk\bin

C:\>cd %mstools%

C:\DDK\bin>setenv

usage: setenv <directory> [free|checked]

  Example:  setenv d:\ddk checked     set checked environment
  Example:  setenv d:\ddk             defaults to free environment


C:\DDK\bin>setenv c:\ddk
******  B A T C H   R E C U R S I O N  exceeds STACK limits ******
Recursion Count=1267, Stack Usage=90 percent
******       B A T C H   PROCESSING IS   A B O R T E D      ******

C:\DDK\bin>set mstools=trash

C:\DDK\bin>setenv c:\ddk
The system cannot find the path specified.
0
 
rdnoAuthor Commented:
I'm going to reinstall NT 4 on a clean partition, just with the SDK, DDK and VC++
0
 
jkrCommented:
>>C:\>set MSTOOLS=c:\ddk\bin

This will lead to an infinite recursion...

You don't have to do that ;-)

Simply close the console window and open a new one...
0
 
jkrCommented:
set MSTOOS=something
setenv c:\ddk free

should do it - if you examine the batch file, you'll see that it only tries to set the SDK evironment before it sets the DDK environment. And as the SDK environment is already set in your global system environment, this is obsolete...
0
 
TryCommented:
"jkr" you remind me a lot of Scott Meyers!  Both of you are radicals when it comes to probing the software boundaries, and who knows the territory very well.
0
 
rdnoAuthor Commented:
jkr.... I think you know the answer on my problem, if I give you the points, do you want to help me further when I need it by mail?
If so, I would be glad, cuz I am totally new to driver development, but it has to B done!

   - Raymond
0
 
jkrCommented:
>>if I give you the points, do you want
>>to help me further when I need it by
>>mail?

Sure, no problem...
0
 
rdnoAuthor Commented:
OK. tnx.
send a mail to rdno@chello.nl
and we go on by mail..
0
 
jkrCommented:
On the way ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 11
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now