SetupCopyOEMInf with cat files

Hi all,

I seem to being having comprehension issues with the help for SetupCopyOEMInf. I have a signed driver, so I have a sys, cat, and .inf file. To complete the installation, I copy the .sys to c:\windows\system32\drivers, and then I call SetupCopyOEMInf twice, the first time with SP_COPY_OEMINF_CATALOG_ONLY CopyStyle, and the second time with the CopyStyle set to zero. In both cases, I am passing the full path to the driver’s .inf file as the first parameter, then NULL, SPOST_PATH, CopyStyle, char *, MAX_PATH, &Size, NULL).

From the documentation, it looks like I should do this because it says:

SP_COPY_OEMINF_CATALOG_ONLY The specified .inf file’s corresponding catalog files is copied to %windir%\Inf. If this flag is specified, the destination filename information is entered upon successful return if the specified .inf file already exists in the Inf directory.

And then it says:

If the specified .inf file already exists a further check is performed to determine if the specified .inf file contains a CatalogFile= entry in its [Version] section. If it does, the .inf files’s %windir%\Inf primary filename with a “.cat” extension is used to determine if the catalog is already installed. If there is a catalog installed, but it is not the same as the catalog associated with the source .inf, this is not considered to be a match and enumerations continue. It is possible to have multiple identical .inf files with unique catalogs contained in %windir%\Inf directory. If an existing match is not found, the .inf and .cat files are installed under a new and unique name.

Which looks like the cat file must be installed before the .inf file, I think.

The bad behavior I am seeing is that on a clean Vista install, the installation seems to fail (not sure why). When the PDO gets created, Vista seems to be unable to find a driver, and yet doesn’t pop the “Found New Hardware” dialog. It’s almost like it’s confused. On a system where this driver has been previously installed, it seems to work fine.

Both calls to SetupCopyOEMInf return SUCCESS, and the .inf file, .cat and .sys can be seen in the appropriate folders.

Anyone know what the correct ordering is for the .cat and .inf? I’ve tried a few different permutations, and been unable to succeed.

In my experience you only need to call this once to tell the system to copy
the INF & CAT together into the %windir%\inf folder as an OEMnnn.inf.

Looking (for confirmation) at the DEVCON sample, the “dp_add” verb is
implemented simply as a call to SetupCopyOEMInf() with CopyStyle specified
as zero (no flags).

Not to head onto a tangent but why do you call the function with
SP_COPY_OEMINF_CATALOG_ONLY *first*?

I assume your goal is to ensure that the driver package is registered with
PnP so that it will be selected (automatically?) when a suitable DevNode is
created. AFAIK you do not need to ‘help’ Windows figure out how to get the
.INF/.CAT pair into the right places in the correct order - it handles that
without any assistance in the case of an OEMnnn.inf. NT6 has even more
machinery (the DriverStore) wired into all of this. For the most part my
experience when Vista arrived was to rip out code that had accumulated in
some driver install programs from various broken behaviors of Win2K and just
let SetupCopyOEMInf() do what it does. That seems to be working pretty fine
on XPSP3 and later [for me, YMMV].

Regarding you believing you have a “comprehension issue” - don’t be so quick
to take responsibility for this on yourself after reading the SDK docs for
SETUPAPI. Every time I find myself reading this area of the DOCs I come
away more confused than when I went in.

Bewilderingly complex, under-documented, loaded with esoteric detail and
little practical guidance - if DEVCON does what you are trying to
accomplish, it is the *best* documentation.

If Difx does what you need, then seriously consider using it instead.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of john.robinson@hp.com
Sent: Wednesday, October 14, 2009 11:07 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] SetupCopyOEMInf with cat files

Hi all,

I seem to being having comprehension issues with the help for
SetupCopyOEMInf. I have a signed driver, so I have a sys, cat, and .inf
file. To complete the installation, I copy the .sys to
c:\windows\system32\drivers, and then I call SetupCopyOEMInf twice, the
first time with SP_COPY_OEMINF_CATALOG_ONLY CopyStyle, and the second time
with the CopyStyle set to zero. In both cases, I am passing the full path
to the driver’s .inf file as the first parameter, then NULL, SPOST_PATH,
CopyStyle, char *, MAX_PATH, &Size, NULL).

From the documentation, it looks like I should do this because it says:

SP_COPY_OEMINF_CATALOG_ONLY The specified .inf file’s corresponding catalog
files is copied to %windir%\Inf. If this flag is specified, the destination
filename information is entered upon successful return if the specified .inf
file already exists in the Inf directory.

And then it says:

If the specified .inf file already exists a further check is performed to
determine if the specified .inf file contains a CatalogFile= entry in its
[Version] section. If it does, the .inf files’s %windir%\Inf primary
filename with a “.cat” extension is used to determine if the catalog is
already installed. If there is a catalog installed, but it is not the same
as the catalog associated with the source .inf, this is not considered to be
a match and enumerations continue. It is possible to have multiple identical
.inf files with unique catalogs contained in %windir%\Inf directory. If an
existing match is not found, the .inf and .cat files are installed under a
new and unique name.

Which looks like the cat file must be installed before the .inf file, I
think.

The bad behavior I am seeing is that on a clean Vista install, the
installation seems to fail (not sure why). When the PDO gets created, Vista
seems to be unable to find a driver, and yet doesn’t pop the “Found New
Hardware” dialog. It’s almost like it’s confused. On a system where this
driver has been previously installed, it seems to work fine.

Both calls to SetupCopyOEMInf return SUCCESS, and the .inf file, .cat and
.sys can be seen in the appropriate folders.

Anyone know what the correct ordering is for the .cat and .inf? I’ve tried
a few different permutations, and been unable to succeed.


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

Thanks, David. I had it that way (single call, no flags), but then I noticed my XP driver showed as unsigned. I now realize that’s because we’re not WHQL’d (there is no WHQL class for our device). In trying to get XP (SP2, I think) to recognize that it was a signed driver, I thought the help said you should copy the .cat file in using (SP_COPY_OEMINF_CATALOG_ONLY), so that it was available for the .inf to validate against.

I’ve returned it to no flags and a single call. It worked for me upto now, so it’s probably the right thing to do.

>I now realize that’s because we’re not WHQL’d (there is no WHQL class for >our device).
If your driver could not fit in a category for Windows Logo or others word “WHQL signature” you always have a choice to get signature in “Unclassified” category. And I believe you already have such signature and this would be enough.

Igor Sharovar

Would SetupCopyOEMInf handle the .sys file too? It doesn’t seem to. Is there an equivalent routine to copy the .sys into the right place? I wasn’t able to find one. We’re just using regular file copy, and then setting protection appropriately.

What do you mean by “handle the sys file too?” - Do you mean copy it
somewhere? No, not per-se.

Is this a PnP driver or some legacy thing? I should have asked you that
long ago.

For a PnP driver, getting the driver package into the DriverStore is all you
need to do and SetupCopyOEMInf will trigger that process on Vista. On
pre-Vista, there is not ‘DriverStore’ (though Difx seems to create one
privately). The path to the source files (where your .SYS might be) is
captured at the time the .INF is copied and compiled into a .PNF.

When a device is installed by PnP, the class installer (and co-installers)
will conspire with the system to copy all of the files per the instructions
in the INF and matching DDInstall section.

If this is a legacy type install then you probably have to do most of the
heavy lifting. This is not exactly an area where I have done much work and
so perhaps the DEVCON sample and/or other ‘Class Filter’ install samples are
better guidance.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of john.robinson@hp.com
Sent: Thursday, October 15, 2009 8:13 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SetupCopyOEMInf with cat files

Would SetupCopyOEMInf handle the .sys file too? It doesn’t seem to. Is
there an equivalent routine to copy the .sys into the right place? I wasn’t
able to find one. We’re just using regular file copy, and then setting
protection appropriately.


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

Yes, it’s pnp. I’m pre-installing the driver prior to the pnp detect event. I’ve found if I copy the .sys to the sys32/drivers prior to calling SetupCopyOEMInf, everything seems to work ok. I’m pretty sure the driver is referenced from the sys32 dir - I can delete the source install location once the device has been detected and installed, and the registry for the driver points to system32\drivers\xxx.sys. I was just surprised there wasn’t an analogous function for the .sys file (or that SetupCopy captured the .sys along with the .inf).

Thanks everyone for your help

You should not need to manually copy the .SYS file (or any other files) for
a PnP INF - indeed, the DDInstall section should simply reference a
CopyFiles section to do the copying. Otherwise (and without all of the
remainder of the ‘stuff’ in a propery PnP INF) the system will not correctly
know the boundaries of your “driver package”.

Forgive me but it seems like you are fighting the system - does not creating
and using the ‘typical’ INF driven PnP install process satisfactorily
install your device’s drivers?

Pre-installing a driver should be no more complex than calling
SetupCopyOEMInf(). This is exactly what DEVCON does for the dp_add verb.
Nothing more.

Deleting the source location results in a very poor user experience - for
instance, rollback is no longer possible - and is the reason for the
DriverStore in Vista (and the equivalent facility in XP as part of Difx).
I suggest you look seriously at using DifxApp. The headache reduction
factor is pretty high.

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of john.robinson@hp.com
Sent: Friday, October 16, 2009 12:14 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] SetupCopyOEMInf with cat files

Yes, it’s pnp. I’m pre-installing the driver prior to the pnp detect event.
I’ve found if I copy the .sys to the sys32/drivers prior to calling
SetupCopyOEMInf, everything seems to work ok. I’m pretty sure the driver is
referenced from the sys32 dir - I can delete the source install location
once the device has been detected and installed, and the registry for the
driver points to system32\drivers\xxx.sys. I was just surprised there
wasn’t an analogous function for the .sys file (or that SetupCopy captured
the .sys along with the .inf).

Thanks everyone for your help


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