Archive: Customize Spring-Installer on-the-fly (when downloading)


Customize Spring-Installer on-the-fly (when downloading)
  i want to customize an nsis-installer on the fly, an php-script should attach some zip-files + some data, where theses files should be installed. Did someone try this?

In general, the php script should do something like this:

file_get_contents('nsis_setup.exe');

if ($param=="attach"){
>file_get_contents('some_data');
echo'ATTACHED'; //attach tag
>echo filesize('nsis_setup.exe'); //attach offset
>}
and the installer itselfs should check if the tag + offset is avaiable.

if so, it should extract the attached file.

any ideas/suggestions how to do that? is that possible with the nsis installer?

i try to modify the installer of an engine, that it can be customized to attach an game and an game-map to the installer.

The ReadCustomerData function may be of interest to you. Basically you can just append whatever data you want to an NSIS exe, it won't break. You will however have to add your own integrity checks, as the NSIS CRC check only covers the installer part of the exe.


Originally posted by MSG
The ReadCustomerData function may be of interest to you. Basically you can just append whatever data you want to an NSIS exe, it won't break. You will however have to add your own integrity checks, as the NSIS CRC check only covers the installer part of the exe.
Where is this ReadCustomerData function? I didn't find it in the NSIS help file.

http://nsis.sourceforge.net/ReadCustomerData


Try google. It often helps when you want to find something.


thanks, that helped a lot!

now i'm having problems, how to copy parts of binary data from the installer:


;Reads last bytes from installer, checks if it is SPRING<START><LENGTH>
;then reads from installer at pos <START> <LENGTH> bytes
FileOpen $0 $EXEPATH r
FileSeek $0 -10 END

;check if signature found (6 Bytes)
FileRead $0 $1 6
DetailPrint "Signature read: $1"
StrCmpS $1 'SPRING' 0 end

;Last bytes contains offset (4 Bytes)
FileReadByte $0 $1 ;read byte into $1
System::Int64Op $1 << 24 ; shift left
Pop $2 ; store in $0

FileReadByte $0 $1
System::Int64Op $1 << 16
Pop $3
System::Int64Op $2 + $3
Pop $2

FileReadByte $0 $1
System::Int64Op $1 << 8
Pop $3
System::Int64Op $2 + $3
Pop $2

FileReadByte $0 $1
System::Int64Op $1 + $2
Pop $5

DetailPrint "Custom Data starts at: $5"

MessageBox MB_OK "Read Signature done"

;TODO: do until here on init

;signature found, read offset where ini files start

System::Call 'msvcrt.dll::calloc(i 1024, i 1) i .r0' ; creates a 1024 size buffer
MessageBox MB_OK "Opening Installer file $EXEPATH"
System::Call 'msvcrt.dll::_open($EXEPATH, i 0x8000) i .r1' ; open first file

MessageBox MB_OK "Seeking to adress $5"
;fseek to offset
System::Call 'msvcrt.dll::_lseek(i r1, i $5, i 0) i .r1' ; seek to position of ini

System::Call 'msvcrt.dll::_open(t "$INSTDIR\prueba2.bin", i 0x8101) i .r2' ; open second file, mode create|trunc|binary
System::Call 'msvcrt.dll::_read(i r1, i r0,i 1024) i .r3' ;read the first file
System::Call 'msvcrt.dll::_write(i r2, i r0,i 1024) i .r3' ;and writes to the second
System::Call 'msvcrt.dll::_close(i r1)' ; close file 1
System::Call 'msvcrt.dll::_close(i r2)' ; close file 2
System::Call 'msvcrt.dll::free(i ro)'

end:
what's wrong here, i only get 1024 Null-bytes written into the destination? Is my usage of _lseek wrong? The Offset seems to be correct. I'm a bit confused about the System::Call's...

(the installer is for springrts...)

ok, i did it:
https://github.com/spring/spring/blo...mInstaller.nsh

its a bit ugly, but seems to work...

any hints for improvements are welcome :-)


IMHO it could be better to reimplement that as plugin, but i'm new to nsis, so this would take to much time at the moment :-/