Installing drivers and Inno Setup

Since we were discussing Inno Setup the other day and I just went through
some pain, I thought I’d share and hopefully help someone else.

I’ve always created an install batch file which calls rundll32 and does the
install of my drivers. It’s always worked great, until Vista 64. Since
Inno Setup is a 32-bit program, redirection is on (to the SysWow64 folder),
but they are smart and disable it, which made me think I’d be OK.
Unfortunately, when Inno launched my batch file, it apparently got a 32-bit
cmd.exe, which ran the 32-bit rundll32 which put my 64-bit driver in the
SysWow64\drivers folder.

Soo… to install a 64-bit driver from the 32-bit Inno setup, use something
like the following in your .iss file (especially the part in the Run
section):

function IsX64: Boolean;  
begin  
 Result := IsWin64 and (ProcessorArchitecture = paX64);  
end;  
  
function IsIA64: Boolean;  
begin  
 Result := IsWin64 and (ProcessorArchitecture = paIA64);  
end;  
  
function Isx86: Boolean;  
begin  
 Result := not IsWin64;  
end;  
  
[Files]  
Source: <driver>x86.sys; DestDir: {app}; Check: Isx86;<br>Source: <driver>x86.inf; DestDir: {app}; Check: Isx86;<br>Source: <driver>x64.sys; DestDir: {app}; Check: Isx64;<br>Source: <driver>x64.inf; DestDir: {app}; Check: Isx64;<br>Source: <driver>IA64.sys; DestDir: {app}; Check: IsIA64;<br>Source: <driver>IA64.inf; DestDir: {app}; Check: IsIA64;<br><br>[Run]<br>Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>DefaultInstall 132 .\<driver>IA64.inf"; WorkingDir: {app}; Flags: 64bit;<br>Check: IsIA64;<br>Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>DefaultInstall 132 .\<driver>x64.inf"; WorkingDir: {app}; Flags: 64bit;<br>Check: IsX64;<br>Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>DefaultInstall 132 .\<driver>x86.inf"; WorkingDir: {app}; Flags: 32bit;<br>Check: IsX86;<br><br>Hope that helps someone.<br><br>Doug</driver></driver></driver></driver></driver></driver></driver></driver></driver>

I have seen this break with SP1. Installing an INF on XP/2003 x64 and Vista
SP0 calling the 32 bit version of setupApi from a Wow64 process correctly
installs drivers to the System32\drivers directory, on Vista SP1 it installs
to the Syswow64\drivers directory which never makes sense. The solution is
to make sure to run the 64 bit version of rundll32.exe (argh).

//Daniel

“Doug” wrote in message news:xxxxx@ntfsd…
> Since we were discussing Inno Setup the other day and I just went through
> some pain, I thought I’d share and hopefully help someone else.
>
> I’ve always created an install batch file which calls rundll32 and does
> the
> install of my drivers. It’s always worked great, until Vista 64. Since
> Inno Setup is a 32-bit program, redirection is on (to the SysWow64
> folder),
> but they are smart and disable it, which made me think I’d be OK.
> Unfortunately, when Inno launched my batch file, it apparently got a
> 32-bit
> cmd.exe, which ran the 32-bit rundll32 which put my 64-bit driver in the
> SysWow64\drivers folder.
>
> Soo… to install a 64-bit driver from the 32-bit Inno setup, use
> something
> like the following in your .iss file (especially the part in the Run
> section):
>
> ```
> function IsX64: Boolean;
> begin
> Result := IsWin64 and (ProcessorArchitecture = paX64);
> end;
>
> function IsIA64: Boolean;
> begin
> Result := IsWin64 and (ProcessorArchitecture = paIA64);
> end;
>
> function Isx86: Boolean;
> begin
> Result := not IsWin64;
> end;
>
> [Files]
> Source: x86.sys; DestDir: {app}; Check: Isx86;
> Source: x86.inf; DestDir: {app}; Check: Isx86;
> Source: x64.sys; DestDir: {app}; Check: Isx64;
> Source: x64.inf; DestDir: {app}; Check: Isx64;
> Source: IA64.sys; DestDir: {app}; Check: IsIA64;
> Source: IA64.inf; DestDir: {app}; Check: IsIA64;
>
> [Run]
> Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> DefaultInstall 132 .<driver>IA64.inf”; WorkingDir: {app}; Flags: 64bit;
> Check: IsIA64;
> Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> DefaultInstall 132 .<driver>x64.inf”; WorkingDir: {app}; Flags: 64bit;
> Check: IsX64;
> Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> DefaultInstall 132 .<driver>x86.inf”; WorkingDir: {app}; Flags: 32bit;
> Check: IsX86;
>
> Hope that helps someone.
>
> Doug
>
>

Here’s something easier (the code for detecting install arc is already
included with Inno):
In [Setup] section:
ArchitecturesInstallIn64BitMode=x64

In [Files] Section
Source: C:\x64\MyDrv.sys; DestDir: {sys}; Flags: 64bit; Check:
Is64BitInstallMode

In [Run] section (will also provide a checkbox to let the user decide whether
to install the drivers automatically):
Filename: rundll32.exe MyDrv.inf; Description: Install drivers automatically;
StatusMsg: Installing drivers…; Flags: runascurrentuser postinstall
Or
Filename: rundll32.exe MyDrv.inf

Doug wrote:

Since we were discussing Inno Setup the other day and I just went through
some pain, I thought I’d share and hopefully help someone else.

I’ve always created an install batch file which calls rundll32 and does the
install of my drivers. It’s always worked great, until Vista 64. Since
Inno Setup is a 32-bit program, redirection is on (to the SysWow64 folder),
but they are smart and disable it, which made me think I’d be OK.
Unfortunately, when Inno launched my batch file, it apparently got a 32-bit
cmd.exe, which ran the 32-bit rundll32 which put my 64-bit driver in the
SysWow64\drivers folder.

Soo… to install a 64-bit driver from the 32-bit Inno setup, use something
like the following in your .iss file (especially the part in the Run
section):

function IsX64: Boolean;  
begin  
Result := IsWin64 and (ProcessorArchitecture = paX64);  
end;  
 
function IsIA64: Boolean;  
begin  
Result := IsWin64 and (ProcessorArchitecture = paIA64);  
end;  
 
function Isx86: Boolean;  
begin  
Result := not IsWin64;  
end;  
 
[Files]  
Source: <driver>x86.sys; DestDir: {app}; Check: Isx86;<br>&gt; Source: <driver>x86.inf; DestDir: {app}; Check: Isx86;<br>&gt; Source: <driver>x64.sys; DestDir: {app}; Check: Isx64;<br>&gt; Source: <driver>x64.inf; DestDir: {app}; Check: Isx64;<br>&gt; Source: <driver>IA64.sys; DestDir: {app}; Check: IsIA64;<br>&gt; Source: <driver>IA64.inf; DestDir: {app}; Check: IsIA64;<br>&gt;<br>&gt; [Run]<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>IA64.inf"; WorkingDir: {app}; Flags: 64bit;<br>&gt; Check: IsIA64;<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>x64.inf"; WorkingDir: {app}; Flags: 64bit;<br>&gt; Check: IsX64;<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>x86.inf"; WorkingDir: {app}; Flags: 32bit;<br>&gt; Check: IsX86;<br>&gt;<br>&gt; Hope that helps someone.<br>&gt;<br>&gt; Doug<br>&gt;<br>&gt; ---<br>&gt; NTFSD is sponsored by OSR<br>&gt;<br>&gt; For our schedule debugging and file system seminars<br>&gt; (including our new fs mini-filter seminar) visit:<br>&gt; http://www.osr.com/seminars<br>&gt;<br>&gt; You are currently subscribed to ntfsd as: xxxxx@alfasp.com<br>&gt; To unsubscribe send a blank email to xxxxx@lists.osr.com<br><br>--<br>Kind regards, Dejan (MSN support: xxxxx@alfasp.com)<br>http://www.alfasp.com<br>File system audit, security and encryption kits.</driver></driver></driver></driver></driver></driver></driver></driver></driver>

Not sure how Doug’s code works, but the tips I posted in this topic surely
work in Vista SP1 (with and without the UAC).

xxxxx@resplendence.com wrote:

I have seen this break with SP1. Installing an INF on XP/2003 x64 and Vista
SP0 calling the 32 bit version of setupApi from a Wow64 process correctly
installs drivers to the System32\drivers directory, on Vista SP1 it installs
to the Syswow64\drivers directory which never makes sense. The solution is
to make sure to run the 64 bit version of rundll32.exe (argh).

//Daniel


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Hi Dejan –

I looked at ArchitecturesInstallIn64BitMode, but wanted to handle x86, x64
and IA64 all in one installer. Does that work with this method?

Doug

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Tuesday, August 05, 2008 10:03 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Installing drivers and Inno Setup

Here’s something easier (the code for detecting install arc is already
included with Inno):
In [Setup] section:
ArchitecturesInstallIn64BitMode=x64

In [Files] Section
Source: C:\x64\MyDrv.sys; DestDir: {sys}; Flags: 64bit; Check:
Is64BitInstallMode

In [Run] section (will also provide a checkbox to let the user decide
whether
to install the drivers automatically):
Filename: rundll32.exe MyDrv.inf; Description: Install drivers
automatically;
StatusMsg: Installing drivers…; Flags: runascurrentuser postinstall
Or
Filename: rundll32.exe MyDrv.inf

Doug wrote:

Since we were discussing Inno Setup the other day and I just went through
some pain, I thought I’d share and hopefully help someone else.

I’ve always created an install batch file which calls rundll32 and does
the
install of my drivers. It’s always worked great, until Vista 64. Since
Inno Setup is a 32-bit program, redirection is on (to the SysWow64
folder),
but they are smart and disable it, which made me think I’d be OK.
Unfortunately, when Inno launched my batch file, it apparently got a
32-bit
cmd.exe, which ran the 32-bit rundll32 which put my 64-bit driver in the
SysWow64\drivers folder.

Soo… to install a 64-bit driver from the 32-bit Inno setup, use
something
like the following in your .iss file (especially the part in the Run
section):

function IsX64: Boolean;  
begin  
Result := IsWin64 and (ProcessorArchitecture = paX64);  
end;  
 
function IsIA64: Boolean;  
begin  
Result := IsWin64 and (ProcessorArchitecture = paIA64);  
end;  
 
function Isx86: Boolean;  
begin  
Result := not IsWin64;  
end;  
 
[Files]  
Source: <driver>x86.sys; DestDir: {app}; Check: Isx86;<br>&gt; Source: <driver>x86.inf; DestDir: {app}; Check: Isx86;<br>&gt; Source: <driver>x64.sys; DestDir: {app}; Check: Isx64;<br>&gt; Source: <driver>x64.inf; DestDir: {app}; Check: Isx64;<br>&gt; Source: <driver>IA64.sys; DestDir: {app}; Check: IsIA64;<br>&gt; Source: <driver>IA64.inf; DestDir: {app}; Check: IsIA64;<br>&gt;<br>&gt; [Run]<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>IA64.inf"; WorkingDir: {app}; Flags: 64bit;<br>&gt; Check: IsIA64;<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>x64.inf"; WorkingDir: {app}; Flags: 64bit;<br>&gt; Check: IsX64;<br>&gt; Filename: {sys}\rundll32.exe; Parameters: "setupapi,InstallHinfSection<br>&gt; DefaultInstall 132 .\<driver>x86.inf"; WorkingDir: {app}; Flags: 32bit;<br>&gt; Check: IsX86;<br>&gt;<br>&gt; Hope that helps someone.<br>&gt;<br>&gt; Doug<br>&gt;<br>&gt; ---<br>&gt; NTFSD is sponsored by OSR<br>&gt;<br>&gt; For our schedule debugging and file system seminars<br>&gt; (including our new fs mini-filter seminar) visit:<br>&gt; http://www.osr.com/seminars<br>&gt;<br>&gt; You are currently subscribed to ntfsd as: xxxxx@alfasp.com<br>&gt; To unsubscribe send a blank email to xxxxx@lists.osr.com<br><br>--<br>Kind regards, Dejan (MSN support: xxxxx@alfasp.com)<br>http://www.alfasp.com<br>File system audit, security and encryption kits.<br><br>---<br>NTFSD is sponsored by OSR<br><br>For our schedule debugging and file system seminars<br>(including our new fs mini-filter seminar) visit: <br>http://www.osr.com/seminars<br><br>You are currently subscribed to ntfsd as: xxxxx@poweradmin.com<br>To unsubscribe send a blank email to xxxxx@lists.osr.com</driver></driver></driver></driver></driver></driver></driver></driver></driver>

Yep. Our installation is a 32-bit Inno exe that install both x86 and x64
drivers. I can send you the sample if you want. (can’t attach it to NTFSD)

Doug wrote:

Hi Dejan –

I looked at ArchitecturesInstallIn64BitMode, but wanted to handle x86, x64
and IA64 all in one installer. Does that work with this method?

Doug

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Tuesday, August 05, 2008 10:03 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Installing drivers and Inno Setup

Here’s something easier (the code for detecting install arc is already
included with Inno):
In [Setup] section:
ArchitecturesInstallIn64BitMode=x64

In [Files] Section
Source: C:\x64\MyDrv.sys; DestDir: {sys}; Flags: 64bit; Check:
Is64BitInstallMode

In [Run] section (will also provide a checkbox to let the user decide
whether
to install the drivers automatically):
Filename: rundll32.exe MyDrv.inf; Description: Install drivers
automatically;
StatusMsg: Installing drivers…; Flags: runascurrentuser postinstall
Or
Filename: rundll32.exe MyDrv.inf

Doug wrote:

> Since we were discussing Inno Setup the other day and I just went through
> some pain, I thought I’d share and hopefully help someone else.
>
> I’ve always created an install batch file which calls rundll32 and does
the
> install of my drivers. It’s always worked great, until Vista 64. Since
> Inno Setup is a 32-bit program, redirection is on (to the SysWow64
folder),
> but they are smart and disable it, which made me think I’d be OK.
> Unfortunately, when Inno launched my batch file, it apparently got a
32-bit
> cmd.exe, which ran the 32-bit rundll32 which put my 64-bit driver in the
> SysWow64\drivers folder.
>
> Soo… to install a 64-bit driver from the 32-bit Inno setup, use
something
> like the following in your .iss file (especially the part in the Run
> section):
>
> ```
> function IsX64: Boolean;
> begin
> Result := IsWin64 and (ProcessorArchitecture = paX64);
> end;
>
> function IsIA64: Boolean;
> begin
> Result := IsWin64 and (ProcessorArchitecture = paIA64);
> end;
>
> function Isx86: Boolean;
> begin
> Result := not IsWin64;
> end;
>
> [Files]
> Source: x86.sys; DestDir: {app}; Check: Isx86;
> > Source: x86.inf; DestDir: {app}; Check: Isx86;
> > Source: x64.sys; DestDir: {app}; Check: Isx64;
> > Source: x64.inf; DestDir: {app}; Check: Isx64;
> > Source: IA64.sys; DestDir: {app}; Check: IsIA64;
> > Source: IA64.inf; DestDir: {app}; Check: IsIA64;
> >
> > [Run]
> > Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> > DefaultInstall 132 .<driver>IA64.inf”; WorkingDir: {app}; Flags: 64bit;
> > Check: IsIA64;
> > Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> > DefaultInstall 132 .<driver>x64.inf”; WorkingDir: {app}; Flags: 64bit;
> > Check: IsX64;
> > Filename: {sys}\rundll32.exe; Parameters: “setupapi,InstallHinfSection
> > DefaultInstall 132 .<driver>x86.inf”; WorkingDir: {app}; Flags: 32bit;
> > Check: IsX86;
> >
> > Hope that helps someone.
> >
> > Doug
> >
> > —
> > NTFSD is sponsored by OSR
> >
> > For our schedule debugging and file system seminars
> > (including our new fs mini-filter seminar) visit:
> > http://www.osr.com/seminars
> >
> > You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> –
> Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
> http://www.alfasp.com
> File system audit, security and encryption kits.
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@poweradmin.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.