Question regarding on how to do an NDIS Driver installation using NSIS

On 9/24/2014 7:06 AM, Jonathan Weinraub wrote:

Besides nsis being free, i don’t mind the msi curveball/learning curve.

If you ever do want to create MSI packages, the WiX Toolset is free and
open source too: http://wixtoolset.org/ .


Bruce

I had actually downloaded that but never got around to learn it.
But since I am not the developer, I won’t be using Visual Studio.
I use HM Edit for NSIS as my IDE.

My only requirements that caused me to really put the kibosh on it was the
custom things I had made.

I had designed a few plugins (dlls) that is pretty much done in pure Win32
C that graphically shows a dialogue box that behaves in a strict manner
that NSIS dialogues wouldnt do, so i made it myself in C.
There are two such dialogues. If I can make a custom MessageBox that just
returns values, that a functin calling it can handle then, yay!

I have extensive OS requirements that get checked before loading.
Depending if it is say XP, 2000, 7, 8, and 32 or 64 bit of each it can do
certain things at certain times.
Including now with the restrictions on this service I am trying to get
done that works on 7 and 8.1 but not 8.0.
Obviously standard stuff if the process is already running it shouldn’t be
installed until it is closed.
Uninstalling previous version first.
That refresh shell icon I did earlier.

Determining which .NET is installed and install it if necessary. All
files are included in the disc because the software assumes there is no
internet access.
Hwoever, it does add extensive (advanced) firewall rules programmatically
as well.

Making file associations with custom document icon.
Registers a few dll’s and of course uninstall will need to reverse this
with the uinstaller program.
Makes icons for all users rather than current user.
So while most of it is run in the mill, there is some significant
functionality I will need to find new ways of doing.

Now I don’t have the time since I have some major projects scheduled, but
once that is done, I will certainly try to find new ways of making the
msi.

As it stands, my nsi script is little over a thousand lines of code.
Not including any attached functions/headers

While free isn’t a requirement, I can certainly switch to InstallShield if
need be if it means it is the better solution for us.

I like nsis not only because its free and its robust community, but also
because the installers are superior in speed compared to the older
installshield that my predecessor did back in the day (it might have been
3 or 4.0 days for IS)

Thanks.

jon

From: Bruce Cran
To: “Windows System Software Devs Interest List”
Date: 24/09/2014 11:00
Subject: Re: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS
Sent by: xxxxx@lists.osr.com

On 9/24/2014 7:06 AM, Jonathan Weinraub wrote:
> Besides nsis being free, i don’t mind the msi curveball/learning curve.

If you ever do want to create MSI packages, the WiX Toolset is free and
open source too: http://wixtoolset.org/ .


Bruce


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

Bruce Cran wrote:

On 9/24/2014 7:06 AM, Jonathan Weinraub wrote:
> Besides nsis being free, i don’t mind the msi curveball/learning curve.
If you ever do want to create MSI packages, the WiX Toolset is free and
open source too: http://wixtoolset.org/ .

I did try to climb aboard that bandwagon. I actually ported one of my
installers to WiX and got it mostly working. It just seemed a lot more
opaque. I recognize that is an unfair snap judgment based on my
inexperience, and if NSIS exploded tomorrow, I’d jump right on WiX.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

I had similar experiences with WiX, sorta mostly kinda working, but
never something I would ship. NSIS worked out of the starting gate, and was
a lot easier to use. Interestingly enough, I have never had a complaint
from clients when I use NSIS, but have been told multiple times “NO WiX”.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, September 24, 2014 12:22 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS

Bruce Cran wrote:

On 9/24/2014 7:06 AM, Jonathan Weinraub wrote:
> Besides nsis being free, i don’t mind the msi curveball/learning curve.
If you ever do want to create MSI packages, the WiX Toolset is free
and open source too: http://wixtoolset.org/ .

I did try to climb aboard that bandwagon. I actually ported one of my
installers to WiX and got it mostly working. It just seemed a lot more
opaque. I recognize that is an unfair snap judgment based on my
inexperience, and if NSIS exploded tomorrow, I’d jump right on WiX.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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 9/24/2014 10:21 AM, Tim Roberts wrote:

I did try to climb aboard that bandwagon. I actually ported one of my
installers to WiX and got it mostly working. It just seemed a lot more
opaque. I recognize that is an unfair snap judgment based on my
inexperience, and if NSIS exploded tomorrow, I’d jump right on WiX.

It is opaque, and that to me is one of the main advantages. For
example Windows Installer will handle moving the installation directory
if a user chooses a different one during a modify/upgrade scenario -
testing the latest NSIS installer, it forgets about that and instead
orphans the old installation. The main problem with Windows Installer
is that it’s almost entirely a new system to learn (install sequences,
component rules etc.), whereas NSIS is familiar to most people who have
done Windows programming and a bit of scripting.


Bruce

Hi,

Sorry for taking so long to answer again. This is what I did.

C:\temp>netcfg -l foo.inf -c s -i foo -v
Trying to install foo …

…foo.inf was copied to C:\Windows\INF\oem162.inf.

…done.

And it automatically added and enabled it.
I assume I can use the string as is for a shell.execute() type of command
for the purpose of doing this in NSIS
is there a way to capture the return value to verify it was successful or
not (without the verbose)

I also assume the uninstall is pretty straight forward too.

Thanks again!

-jon

From: Dave Cattley
To: “Windows System Software Devs Interest List”
Date: 16/09/2014 12:00
Subject: RE: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS
Sent by: xxxxx@lists.osr.com

Does the component have an INF file? What class (look for Class= … )
is it? Net, NetService, NetTrans, NetClient, something else?

For NetService, NetTrans, and NetClient then look at the BindView sample
or use DIFXAPI (or DIFXAPP if you are installing from an MSI package). Or
if you just want to exec some command line that will work use NETCFG.EXE
(inbox utility on Vista+)

netcfg [-v] [-e] [-winpe] [-l ] -c

-i


-winpe installs TCP/IP, NetBIOS and Microsoft Client for Windows
preinstallation envrionment
-l provides the location of INF
-c provides the class of the component to be installed (p ==
Protocol, s == Service, c == Client)
-i provides the component ID

The arguments must be passed in the order shown.

Examples:
netcfg -l c:\oemdir\foo.inf -c p -i foo
…installs protocol ‘foo’ using c:\oemdir\foo.inf

netcfg -c s -i MS_Server
…installs service ‘MS_Server’

OR

netcfg [-v] -winpe
Examples:
netcfg -v -winpe
…Installs TCP/IP, NetBIOS and Microsoft Client for Windows
preinstallation environment

OR

netcfg [-v] -q
Example:
netcfg -q MS_IPX
…displays if component ‘MS_IPX’ is installed

OR

netcfg [-v] [-e] -u
Example:
netcfg -u MS_IPX
…uninstalls component ‘MS_IPX’

OR

netcfg [-v] -s
where,
-s\tprovides the type of components to show
\ta == adapters, n == net components
Examples:
netcfg -s n
…shows all installed net components

OR

netcfg [-v] -b
Examples:
netcfg -b ms_tcpip
…shows binding paths containing ‘MS_TCPIP’

General Notes:\n"
-v Run in verbose (detailed) mode
-e Use servicing environment variables during install and uninstall
-? Displays this help information

My question to you was how do they (the devs) install it. Do they use
BindView? Do they use the NDIS.COM sample installer? Have you
installed the driver manually? How do you do it?

Good Luck,

Dave Cattley

NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

You already have the source code to netcfg.exe - it’s straight out of the bindview sample. Start with the sample’s InstallSpecifiedComponent function. I think you’ll find that when you strip away the sample’s GUI code, it boils down to just a few dozen lines of code to install the driver directly. It would take almost as many lines of code to screenscrape the error code from netcfg.exe.

https://code.msdn.microsoft.com/Bindview-ec8f6e0a/sourcecode?fileId=51239&pathId=1166401964

That i did not know.
I can probably use the same code to make it a NSIS DLL that takes in the
arguments of the code to do the install and uninstall.
either way, I am definitely on the correct track.

Thanks so much

From: Jeffrey Tippet
To: “Windows System Software Devs Interest List”
Date: 09/10/2014 16:33
Subject: RE: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS
Sent by: xxxxx@lists.osr.com

You already have the source code to netcfg.exe - it’s straight out of the
bindview sample. Start with the sample’s InstallSpecifiedComponent
function. I think you’ll find that when you strip away the sample’s GUI
code, it boils down to just a few dozen lines of code to install the
driver directly. It would take almost as many lines of code to
screenscrape the error code from netcfg.exe.

https://code.msdn.microsoft.com/Bindview-ec8f6e0a/sourcecode?fileId=51239&pathId=1166401964


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

I just want to reiterate my original advice in context here.

My suggestion to exec NETCFG.EXE and collect & parse its output in NSIS was not based on the ease of which one might the code to do what it is doing but was based on the fact that NSIS is a 32-bit executable and as such on a 64-bit Windows running in WOW64 it will not be permitted to call INetCfg interfaces or anything that relies on SETUPDI as those are only minimally operational in WOW64. Specifically, any operation that might need to invoke a CoInstaller, ClassInstaller, or NotfiyObject (of which Install and Remove will require most of these) is not permitted since those modules are *NATIVE* code.

So the advice to just suck it up and exec NETCFG.EXE takes into account that you are not going to ship two installers (one 32-bit and one 64-bit) and your installer needs some way to install (and remove, the other few dozen lines of code, and upgrade the hard one which is remove followed by install) and it has to work on both 32-bit and 64-bit systems. NETCFG.EXE is a package of functionality that exists as native code on all NT6 platforms.

So sure, not as sexy as writing a DLL that you can then call with the system package but at least it will work on x64 the same as it works on x86.

I can’t say as I am disagreeing with Mr. Tippet that the code itself is straightforward but perhaps just looking at the entire set of issues through the lenses of someone whom has built exactly what you need (multiple times, in all of NSIS, MSI, and stand-alone utilities).

Good Luck,

Dave Cattley

Fair points. I had forgotten that the original context of the thread was about 32-bit running on 64-bit OS.

Also, I personally have very little experience with NSIS. So if you’re plugging into NSIS, there’s wisdom in deferring to somebody who *does* have experience with NSIS.

My claim to expertise is solely that I am the developer who currently has the blessing of maintaining the INetCfg APIs.

After examining the source code, and while it may be sexier to go with my
own custom dll, and i may very well do that in the future, but for now, i
think shellexec is fine enough. the deadline for this endeavour is next
month and i got a lot of other pressing projects taking up a lot of time,
so while i see exec a command as quick and dirty, i will have to agree
with the KISS philosophy. Thank you though Mr Cattley, for your opinion
is going to convince me for at least in this release to use the
netcfg.exe. If i were to change my mind later, if anything when things
are less busy, and for the challenge, then yes, i can…but for now, this
is fine enough.

From: Dave Cattley
To: “Windows System Software Devs Interest List”
Date: 09/10/2014 19:19
Subject: RE: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS
Sent by: xxxxx@lists.osr.com



I just want to reiterate my original advice in context here.

My suggestion to exec NETCFG.EXE and collect & parse its output in NSIS
was not based on the ease of which one might the code to do what it is
doing but was based on the fact that NSIS is a 32-bit executable and as
such on a 64-bit Windows running in WOW64 it will not be permitted to call
INetCfg interfaces or anything that relies on SETUPDI as those are only
minimally operational in WOW64. Specifically, any operation that might
need to invoke a CoInstaller, ClassInstaller, or NotfiyObject (of which
Install and Remove will require most of these) is not permitted since
those modules are NATIVE code.

So the advice to just suck it up and exec NETCFG.EXE takes into account
that you are not going to ship two installers (one 32-bit and one 64-bit)
and your installer needs some way to install (and remove, the other few
dozen lines of code, and upgrade the hard one which is remove followed by
install) and it has to work on both 32-bit and 64-bit systems. NETCFG.EXE
is a package of functionality that exists as native code on all NT6
platforms.

So sure, not as sexy as writing a DLL that you can then call with the
system package but at least it will work on x64 the same as it works on
x86.

I can’t say as I am disagreeing with Mr. Tippet that the code itself is
straightforward but perhaps just looking at the entire set of issues
through the lenses of someone whom has built exactly what you need
(multiple times, in all of NSIS, MSI, and stand-alone utilities).

Good Luck,

Dave Cattley

NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

NSIS compiles it as a 32-bit installer regardless if it is running on a
32/64 bit system.
there is code clauses ( if osArch == 64 ) … do this, else … do that
(meaning it copies the appropriate files/dlls, registers the appropriate
files, and configures whatever is needed.
so, essentially i will need to do an if OS==7 && os==8.1 && osArch == 64
do one thing… and 32 bit do the other, and the else clause use the third
party tool we used to use for other circumstances (since the service
apparently is not functional on os 8.0 and XP/2000/and far as i know
vista)

thanks again to all for your advice. now i am doing the shellexec routine
i should be fine to finish this up and get back to my other work lol

From: Jeffrey Tippet
To: “Windows System Software Devs Interest List”
Date: 09/10/2014 21:23
Subject: RE: [ntdev] Question regarding on how to do an NDIS Driver
installation using NSIS
Sent by: xxxxx@lists.osr.com

Fair points. I had forgotten that the original context of the thread was
about 32-bit running on 64-bit OS.

Also, I personally have very little experience with NSIS. So if you’re
plugging into NSIS, there’s wisdom in deferring to somebody who does
have experience with NSIS.

My claim to expertise is solely that I am the developer who currently has
the blessing of maintaining the INetCfg APIs.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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