Writing INF files for NT4 driver...

Oh my, the messes I get myself into.

I’ve been assigned to write an INF file to install an existing driver under NT4.

Background:
The driver is the communication interface between a windows program
and a custom ISA board. The driver does work and has not been touched
in several years.

Up until now, the driver has been loaded on the fly by the application
via the service manager APIs. (yes, that’s right, we’re loading the
driver for an actual piece of hardware on the fly.).

New security requirements demand that we run the application as a
non-administrative user. This, of course, means that we no longer have
the option of loading the driver on the fly - we’re going to have to
properly install it.

Now, I’ve done driver development before, including the creation of an
INF file, but I did it under Windows XP, and on a previous job.

The driver install consits of a single .sys file and a couple of
registry entries.

Things I’ve done:
I’ve verified (using the OSR DriverLoader) that I can in fact register
and run the driver correctly, when I place the driver file in
c:\winnt\system32\drivers.

My problems:
Is C:\winnt\system32\drivers the correct location for a non-PNP driver to live?

I’ve hacked up an INF file (below) that I’m trying to use, based on a
reading of the INF docs in the current WDK documentation, and a
working XP INF file. I can’t get it to load, either by right-clicking
on the inf file (I don’t get an error, just nothing happens), nor by
using the Multimedia control panel (I figured since I used class
‘Media’, that would be the one to use).

Can anyone point me the direction of what I’m doing wrong here?
Obviously the problem is that I don’t know enough about NT4 INF files,
but I may simply be going about the installation incorrectly.

Any help would be appreciated. Thanks!

The prototype INF file:

;Copyright 2007 Gilbarco Veeder-Root
;
; Install information file for sc3.sys driver
; This driver is NT4 ONLY!
;
; This inf was written LONG after the driver.
;

;--------- Version Section ---------------------------------------------------

[Version]
Signature=“$WINDOWS NT$”
; TODO: which class should this driver be?
Class=Media
ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
Provider=%Provider%
; TODO: find out ver # of actual driver.
DriverVer=11/7/2007,0.0.0.1

;--------- DestinationDirs Section -------------------------------------------

; I think on NT, drivers go in %windir%/system32/drivers. that’s dirid 12
[DestinationDirs]
DefaultDestDir = 12

;--------- SourceDiskNames and SourceDiskFiles Section -----------------------
; These sections identify source disks and files for installation.

[SourceDisksNames]
; one source disk only, driver in \i386 directory
1 = %DiskId1%,\i386

[SourceDisksFiles]
SC3.sys = 1,

;--------- Manufacturer and Models Sections ----------------------------------

[Manufacturer]
%Provider%=DeviceList

; Models section - NT4
[DeviceList]
%SC3Desc%=DriverInstall

;---------- DDInstall Sections -----------------------------------------------

; --------- Windows NT -----------------
[DriverInstall]
CopyFiles=DriverFiles
AddReg = SC3HW_Registry

[DriverInstall.Services]
Addservice = SC3, 0x2, DriverService, EventLogging

;---------- End DDInstall Sections

; --------- Service ----------------------
[DriverService]
DisplayName = %ServiceDescription%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\SC3.sys
LoadOrderGroup = Extended Base

; --------- Event Logging ----------------------
; add registry entries so that event logger can translate
; our messages. Reference iologmsg.dll (standard system messages)
[EventLogging]
AddReg=EventLogAddReg

[EventLogAddReg]
HKR,EventMessageFile,0x00020000,“%11%\iologmsg.dll”
HKR,TypesSupported,0x00010001,7

; --------- Hardware Specific Registry entries ----------------------

[SC3HW_Registry]
; two DWORDs - segement and irq
HKLM,“hardware\devicemap\gasboysc3”,segment,0x00010001,0xD0000
HKLM,“hardware\devicemap\gasboysc3”,irq,0x00010001,0xA

; --------- Files ----------------------

[DriverFiles]
SC3.sys,2

;--------- Strings Section ---------------------------------------------------

[Strings]
Provider = “Gilbarco Veedeer-Root”
SC3Desc = “SC3 Device”
ServiceDescription = “SC3 Device Driver”
DiskId1 = “SC3 Device Installation Disk #1

REG_SZ = 0x00000000
REG_MULTI_SZ = 0x00010000
REG_EXPAND_SZ = 0x00020000
REG_BINARY = 0x00000001
REG_DWORD = 0x00010001
REG_NONE = 0x00020001

SERVICE_KERNEL_DRIVER = 0x00000001
SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
SERVICE_ADAPTER = 0x00000004
SERVICE_RECOGNIZER_DRIVER = 0x00000008

SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2

SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4

SERVICE_ERROR_IGNORE = 0x00000000
SERVICE_ERROR_NORMAL = 0x00000001
SERVICE_ERROR_SEVERE = 0x00000002
SERVICE_ERROR_CRITICAL = 0x00000003


Michael Kohne
xxxxx@kohne.org

> Is C:\winnt\system32\drivers the correct location for a non-PNP driver to

live?

NT 4 didn’t have pnp, so yes.

I’ve hacked up an INF file (below) that I’m trying to use, based on a
reading of the INF docs in the current WDK documentation, and a
working XP INF file. I can’t get it to load, either by right-clicking
on the inf file (I don’t get an error, just nothing happens), nor by
using the Multimedia control panel (I figured since I used class
‘Media’, that would be the one to use).

“Add new hardware” is your friend. Do that, select “have disk”, point to
the INF file. You probably have to manually select the device type, which I
suppose would be “sound and ” (name changes with every OS version
and I don’t have an NT 4 install here to check.)

From memory I think this inf file will probably work on NT 4, but you have a
lot of unnecessary stuff up at the front. It may not hurt anythign though.

> Signature=“$WINDOWS NT$”
> ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
> DriverVer=11/7/2007,0.0.0.1

Loren

----- Original Message -----
From: “Michael Kohne”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, November 07, 2007 12:43 PM
Subject: [ntdev] Writing INF files for NT4 driver…

> Oh my, the messes I get myself into.
>
> I’ve been assigned to write an INF file to install an existing driver
> under NT4.
>
> Background:
> The driver is the communication interface between a windows program
> and a custom ISA board. The driver does work and has not been touched
> in several years.
>
> Up until now, the driver has been loaded on the fly by the application
> via the service manager APIs. (yes, that’s right, we’re loading the
> driver for an actual piece of hardware on the fly.).
>
> New security requirements demand that we run the application as a
> non-administrative user. This, of course, means that we no longer have
> the option of loading the driver on the fly - we’re going to have to
> properly install it.
>
> Now, I’ve done driver development before, including the creation of an
> INF file, but I did it under Windows XP, and on a previous job.
>
> The driver install consits of a single .sys file and a couple of
> registry entries.
>
> Things I’ve done:
> I’ve verified (using the OSR DriverLoader) that I can in fact register
> and run the driver correctly, when I place the driver file in
> c:\winnt\system32\drivers.
>
> My problems:
> Is C:\winnt\system32\drivers the correct location for a non-PNP driver to
> live?
>
> I’ve hacked up an INF file (below) that I’m trying to use, based on a
> reading of the INF docs in the current WDK documentation, and a
> working XP INF file. I can’t get it to load, either by right-clicking
> on the inf file (I don’t get an error, just nothing happens), nor by
> using the Multimedia control panel (I figured since I used class
> ‘Media’, that would be the one to use).
>
> Can anyone point me the direction of what I’m doing wrong here?
> Obviously the problem is that I don’t know enough about NT4 INF files,
> but I may simply be going about the installation incorrectly.
>
> Any help would be appreciated. Thanks!
>
> The prototype INF file:
>
> ;Copyright 2007 Gilbarco Veeder-Root
> ;
> ; Install information file for sc3.sys driver
> ; This driver is NT4 ONLY!
> ;
> ; This inf was written LONG after the driver.
> ;
>
> ;--------- Version
> Section ---------------------------------------------------
>
> [Version]
> Signature=“$WINDOWS NT$”
> ; TODO: which class should this driver be?
> Class=Media
> ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
> Provider=%Provider%
> ; TODO: find out ver # of actual driver.
> DriverVer=11/7/2007,0.0.0.1
>
>
> ;--------- DestinationDirs
> Section -------------------------------------------
>
> ; I think on NT, drivers go in %windir%/system32/drivers. that’s dirid 12
> [DestinationDirs]
> DefaultDestDir = 12
>
>
> ;--------- SourceDiskNames and SourceDiskFiles
> Section -----------------------
> ; These sections identify source disks and files for installation.
>
> [SourceDisksNames]
> ; one source disk only, driver in \i386 directory
> 1 = %DiskId1%,\i386
>
> [SourceDisksFiles]
> SC3.sys = 1,
>
>
> ;--------- Manufacturer and Models
> Sections ----------------------------------
>
> [Manufacturer]
> %Provider%=DeviceList
>
> ; Models section - NT4
> [DeviceList]
> %SC3Desc%=DriverInstall
>
>
> ;---------- DDInstall
> Sections -----------------------------------------------
>
> ; --------- Windows NT -----------------
> [DriverInstall]
> CopyFiles=DriverFiles
> AddReg = SC3HW_Registry
>
> [DriverInstall.Services]
> Addservice = SC3, 0x2, DriverService, EventLogging
>
> ;---------- End DDInstall Sections
>
>
> ; --------- Service ----------------------
> [DriverService]
> DisplayName = %ServiceDescription%
> ServiceType = %SERVICE_KERNEL_DRIVER%
> StartType = %SERVICE_DEMAND_START%
> ErrorControl = %SERVICE_ERROR_NORMAL%
> ServiceBinary = %12%\SC3.sys
> LoadOrderGroup = Extended Base
>
> ; --------- Event Logging ----------------------
> ; add registry entries so that event logger can translate
> ; our messages. Reference iologmsg.dll (standard system messages)
> [EventLogging]
> AddReg=EventLogAddReg
>
> [EventLogAddReg]
> HKR,EventMessageFile,0x00020000,“%11%\iologmsg.dll”
> HKR,TypesSupported,0x00010001,7
>
> ; --------- Hardware Specific Registry entries ----------------------
>
> [SC3HW_Registry]
> ; two DWORDs - segement and irq
> HKLM,“hardware\devicemap\gasboysc3”,segment,0x00010001,0xD0000
> HKLM,“hardware\devicemap\gasboysc3”,irq,0x00010001,0xA
>
>
> ; --------- Files ----------------------
>
> [DriverFiles]
> SC3.sys,2
>
> ;--------- Strings
> Section ---------------------------------------------------
>
> [Strings]
> Provider = “Gilbarco Veedeer-Root”
> SC3Desc = “SC3 Device”
> ServiceDescription = “SC3 Device Driver”
> DiskId1 = “SC3 Device Installation Disk #1
>
> REG_SZ = 0x00000000
> REG_MULTI_SZ = 0x00010000
> REG_EXPAND_SZ = 0x00020000
> REG_BINARY = 0x00000001
> REG_DWORD = 0x00010001
> REG_NONE = 0x00020001
>
> SERVICE_KERNEL_DRIVER = 0x00000001
> SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
> SERVICE_ADAPTER = 0x00000004
> SERVICE_RECOGNIZER_DRIVER = 0x00000008
>
> SERVICE_BOOT_START = 0x0
> SERVICE_SYSTEM_START = 0x1
> SERVICE_AUTO_START = 0x2
>
> SERVICE_DEMAND_START = 0x3
> SERVICE_DISABLED = 0x4
>
> SERVICE_ERROR_IGNORE = 0x00000000
> SERVICE_ERROR_NORMAL = 0x00000001
> SERVICE_ERROR_SEVERE = 0x00000002
> SERVICE_ERROR_CRITICAL = 0x00000003
>
>
>
> –
> Michael Kohne
> xxxxx@kohne.org
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

On 11/8/07, Loren Wilton wrote:
> > Is C:\winnt\system32\drivers the correct location for a non-PNP driver to
> > live?
>
> NT 4 didn’t have pnp, so yes.

Good, at least I had that much right.

<snip: mike can load hacked up inf file>
>
> “Add new hardware” is your friend. Do that, select “have disk”, point to
> the INF file. You probably have to manually select the device type, which I
> suppose would be “sound and ” (name changes with every OS version
> and I don’t have an NT 4 install here to check.)

Where would you expect to find the add new hardware functionality?
I’ve looked under the system control panel, the devices control panel,
etc and can’t find any mention of it.

I have played a little bit with some examples I received of NT4 INF
files (from an old DDK). Using the SCSI control panel, I can see them,
and the SCSI example comes up, while the non-SCSI examples say ‘The
specified location does not contain information about your hardware’.
Similarly, if I use the ‘tape’ control panel, the tape example comes
up, the other examples say ‘The specified location does not contain
information about your hardware’.

My suspicion (and possibly false memory) is that NT4 didn’t have a
general ‘add hardware’ facility (except possibly in the setup
program), but instead has specific control panels to load specific
types of hardware. I suspect add new hardware was introduced with PnP
in Win2K.

Any opinions on what I’ve come up with? I’m laregely clueless here
(all my previous driver work has been under XP), so any help is
appreciated.

Thanks!


Michael Kohne
xxxxx@kohne.org</snip:>

Michael Kohne wrote:
> I’ve been assigned to write an INF file to install
> an existing driver under NT4.

Please see
http://www.osronline.com/DDKx/install/create-inf_9xpj.htm
http://www.google.de/search?q=Cross-Platform+INF+Files+NT4

Hope it helps,
-H

> Where would you expect to find the add new hardware functionality?

I’ve looked under the system control panel, the devices control panel,
etc and can’t find any mention of it.

Um. I *thought* NT 4 had that, but maybe I’m mistaken. I’m on the road and
don’t have NT 4 here to check.

BTW, if you have a software install technique that works, rip it out of the
app and put it into an install program and just use that. If you don’t
uninstall the driver it will be sitting there waiting to be used each time
the app comes up.

Loren

On 11/9/07, Loren Wilton wrote:
> > Where would you expect to find the add new hardware functionality?
> > I’ve looked under the system control panel, the devices control panel,
> > etc and can’t find any mention of it.
>
> Um. I thought NT 4 had that, but maybe I’m mistaken. I’m on the road and
> don’t have NT 4 here to check.

It’s not impossible that it was added by a service pack that our
system isn’t using (I didn’t get an NT4 install CD, I just got a
pre-installed system from our factory). So perhaps it was added later.

> BTW, if you have a software install technique that works, rip it out of the
> app and put it into an install program and just use that. If you don’t
> uninstall the driver it will be sitting there waiting to be used each time
> the app comes up.

Yes. As it happens, I’ve just found out that the driver depends on
registry keys that are in a section that gets wiped out on boot (by
windows, apparently). So I’m basically toast as far as writing the INF
file goes anway.

It looks like I’m just going to have to write a simple service,
running as Administrator, that sets the keys and loads the driver (if
not already loaded). Basically, rip the load code out of the app, put
it in a service.

Thanks everyone, for all your help (again).

I really appreciate it.


Michael Kohne
xxxxx@kohne.org