win-pvdrivers

changeset 431:0514d961532d

Update to support dpinst so that driver install works under 64 bit
author James Harper <james.harper@bendigoit.com.au>
date Wed Sep 10 14:43:12 2008 +1000 (2008-09-10)
parents e402c21ae722
children 68565fbe4425
files common.inc driver.nsh drvsetup.nsh installer.nsi
line diff
     1.1 --- a/common.inc	Mon Sep 08 22:42:26 2008 +1000
     1.2 +++ b/common.inc	Wed Sep 10 14:43:12 2008 +1000
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.9.10.14
     1.5 +VERSION=0.9.10.15
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  MSC_WARNING_LEVEL=/W4
     1.8  INCLUDES = ..\common\include;..\common\include\public
     2.1 --- a/driver.nsh	Mon Sep 08 22:42:26 2008 +1000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,105 +0,0 @@
     2.4 -!include "winver.nsh"
     2.5 -!include "drvsetup.nsh"
     2.6 - 
     2.7 -;
     2.8 -; Written by Kuba Ober
     2.9 -; Copyright (c) 2004 Kuba Ober
    2.10 -;
    2.11 -; Permission is hereby granted, free of charge, to any person obtaining a 
    2.12 -; copy of this software and associated documentation files (the "Software"), 
    2.13 -; to deal in the Software without restriction, including without limitation 
    2.14 -; the rights to use, copy, modify, merge, publish, distribute, sublicense, 
    2.15 -; and/or sell copies of the Software, and to permit persons to whom the 
    2.16 -; Software is furnished to do so, subject to the following conditions:
    2.17 -;
    2.18 -; The above copyright notice and this permission notice shall be included in 
    2.19 -; all copies or substantial portions of the Software.
    2.20 -; 
    2.21 -; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.22 -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.23 -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.24 -; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    2.25 -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    2.26 -; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    2.27 -; DEALINGS IN THE SOFTWARE.
    2.28 - 
    2.29 -;
    2.30 -; U S A G E
    2.31 -;
    2.32 -; Push "c:\program files\yoursoftware\driver" 
    2.33 -;  -- the directory of the .inf file
    2.34 -; Push "c:\program files\yoursoftware\driver\driver.inf"
    2.35 -;  -- the filepath of the .inf file (directory + filename)
    2.36 -; Push "USB\VID_1234&PID_5678"
    2.37 -;  -- the HID (Hardware ID) of your device
    2.38 -; Call InstallUpgradeDriver
    2.39 -;
    2.40 -; Your driver (minimally the .inf and .sys files) should already by installed
    2.41 -; by your NSIS script.
    2.42 -;
    2.43 -; Typically, you would put the driver either in $INSTDIR or $INSTDIR\Driver
    2.44 -; It's up to you, of course.
    2.45 -;
    2.46 -; The driver (i.e. .inf, .sys and related files) must be present for the
    2.47 -; lifetime of your application, you shouldn't remove them after calling
    2.48 -; this function!
    2.49 -;
    2.50 -; You DON'T want to put the driver in any of system directories. Windows
    2.51 -; will do it when the device is first plugged in.
    2.52 - 
    2.53 -Function InstallUpgradeDriver
    2.54 - 
    2.55 - Pop $R0 ; HID
    2.56 - Pop $R1 ; INFPATH
    2.57 - Pop $R2 ; INFDIR
    2.58 - 
    2.59 - ; Get the Windows version
    2.60 - Call GetWindowsVersion
    2.61 - Pop $R3 ; Windows Version
    2.62 - ;DetailPrint 'Windows Version: $R3'
    2.63 - StrCmp $R3 '2000' lbl_upgrade
    2.64 - StrCmp $R3 'XP' lbl_upgrade
    2.65 - StrCmp $R3 '2003' lbl_upgrade
    2.66 - DetailPrint "Windows $R3 doesn't support automatic driver updates."
    2.67 - 
    2.68 - ; Upgrade the driver if the device is already plugged in
    2.69 - Goto lbl_noupgrade
    2.70 -lbl_upgrade:
    2.71 - System::Get '${sysUpdateDriverForPlugAndPlayDevices}'
    2.72 - Pop $0
    2.73 - StrCmp $0 'error' lbl_noapi
    2.74 - DetailPrint "Updating the driver..."
    2.75 - ; 0, HID, INFPATH, 0, 0
    2.76 - Push $INSTDIR ; Otherwise this function will swallow it, dunno why
    2.77 - System::Call '${sysUpdateDriverForPlugAndPlayDevices}?e (0, R0, R1, 0, 0) .r0'
    2.78 - Pop $1 ; last error
    2.79 - Pop $INSTDIR
    2.80 - IntCmp $0 1 lbl_done
    2.81 - IntCmp $1 ${ERROR_NO_SUCH_DEVINST} lbl_notplugged
    2.82 - 
    2.83 - DetailPrint "Driver update has failed. ($R3:$0,$1)"
    2.84 - Goto lbl_noupgrade
    2.85 -lbl_notplugged:
    2.86 - DetailPrint "The device is not plugged in, cannot update the driver."
    2.87 - Goto lbl_noupgrade
    2.88 -lbl_noapi:
    2.89 - DetailPrint "Your Windows $R3 doesn't support driver updates."
    2.90 - 
    2.91 -lbl_noupgrade:
    2.92 - ; Pre-install the driver
    2.93 - System::Get '${sysSetupCopyOEMInf}'
    2.94 - Pop $0
    2.95 - StrCmp $0 'error' lbl_inoapi
    2.96 - DetailPrint "Installing the driver..."
    2.97 - ; INFPATH, INFDIR, SPOST_PATH, "", 0, 0, 0, 0
    2.98 - System::Call '${sysSetupCopyOEMInf}?e (R1, R2, ${SPOST_PATH}, 0, 0, 0, 0, 0) .r0'
    2.99 - Pop $1 ; last error
   2.100 - IntCmp $0 1 lbl_nodriver
   2.101 - DetailPrint 'Driver pre-installation has failed with error #$1 ($R3)'
   2.102 - Goto lbl_done
   2.103 -lbl_inoapi:
   2.104 - DetailPrint "Your Windows $R3 doesn't support driver pre-installation."
   2.105 -lbl_nodriver:
   2.106 -lbl_done:
   2.107 - 
   2.108 -FunctionEnd
     3.1 --- a/drvsetup.nsh	Mon Sep 08 22:42:26 2008 +1000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,15 +0,0 @@
     3.4 -; BOOL UpdateDriverForPlugAndPlayDevices(HWND, PSTR, PSTR, DWORD, PBOOL);
     3.5 -!define sysUpdateDriverForPlugAndPlayDevices "newdev::UpdateDriverForPlugAndPlayDevices(i, t, t, i, *i) i"
     3.6 -; the masked value of ERROR_NO_SUCH_DEVINST is 523
     3.7 -!define ERROR_NO_SUCH_DEVINST -536870389
     3.8 - 
     3.9 -;BOOL SetupCopyOEMInf(PSTR, PSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR);
    3.10 -!define sysSetupCopyOEMInf "setupapi::SetupCopyOEMInf(t, t, i, i, i, i, *i, t) i"
    3.11 -!define SPOST_NONE 0
    3.12 -!define SPOST_PATH 1
    3.13 -!define SPOST_URL 2
    3.14 -!define SP_COPY_DELETESOURCE 0x1
    3.15 -!define SP_COPY_REPLACEONLY 0x2
    3.16 -!define SP_COPY_NOOVERWRITE 0x8
    3.17 -!define SP_COPY_OEMINF_CATALOG_ONLY 0x40000
    3.18 -
     4.1 --- a/installer.nsi	Mon Sep 08 22:42:26 2008 +1000
     4.2 +++ b/installer.nsi	Wed Sep 10 14:43:12 2008 +1000
     4.3 @@ -1,12 +1,16 @@
     4.4  !include "MUI.nsh"
     4.5 -!include "driver.nsh"
     4.6 +!include "winver.nsh"
     4.7 +
     4.8 +Var MYPROGRAMFILES
     4.9 +Var ARCH_SPEC
    4.10  
    4.11  !define AppName "Xen PV Drivers"
    4.12  !define StartMenu "$SMPROGRAMS\${AppName}"
    4.13 -!define Version "0.9.11-pre14"
    4.14 +!define Version "0.9.11-pre15"
    4.15  #!define Version "$%VERSION%"
    4.16  Name "${AppName}"
    4.17 -InstallDir "$PROGRAMFILES\${AppName}"
    4.18 +
    4.19 +#InstallDir "$MYPROGRAMFILES\${AppName}"
    4.20  OutFile "${AppName} ${Version}.exe"
    4.21  
    4.22  # make sure /GPLPV is not currently active
    4.23 @@ -29,6 +33,17 @@ Section "Common Files"
    4.24    File .\doc\Installing.txt
    4.25    File .\doc\Readme.txt
    4.26    File .\doc\TODO.txt
    4.27 +  ExecWait 'NET STOP ShutdownMon'
    4.28 +  StrCmp $ARCH_SPEC "amd64" amd64
    4.29 +  File .\target\winnet\i386\copyconfig.exe
    4.30 +  File .\target\winnet\i386\shutdownmon.exe
    4.31 +  File $%DDK_PATH%\redist\DIFx\DPInst\EngMui\x86\DPInst.exe
    4.32 +  Goto amd64_done
    4.33 +amd64:
    4.34 +  File .\target\winnet\amd64\copyconfig.exe
    4.35 +  File .\target\winnet\amd64\shutdownmon.exe
    4.36 +  File $%DDK_PATH%\redist\DIFx\DPInst\EngMui\amd64\DPInst.exe
    4.37 +amd64_done:
    4.38    CreateDirectory "${StartMenu}\"
    4.39    CreateShortCut "${StartMenu}\Building.lnk" "$INSTDIR\Building.txt"
    4.40    CreateShortCut "${StartMenu}\Installing.lnk" "$INSTDIR\Installing.txt"
    4.41 @@ -37,20 +52,18 @@ Section "Common Files"
    4.42    CreateShortCut "${StartMenu}\Wiki Page.lnk" "http://wiki.xensource.com/xenwiki/XenWindowsGplPv" 
    4.43    WriteUninstaller $INSTDIR\Uninstall.exe
    4.44    CreateShortCut "${StartMenu}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
    4.45 -
    4.46  SectionEnd
    4.47  
    4.48  Section "Windows 2000" win2k
    4.49    SetOutPath $INSTDIR
    4.50    File /nonfatal .\ca.cer
    4.51 -  File .\target\win2k\i386\copyconfig.exe
    4.52 -  File .\target\win2k\i386\shutdownmon.exe
    4.53    SetOutPath $INSTDIR\drivers
    4.54    File .\target\win2k\xenpci.inf
    4.55    File .\target\win2k\xennet.inf
    4.56    File .\target\win2k\xenvbd.inf
    4.57    File .\target\win2k\xenscsi.inf
    4.58    File .\target\win2k\xenstub.inf
    4.59 +  File /nonfatal .\target\win2k\xengplpv.cat
    4.60    SetOutPath $INSTDIR\drivers\i386
    4.61    File .\target\win2k\i386\xenpci.sys
    4.62    File .\target\win2k\i386\xenhide.sys
    4.63 @@ -64,8 +77,6 @@ SectionEnd
    4.64  Section "Windows XP" winxp
    4.65    SetOutPath $INSTDIR
    4.66    File /nonfatal .\ca.cer
    4.67 -  File .\target\winxp\i386\copyconfig.exe
    4.68 -  File .\target\winxp\i386\shutdownmon.exe
    4.69    SetOutPath $INSTDIR\drivers
    4.70    File .\target\winxp\xenpci.inf
    4.71    File .\target\winxp\xennet.inf
    4.72 @@ -86,8 +97,6 @@ SectionEnd
    4.73  Section "Windows 2003 x32" win2k3x32
    4.74    SetOutPath $INSTDIR
    4.75    File /nonfatal .\ca.cer
    4.76 -  File .\target\winnet\i386\copyconfig.exe
    4.77 -  File .\target\winnet\i386\shutdownmon.exe
    4.78    SetOutPath $INSTDIR\drivers
    4.79    File .\target\winnet\xenpci.inf
    4.80    File .\target\winnet\xennet.inf
    4.81 @@ -108,8 +117,6 @@ SectionEnd
    4.82  Section "Windows 2003 x64" win2k3x64
    4.83    SetOutPath $INSTDIR
    4.84    File /nonfatal .\ca.cer
    4.85 -  File .\target\winnet\amd64\copyconfig.exe
    4.86 -  File .\target\winnet\amd64\shutdownmon.exe
    4.87    SetOutPath $INSTDIR\drivers
    4.88    File .\target\winnet\xenpci.inf
    4.89    File .\target\winnet\xennet.inf
    4.90 @@ -130,8 +137,6 @@ SectionEnd
    4.91  Section "Windows 2008 x32" win2k8x32
    4.92    SetOutPath $INSTDIR
    4.93    File /nonfatal .\ca.cer
    4.94 -  File .\target\winlh\i386\copyconfig.exe
    4.95 -  File .\target\winlh\i386\shutdownmon.exe
    4.96    SetOutPath $INSTDIR\drivers
    4.97    File .\target\winlh\xenpci.inf
    4.98    File .\target\winlh\xennet.inf
    4.99 @@ -152,8 +157,6 @@ SectionEnd
   4.100  Section "Windows 2008 x64" win2k8x64
   4.101    SetOutPath $INSTDIR
   4.102    File /nonfatal .\ca.cer
   4.103 -  File .\target\winlh\amd64\copyconfig.exe
   4.104 -  File .\target\winlh\amd64\shutdownmon.exe
   4.105    SetOutPath $INSTDIR\drivers
   4.106    File .\target\winlh\xenpci.inf
   4.107    File .\target\winlh\xennet.inf
   4.108 @@ -172,10 +175,12 @@ Section "Windows 2008 x64" win2k8x64
   4.109  SectionEnd
   4.110  
   4.111  Section /o "Install Cert" installcert
   4.112 -  ExecWait 'rundll32.exe cryptext.dll,CryptExtAddCER $INSTDIR\ca.cer'
   4.113 +  ExecWait 'rundll32.exe cryptext.dll,CryptExtAddCER "$INSTDIR\ca.cer"'
   4.114  SectionEnd
   4.115  
   4.116  Section "Install Drivers" installdrivers
   4.117 +  ExecWait '"$INSTDIR\DPInst.exe" /PATH "$INSTDIR\drivers" /LM /SA /SE /SW'
   4.118 +!if false
   4.119    Push "$INSTDIR\drivers"
   4.120    Push "$INSTDIR\drivers\xennet.inf"
   4.121    Push "XEN\VIF"
   4.122 @@ -210,16 +215,16 @@ Section "Install Drivers" installdrivers
   4.123    Push "$INSTDIR\drivers\xenpci.inf"
   4.124    Push "PCI\VEN_5853&DEV_0001"
   4.125    Call InstallUpgradeDriver
   4.126 +!endif
   4.127  SectionEnd
   4.128  
   4.129  Section "Shutdown Monitor Service" shutdownmon
   4.130 -  ExecWait 'NET STOP ShutdownMon'
   4.131    ExecWait '"$INSTDIR\ShutdownMon.exe" -u'
   4.132    ExecWait '"$INSTDIR\ShutdownMon.exe" -i'
   4.133    ExecWait 'NET START ShutdownMon'
   4.134  SectionEnd
   4.135    
   4.136 -Section "Copy Network Config" copynetworkconfig
   4.137 +Section /o "Copy Network Config" copynetworkconfig
   4.138    MessageBox MB_OKCANCEL "This will copy the network IP configuration from the qemu network adapter to the gplpv xennet network adapter. Ensure that all the drivers are loaded for all the network adapters before clicking OK" IDCANCEL done
   4.139    ExecWait '"$INSTDIR\copyconfig.exe"'
   4.140  done:
   4.141 @@ -245,6 +250,17 @@ no_GPLPV:
   4.142    
   4.143    Call GetWindowsVersion
   4.144    Pop $R0
   4.145 +
   4.146 +  ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" PROCESSOR_ARCHITECTURE
   4.147 +  StrCmp $0 "AMD64" is_amd64
   4.148 +  StrCpy $MYPROGRAMFILES $PROGRAMFILES
   4.149 +  StrCpy $ARCH_SPEC "i386"
   4.150 +  Goto amd64_done
   4.151 +is_amd64:
   4.152 +  StrCpy $MYPROGRAMFILES $PROGRAMFILES64
   4.153 +  StrCpy $ARCH_SPEC "amd64"
   4.154 +amd64_done:
   4.155 +  StrCpy $INSTDIR "$MYPROGRAMFILES\${AppName}"
   4.156    
   4.157    StrCmp $R0 "2000" 0 check_XP
   4.158    StrCpy $arch "win2k"