2002-08-02 10:01:35 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include "fileform.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "state.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#include "exec.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
#define EXEC_ERROR 0x7FFFFFFF
|
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
|
|
|
HWND g_SectionHack;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_STACK
|
|
|
|
typedef struct _stack_t {
|
|
|
|
struct _stack_t *next;
|
|
|
|
char text[NSIS_MAX_STRLEN];
|
|
|
|
} stack_t;
|
|
|
|
|
|
|
|
static stack_t *g_st;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int exec_errorflag;
|
|
|
|
#ifdef NSIS_SUPPORT_REBOOT
|
|
|
|
static int exec_rebootflag;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
|
|
|
HBITMAP g_hBrandingBitmap = 0;
|
|
|
|
#endif
|
|
|
|
|
2002-08-08 15:04:45 +00:00
|
|
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
|
|
|
char plugins_temp_dir[NSIS_MAX_STRLEN]="";
|
|
|
|
#endif
|
|
|
|
|
2002-08-07 15:14:40 +00:00
|
|
|
extern HWND m_curwnd;
|
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
static WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
HANDLE h;
|
|
|
|
static WIN32_FIND_DATA fd;
|
|
|
|
h = FindFirstFile(buf,&fd);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
FindClose(h);
|
|
|
|
return &fd;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS
|
|
|
|
// based loosely on code from Tim Kosse
|
|
|
|
// in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys),
|
|
|
|
// but in win2k you need to do this manually.
|
2002-08-19 23:18:19 +00:00
|
|
|
static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
HKEY key;
|
|
|
|
int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ALL_ACCESS,&key);
|
|
|
|
if (retval==ERROR_SUCCESS)
|
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
// NB - don't change this to static (recursive function)
|
2002-08-02 10:01:35 +00:00
|
|
|
char buffer[MAX_PATH+1];
|
|
|
|
while (RegEnumKey(key,0,buffer,MAX_PATH+1)==ERROR_SUCCESS)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (onlyifempty)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
|
|
|
return !ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if ((retval=myRegDeleteKeyEx(key,buffer,0)) != ERROR_SUCCESS) break;
|
|
|
|
}
|
|
|
|
RegCloseKey(key);
|
|
|
|
retval=RegDeleteKey(thiskey,lpSubKey);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
#endif//NSIS_SUPPORT_REGISTRYFUNCTIONS
|
|
|
|
|
|
|
|
extern char g_all_user_var_flag;
|
|
|
|
|
2002-09-19 22:25:15 +00:00
|
|
|
static int NSISCALL ExecuteEntry(entry *entry_);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
static int NSISCALL resolveaddr(int v)
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
|
|
|
if (v<0) return myatoi(g_usrvars[-(v+1)]); // if <0, that means we
|
|
|
|
return v;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2002-09-19 22:25:15 +00:00
|
|
|
int NSISCALL ExecuteCodeSegment(int pos, HWND hwndProgress)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
while (pos >= 0)
|
|
|
|
{
|
|
|
|
int rv;
|
2002-09-19 22:25:15 +00:00
|
|
|
if (g_inst_entry[pos].which == EW_RET) return 0;
|
|
|
|
rv=ExecuteEntry(g_inst_entry + pos);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (rv == EXEC_ERROR) return EXEC_ERROR;
|
|
|
|
|
|
|
|
rv=resolveaddr(rv);
|
2002-09-19 21:53:24 +00:00
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
if (!rv) { rv++; pos++; }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int t=pos;
|
|
|
|
rv--; // rv is decremented here by 1, since it was +1 on the other end.
|
|
|
|
pos=rv; // set new position
|
|
|
|
rv-=t; // set rv to delta for progress adjustment
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
|
|
|
|
if (hwndProgress)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
extern int progress_bar_pos, progress_bar_len;
|
|
|
|
progress_bar_pos+=rv;
|
2002-09-25 03:14:53 +00:00
|
|
|
SendMessage(hwndProgress,PBM_SETPOS,MulDiv(progress_bar_pos,30000,progress_bar_len+!progress_bar_len),0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-30 21:42:58 +00:00
|
|
|
static char bufs[5][NSIS_MAX_STRLEN];
|
2002-09-19 21:53:24 +00:00
|
|
|
static int *parms;
|
|
|
|
|
|
|
|
static int NSISCALL process_string_fromparm_toint(int id_)
|
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
return myatoi(process_string(ps_tmpbuf,GetStringFromStringTab(parms[id_])));
|
2002-09-19 21:53:24 +00:00
|
|
|
}
|
|
|
|
|
2002-09-24 18:49:21 +00:00
|
|
|
// NB - USE CAUTION when rearranging code to make use of the new return value of
|
|
|
|
// this function - be sure the parm being accessed is not modified before the call.
|
|
|
|
static char * NSISCALL process_string_fromparm_tobuf(int id_)
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
2002-09-25 02:36:30 +00:00
|
|
|
return process_string_fromtab(bufs[id_ >> 4], parms[id_ & 0xF]);
|
2002-09-19 21:53:24 +00:00
|
|
|
}
|
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
// returns EXEC_ERROR on error
|
|
|
|
// returns 0, advance position by 1
|
|
|
|
// otherwise, returns new_position+1
|
2002-09-19 22:25:15 +00:00
|
|
|
static int NSISCALL ExecuteEntry(entry *entry_)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-21 02:44:49 +00:00
|
|
|
char *buf0 = bufs[0];
|
|
|
|
char *buf1 = bufs[1];
|
|
|
|
char *buf2 = bufs[2];
|
|
|
|
char *buf3 = bufs[3];
|
2002-09-30 21:42:58 +00:00
|
|
|
char *buf4 = bufs[4];
|
2002-09-21 02:44:49 +00:00
|
|
|
|
2002-08-28 10:08:38 +00:00
|
|
|
// changed by Amir Szekely 28 August 2002
|
|
|
|
// shaves off 0.5KB
|
2002-09-21 02:44:49 +00:00
|
|
|
int parm0 = (parms = entry_->offsets)[0]; // the ordering of these makes a size diff (4 bytes) -Justin
|
|
|
|
char *var0 = g_usrvars[parm0];
|
2002-09-19 21:53:24 +00:00
|
|
|
int parm1 = parms[1];
|
2002-09-21 02:44:49 +00:00
|
|
|
char *var1 = g_usrvars[parm1];
|
2002-09-19 21:53:24 +00:00
|
|
|
int parm2 = parms[2];
|
2002-09-21 02:44:49 +00:00
|
|
|
char *var2 = g_usrvars[parm2];
|
2002-09-19 21:53:24 +00:00
|
|
|
int parm3 = parms[3];
|
2002-09-21 02:44:49 +00:00
|
|
|
char *var3 = g_usrvars[parm3];
|
2002-09-19 21:53:24 +00:00
|
|
|
int parm4 = parms[4];
|
|
|
|
int parm5 = parms[5];
|
|
|
|
//char *var4 = g_usrvars[parm4]; // not used yet
|
|
|
|
//char *var5 = g_usrvars[parm5];
|
2002-09-19 22:25:15 +00:00
|
|
|
int which = entry_->which;
|
2002-08-02 10:01:35 +00:00
|
|
|
switch (which)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
case EW_NOP:
|
|
|
|
log_printf2("Jump: %d",parm0);
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm0;
|
2002-08-02 10:01:35 +00:00
|
|
|
case EW_ABORT:
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Aborting: \"%s\"",buf0);
|
|
|
|
update_status_text("",buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return EXEC_ERROR;
|
|
|
|
case EW_QUIT:
|
|
|
|
g_quit_flag++;
|
|
|
|
if (g_hwnd) PostQuitMessage(0); // make sure we bail out fast.
|
|
|
|
return EXEC_ERROR;
|
|
|
|
case EW_CALL:
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
int v=resolveaddr(parm0)-1; // address is -1, since we encode it as +1
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Call: %d",v);
|
2002-09-19 22:25:15 +00:00
|
|
|
return ExecuteCodeSegment(v,NULL);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
case EW_UPDATETEXT:
|
2002-10-01 17:16:49 +00:00
|
|
|
if (parm1) {
|
|
|
|
static int old_st_updateflag=3;
|
|
|
|
if (parm1&8) ui_st_updateflag=old_st_updateflag;
|
|
|
|
else {
|
|
|
|
old_st_updateflag=ui_st_updateflag;
|
|
|
|
ui_st_updateflag=parm1;
|
|
|
|
}
|
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
else
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf3=process_string_fromparm_tobuf(0x30);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("detailprint: %s",buf3);
|
|
|
|
update_status_text(buf3,"");
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_SLEEP:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
int x=process_string_fromparm_toint(0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (x < 1) x=1;
|
|
|
|
log_printf2("Sleep(%d)",x);
|
|
|
|
Sleep(x);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_SETSFCONTEXT:
|
2002-08-28 10:08:38 +00:00
|
|
|
g_all_user_var_flag=parm0;
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
case EW_HIDEWINDOW:
|
|
|
|
log_printf("HideWindow");
|
|
|
|
ShowWindow(g_hwnd,SW_HIDE);
|
|
|
|
return 0;
|
|
|
|
case EW_BRINGTOFRONT:
|
|
|
|
log_printf("BringToFront");
|
|
|
|
ShowWindow(g_hwnd,SW_SHOW);
|
|
|
|
SetForegroundWindow(g_hwnd);
|
|
|
|
return 0;
|
|
|
|
case EW_SETWINDOWCLOSE:
|
2002-08-28 10:08:38 +00:00
|
|
|
g_autoclose=parm0;
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
case EW_CHDETAILSVIEW:
|
2002-08-28 10:08:38 +00:00
|
|
|
if (insthwndbutton) ShowWindow(insthwndbutton,parm1);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (insthwnd) ShowWindow(insthwnd,parm0);
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_SETFILEATTRIBUTES: {
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("SetFileAttributes: \"%s\":%08X",buf0,parm1);
|
|
|
|
if (!SetFileAttributes(buf0,parm1))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
log_printf("SetFileAttributes failed.");
|
|
|
|
}
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_CREATEDIR: {
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x10);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("CreateDirectory: \"%s\" (%d)",buf1,parm1);
|
|
|
|
if (parm1)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_OUTPUTDIR,buf1);
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(state_output_directory,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-10-01 14:13:23 +00:00
|
|
|
else update_status_text_from_lang(LANG_CREATEDIR,buf1);
|
2002-09-25 13:10:21 +00:00
|
|
|
{
|
|
|
|
char *tp;
|
|
|
|
char *p;
|
|
|
|
p=buf1;
|
|
|
|
while (*p == ' ') p=CharNext(p);
|
|
|
|
if (*p) {
|
|
|
|
tp=CharNext(p);
|
|
|
|
if (*(WORD*)tp == CHAR2_TO_WORD(':','\\')) p=tp+2;
|
|
|
|
else if (*(WORD*)p == CHAR2_TO_WORD('\\','\\'))
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; x < 2; x ++)
|
|
|
|
{
|
|
|
|
while (*p != '\\' && *p) p=CharNext(p); // skip host then share
|
|
|
|
if (*p) p=CharNext(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else return 0;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
while (*p != '\\' && *p) p=CharNext(p);
|
|
|
|
if (!*p) CreateDirectory(buf1,NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p=0;
|
|
|
|
CreateDirectory(buf1,NULL);
|
|
|
|
*p++ = '\\';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_IFFILEEXISTS: {
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (file_exists(buf0))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("IfFileExists: file \"%s\" exists, jumping %d",buf0,parm1);
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm1;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("IfFileExists: file \"%s\" does not exist, jumping %d",buf0,parm2);
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
case EW_IFERRORS:
|
|
|
|
{
|
|
|
|
int f=exec_errorflag;
|
2002-08-28 10:08:38 +00:00
|
|
|
exec_errorflag=parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (f)
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm0;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm1;
|
2002-08-02 10:01:35 +00:00
|
|
|
#ifdef NSIS_SUPPORT_RENAME
|
|
|
|
case EW_RENAME:
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x11);
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(buf3,buf0);
|
|
|
|
if (mystrlen(buf0)+mystrlen(buf1) < NSIS_MAX_STRLEN-3)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
lstrcat(buf3,"->");
|
|
|
|
lstrcat(buf3,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Rename: %s",buf3);
|
|
|
|
if (MoveFile(buf0,buf1))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_RENAME,buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
2002-09-19 21:53:24 +00:00
|
|
|
if (parm2 && file_exists(buf0))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_REBOOT
|
|
|
|
exec_rebootflag++;
|
|
|
|
#endif
|
2002-09-19 21:53:24 +00:00
|
|
|
MoveFileOnReboot(buf0,buf1);
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_RENAMEONREBOOT,buf3);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Rename on reboot: %s",buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
exec_errorflag++;
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Rename failed: %s",buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_RENAME
|
|
|
|
#ifdef NSIS_SUPPORT_FNUTIL
|
|
|
|
case EW_GETFULLPATHNAME:
|
|
|
|
{
|
|
|
|
char *fp;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *p=var0;
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!GetFullPathName(buf0,NSIS_MAX_STRLEN,p,&fp))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
*p=0;
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
else if (fp>buf0 && *fp)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
WIN32_FIND_DATA *fd=file_exists(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (fd)
|
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
mystrcpy(fp,fd->cFileName);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
*p=0;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
if (!parm2) GetShortPathName(p,p,NSIS_MAX_STRLEN);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_SEARCHPATH:
|
|
|
|
{
|
|
|
|
char *fp;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!SearchPath(NULL,buf0,NULL,NSIS_MAX_STRLEN,p,&fp))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
2002-09-22 14:22:35 +00:00
|
|
|
p[0]=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_GETTEMPFILENAME:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *textout=var0;
|
|
|
|
if (!GetTempPath(NSIS_MAX_STRLEN,buf0) || !GetTempFileName(buf0,"nst",0,textout))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
2002-09-22 14:22:35 +00:00
|
|
|
*textout=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
#ifdef NSIS_SUPPORT_FILE
|
|
|
|
case EW_EXTRACTFILE:
|
|
|
|
{
|
|
|
|
HANDLE hOut;
|
|
|
|
int ret;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf3=process_string_fromparm_tobuf(0x31);
|
2002-09-30 21:42:58 +00:00
|
|
|
#define overwriteflag parm0
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("File: overwriteflag=%d, name=\"%s\"",overwriteflag,buf3);
|
|
|
|
if (validpathspec(buf3))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(buf0,buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-25 02:13:38 +00:00
|
|
|
else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
_tryagain:
|
|
|
|
if (!overwriteflag)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
int attr=GetFileAttributes(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (attr & FILE_ATTRIBUTE_READONLY)
|
2002-09-19 21:53:24 +00:00
|
|
|
SetFileAttributes(buf0,attr^FILE_ATTRIBUTE_READONLY);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
if (overwriteflag == 3) // check date and time
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
WIN32_FIND_DATA *ffd=file_exists(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
overwriteflag=1; // if it doesn't exist, fall back to no overwrites (since it shouldn't matter anyway)
|
|
|
|
if (ffd)
|
|
|
|
{
|
|
|
|
overwriteflag=(CompareFileTime(&ffd->ftLastWriteTime,(FILETIME*)(parms+3)) >= 0); // if first one is newer, then don't overwrite
|
|
|
|
}
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
hOut=myOpenFile(buf0,GENERIC_WRITE,(overwriteflag==1)?CREATE_NEW:CREATE_ALWAYS);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (hOut == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (overwriteflag)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_SKIPPED,buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (overwriteflag==2) exec_errorflag++;
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf0,overwriteflag);
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("File: error creating \"%s\"",buf0);
|
|
|
|
mystrcpy(buf2,g_usrvars[0]);//save $0
|
|
|
|
mystrcpy(g_usrvars[0],buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-10-01 14:13:23 +00:00
|
|
|
process_string_fromtab(buf1,LANG_FILEERR);
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(g_usrvars[0],buf2); // restore $0
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
switch (my_MessageBox(buf1,MB_ABORTRETRYIGNORE|MB_ICONSTOP))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
case IDRETRY:
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf("File: error, user retry");
|
2002-08-02 10:01:35 +00:00
|
|
|
goto _tryagain;
|
|
|
|
case IDIGNORE:
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf("File: error, user cancel");
|
2002-08-02 10:01:35 +00:00
|
|
|
exec_errorflag++;
|
|
|
|
return 0;
|
|
|
|
default:
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf("File: error, user abort");
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_CANTWRITE,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
return EXEC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_EXTRACT,buf3);
|
2002-08-28 10:08:38 +00:00
|
|
|
ret=GetCompressedDataFromDataBlock(parm2,hOut);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("File: wrote %d to \"%s\"",ret,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm3 != 0xffffffff || parm4 != 0xffffffff)
|
2002-08-02 10:01:35 +00:00
|
|
|
SetFileTime(hOut,(FILETIME*)(parms+3),NULL,(FILETIME*)(parms+3));
|
|
|
|
|
|
|
|
CloseHandle(hOut);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
if (ret == -2)
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
wsprintf(buf0,"%s%s",LANG_STR(LANG_ERRORWRITING),buf3);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
mystrcpy(buf0,LANG_STR(LANG_ERRORDECOMPRESSING));
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("%s",buf0);
|
|
|
|
my_MessageBox(buf0,MB_OK|MB_ICONSTOP);
|
2002-08-02 10:01:35 +00:00
|
|
|
return EXEC_ERROR;
|
|
|
|
}
|
2002-09-23 14:07:39 +00:00
|
|
|
|
|
|
|
#undef overwriteflag
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_FILE
|
|
|
|
#ifdef NSIS_SUPPORT_DELETE
|
|
|
|
case EW_DELETEFILE:
|
|
|
|
{
|
|
|
|
HANDLE h;
|
|
|
|
WIN32_FIND_DATA fd;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf1=process_string_fromparm_tobuf(0x10);
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(buf0,buf1);
|
|
|
|
log_printf2("Delete: \"%s\"",buf0);
|
|
|
|
trimslashtoend(buf0);
|
|
|
|
h=FindFirstFile(buf1,&fd);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
wsprintf(buf1,"%s\\%s",buf0,fd.cFileName);
|
|
|
|
if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
|
|
|
SetFileAttributes(buf1,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY);
|
|
|
|
if (DeleteFile(buf1))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Delete: DeleteFile(\"%s\")",buf1);
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_DELETEFILE,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm1)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
#ifdef NSIS_SUPPORT_REBOOT
|
|
|
|
exec_rebootflag++;
|
|
|
|
#endif
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf1);
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_DELETEONREBOOT,buf1);
|
2002-09-19 21:53:24 +00:00
|
|
|
MoveFileOnReboot(buf1,NULL);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (FindNextFile(h,&fd));
|
|
|
|
FindClose(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_DELETE
|
|
|
|
#ifdef NSIS_SUPPORT_MESSAGEBOX
|
2002-09-19 21:53:24 +00:00
|
|
|
case EW_MESSAGEBOX: // MessageBox
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
int v;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf3=process_string_fromparm_tobuf(0x31);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("MessageBox: %d,\"%s\"",parm0,buf3);
|
|
|
|
v=my_MessageBox(buf3,parm0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (v)
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
if (v==(parm2&0xffff))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm3;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
if (v==(parm2>>16))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm4;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else exec_errorflag++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_MESSAGEBOX
|
|
|
|
#ifdef NSIS_SUPPORT_RMDIR
|
|
|
|
case EW_RMDIR:
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("RMDir: \"%s\"",buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
if (lastchar(buf0)=='\\') trimslashtoend(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
doRMDir(buf0,parm1);
|
|
|
|
if (file_exists(buf0)) exec_errorflag++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_RMDIR
|
|
|
|
#ifdef NSIS_SUPPORT_STROPTS
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_STRLEN: {
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-09-19 21:53:24 +00:00
|
|
|
myitoa(var0,mystrlen(buf0));
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
case EW_ASSIGNVAR:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
int newlen=process_string_fromparm_toint(2);
|
|
|
|
int start=process_string_fromparm_toint(3);
|
2002-08-02 10:01:35 +00:00
|
|
|
int l;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-08-02 10:01:35 +00:00
|
|
|
*p=0;
|
2002-09-29 20:25:15 +00:00
|
|
|
if (!parm2 || newlen)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
l=mystrlen(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
if (start<0) start=l+start;
|
|
|
|
if (start>=0)
|
|
|
|
{
|
|
|
|
if (start>l) start=l;
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(p,buf0+start);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (newlen)
|
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
if (newlen<0) newlen=mystrlen(p)+newlen;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (newlen<0) newlen=0;
|
|
|
|
if (newlen < NSIS_MAX_STRLEN) p[newlen]=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_STRCMP: {
|
|
|
|
char *buf2=process_string_fromparm_tobuf(0x20);
|
|
|
|
char *buf3=process_string_fromparm_tobuf(0x31);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!lstrcmpi(buf2,buf3)) return parm2;
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm3;
|
2002-08-02 10:01:35 +00:00
|
|
|
#endif//NSIS_SUPPORT_STROPTS
|
|
|
|
#ifdef NSIS_SUPPORT_ENVIRONMENT
|
|
|
|
case EW_READENVSTR:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm2)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!GetEnvironmentVariable(buf0,p,NSIS_MAX_STRLEN))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
2002-09-22 14:22:35 +00:00
|
|
|
*p=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
ExpandEnvironmentStrings(buf0,p,NSIS_MAX_STRLEN);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
p[NSIS_MAX_STRLEN-1]=0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_ENVIRONMENT
|
|
|
|
#ifdef NSIS_SUPPORT_INTOPTS
|
|
|
|
case EW_INTCMP:
|
|
|
|
{
|
|
|
|
int v,v2;
|
2002-09-19 21:53:24 +00:00
|
|
|
v=process_string_fromparm_toint(0);
|
|
|
|
v2=process_string_fromparm_toint(1);
|
2002-08-28 10:08:38 +00:00
|
|
|
if (v<v2) return parm3;
|
|
|
|
if (v>v2) return parm4;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
case EW_INTCMPU:
|
|
|
|
{
|
|
|
|
unsigned int v,v2;
|
2002-09-19 21:53:24 +00:00
|
|
|
v=(unsigned int)process_string_fromparm_toint(0);
|
|
|
|
v2=(unsigned int)process_string_fromparm_toint(1);
|
2002-08-28 10:08:38 +00:00
|
|
|
if (v<v2) return parm3;
|
|
|
|
if (v>v2) return parm4;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
case EW_INTOP:
|
|
|
|
{
|
|
|
|
int v,v2;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
|
|
|
v=process_string_fromparm_toint(1);
|
|
|
|
v2=process_string_fromparm_toint(2);
|
2002-08-28 10:08:38 +00:00
|
|
|
switch (parm3)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
case 0: v+=v2; break;
|
|
|
|
case 1: v-=v2; break;
|
|
|
|
case 2: v*=v2; break;
|
|
|
|
case 3: if (v2) v/=v2; else { v=0; exec_errorflag++; } break;
|
|
|
|
case 4: v|=v2; break;
|
|
|
|
case 5: v&=v2; break;
|
|
|
|
case 6: v^=v2; break;
|
|
|
|
case 7: v=~v; break;
|
|
|
|
case 8: v=!v; break;
|
|
|
|
case 9: v=v||v2; break;
|
|
|
|
case 10: v=v&&v2; break;
|
|
|
|
case 11: if (v2) v%=v2; else { v=0; exec_errorflag++; } break;
|
|
|
|
}
|
|
|
|
myitoa(p,v);
|
|
|
|
}
|
|
|
|
return 0;
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_INTFMT: {
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-09-19 21:53:24 +00:00
|
|
|
wsprintf(var0,
|
|
|
|
buf0,
|
|
|
|
process_string_fromparm_toint(2));
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_INTOPTS
|
|
|
|
#ifdef NSIS_SUPPORT_STACK
|
|
|
|
case EW_PUSHPOP:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
stack_t *s=g_st;
|
2002-08-28 10:08:38 +00:00
|
|
|
int cnt=parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (cnt) //Exch contributed by Fritz Elfert
|
|
|
|
{
|
|
|
|
while (cnt--&&s) s=s->next;
|
|
|
|
if (!s)
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
log_printf2("Exch: stack < %d elements",parm2);
|
2002-08-02 10:01:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(buf0,s->text);
|
2002-08-19 21:24:44 +00:00
|
|
|
mystrcpy(s->text,g_st->text);
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(g_st->text,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
else if (parm1)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!s)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
log_printf("Pop: stack empty");
|
|
|
|
exec_errorflag++;
|
|
|
|
return 0;
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(var0,s->text);
|
|
|
|
g_st=s->next;
|
2002-08-02 10:01:35 +00:00
|
|
|
GlobalFree((HGLOBAL)s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-07 20:49:18 +00:00
|
|
|
s=(stack_t*)my_GlobalAlloc(sizeof(stack_t));
|
2002-08-28 10:08:38 +00:00
|
|
|
process_string_fromtab(s->text,parm0);
|
2002-08-02 10:01:35 +00:00
|
|
|
s->next=g_st;
|
|
|
|
g_st=s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_STACK
|
|
|
|
#ifdef NSIS_SUPPORT_HWNDS
|
|
|
|
case EW_FINDWINDOW:
|
|
|
|
case EW_SENDMESSAGE:
|
|
|
|
{
|
|
|
|
int v;
|
2002-09-19 21:53:24 +00:00
|
|
|
int b3=process_string_fromparm_toint(3);
|
|
|
|
int b4=process_string_fromparm_toint(4);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
if (which == EW_SENDMESSAGE)
|
2002-09-13 20:59:04 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
HWND hwnd=(HWND)process_string_fromparm_toint(1);
|
|
|
|
int msg=process_string_fromparm_toint(2);
|
|
|
|
if (parm5&1)
|
2002-09-13 21:23:01 +00:00
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
b3=(int)process_string_fromparm_tobuf(0x03);
|
2002-09-13 21:23:01 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
if (parm5&2)
|
2002-09-13 21:23:01 +00:00
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
b4=(int)process_string_fromparm_tobuf(0x14);
|
2002-09-13 21:23:01 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-13 22:07:07 +00:00
|
|
|
if (parm5>>2) exec_errorflag += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(LPDWORD)&v);
|
2002-09-13 21:23:01 +00:00
|
|
|
else v=SendMessage(hwnd,msg,b3,b4);
|
2002-09-13 20:59:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x12);
|
2002-09-19 21:53:24 +00:00
|
|
|
v=(int)FindWindowEx((HWND)b3,(HWND)b4,buf0[0]?buf0:NULL,buf1[0]?buf1:NULL);
|
2002-08-21 16:36:09 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
|
2002-10-02 11:48:05 +00:00
|
|
|
if (parm0>=0)
|
2002-09-19 21:53:24 +00:00
|
|
|
myitoa(var0,v);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_ISWINDOW:
|
2002-09-19 21:53:24 +00:00
|
|
|
if (IsWindow((HWND)process_string_fromparm_toint(0))) return parm1;
|
2002-08-28 10:08:38 +00:00
|
|
|
return parm2;
|
2002-09-18 19:08:53 +00:00
|
|
|
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
2002-08-21 16:36:09 +00:00
|
|
|
case EW_GETDLGITEM:
|
|
|
|
myitoa(
|
2002-09-19 21:53:24 +00:00
|
|
|
var0,
|
2002-08-21 16:36:09 +00:00
|
|
|
(int)GetDlgItem(
|
2002-09-19 21:53:24 +00:00
|
|
|
(HWND)process_string_fromparm_toint(1),
|
|
|
|
process_string_fromparm_toint(2)
|
2002-08-21 16:36:09 +00:00
|
|
|
)
|
|
|
|
);
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
2002-08-25 10:53:00 +00:00
|
|
|
case EW_SETWINDOWLONG:
|
2002-09-19 21:53:24 +00:00
|
|
|
SetWindowLong((HWND)process_string_fromparm_toint(0),parm1,process_string_fromparm_toint(2));
|
2002-08-25 10:53:00 +00:00
|
|
|
return 0;
|
2002-09-18 19:08:53 +00:00
|
|
|
case EW_SETBRANDINGIMAGE:
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
HWND hwImage = GetDlgItem(g_hwnd, parm1);
|
|
|
|
GetWindowRect(hwImage, &r);
|
|
|
|
if (g_hBrandingBitmap) DeleteObject(g_hBrandingBitmap);
|
|
|
|
g_hBrandingBitmap=LoadImage(
|
|
|
|
0,
|
2002-09-24 18:49:21 +00:00
|
|
|
process_string_fromparm_tobuf(0x00),
|
2002-09-18 19:08:53 +00:00
|
|
|
IMAGE_BITMAP,
|
|
|
|
parm2?r.right-r.left:0,
|
|
|
|
parm2?r.bottom-r.top:0,
|
|
|
|
LR_LOADFROMFILE
|
|
|
|
);
|
|
|
|
SendMessage(
|
|
|
|
hwImage,
|
|
|
|
STM_SETIMAGE,
|
|
|
|
IMAGE_BITMAP,
|
|
|
|
(LPARAM)g_hBrandingBitmap
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_CREATEFONT:
|
|
|
|
{
|
2002-09-21 06:13:15 +00:00
|
|
|
static LOGFONT f;
|
2002-09-19 21:53:24 +00:00
|
|
|
f.lfHeight=-MulDiv(process_string_fromparm_toint(2),GetDeviceCaps(GetDC(g_hwnd),LOGPIXELSY),72);
|
|
|
|
f.lfWeight=process_string_fromparm_toint(3);
|
2002-09-18 19:08:53 +00:00
|
|
|
f.lfItalic=parm4&1;
|
|
|
|
f.lfUnderline=parm4&2;
|
|
|
|
f.lfStrikeOut=parm4&4;
|
2002-11-01 20:34:55 +00:00
|
|
|
f.lfCharSet=DEFAULT_CHARSET;
|
2002-09-18 19:08:53 +00:00
|
|
|
process_string_fromtab(f.lfFaceName,parm1);
|
2002-09-19 21:53:24 +00:00
|
|
|
myitoa(var0,(int)CreateFontIndirect(&f));
|
2002-09-18 19:08:53 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
|
|
|
#endif//NSIS_SUPPORT_HWNDS
|
2002-08-02 10:01:35 +00:00
|
|
|
#ifdef NSIS_SUPPORT_SHELLEXECUTE
|
|
|
|
case EW_SHELLEXEC: // this uses improvements of Andras Varga
|
|
|
|
{
|
|
|
|
int x;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x11);
|
|
|
|
char *buf2=process_string_fromparm_tobuf(0x22);
|
2002-09-19 21:53:24 +00:00
|
|
|
wsprintf(buf3,"%s %s",buf0,buf1);
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_EXECSHELL, buf3);
|
2002-09-19 21:53:24 +00:00
|
|
|
x=(int)ShellExecute(g_hwnd,buf0[0]?buf0:NULL,buf1,buf2[0]?buf2:NULL,state_output_directory,parm3);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (x < 33)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf5("ExecShell: warning: error (\"%s\": file:\"%s\" params:\"%s\")=%d",buf0,buf1,buf2,x);
|
2002-08-02 10:01:35 +00:00
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf4("ExecShell: success (\"%s\": file:\"%s\" params:\"%s\")",buf0,buf1,buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_SHELLEXECUTE
|
|
|
|
#ifdef NSIS_SUPPORT_EXECUTE
|
|
|
|
case EW_EXECUTE:
|
|
|
|
{
|
|
|
|
HANDLE hProc;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Exec: command=\"%s\"",buf0);
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_EXECUTE,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
hProc=myCreateProcess(buf0,*state_output_directory?state_output_directory:NULL);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
if (hProc)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Exec: success (\"%s\")",buf0);
|
|
|
|
if (parm1)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
DWORD lExitCode;
|
|
|
|
while (WaitForSingleObject(hProc,100) == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
static MSG msg;
|
|
|
|
while (PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_REMOVE))
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
GetExitCodeProcess(hProc, &lExitCode);
|
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
if (parm2>=0) myitoa(var2,lExitCode);
|
2002-08-02 10:01:35 +00:00
|
|
|
else if (lExitCode) exec_errorflag++;
|
|
|
|
}
|
|
|
|
CloseHandle( hProc );
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
else
|
|
|
|
{
|
2002-08-02 10:01:35 +00:00
|
|
|
exec_errorflag++;
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Exec: failed createprocess (\"%s\")",buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_EXECUTE
|
|
|
|
#ifdef NSIS_SUPPORT_GETFILETIME
|
2002-09-19 21:53:24 +00:00
|
|
|
case EW_GETFILETIME:
|
2002-08-02 10:01:35 +00:00
|
|
|
// this new implementation based on one by Dave Bau
|
|
|
|
// used FindFirstFile instead of GetFileTime to better handle files that are locked.
|
|
|
|
// also allows GetFileTime to be passed a wildcard.
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
|
|
|
WIN32_FIND_DATA *ffd;
|
|
|
|
char *highout=var1;
|
|
|
|
char *lowout=var2;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
ffd=file_exists(buf0);
|
|
|
|
if (ffd)
|
|
|
|
{
|
|
|
|
myitoa(lowout,ffd->ftLastWriteTime.dwLowDateTime);
|
|
|
|
myitoa(highout,ffd->ftLastWriteTime.dwHighDateTime);
|
|
|
|
}
|
|
|
|
else
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
*lowout=*highout=0;
|
2002-09-19 21:53:24 +00:00
|
|
|
exec_errorflag++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_GETFILETIME
|
|
|
|
#ifdef NSIS_SUPPORT_GETDLLVERSION
|
|
|
|
case EW_GETDLLVERSION:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *highout=var1;
|
|
|
|
char *lowout=var2;
|
2002-08-02 10:01:35 +00:00
|
|
|
DWORD s1;
|
|
|
|
DWORD t[4]; // our two members are the 3rd and 4th..
|
|
|
|
VS_FIXEDFILEINFO *pvsf1=(VS_FIXEDFILEINFO*)t;
|
|
|
|
DWORD d;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
s1=GetFileVersionInfoSize(buf0,&d);
|
2002-08-02 10:01:35 +00:00
|
|
|
*lowout=*highout=0;
|
|
|
|
exec_errorflag++;
|
|
|
|
if (s1)
|
|
|
|
{
|
|
|
|
void *b1;
|
2002-09-07 20:49:18 +00:00
|
|
|
b1=my_GlobalAlloc(s1);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (b1)
|
|
|
|
{
|
|
|
|
UINT uLen;
|
2002-09-19 21:53:24 +00:00
|
|
|
if (GetFileVersionInfo(buf0,0,s1,b1) && VerQueryValue(b1,"\\",(void*)&pvsf1,&uLen))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
myitoa(highout,pvsf1->dwFileVersionMS);
|
|
|
|
myitoa(lowout,pvsf1->dwFileVersionLS);
|
|
|
|
|
|
|
|
exec_errorflag--;
|
|
|
|
}
|
|
|
|
GlobalFree(b1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_GETDLLVERSION
|
|
|
|
#ifdef NSIS_SUPPORT_ACTIVEXREG
|
|
|
|
case EW_REGISTERDLL:
|
|
|
|
{
|
|
|
|
HRESULT hres=OleInitialize(NULL);
|
|
|
|
exec_errorflag++;
|
|
|
|
if (hres == S_FALSE || hres == S_OK)
|
|
|
|
{
|
|
|
|
HANDLE h;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x11);
|
2002-09-19 21:53:24 +00:00
|
|
|
|
|
|
|
h=LoadLibrary(buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (h)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
FARPROC funke = GetProcAddress(h,buf1);
|
|
|
|
if (funke)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag--;
|
2002-09-29 20:25:15 +00:00
|
|
|
if (parm2)
|
|
|
|
{
|
|
|
|
char *buf2=process_string_fromparm_tobuf(0x22);
|
|
|
|
update_status_text(buf2,buf0);
|
2002-10-16 16:51:58 +00:00
|
|
|
if (funke()) exec_errorflag++;
|
2002-09-29 20:25:15 +00:00
|
|
|
}
|
|
|
|
else
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
void (*func)(HWND,int,char*,void*);
|
|
|
|
func=(void*)funke;
|
|
|
|
func(g_hwnd,NSIS_MAX_STRLEN,(char*)g_usrvars,
|
|
|
|
#ifdef NSIS_SUPPORT_STACK
|
|
|
|
(void*)&g_st);
|
|
|
|
#else
|
|
|
|
NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_CANNOTFINDSYMBOL,buf1);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("Error registering DLL: %s not found in %s",buf1,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-11-01 20:34:55 +00:00
|
|
|
if (!parm3) while (FreeLibrary(h));
|
2002-09-23 14:07:39 +00:00
|
|
|
// saves 2 bytes - FreeLibrary((HANDLE)((unsigned long)h&(unsigned long)parm3));
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_COULDNOTLOAD,buf0);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("Error registering DLL: Could not load %s",buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
OleUninitialize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_NOOLE,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
log_printf("Error registering DLL: Could not initialize OLE");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
#ifdef NSIS_SUPPORT_CREATESHORTCUT
|
2002-09-24 18:49:21 +00:00
|
|
|
case EW_CREATESHORTCUT: {
|
|
|
|
char *buf2=process_string_fromparm_tobuf(0x20);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x11);
|
|
|
|
char *buf0=process_string_fromparm_tobuf(0x02);
|
|
|
|
char *buf3=process_string_fromparm_tobuf(0x33);
|
2002-09-25 12:54:10 +00:00
|
|
|
char *buf4=process_string_fromparm_tobuf(0x45);
|
|
|
|
|
|
|
|
HRESULT hres;
|
|
|
|
int rv=1;
|
|
|
|
IShellLink* psl;
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
log_printf8("CreateShortCut: out: \"%s\", in: \"%s %s\", icon: %s,%d, sw=%d, hk=%d",
|
2002-09-25 12:54:10 +00:00
|
|
|
buf2,buf1,buf0,buf3,parm4&0xff,(parm4&0xff00)>>8,parm4>>16);
|
|
|
|
|
|
|
|
hres=OleInitialize(NULL);
|
|
|
|
if (hres == S_FALSE || hres == S_OK) {
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLink, (void **) &psl);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
IPersistFile* ppf;
|
|
|
|
|
|
|
|
hres = psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile, (void **) &ppf);
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
|
|
|
|
hres = psl->lpVtbl->SetPath(psl,buf1);
|
|
|
|
psl->lpVtbl->SetWorkingDirectory(psl,state_output_directory);
|
|
|
|
if ((parm4&0xff00)>>8) psl->lpVtbl->SetShowCmd(psl,(parm4&0xff00)>>8);
|
|
|
|
psl->lpVtbl->SetHotkey(psl,(unsigned short)(parm4>>16));
|
|
|
|
if (buf3[0]) psl->lpVtbl->SetIconLocation(psl,buf3,parm4&0xff);
|
|
|
|
psl->lpVtbl->SetArguments(psl,buf0);
|
|
|
|
psl->lpVtbl->SetDescription(psl,buf4);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
WCHAR wsz[1024];
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, buf2, -1, wsz, 1024);
|
|
|
|
hres=ppf->lpVtbl->Save(ppf,(const WCHAR*)wsz,TRUE);
|
|
|
|
if (SUCCEEDED(hres)) rv=0;
|
|
|
|
}
|
|
|
|
ppf->lpVtbl->Release(ppf);
|
|
|
|
}
|
|
|
|
psl->lpVtbl->Release(psl);
|
|
|
|
}
|
|
|
|
OleUninitialize();
|
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-25 12:54:10 +00:00
|
|
|
if (rv)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_ERRORCREATINGSHORTCUT,buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_CREATESHORTCUT,buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-24 18:49:21 +00:00
|
|
|
}
|
2002-08-02 10:01:35 +00:00
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_CREATESHORTCUT
|
|
|
|
#ifdef NSIS_SUPPORT_COPYFILES
|
|
|
|
case EW_COPYFILES: // CopyFile (added by NOP)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
SHFILEOPSTRUCT op;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x11);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("CopyFiles \"%s\"->\"%s\"",buf0,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
op.hwnd=g_hwnd;
|
|
|
|
op.wFunc=FO_COPY;
|
2002-09-19 21:53:24 +00:00
|
|
|
buf0[mystrlen(buf0)+1]=0;
|
|
|
|
buf1[mystrlen(buf1)+1]=0;
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-10-01 14:13:23 +00:00
|
|
|
wsprintf(buf2,"%s%s",LANG_STR(LANG_COPYTO),buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
op.pFrom=buf0;
|
|
|
|
op.pTo=buf1;
|
|
|
|
op.lpszProgressTitle=buf2;
|
2002-08-28 10:08:38 +00:00
|
|
|
op.fFlags=parm2;
|
2002-09-19 21:53:24 +00:00
|
|
|
update_status_text("",buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
res=SHFileOperation(&op);
|
2002-08-25 10:53:00 +00:00
|
|
|
if (res)
|
2002-08-02 10:01:35 +00:00
|
|
|
{ // some of these changes were from Edgewise (wiked_edge@yahoo.com)
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_COPYFAILED,"");
|
2002-08-02 10:01:35 +00:00
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_COPYFILES
|
|
|
|
#ifdef NSIS_SUPPORT_REBOOT
|
|
|
|
case EW_REBOOT:
|
|
|
|
exec_errorflag++;
|
|
|
|
{
|
|
|
|
HANDLE h=LoadLibrary("advapi32.dll");
|
|
|
|
if (h)
|
|
|
|
{
|
2002-11-12 18:19:24 +00:00
|
|
|
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
|
|
|
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
|
|
|
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
2002-08-02 10:01:35 +00:00
|
|
|
OPT=(void*)GetProcAddress(h,"OpenProcessToken");
|
|
|
|
LPV=(void*)GetProcAddress(h,"LookupPrivilegeValueA");
|
|
|
|
ATP=(void*)GetProcAddress(h,"AdjustTokenPrivileges");
|
|
|
|
if (OPT && LPV && ATP)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
HANDLE hToken;
|
|
|
|
TOKEN_PRIVILEGES tkp;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (OPT(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
LPV(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
|
2002-08-02 10:01:35 +00:00
|
|
|
tkp.PrivilegeCount = 1;
|
2002-09-19 21:53:24 +00:00
|
|
|
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
|
|
|
ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
if (ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0)) ExitProcess(0);
|
|
|
|
|
|
|
|
FreeLibrary(h);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EW_IFREBOOTFLAG: return parms[!exec_rebootflag];
|
2002-08-28 10:08:38 +00:00
|
|
|
case EW_SETREBOOTFLAG: exec_rebootflag=parm0; return 0;
|
2002-08-02 10:01:35 +00:00
|
|
|
#endif//NSIS_SUPPORT_REBOOT
|
|
|
|
#ifdef NSIS_SUPPORT_INIFILES
|
|
|
|
case EW_WRITEINI:
|
|
|
|
{
|
2002-11-07 20:12:01 +00:00
|
|
|
char *sec=0, *key=0, *str=0;
|
2002-09-19 21:53:24 +00:00
|
|
|
#ifdef NSIS_CONFIG_LOG
|
|
|
|
mystrcpy(buf1,"<RM>");
|
|
|
|
mystrcpy(buf2,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
#endif
|
2002-11-07 20:12:01 +00:00
|
|
|
if (parm0)
|
|
|
|
{
|
|
|
|
sec=process_string_fromparm_tobuf(0x00);
|
|
|
|
}
|
2002-09-29 20:25:15 +00:00
|
|
|
if (parm1)
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
2002-11-08 11:15:25 +00:00
|
|
|
key=process_string_fromparm_tobuf(0x11);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-29 20:25:15 +00:00
|
|
|
if (parm2)
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
2002-11-07 20:12:01 +00:00
|
|
|
str=process_string_fromparm_tobuf(0x22);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-24 18:49:21 +00:00
|
|
|
buf3=process_string_fromparm_tobuf(0x33);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf5("WriteINIStr: wrote [%s] %s=%s in %s",buf0,buf1,buf2,buf3);
|
2002-11-07 20:12:01 +00:00
|
|
|
if (!WritePrivateProfileString(sec,key,str,buf3)) exec_errorflag++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_READINISTR:
|
|
|
|
{
|
|
|
|
static const char *errstr="!N~";
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x12);
|
|
|
|
char *buf2=process_string_fromparm_tobuf(0x23);
|
2002-09-19 21:53:24 +00:00
|
|
|
GetPrivateProfileString(buf0,buf1,errstr,p,NSIS_MAX_STRLEN-1,buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (*((int*)errstr) == *((int*)p))
|
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
p[0]=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_INIFILES
|
|
|
|
#ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS
|
|
|
|
case EW_DELREG:
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
int rootkey=parm0;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf3=process_string_fromparm_tobuf(0x31);
|
2002-08-02 10:01:35 +00:00
|
|
|
exec_errorflag++;
|
2002-09-29 20:25:15 +00:00
|
|
|
if (parm2)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegOpenKeyEx((HKEY)rootkey,buf3,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x02);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf4("DeleteRegValue: %d\\%s\\%s",rootkey,buf3,buf0);
|
|
|
|
if (RegDeleteValue(hKey,buf0) == ERROR_SUCCESS) exec_errorflag--;
|
2002-08-02 10:01:35 +00:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("DeleteRegKey: %d\\%s",rootkey,buf3);
|
|
|
|
if (myRegDeleteKeyEx((HKEY)rootkey,buf3,parm3) == ERROR_SUCCESS) exec_errorflag--;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_WRITEREG: // write registry value
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
2002-08-28 10:08:38 +00:00
|
|
|
int rootkey=parm0;
|
|
|
|
int type=parm4;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf1=process_string_fromparm_tobuf(0x12);
|
|
|
|
char *buf3=process_string_fromparm_tobuf(0x31);
|
2002-09-19 21:53:24 +00:00
|
|
|
exec_errorflag++;
|
|
|
|
if (RegCreateKey((HKEY)rootkey,buf3,&hKey) == ERROR_SUCCESS)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
if (type <= 1)
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf2=process_string_fromparm_tobuf(0x23);
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegSetValueEx(hKey,buf1,0,type==1?REG_SZ:REG_EXPAND_SZ,buf2,mystrlen(buf2)+1) == ERROR_SUCCESS) exec_errorflag--;
|
|
|
|
log_printf5("WriteRegStr: set %d\\%s\\%s to %s",rootkey,buf3,buf1,buf2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else if (type == 2)
|
|
|
|
{
|
|
|
|
DWORD l;
|
2002-09-19 21:53:24 +00:00
|
|
|
l=process_string_fromparm_toint(3);
|
|
|
|
if (RegSetValueEx(hKey,buf1,0,REG_DWORD,(unsigned char*)&l,4) == ERROR_SUCCESS) exec_errorflag--;
|
|
|
|
log_printf5("WriteRegDWORD: set %d\\%s\\%s to %d",rootkey,buf3,buf1,l);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else if (type == 3)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
int len=GetCompressedDataFromDataBlockToMemory(parm3, buf2, NSIS_MAX_STRLEN);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (len >= 0)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegSetValueEx(hKey,buf1,0,REG_BINARY,buf2,len) == ERROR_SUCCESS) exec_errorflag--;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf5("WriteRegBin: set %d\\%s\\%s with %d bytes",rootkey,buf3,buf1,len);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
else { log_printf3("WriteReg: error creating key %d\\%s",rootkey,buf3); }
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_READREGSTR: // read registry string
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
2002-08-28 10:08:38 +00:00
|
|
|
int rootkey=parm1;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x02); // buf0 == subkey
|
|
|
|
char *buf1=process_string_fromparm_tobuf(0x13); // buf1 == key name
|
2002-08-02 10:01:35 +00:00
|
|
|
p[0]=0;
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegOpenKeyEx((HKEY)rootkey,buf0,0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
DWORD l = NSIS_MAX_STRLEN;
|
|
|
|
DWORD t;
|
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegQueryValueEx(hKey,buf1,NULL,&t,p,&l ) != ERROR_SUCCESS ||
|
2002-08-02 10:01:35 +00:00
|
|
|
(t != REG_DWORD && t != REG_SZ && t != REG_EXPAND_SZ))
|
|
|
|
{
|
|
|
|
p[0]=0;
|
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
else
|
2002-09-19 21:53:24 +00:00
|
|
|
{
|
|
|
|
if (t==REG_DWORD)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
if (!parm4) exec_errorflag++;
|
2002-08-02 10:01:35 +00:00
|
|
|
myitoa(p,*((DWORD*)p));
|
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
else if (parm4) exec_errorflag++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
else exec_errorflag++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_REGENUM:
|
|
|
|
{
|
|
|
|
HKEY key;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *p=var0;
|
|
|
|
int b=process_string_fromparm_toint(3);
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf1=process_string_fromparm_tobuf(0x12);
|
2002-08-02 10:01:35 +00:00
|
|
|
p[0]=0;
|
2002-09-19 21:53:24 +00:00
|
|
|
if (RegOpenKeyEx((HKEY)parm1,buf1,0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
DWORD d=NSIS_MAX_STRLEN-1;
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm4) RegEnumKey(key,b,p,d);
|
2002-08-02 10:01:35 +00:00
|
|
|
else RegEnumValue(key,b,p,&d,NULL,NULL,NULL,NULL);
|
|
|
|
p[NSIS_MAX_STRLEN-1]=0;
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
else exec_errorflag++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_REGISTRYFUNCTIONS
|
|
|
|
#ifdef NSIS_SUPPORT_FILEFUNCTIONS
|
2002-09-19 21:53:24 +00:00
|
|
|
case EW_FCLOSE:
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *t=var0;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (*t) CloseHandle((HANDLE)myatoi(t));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FOPEN:
|
|
|
|
{
|
|
|
|
HANDLE h;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *handleout=var3;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
h=myOpenFile(buf0,parm1,parm2);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (h == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
*handleout=0;
|
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myitoa(handleout,(int)h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FPUTS:
|
|
|
|
{
|
|
|
|
DWORD dw;
|
|
|
|
int l;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *t=var0;
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm2)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
((unsigned char *)buf1)[0]=process_string_fromparm_toint(1)&0xff;
|
2002-08-02 10:01:35 +00:00
|
|
|
l=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
l=mystrlen(process_string_fromparm_tobuf(0x11));
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
if (!*t || !WriteFile((HANDLE)myatoi(t),buf1,l,&dw,NULL))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FGETS:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *textout=var1;
|
2002-08-02 10:01:35 +00:00
|
|
|
DWORD dw;
|
|
|
|
int rpos=0;
|
2002-09-19 21:53:24 +00:00
|
|
|
char *hptr=var0;
|
|
|
|
int maxlen=process_string_fromparm_toint(2);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (maxlen<1) return 0;
|
|
|
|
if (maxlen > NSIS_MAX_STRLEN-1) maxlen=NSIS_MAX_STRLEN-1;
|
|
|
|
if (*hptr)
|
|
|
|
{
|
|
|
|
char lc=0;
|
|
|
|
int rcnt=0;
|
|
|
|
HANDLE h=(HANDLE)myatoi(hptr);
|
|
|
|
while (rpos<maxlen)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
if (!ReadFile(h,&c,1,&dw,NULL) || dw != 1) break;
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm3)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
myitoa(textout,(unsigned int)(unsigned char)c);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!c) break;
|
2002-09-19 21:53:24 +00:00
|
|
|
if (lc == '\r' || lc == '\n')
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
if (lc == c || (c != '\r' && c != '\n')) SetFilePointer(h,-1,NULL,FILE_CURRENT);
|
|
|
|
else textout[rpos++]=c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
textout[rpos++]=c;
|
|
|
|
lc=c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
textout[rpos]=0;
|
|
|
|
if (!rpos) exec_errorflag++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FSEEK:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *t=var0;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (*t)
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
DWORD v=SetFilePointer((HANDLE)myatoi(t),process_string_fromparm_toint(1),NULL,parm2);
|
|
|
|
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm3>=0)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
myitoa(var3,v);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_FILEFUNCTIONS
|
|
|
|
#ifdef NSIS_SUPPORT_FINDFIRST
|
|
|
|
case EW_FINDCLOSE:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *t=var0;
|
2002-08-02 10:01:35 +00:00
|
|
|
if (*t) FindClose((HANDLE)myatoi(t));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FINDNEXT:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *textout=var0;
|
|
|
|
char *t=var1;
|
2002-08-02 10:01:35 +00:00
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
if (*t && FindNextFile((HANDLE)myatoi(t),&fd))
|
|
|
|
{
|
2002-08-19 21:24:44 +00:00
|
|
|
mystrcpy(textout,fd.cFileName);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exec_errorflag++;
|
|
|
|
*textout=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case EW_FINDFIRST:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
char *textout=var1;
|
|
|
|
char *handleout=var2;
|
2002-08-02 10:01:35 +00:00
|
|
|
HANDLE h;
|
|
|
|
WIN32_FIND_DATA fd;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-09-19 21:53:24 +00:00
|
|
|
h=FindFirstFile(buf0,&fd);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (h == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
*handleout=0;
|
|
|
|
*textout=0;
|
|
|
|
exec_errorflag++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myitoa(handleout,(int)h);
|
2002-08-19 21:24:44 +00:00
|
|
|
mystrcpy(textout,fd.cFileName);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_SUPPORT_FINDFIRST
|
|
|
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
|
|
|
case EW_WRITEUNINSTALLER:
|
|
|
|
{
|
|
|
|
int ret=-666;
|
|
|
|
HANDLE hFile;
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x00);
|
2002-08-02 10:01:35 +00:00
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
if (validpathspec(buf0))
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
mystrcpy(buf1,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
else
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-25 02:13:38 +00:00
|
|
|
lstrcat(addtrailingslash(mystrcpy(buf1,state_install_directory)),buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-19 21:53:24 +00:00
|
|
|
hFile=myOpenFile(buf1,GENERIC_WRITE,CREATE_ALWAYS);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
unsigned char *filebuf;
|
2002-09-07 20:49:18 +00:00
|
|
|
filebuf=(unsigned char *)my_GlobalAlloc(g_filehdrsize);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (filebuf)
|
|
|
|
{
|
|
|
|
int fixoffs=0;
|
2002-09-25 03:34:30 +00:00
|
|
|
DWORD lout;
|
2002-09-24 23:26:55 +00:00
|
|
|
SetSelfFilePointer(0,FILE_BEGIN);
|
2002-09-25 03:34:30 +00:00
|
|
|
ReadSelfFile((char*)filebuf,g_filehdrsize);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (g_inst_header->uninstdata_offset != -1)
|
|
|
|
{
|
|
|
|
// Changed by Amir Szekely 11th July 2002
|
2002-09-23 14:07:39 +00:00
|
|
|
unsigned char* seeker;
|
|
|
|
unsigned char* unicon_data = seeker = (unsigned char*)my_GlobalAlloc(g_inst_header->uninsticon_size);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (unicon_data) {
|
|
|
|
GetCompressedDataFromDataBlockToMemory(g_inst_header->uninstdata_offset,
|
|
|
|
unicon_data,g_inst_header->uninsticon_size);
|
2002-09-23 14:07:39 +00:00
|
|
|
//for (i = 0; i < *(DWORD*)unicon_data; i++) {
|
|
|
|
while (*seeker) {
|
2002-08-02 10:01:35 +00:00
|
|
|
DWORD dwSize, dwOffset;
|
|
|
|
dwSize = *(DWORD*)seeker;
|
|
|
|
seeker += sizeof(DWORD);
|
|
|
|
dwOffset = *(DWORD*)seeker;
|
|
|
|
seeker += sizeof(DWORD);
|
2002-08-09 15:26:42 +00:00
|
|
|
mini_memcpy(filebuf+dwOffset, seeker, dwSize);
|
2002-08-02 10:01:35 +00:00
|
|
|
seeker += dwSize;
|
|
|
|
}
|
|
|
|
GlobalFree(unicon_data);
|
|
|
|
}
|
|
|
|
}
|
2002-09-25 03:34:30 +00:00
|
|
|
WriteFile(hFile,(char*)filebuf,g_filehdrsize,&lout,NULL);
|
2002-08-02 10:01:35 +00:00
|
|
|
GlobalFree(filebuf);
|
|
|
|
ret=GetCompressedDataFromDataBlock(-1,hFile);
|
|
|
|
}
|
|
|
|
CloseHandle(hFile);
|
|
|
|
}
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf3("created uninstaller: %d, \"%s\"",ret,buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_ERRORCREATING,buf0);
|
2002-09-19 21:53:24 +00:00
|
|
|
DeleteFile(buf1);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
2002-10-01 14:13:23 +00:00
|
|
|
update_status_text_from_lang(LANG_CREATEDUNINST,buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
|
|
|
#ifdef NSIS_CONFIG_LOG
|
|
|
|
case EW_LOG:
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm0)
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
log_printf2("settings logging to %d",parm1);
|
|
|
|
log_dolog=parm1;
|
|
|
|
log_printf2("logging set to %d",parm1);
|
2002-08-19 23:18:19 +00:00
|
|
|
if (!g_log_file && log_dolog) build_g_logfile();
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-24 18:49:21 +00:00
|
|
|
char *buf0=process_string_fromparm_tobuf(0x01);
|
2002-09-19 21:53:24 +00:00
|
|
|
log_printf2("%s",buf0);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_CONFIG_LOG
|
|
|
|
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
|
|
|
case EW_SECTIONSET:
|
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
int x=process_string_fromparm_toint(0);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (g_inst_section && x >= 0 && x < g_inst_header->num_sections)
|
|
|
|
{
|
|
|
|
int z=0;
|
|
|
|
if (g_SectionHack)
|
|
|
|
{
|
|
|
|
int a;
|
2002-09-29 20:25:15 +00:00
|
|
|
for (a = 0; a < x; a ++) if (g_inst_section[a].name_ptr) z++;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 10:08:38 +00:00
|
|
|
if (parm1==0) //set text
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
|
|
|
if (g_SectionHack)
|
|
|
|
{
|
2002-08-28 10:08:38 +00:00
|
|
|
SendMessage(g_SectionHack,WM_USER+0x17,x,parm2);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
g_inst_section[x].name_ptr=parm2;
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
else if (parm1==1) // get text
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-09-19 21:53:24 +00:00
|
|
|
process_string_fromtab(var2,g_inst_section[x].name_ptr);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-08-28 10:08:38 +00:00
|
|
|
else if (parm1==2) // set flags
|
2002-08-02 10:01:35 +00:00
|
|
|
{
|
2002-10-02 15:01:06 +00:00
|
|
|
g_inst_section[x].flags=process_string_fromparm_toint(2);
|
2002-08-02 10:01:35 +00:00
|
|
|
if (g_SectionHack)
|
|
|
|
{
|
2002-10-05 16:20:13 +00:00
|
|
|
SendMessage(g_SectionHack,WM_USER+0x18,x,(LPARAM)(g_inst_section[x].flags&SF_SELECTED));
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // get flags
|
|
|
|
{
|
2002-10-02 15:01:06 +00:00
|
|
|
myitoa(var2,g_inst_section[x].flags);
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else exec_errorflag++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#endif//NSIS_CONFIG_COMPONENTPAGE
|
2002-09-18 19:08:53 +00:00
|
|
|
|
|
|
|
// Added by Ximon Eighteen 5th August 2002
|
2002-08-05 02:05:00 +00:00
|
|
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
2002-08-05 19:13:52 +00:00
|
|
|
case EW_PLUGINCOMMANDPREP:
|
2002-08-21 16:36:09 +00:00
|
|
|
// $0 temp plug-ins dir
|
2002-08-19 21:24:44 +00:00
|
|
|
if (!*plugins_temp_dir) mystrcpy(plugins_temp_dir,g_usrvars[0]);
|
2002-08-05 02:05:00 +00:00
|
|
|
return 0;
|
|
|
|
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
2002-08-02 10:01:35 +00:00
|
|
|
}
|
2002-10-01 14:13:23 +00:00
|
|
|
my_MessageBox(LANG_STR(LANG_INSTCORRUPTED),MB_OK|MB_ICONSTOP);
|
2002-08-02 10:01:35 +00:00
|
|
|
return EXEC_ERROR;
|
|
|
|
}
|