home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / nsis-2.46-setup.exe / Include / VPatchLib.nsh < prev    next >
Encoding:
Text File  |  2007-12-01  |  724 b   |  48 lines

  1. ; PatchLib v3.0
  2. ; =============
  3. ;
  4. ; Library with macro for use with VPatch (DLL version) in NSIS 2.0.5+
  5. ; Created by Koen van de Sande
  6.  
  7. !include LogicLib.nsh
  8.  
  9. !macro VPatchFile PATCHDATA SOURCEFILE TEMPFILE
  10.  
  11.   Push $1
  12.   Push $2
  13.   Push $3
  14.   Push $4
  15.  
  16.   Push ${SOURCEFILE}
  17.   Push ${TEMPFILE}
  18.  
  19.   Pop $2 # temp file
  20.   Pop $3 # source file
  21.  
  22.   InitPluginsDir
  23.   GetTempFileName $1 $PLUGINSDIR
  24.   File /oname=$1 ${PATCHDATA}
  25.  
  26.   vpatch::vpatchfile $1 $3 $2
  27.   Pop $4
  28.   DetailPrint $4
  29.  
  30.   StrCpy $4 $4 2
  31.   ${Unless} $4 == "OK"
  32.     SetErrors
  33.   ${EndIf}
  34.  
  35.   ${If} ${FileExists} $2
  36.     Delete $3
  37.     Rename /REBOOTOK $2 $3
  38.   ${EndIf}
  39.  
  40.   Delete $1
  41.  
  42.   Pop $4
  43.   Pop $3
  44.   Pop $2
  45.   Pop $1
  46.  
  47. !macroend
  48.