win-pvdrivers

view driver.nsh @ 387:48df739c66d4

Removed some debugging calls to the HLT instruction
author James Harper <james.harper@bendigoit.com.au>
date Fri Jul 11 14:05:34 2008 +1000 (2008-07-11)
parents 89e1a0af859c
children
line source
1 !include "winver.nsh"
2 !include "drvsetup.nsh"
4 ;
5 ; Written by Kuba Ober
6 ; Copyright (c) 2004 Kuba Ober
7 ;
8 ; Permission is hereby granted, free of charge, to any person obtaining a
9 ; copy of this software and associated documentation files (the "Software"),
10 ; to deal in the Software without restriction, including without limitation
11 ; the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 ; and/or sell copies of the Software, and to permit persons to whom the
13 ; Software is furnished to do so, subject to the following conditions:
14 ;
15 ; The above copyright notice and this permission notice shall be included in
16 ; all copies or substantial portions of the Software.
17 ;
18 ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 ; DEALINGS IN THE SOFTWARE.
26 ;
27 ; U S A G E
28 ;
29 ; Push "c:\program files\yoursoftware\driver"
30 ; -- the directory of the .inf file
31 ; Push "c:\program files\yoursoftware\driver\driver.inf"
32 ; -- the filepath of the .inf file (directory + filename)
33 ; Push "USB\VID_1234&PID_5678"
34 ; -- the HID (Hardware ID) of your device
35 ; Call InstallUpgradeDriver
36 ;
37 ; Your driver (minimally the .inf and .sys files) should already by installed
38 ; by your NSIS script.
39 ;
40 ; Typically, you would put the driver either in $INSTDIR or $INSTDIR\Driver
41 ; It's up to you, of course.
42 ;
43 ; The driver (i.e. .inf, .sys and related files) must be present for the
44 ; lifetime of your application, you shouldn't remove them after calling
45 ; this function!
46 ;
47 ; You DON'T want to put the driver in any of system directories. Windows
48 ; will do it when the device is first plugged in.
50 Function InstallUpgradeDriver
52 Pop $R0 ; HID
53 Pop $R1 ; INFPATH
54 Pop $R2 ; INFDIR
56 ; Get the Windows version
57 Call GetWindowsVersion
58 Pop $R3 ; Windows Version
59 ;DetailPrint 'Windows Version: $R3'
60 StrCmp $R3 '2000' lbl_upgrade
61 StrCmp $R3 'XP' lbl_upgrade
62 StrCmp $R3 '2003' lbl_upgrade
63 DetailPrint "Windows $R3 doesn't support automatic driver updates."
65 ; Upgrade the driver if the device is already plugged in
66 Goto lbl_noupgrade
67 lbl_upgrade:
68 System::Get '${sysUpdateDriverForPlugAndPlayDevices}'
69 Pop $0
70 StrCmp $0 'error' lbl_noapi
71 DetailPrint "Updating the driver..."
72 ; 0, HID, INFPATH, 0, 0
73 Push $INSTDIR ; Otherwise this function will swallow it, dunno why
74 System::Call '${sysUpdateDriverForPlugAndPlayDevices}?e (0, R0, R1, 0, 0) .r0'
75 Pop $1 ; last error
76 Pop $INSTDIR
77 IntCmp $0 1 lbl_done
78 IntCmp $1 ${ERROR_NO_SUCH_DEVINST} lbl_notplugged
80 DetailPrint "Driver update has failed. ($R3:$0,$1)"
81 Goto lbl_noupgrade
82 lbl_notplugged:
83 DetailPrint "The device is not plugged in, cannot update the driver."
84 Goto lbl_noupgrade
85 lbl_noapi:
86 DetailPrint "Your Windows $R3 doesn't support driver updates."
88 lbl_noupgrade:
89 ; Pre-install the driver
90 System::Get '${sysSetupCopyOEMInf}'
91 Pop $0
92 StrCmp $0 'error' lbl_inoapi
93 DetailPrint "Installing the driver..."
94 ; INFPATH, INFDIR, SPOST_PATH, "", 0, 0, 0, 0
95 System::Call '${sysSetupCopyOEMInf}?e (R1, R2, ${SPOST_PATH}, 0, 0, 0, 0, 0) .r0'
96 Pop $1 ; last error
97 IntCmp $0 1 lbl_nodriver
98 DetailPrint 'Driver pre-installation has failed with error #$1 ($R3)'
99 Goto lbl_done
100 lbl_inoapi:
101 DetailPrint "Your Windows $R3 doesn't support driver pre-installation."
102 lbl_nodriver:
103 lbl_done:
105 FunctionEnd