[Setup] AppName=My Application AppVerName=My Application Ver 1.5 DefaultDirName={pf}\My Application SolidCompression=yes Compression=lzma/ultra [code] type TTimerProc=procedure(h:longword; msg:longword; idevent:longword; dwTime:longword); function SetTimer(hWnd: longword; nIDEvent, uElapse: longword; lpTimerFunc: longword): longword; external 'SetTimer@user32.dll stdcall'; // used for timerproc access function wsprintf( a:ansistring; b:ansistring; c:TTimerProc ): longword; external 'wsprintfA@user32.dll cdecl'; // used for copying of generated code from string to allocated memory function memcpy( a:longword; c:ansistring; l:longword ): longword; external 'memcpy@msvcrt.dll cdecl'; // required memory allocation with executable permissions function VirtualAlloc( a:longword; b:longword; c:longword; d:longword ): longword; external 'VirtualAlloc@kernel32.dll stdcall'; //function VirtualFree( a:longword; b:longword; c:longword ): longword; // external 'VirtualFree@kernel32.dll stdcall'; function sh_wrap( u: TTimerProc ): longword; var x,y,cb: longword; s: ansistring; begin SetLength( s, 256 ); wsprintf( s, '%i %i;', u ); // fetch 1st pointer dword x := StrToInt( Copy(s,1,Pos(' ',s)-1) ); // fetch 2nd pointer dword Delete( s, 1, Pos(' ',s) ); y := StrToInt( Copy(s,1,Pos(';',s)-1) ); // x86 code for callback function with 4 args s := chr(85)+chr(139)+chr(236)+chr(104)+chr(x)+chr(x shr 8)+chr(x shr 16)+chr(x shr 24)+chr(139)+chr(85)+chr(8)+chr(139)+chr(77)+chr(12)+chr(255)+chr(181)+chr(16)+chr(0)+chr(0)+chr(0)+chr(255)+chr(181)+chr(20)+chr(0)+chr(0)+chr(0)+chr(184)+chr(y)+chr(y shr 8)+chr(y shr 16)+chr(y shr 24)+chr(255)+chr(85)+chr(252)+chr(90)+chr(93)+chr(194)+chr(16)+chr(0); // SaveStringToFile( 'z:\tmp1', s, false ); // allocate executable memory cb := VirtualAlloc( 0, $2000, $1000, $40 ); // copy the generated code memcpy( cb, s, Length(s) ); result := cb; end; procedure mytimerproc1(h:longword; msg:longword; idevent:longword; dwTime:longword); begin WizardForm.WelcomePage.Color:=random($FFFFFF); WizardForm.WelcomeLabel2.Font.Color:=random($FFFFFF); end; procedure mytimerproc2(h:longword; msg:longword; idevent:longword; dwTime:longword); begin WizardForm.WelcomeLabel1.Font.Color:=random($FFFFFF); WizardForm.Color:=random($FFFFFF); end; procedure InitializeWizard(); begin settimer(0,0,1000,sh_wrap(@mytimerproc1)); settimer(0,0,700,sh_wrap(@mytimerproc2)); end; |