Skip to content

Commit

Permalink
NSIS: add a System Restore point creation during driver installation
Browse files Browse the repository at this point in the history
Use the SysRestore.dll based on https://github.com/hsluoyz/SysRestore
as the one found on https://nsis.sourceforge.net/SysRestore_plug-in
does not work fine with Windows 10.
  • Loading branch information
pquantin committed Feb 23, 2017
1 parent 6e471a2 commit b39b5ac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Binary file added nsis/SysRestore.dll
Binary file not shown.
28 changes: 27 additions & 1 deletion nsis/USBPcap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
!include "x64.nsh"
!include "WinVer.nsh"

!addplugindir .

!macro __MOZ__WinVer_DefineOSTests WinVer
!insertmacro __WinVer_DefineOSTest AtLeast ${WinVer} ""
!insertmacro __WinVer_DefineOSTest AtMost ${WinVer} ""
Expand Down Expand Up @@ -106,7 +108,7 @@ done:
MessageBox MB_OK "Unsupported Windows version. Only XP, Vista, 7 and 8 are supported."
Quit
${EndIf}

; Make sure we have the SHA-2 hotfix installed on Windows 7
; https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11766
${If} ${IsWin7}
Expand Down Expand Up @@ -143,12 +145,26 @@ Section "USBPcap Driver" SEC_USBPCAPDRIVER
SectionIn RO
SetOutPath "$INSTDIR"

Var /GLOBAL restore_point_success
!define RESTORE_POINT_NAME_INSTALL "USBPcap ${VERSION} installation"

DetailPrint "Start setting system restore point: ${RESTORE_POINT_NAME_INSTALL}"
SysRestore::StartRestorePoint /NOUNLOAD "${RESTORE_POINT_NAME_INSTALL}"
Pop $0
${If} $0 != 0
DetailPrint "Error occurred when starting setting system restore point, return value=|$0|"
${Else}
StrCpy $restore_point_success "yes"
${Endif}

${If} ${RunningX64}
${DisableX64FSRedirection}
SetRegView 64
${EndIf}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USBPcap" \
"DisplayName" "USBPcap ${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USBPcap" \
"DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USBPcap" \
"UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\USBPcap" \
Expand Down Expand Up @@ -195,6 +211,7 @@ Section "USBPcap Driver" SEC_USBPCAPDRIVER
${EndIf}

ExecWait '$SYSDIR\RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 128 .\USBPcap.inf'

${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
Expand All @@ -214,6 +231,15 @@ Section "USBPcapCMD" SEC_USBPCAPCMD
${Else}
File /oname=USBPcapCMD.exe "..\Release\USBPcapCMD_x86.exe"
${EndIf}

${If} $restore_point_success == "yes"
DetailPrint "Finish setting system restore point: ${RESTORE_POINT_NAME_INSTALL}"
SysRestore::FinishRestorePoint /NOUNLOAD
Pop $0
${If} $0 != 0
DetailPrint "Error occurred when finishing setting system restore point, return value=|$0|"
${EndIf}
${EndIf}
SectionEnd

Section "Detect USB 3.0" SEC_USB3
Expand Down

0 comments on commit b39b5ac

Please sign in to comment.