update-to-nsis-script-20040313
authorJeffrey Altman <jaltman@mit.edu>
Sat, 13 Mar 2004 21:24:41 +0000 (21:24 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 13 Mar 2004 21:24:41 +0000 (21:24 +0000)
Modify NSIS script to prevent overwriting variables

src/WINNT/install/NSIS/OpenAFS.nsi

index 268e743..36d1b1f 100644 (file)
@@ -638,19 +638,6 @@ skipremove:
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "LogonScript" "$INSTDIR\Client\Program\afscreds.exe -:%s -x"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Name" "OpenAFSDaemon"
 
-  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
-  strcpy $REG_VALUE   "DependOnGroup" 
-  strcpy $REG_DATA_1  "PNP_TDI"
-  strcpy $REG_DATA_2  ""
-  strcpy $REG_DATA_3  ""
-  Call RegWriteMultiStr
-  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
-  strcpy $REG_VALUE   "DependOnService" 
-  strcpy $REG_DATA_1  "Tcpip"
-  strcpy $REG_DATA_2  "NETBIOS"
-  strcpy $REG_DATA_3  "NetBT"
-  Call RegWriteMultiStr
-
   ;Write cell name
   ReadINIStr $R0 $1 "Field 2" "State"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "Cell" $R0
@@ -669,6 +656,20 @@ skipremove:
 !IFDEF DEBUG
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NoFindLanaByName" 1
 !ENDIF
+
+  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
+  strcpy $REG_VALUE   "DependOnGroup" 
+  strcpy $REG_DATA_1  "PNP_TDI"
+  strcpy $REG_DATA_2  ""
+  strcpy $REG_DATA_3  ""
+  Call RegWriteMultiStr
+  strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" 
+  strcpy $REG_VALUE   "DependOnService" 
+  strcpy $REG_DATA_1  "Tcpip"
+  strcpy $REG_DATA_2  "NETBIOS"
+  strcpy $REG_DATA_3  "NetBT"
+  Call RegWriteMultiStr
+
   SetRebootFlag true
   
   WriteUninstaller "$INSTDIR\Uninstall.exe"
@@ -3487,47 +3488,52 @@ Function RegWriteMultiStr
 !define RegSetValueEx            "Advapi32::RegSetValueExA(i, t, i, i, i, i) i"
 !define RegCloseKey              "Advapi32::RegCloseKeyA(i) i"
 
+  Exch $R0
+  Push $R1
+  Push $R2
+  Push $R9
+
   SetPluginUnload alwaysoff
   ; Create a buffer for the multi_sz value
   System::Call "*(&t${NSIS_MAX_STRLEN}) i.r1"
   ; Open/create the registry key
   System::Call "${RegCreateKey}(${HKEY_LOCAL_MACHINE}, '$REG_SUB_KEY', .r0) .r9"
   ; Failed?
-  IntCmp $9 0 write
+  IntCmp $R9 0 write
     MessageBox MB_OK|MB_ICONSTOP "Can't create registry key! ($9)"
     Goto noClose
 
   write:
     ; Fill in the buffer with our strings
-    StrCpy $2 $1                            ; Initial position
+    StrCpy $R2 $R1                            ; Initial position
 
-    StrLen $9 '$REG_DATA_1'                 ; Length of first string
-    IntOp $9 $9 + 1                         ; Plus null
-    System::Call "*$2(&t$9 '$REG_DATA_1')"  ; Place the string
-    IntOp $2 $2 + $9                        ; Advance to the next position
+    StrLen $R9 '$REG_DATA_1'                 ; Length of first string
+    IntOp $R9 $R9 + 1                         ; Plus null
+    System::Call "*$R2(&t$R9 '$REG_DATA_1')"  ; Place the string
+    IntOp $R2 $R2 + $R9                        ; Advance to the next position
 
     StrCmp '$REG_DATA_2' "" terminate
-    StrLen $9 '$REG_DATA_2'                 ; Length of second string
-    IntOp $9 $9 + 1                         ; Plus null
-    System::Call "*$2(&t$9 '$REG_DATA_2')"  ; Place the string
-    IntOp $2 $2 + $9                        ; Advance to the next position
+    StrLen $R9 '$REG_DATA_2'                 ; Length of second string
+    IntOp $R9 $R9 + 1                         ; Plus null
+    System::Call "*$R2(&t$R9 '$REG_DATA_2')"  ; Place the string
+    IntOp $R2 $R2 + $R9                        ; Advance to the next position
 
     StrCmp '$REG_DATA_3' "" terminate
-    StrLen $9 '$REG_DATA_3'                 ; Length of third string
-    IntOp $9 $9 + 1                         ; Plus null
-    System::Call "*$2(&t$9 '$REG_DATA_3')"  ; Place the string
-    IntOp $2 $2 + $9                        ; Advance to the next position
+    StrLen $R9 '$REG_DATA_3'                 ; Length of third string
+    IntOp $R9 $R9 + 1                         ; Plus null
+    System::Call "*$R2(&t$R9 '$REG_DATA_3')"  ; Place the string
+    IntOp $R2 $R2 + $9                        ; Advance to the next position
 
   terminate:
-    System::Call "*$2(&t1 '')"              ; Place the terminating null
-    IntOp $2 $2 + 1                         ; Advance to the next position
+    System::Call "*$R2(&t1 '')"              ; Place the terminating null
+    IntOp $R2 $R2 + 1                         ; Advance to the next position
 
     ; Create/write the value
-    IntOp $2 $2 - $1                        ; Total length
+    IntOp $R2 $R2 - $R1                        ; Total length
     System::Call "${RegSetValueEx}(r0, '$REG_VALUE', 0, ${REG_MULTI_SZ}, r1, r2) .r9"
     ; Failed?
-    IntCmp $9 0 done
-      MessageBox MB_OK|MB_ICONSTOP "Can't set key value! ($9)"
+    IntCmp $R9 0 done
+      MessageBox MB_OK|MB_ICONSTOP "Can't set key value! ($R9)"
       Goto done
 
   done:
@@ -3537,5 +3543,10 @@ Function RegWriteMultiStr
 noClose:
   ; Clear the buffer
   SetPluginUnload manual
-  System::Free $1
+  System::Free $R1
+
+  Pop $R9
+  Pop $R2
+  Pop $R1
+  Exch $R0
 FunctionEnd
\ No newline at end of file