Archive: How to write a good Device Driver installer?


How to write a good Device Driver installer?
I have 2 years old, C++ based, custom installer code for a SCSI CD drive emulation.
I wish to port it to NSIS.

The original code has references to functions like:
SetupDiRegisterDeviceInfo, SetupDiSetDeviceRegistryProperty, SetupDiCallClassInstaller and more SetupDiXXX commands, all of which are nicely documented in the MSDN. I have seen no reference for them in the NSIS, Examples or this forum.
(like to msdn info: http://msdn.microsoft.com/library/de...ce_classes.asp)

A bit of google'ing raised the possibility that the paradigm for device driver installation may have changed to functions like: DriverPackagePreinstall(), DriverPackageInstall(), DriverPackageUninstall() and DriverPackageGetPath(). Those have no reference in NSIS as well.
(link to msdn info: http://www.microsoft.com/whdc/driver...l/DIFxtls.mspx)

NSIS on its part suggest these two helpful links:
link1: http://nsis.sourceforge.net/Driver_i...ion_and_update
link2: http://nsis.sourceforge.net/Service_...s_on_NT/2K/XP)

Now here comes the question (at last):

1. What is the right way to write a device driver installer these days? (regardless to NSIS support on the matter)

2. What is NSIS support on the matter? (admit you did not see that one coming :) )

10x, Liberty


You can call external DLL functions with the System plugin which is bundled with NSIS.

-Stu


Originally posted by Afrow UK
You can call external DLL functions with the System plugin which is bundled with NSIS.
-Stu
ofcourse I can... but for that I need a DLL plugin... hmmm...

so I repharse my two questions....

1. is there such a plugin that does all I need... saving me the time to write it myself?

2. assuming I will write a plugin myself a.k.a "the hard way, all the way". which installer technology is superior the SetupDiXXX or the DriverPackageXXX.?

Liberty

  1. If it's not on the Wiki, it probably doesn't exist. It seems you'd have to write one yourself. If you do end up writing one, please upload it to the Wiki.
  2. It seems DriverPackage* was created after SetupDi* and its description at microsoft.com also states it's simpler. So I guess it's preferable. But I'd make sure it works on all target platforms first. It's very new, so it might work on 2000 and above only, or even XP and above.

You could do an exec of the ".inf" file belonging to the driver... in NSIS, maybenot fully taking the posibillity NSIS has to offer , but you are helped maybe.

running an ".inf" is also not a easy task, some of my Delphi code I once used to install/uninstall device drivers. This Pseudo code you could convert to NSIS script

Whatever way you will solve it, I expect it will not be easy . Alternatively you could post a message with an offer to pay someone to do it for you.

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

const
rsUSN = 'DefaultUninstall';
rsUSNntx86 = 'DefaultUninstall.ntx86'; //make sure these sections exist in your .inf file
rsShellRunDLL32 = 'rundll32.exe';


...

if IsWinNT then
UninstallSectionName:=rsUSNntx86
else
UninstallSectionName:=rsUSN;

...

UnInstallLine:='advpack.dll,LaunchINFSection '+UninstallInfFileName+', '+UninstallSectionName;
TargetPath:='';

shellexecute(h, 'open',pchar(rsShellRunDLL32),pchar(UnInstallLine),pchar(TargetPath),SW_SHOWNORMAL);


Oh, I forgot

On 9x/ME following the DriverPackage* will not work.

You can also just mimic the behaviour of the inf file alltougheter by writing to the registry, pathe etc yourself.

For this you can take a snapshot with system snapshot tools for the registry, and then monitor the API calls when the driver gets installed with other tools. http://www.sysinternals.com/ has some monitoring tools for free. Also the Windowze tool may help.

Good luck, you need that... and persistance!


Originally posted by kichik
It seems DriverPackage* was created after SetupDi* and its description at microsoft.com also states it's simpler. So I guess it's preferable. But I'd make sure it works on all target platforms first. It's very new, so it might work on 2000 and above only, or even XP and above.
did some more homework and in the "Kernel-Mode Driver Framework" (http://www.microsoft.com/whdc/driver/wdf/KMDF_pkg.mspx) the use of Co-Installer (SetupDi* functions) is explicitly specified.
maybe DriverPackage* and SetupDi* are not eqvivalent in some way or maybe the KMDF is not up to date...
I will look for some microsoft forum for this one.