summaryrefslogtreecommitdiff
path: root/Include/Library.nsh
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-03-31 20:38:05 +0200
committerDidier Raboud <odyx@debian.org>2018-03-31 20:38:05 +0200
commit57ba1ad89a375b1a6748bf19df10cc12f6d4706a (patch)
tree73e163b8702ead43b428864cec176f96d6f1bcf4 /Include/Library.nsh
parent1a96fb2827d0e735fce6f6a084f73b9fb186dc3f (diff)
Import Upstream version 2.08
Diffstat (limited to 'Include/Library.nsh')
-rwxr-xr-x[-rw-r--r--]Include/Library.nsh329
1 files changed, 141 insertions, 188 deletions
diff --git a/Include/Library.nsh b/Include/Library.nsh
index afe5f0d..a2a0187 100644..100755
--- a/Include/Library.nsh
+++ b/Include/Library.nsh
@@ -1,169 +1,109 @@
-/*
+#
+# Library.nsh
+#
+# A system for the installation and uninstallation of dynamic
+# link libraries (DLL) and type libraries (TLB). Using this
+# system you can handle the complete setup with one single
+# line of code:
+#
+# * File copying
+# * File copying on reboot
+# * Version checks
+# * Registration and unregistration
+# * Registration and unregistration on reboot
+# * Shared DLL counting
+# * Windows File Protection checks
+#
+# For more information, read appendix B in the documentation.
+#
-***********************
-Macro - Install Library
-***********************
-
-This macro can be used to install DLL and TLB libraries. It checks for version numbers and Windows file protection,
-registers the files and can update files on reboot.
-
-To ask the user for a reboot if required, use the Modern UI with a Finish page or use IfRebootFlag and make your
-own page or message box.
-
-Usage:
-
-!insertmacro InstallLib libtype shared install localfile destfile tempbasedir
-
-Parameters:
-
-libtype The type of the library
-
- DLL Dynamic link library (DLL)
- REGDLL DLL that has to be registered
- TLB Type library or DLL that contains a type LIBRARY
- REGDLLTLB DLL that has to be registered and contains a type library
-
-shared Specify whether the library is shared with other applications
-
- NOTSHARED The library is not shared
- $VARNAME Variable that is empty when the application is installed for the first time,
- which is when the shared library count will be increased.
-
-install Specify the installation method
-
- REBOOT_PROTECTED * Upgrade the library on reboot when in use (required for system files).
- * Upgrade the library if the file is not protected by Windows File Protection.
-
- NOREBOOT_PROTECTED * Warns the user when the library is in use. The user will have to close
- applications using the library.
- * Upgrade the library if the file is not protected by Windows File Protection.
-
- REBOOT_NOTPROTECTED * Upgrade the library on reboot when in use (required for system files).
- * Upgrade the library without checking for Windows File Protection.
-
- NOREBOOT_NOTPROTECTED * Warns the user when the library is in use. The user will have to close
- applications using the library.
- * Upgrade the library without checking for Windows File Protection.
-
-localfile Location of the library on the compiler system
-
-destfile Location to store the library on the user's system
-
-tempbasedir Directory on the user's system to store a temporary file when the system has
- to be rebooted.
-
- For Windows 9x/ME support, this directory should be on the same volume as the
- destination file (destfile).
- The Windows temp directory could be located on any volume, so you cannot use
- this directory.
-
-Options:
-
-LIBRARY_SHELL_EXTENSION
-
- Define this before inserting InstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after registration. Use this to refresh the shell when installing a shell extension or when changing file associations.
-
-LIBRARY_COM
-
- Define this before inserting InstallLib macro to call CoFreeUnusedLibraries after registration. Use this for unloading all unnecessary libraries from memory when installing COM libraries.
-
-Notes:
-
-* If you want to support Windows 9x/ME, you can only use short filenames (8.3).
-
-* You can only compile scripts using this macro on Windows systems.
-
-------------------------
-
-Example:
-
-Var ALREADY_INSTALLED
-;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is
-;already installed.
-
-!insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
-
-
-*************************
-Macro - Uninstall Library
-*************************
-
-This macro can be used to uninstall DLL and TLB libraries. It unregisters files and can remove them on reboot.
-
-Usage:
-
-!insertmacro UnInstallLib libtype shared uninstall file
+!ifndef LIB_INCLUDED
-Parameters:
+!define LIB_INCLUDED
-libtype The type of the library
+!ifndef SHCNE_ASSOCCHANGED
+ !define SHCNE_ASSOCCHANGED 0x08000000
+!endif
+!ifndef SHCNF_IDLIST
+ !define SHCNF_IDLIST 0x0000
+!endif
- DLL Dynamic link library (DLL)
- REGDLL DLL that has to be registered
- TLB Type library or DLL that contains a type LIBRARY
- REGTLB DLL that has to be registered and contains a type library
+Var __INSTALLLLIB_SESSIONGUID
-shared Specify whether the library is shared with other applications
+### Initialize session id (GUID)
+!macro __InstallLib_Helper_InitSession
- NOTSHARED The library is not shared
- SHARE The library is shared and should be removed if the shared library count
- indicates that the file is not in use anymore.
+ StrCmp $__INSTALLLLIB_SESSIONGUID '' 0 +6
-uninstall Specify the uninstallation method
+ System::Alloc 16
+ System::Call 'ole32::CoCreateGuid(i sR0)'
+ System::Call 'ole32::StringFromGUID2(i R0, w .s, i ${NSIS_MAX_STRLEN})'
+ System::Free $R0
+ Pop $__INSTALLLLIB_SESSIONGUID
- NOREMOVE The library should not be removed.
- You should use this option for common or important system files such as the
- Visual Basic/C++/MFC runtimes.
+ StrCmp $__INSTALLLLIB_SESSIONGUID '' 0 +2
+ StrCpy $__INSTALLLLIB_SESSIONGUID 'session'
- REBOOT_PROTECTED * Remove the library on reboot when in use (required for system files).
- * Remove the library if the file is not protected by Windows File Protection.
+!macroend
- NOREBOOT_PROTECTED * Warns the user when the library is in use. The user will have to close
- applications using the library.
- * Remove the library if the file is not protected by Windows File Protection.
+### Add a RegTool entry to register after reboot
+!macro __InstallLib_Helper_AddRegToolEntry mode filename tempdir
- REBOOT_NOTPROTECTED * Remove the library on reboot when in use (required for system files).
- * Remove the library without checking for Windows File Protection.
+ Push $R0
+ Push $R1
+ Push $R2
+ Push $R3
- NOREBOOT_NOTPROTECTED * Warns the user when the library is in use. The user will have to close
- applications using the library.
- * Remove the library without checking for Windows File Protection.
+ ;------------------------
+ ;Copy the parameters
-file Location of the library
+ Push "${filename}"
+ Push "${tempdir}"
-Options:
+ Pop $R2 ; temporary directory
+ Pop $R1 ; file name to register
-LIBRARY_SHELL_EXTENSION
+ ;------------------------
+ ;Initialize session id
- Define this before inserting UninstallLib macro to call SHChangeNotify with SHCNE_ASSOCCHANGED after unregistration. Use this to refresh the shell when uninstalling a shell extension or when changing file associations.
+ !insertmacro __InstallLib_Helper_InitSession
-LIBRARY_COM
+ ;------------------------
+ ;Advance counter
- Define this before inserting UninstallLib macro to call CoFreeUnusedLibraries after unregistration. Use this for unloading all unnecessary libraries from memory when uninstalling COM libraries.
+ StrCpy $R0 0
+ ReadRegDWORD $R0 HKLM "Software\NSIS.Library.RegTool.v2\$__INSTALLLLIB_SESSIONGUID" "count"
+ IntOp $R0 $R0 + 1
+ WriteRegDWORD HKLM "Software\NSIS.Library.RegTool.v2\$__INSTALLLLIB_SESSIONGUID" "count" "$R0"
-------------------------
+ ;------------------------
+ ;Setup RegTool
-Example:
+ ReadRegStr $R3 HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "NSIS.Library.RegTool.v2"
+ IfFileExists $R3 +3
-!insertmacro UnInstallLib REGDLL SHARED REBOOT_NOTPROTECTED $SYSDIR\dllname.dll
+ File /oname=$R2\NSIS.Library.RegTool.v2.exe "${NSISDIR}\Bin\RegTool.bin"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" \
+ "NSIS.Library.RegTool.v2" '"$R2\NSIS.Library.RegTool.v2.exe" /S'
-*/
+ ;------------------------
+ ;Add RegTool entry
-!ifndef LIB_INCLUDED
+ WriteRegStr HKLM "Software\NSIS.Library.RegTool.v2\$__INSTALLLLIB_SESSIONGUID" "$R0.file" "$R1"
+ WriteRegStr HKLM "Software\NSIS.Library.RegTool.v2\$__INSTALLLLIB_SESSIONGUID" "$R0.mode" "${mode}"
-!define LIB_INCLUDED
+ Pop $R3
+ Pop $R2
+ Pop $R1
+ Pop $R0
-!ifndef SHCNE_ASSOCCHANGED
- !define SHCNE_ASSOCCHANGED 0x08000000
-!endif
-!ifndef SHCNF_IDLIST
- !define SHCNF_IDLIST 0x0000
-!endif
+!macroend
+### Install library
!macro InstallLib libtype shared install localfile destfile tempbasedir
!verbose push
- !verbose 3
+ #!verbose 3
Push $R0
Push $R1
@@ -246,7 +186,7 @@ Example:
;------------------------
;Get version information
- !execute '"${NSISDIR}\Bin\LibraryLocal.exe" D ${LOCALFILE}'
+ !execute '"${NSISDIR}\Bin\LibraryLocal.exe" D "${LOCALFILE}"'
!include "${NSISDIR}\Bin\LibraryLocal.nsh"
!ifdef LIBRARY_VERSION_FILENOTFOUND
@@ -274,7 +214,7 @@ Example:
!else
- !execute '"${NSISDIR}\Bin\LibraryLocal.exe" T ${LOCALFILE}'
+ !execute '"${NSISDIR}\Bin\LibraryLocal.exe" T "${LOCALFILE}"'
!include "${NSISDIR}\Bin\LibraryLocal.nsh"
!ifdef LIBRARY_VERSION_FILENOTFOUND
@@ -303,7 +243,7 @@ Example:
!ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB
- !execute '"${NSISDIR}\Bin\LibraryLocal.exe" T ${LOCALFILE}'
+ !execute '"${NSISDIR}\Bin\LibraryLocal.exe" T "${LOCALFILE}"'
!include "${NSISDIR}\Bin\LibraryLocal.nsh"
!endif
@@ -402,36 +342,7 @@ Example:
;------------------------
;Register on reboot
- !ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB
-
- ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "NSIS.Library.RegTool"
- IfFileExists $R0 installlib.rebootreg_${INSTALLLIB_UNIQUE}
-
- File /oname=$R5\NSIS.Library.RegTool.exe "${NSISDIR}\Bin\RegTool.bin"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" \
- "NSIS.Library.RegTool" '"$R5\NSIS.Library.RegTool.exe"'
-
- installlib.rebootreg_${INSTALLLIB_UNIQUE}:
-
- !endif
-
- !ifdef INSTALLLIB_LIBTYPE_REGDLL
-
- WriteRegStr HKLM "Software\NSIS.Library.RegTool" "$R4" 'D'
-
- !endif
-
- !ifdef INSTALLLIB_LIBTYPE_TLB
-
- WriteRegStr HKLM "Software\NSIS.Library.RegTool" "$R4" 'T'
-
- !endif
-
- !ifdef INSTALLLIB_LIBTYPE_REGDLLTLB
-
- WriteRegStr HKLM "Software\NSIS.Library.RegTool" "$R4" 'DT'
-
- !endif
+ Call :installlib.regonreboot_${INSTALLLIB_UNIQUE}
Goto installlib.done_${INSTALLLIB_UNIQUE}
@@ -452,15 +363,37 @@ Example:
!endif
- !ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_REGDLLTLB
+ !ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB
- RegDLL $R4
+ !ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED
- !endif
+ IfRebootFlag 0 installlib.regnoreboot_${INSTALLLIB_UNIQUE}
- !ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB
+ Call :installlib.regonreboot_${INSTALLLIB_UNIQUE}
+
+ Goto installlib.registerfinish_${INSTALLLIB_UNIQUE}
+
+ installlib.regnoreboot_${INSTALLLIB_UNIQUE}:
+
+ !endif
+
+ !ifdef INSTALLLIB_LIBTYPE_TLB | INSTALLLIB_LIBTYPE_REGDLLTLB
+
+ TypeLib::Register $R4
- TypeLib::Register $R4
+ !endif
+
+ !ifdef INSTALLLIB_LIBTYPE_REGDLL | INSTALLLIB_LIBTYPE_REGDLLTLB
+
+ RegDll $R4
+
+ !endif
+
+ !ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED
+
+ installlib.registerfinish_${INSTALLLIB_UNIQUE}:
+
+ !endif
!endif
@@ -483,7 +416,7 @@ Example:
!undef LIBRARY_DEFINE_DONE_LABEL
- installlib.done_${INSTALLLIB_UNIQUE}:
+ installlib.done_${INSTALLLIB_UNIQUE}:
!endif
@@ -506,29 +439,48 @@ Example:
SetOverwrite try
- installlib.file_${INSTALLLIB_UNIQUE}:
- File /oname=$R0 "${LOCALFILE}"
- Return
+ !else
- installlib.end_${INSTALLLIB_UNIQUE}:
+ SetOverwrite on
- SetOverwrite lastused
+ !endif
- !else
+ installlib.file_${INSTALLLIB_UNIQUE}:
+ File /oname=$R0 "${LOCALFILE}"
+ Return
- SetOverwrite on
+ SetOverwrite lastused
- installlib.file_${INSTALLLIB_UNIQUE}:
- File /oname=$R0 "${LOCALFILE}"
- Return
+ ;------------------------
+ ;Register on reboot
- installlib.end_${INSTALLLIB_UNIQUE}:
+ !ifdef INSTALLLIB_INSTALL_REBOOT_PROTECTED | INSTALLLIB_INSTALL_REBOOT_NOTPROTECTED
- SetOverwrite lastused
+ installlib.regonreboot_${INSTALLLIB_UNIQUE}:
+
+ !ifdef INSTALLLIB_LIBTYPE_REGDLL
+ !insertmacro __InstallLib_Helper_AddRegToolEntry 'D' "$R4" "$R5"
+ !endif
+
+ !ifdef INSTALLLIB_LIBTYPE_TLB
+ !insertmacro __InstallLib_Helper_AddRegToolEntry 'T' "$R4" "$R5"
+ !endif
+
+ !ifdef INSTALLLIB_LIBTYPE_REGDLLTLB
+ !insertmacro __InstallLib_Helper_AddRegToolEntry 'D' "$R4" "$R5"
+ !insertmacro __InstallLib_Helper_AddRegToolEntry 'T' "$R4" "$R5"
+ !endif
+
+ Return
!endif
;------------------------
+ ;End label
+
+ installlib.end_${INSTALLLIB_UNIQUE}:
+
+ ;------------------------
;Undefine
!undef INSTALLLIB_UNIQUE
@@ -544,6 +496,7 @@ Example:
!macroend
+### Uninstall library
!macro UnInstallLib libtype shared uninstall file
!verbose push