diff --git a/Source/build.cpp b/Source/build.cpp index 7390c8e3..37412e67 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -515,8 +515,6 @@ int CEXEBuild::datablock_optimize(int start_offset) int CEXEBuild::add_data(const char *data, int length, IGrowBuf *dblock) // returns offset { - // Changed by Amir Szekely 31st July 2002 - // Ability to change compression methods from within the script build_compressor_set=true; int done=0; @@ -1777,8 +1775,9 @@ int CEXEBuild::write_output(void) INFO_MSG("Datablock optimizer saved %d bytes (~%d.%d%%).\n",db_opt_save, pc/10,pc%10); } + + INFO_MSG("\nUsing %s%s compression.\n\n", compressor->GetName(), build_compress_whole?" (compress whole)":""); - INFO_MSG("\n"); int total_usize=exeheader_size; INFO_MSG("EXE header size: %10d / %d bytes\n",exeheader_size_new,exeheader_size); @@ -1917,8 +1916,6 @@ int CEXEBuild::write_output(void) #ifdef NSIS_CONFIG_COMPRESSION_SUPPORT int CEXEBuild::deflateToFile(FILE *fp, char *buf, int len) // len==0 to flush { - // Changed by Amir Szekely 31st July 2002 - // Ability to change compression methods from within the script build_compressor_set=true; char obuf[32768]; @@ -2073,7 +2070,7 @@ int CEXEBuild::uninstall_generate() firstheader *_fh=(firstheader *)udata.get(); _fh->length_of_all_following_data=udata.getlen()+(build_crcchk?sizeof(int):0); } - else + else #endif//NSIS_CONFIG_COMPRESSION_SUPPORT { udata.add(&fh,sizeof(fh)); diff --git a/Source/build.h b/Source/build.h index 60790e18..a04ffc14 100644 --- a/Source/build.h +++ b/Source/build.h @@ -49,7 +49,7 @@ enum { }; class CEXEBuild { - public: + public: CEXEBuild(); ~CEXEBuild(); diff --git a/Source/cbzip2.h b/Source/cbzip2.h index 46fd733c..58909f8a 100644 --- a/Source/cbzip2.h +++ b/Source/cbzip2.h @@ -44,6 +44,10 @@ class CBzip2 : public ICompressor { return stream->avail_out; } + char* GetName() { + return "bzip2"; + } + private: bz_stream *stream; }; diff --git a/Source/compressor.h b/Source/compressor.h index f7c7aa8a..9eb38fff 100644 --- a/Source/compressor.h +++ b/Source/compressor.h @@ -17,6 +17,8 @@ class ICompressor { virtual unsigned int GetAvailIn() = 0; virtual unsigned int GetAvailOut() = 0; + + virtual char* GetName() = 0; }; #endif \ No newline at end of file diff --git a/Source/czlib.h b/Source/czlib.h index 3b092517..5ff87714 100644 --- a/Source/czlib.h +++ b/Source/czlib.h @@ -44,6 +44,10 @@ class CZlib : public ICompressor { return stream->avail_out; } + char* GetName() { + return "zlib"; + } + private: z_stream *stream; }; diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 66a2585d..c68fd2de 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -51,7 +51,7 @@ int g_quit_flag; // set when Quit has been called (meaning bail out ASAP) #error invalid value for NSIS_MAX_INST_TYPES #endif -int g_autoclose; +//int g_autoclose; int progress_bar_pos, progress_bar_len; int g_is_uninstaller; @@ -70,6 +70,9 @@ static int num_sections; // sent to the outer window to tell it to go to the next inner window #define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) +// sent to every child window to tell it it is closing soon +#define WM_NOTIFY_INIGO_MONTOYA (WM_USER+0xb) + // update message used by DirProc and SelProc for space display #define WM_IN_UPDATEMSG (WM_USER+0xf) @@ -129,8 +132,9 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara if (uMsg == WM_CTLCOLORSTATIC) { BOOL brush = (BOOL)GetWindowLong((HWND)lParam, GWL_USERDATA); if (brush == -1) { - SetBkColor((HDC)wParam, GetSysColor(COLOR_BTNFACE)); - SetTextColor((HDC)wParam, GetSysColor(COLOR_BTNFACE)); + COLORREF dlgColor = GetSysColor(COLOR_BTNFACE); + SetBkColor((HDC)wParam, dlgColor); + SetTextColor((HDC)wParam, dlgColor); return (BOOL)GetStockObject(NULL_BRUSH); } SetBkMode((HDC)wParam, TRANSPARENT); @@ -290,7 +294,7 @@ lang_again: int NSISCALL ui_doinstall(void) { num_sections=g_inst_header->num_sections; - g_autoclose=g_inst_cmnheader->misc_flags&1; + g_flags.autoclose=g_inst_cmnheader->misc_flags&1; #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT if (!g_is_uninstaller) #endif @@ -549,6 +553,8 @@ nextPage: process_string_fromtab(g_tmp+mystrlen(g_tmp),this_page->caption); my_SetWindowText(hwndDlg,g_tmp); + SendMessage(m_curwnd, WM_NOTIFY_INIGO_MONTOYA, 0, 0); + #ifdef NSIS_SUPPORT_CODECALLBACKS if (ExecuteCodeSegment(this_page->prefunc,NULL) || this_page->id<0) goto nextPage; @@ -556,7 +562,7 @@ nextPage: if (this_page->id!=NSIS_PAGE_COMPLETED) DestroyWindow(m_curwnd); else { - if (g_autoclose) goto nextPage; + if (g_flags.autoclose) goto nextPage; return 0; } @@ -708,9 +714,6 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM #undef enlink #undef msgfilter } - if (uMsg == WM_CLOSE) { - SendMessage(g_hwnd,WM_CLOSE,0,0); - } return HandleStaticBkColor(); } #endif @@ -743,9 +746,10 @@ static char * NSISCALL inttosizestr(int kb, char *str) static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if (uMsg == WM_DESTROY) + if (uMsg == WM_NOTIFY_INIGO_MONTOYA) { GetUIText(IDC_DIR,state_install_directory,NSIS_MAX_STRLEN); + validate_filename(state_install_directory); #ifdef NSIS_CONFIG_LOG build_g_logfile(); log_dolog = IsDlgButtonChecked(hwndDlg,IDC_CHECK1); @@ -808,7 +812,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar p=scanendslash(post_str); if (p >= post_str && *++p) { - post_str=process_string(ps_tmpbuf,p); + post_str=process_string(p); p=name+mystrlen(name)-mystrlen(post_str); if (p <= name || *CharPrev(name,p)!='\\' || lstrcmpi(p,post_str)) { @@ -1010,7 +1014,8 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar tv.hInsertAfter=TVI_LAST; tv.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE; tv.item.lParam=x; - tv.item.pszText=process_string_fromtab(ps_tmpbuf,sec->name_ptr); + process_string_fromtab(0,sec->name_ptr); + tv.item.pszText=ps_tmpbuf; tv.item.stateMask=TVIS_STATEIMAGEMASK|TVIS_EXPANDED; { @@ -1072,7 +1077,8 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TVITEM tv; tv.hItem=hTreeItems[x]; tv.mask=TVIF_TEXT; - tv.pszText=process_string_fromtab(ps_tmpbuf,ns); + process_string_fromtab(0,ns); + tv.pszText=ps_tmpbuf; TreeView_SetItem(hwndTree1,&tv); } uMsg = WM_USER+0x18; @@ -1184,7 +1190,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } } } - if (uMsg == WM_DESTROY) + if (uMsg == WM_NOTIFY_INIGO_MONTOYA) { if (hImageList) ImageList_Destroy(hImageList); if (hTreeItems) GlobalFree(hTreeItems); diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 2db4d72f..0e5ad5c3 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -24,10 +24,7 @@ typedef struct _stack_t { static stack_t *g_st; #endif -static int exec_errorflag; -#ifdef NSIS_SUPPORT_REBOOT -static int exec_rebootflag; -#endif +union flags g_flags; #ifdef NSIS_CONFIG_PLUGIN_SUPPORT char plugins_temp_dir[NSIS_MAX_STRLEN]=""; @@ -76,8 +73,6 @@ static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyif } #endif//NSIS_SUPPORT_REGISTRYFUNCTIONS -extern char g_all_user_var_flag; - static int NSISCALL ExecuteEntry(entry *entry_); static int NSISCALL resolveaddr(int v) @@ -121,14 +116,18 @@ static int *parms; static int NSISCALL process_string_fromparm_toint(int id_) { - return myatoi(process_string(ps_tmpbuf,GetStringFromStringTab(parms[id_]))); + return myatoi(process_string(GetStringFromStringTab(parms[id_]))); } // 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. +// Use a negative number to get the string validated as a file name static char * NSISCALL process_string_fromparm_tobuf(int id_) { - return process_string_fromtab(bufs[id_ >> 4], parms[id_ & 0xF]); + int id = id_ < 0 ? -id_ : id_; + char *result = process_string_fromtab(bufs[id_ >> 4], parms[id_ & 0xF]); + if (id_ < 0) validate_filename(result); + return result; } // returns EXEC_ERROR on error @@ -201,9 +200,6 @@ static int NSISCALL ExecuteEntry(entry *entry_) Sleep(x); } return 0; - case EW_SETSFCONTEXT: - g_all_user_var_flag=parm0; - return 0; case EW_HIDEWINDOW: log_printf("HideWindow"); ShowWindow(g_hwnd,SW_HIDE); @@ -213,30 +209,31 @@ static int NSISCALL ExecuteEntry(entry *entry_) ShowWindow(g_hwnd,SW_SHOW); SetForegroundWindow(g_hwnd); return 0; - case EW_SETWINDOWCLOSE: - g_autoclose=parm0; + case EW_SETFLAG: + g_flags.flags[parm0]=parm1; return 0; case EW_CHDETAILSVIEW: if (insthwndbutton) ShowWindow(insthwndbutton,parm1); if (insthwnd) ShowWindow(insthwnd,parm0); return 0; case EW_SETFILEATTRIBUTES: { - char *buf0=process_string_fromparm_tobuf(0x00); - log_printf3("SetFileAttributes: \"%s\":%08X",buf0,parm1); - if (!SetFileAttributes(buf0,parm1)) + char *buf1=process_string_fromparm_tobuf(-0x10); + log_printf3("SetFileAttributes: \"%s\":%08X",buf1,parm1); + if (!SetFileAttributes(buf1,parm1)) { - exec_errorflag++; + g_flags.exec_error++; log_printf("SetFileAttributes failed."); } } return 0; case EW_CREATEDIR: { - char *buf1=process_string_fromparm_tobuf(0x10); + char *buf1=process_string_fromparm_tobuf(-0x10); log_printf3("CreateDirectory: \"%s\" (%d)",buf1,parm1); if (parm1) { update_status_text_from_lang(LANG_OUTPUTDIR,buf1); mystrcpy(state_output_directory,buf1); + SetCurrentDirectory(state_output_directory); } else update_status_text_from_lang(LANG_CREATEDIR,buf1); { @@ -273,7 +270,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) } } return 0; - case EW_IFFILEEXISTS: { + case EW_IFFILEEXISTS: + { char *buf0=process_string_fromparm_tobuf(0x00); if (file_exists(buf0)) { @@ -284,47 +282,40 @@ static int NSISCALL ExecuteEntry(entry *entry_) } return parm2; case EW_IFERRORS: - { - int f=exec_errorflag; - exec_errorflag=parm2; - if (f) - { - return parm0; - } - } + if (g_flags.exec_error) return parm0; return parm1; #ifdef NSIS_SUPPORT_RENAME case EW_RENAME: { - char *buf0=process_string_fromparm_tobuf(0x00); - char *buf1=process_string_fromparm_tobuf(0x11); - mystrcpy(buf3,buf0); - if (mystrlen(buf0)+mystrlen(buf1) < NSIS_MAX_STRLEN-3) + char *buf1=process_string_fromparm_tobuf(-0x10); + char *buf2=process_string_fromparm_tobuf(-0x21); + mystrcpy(buf3,buf1); + if (mystrlen(buf1)+mystrlen(buf2) < NSIS_MAX_STRLEN-3) { lstrcat(buf3,"->"); - lstrcat(buf3,buf1); + lstrcat(buf3,buf2); } log_printf2("Rename: %s",buf3); - if (MoveFile(buf0,buf1)) + if (MoveFile(buf1,buf2)) { update_status_text_from_lang(LANG_RENAME,buf3); } else { #ifdef NSIS_SUPPORT_MOVEONREBOOT - if (parm2 && file_exists(buf0)) + if (parm2 && file_exists(buf1)) { #ifdef NSIS_SUPPORT_REBOOT - exec_rebootflag++; + g_flags.exec_reboot++; #endif - MoveFileOnReboot(buf0,buf1); + MoveFileOnReboot(buf1,buf2); update_status_text_from_lang(LANG_RENAMEONREBOOT,buf3); log_printf2("Rename on reboot: %s",buf3); } else #endif { - exec_errorflag++; + g_flags.exec_error++; log_printf2("Rename failed: %s",buf3); } } @@ -339,7 +330,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) char *buf0=process_string_fromparm_tobuf(0x01); if (!GetFullPathName(buf0,NSIS_MAX_STRLEN,p,&fp)) { - exec_errorflag++; + g_flags.exec_error++; *p=0; } else if (fp>buf0 && *fp) @@ -351,7 +342,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) } else { - exec_errorflag++; + g_flags.exec_error++; *p=0; } } @@ -362,10 +353,10 @@ static int NSISCALL ExecuteEntry(entry *entry_) { char *fp; char *p=var0; - char *buf0=process_string_fromparm_tobuf(0x01); + char *buf0=process_string_fromparm_tobuf(-0x01); if (!SearchPath(NULL,buf0,NULL,NSIS_MAX_STRLEN,p,&fp)) { - exec_errorflag++; + g_flags.exec_error++; p[0]=0; } } @@ -375,7 +366,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) char *textout=var0; if (!GetTempFileName(temp_directory,"nst",0,textout)) { - exec_errorflag++; + g_flags.exec_error++; *textout=0; } } @@ -395,6 +386,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) mystrcpy(buf0,buf3); } else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3); + validate_filename(buf0); _tryagain: if (!overwriteflag) { @@ -417,7 +409,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (overwriteflag) { update_status_text_from_lang(LANG_SKIPPED,buf3); - if (overwriteflag==2) exec_errorflag++; + if (overwriteflag==2) g_flags.exec_error++; log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf0,overwriteflag); return 0; } @@ -435,7 +427,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) goto _tryagain; case IDIGNORE: log_printf("File: error, user cancel"); - exec_errorflag++; + g_flags.exec_error++; return 0; default: log_printf("File: error, user abort"); @@ -503,7 +495,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (parm1) { #ifdef NSIS_SUPPORT_REBOOT - exec_rebootflag++; + g_flags.exec_reboot++; #endif log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf1); update_status_text_from_lang(LANG_DELETEONREBOOT,buf1); @@ -512,7 +504,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) else #endif { - exec_errorflag++; + g_flags.exec_error++; } } } @@ -540,7 +532,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) return parm4; } } - else exec_errorflag++; + else g_flags.exec_error++; } return 0; #endif//NSIS_SUPPORT_MESSAGEBOX @@ -553,7 +545,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (lastchar(buf0)=='\\') trimslashtoend(buf0); doRMDir(buf0,parm1); - if (file_exists(buf0)) exec_errorflag++; + if (file_exists(buf0)) g_flags.exec_error++; } return 0; #endif//NSIS_SUPPORT_RMDIR @@ -606,7 +598,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { if (!GetEnvironmentVariable(buf0,p,NSIS_MAX_STRLEN)) { - exec_errorflag++; + g_flags.exec_error++; *p=0; } } @@ -648,7 +640,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) 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 3: if (v2) v/=v2; else { v=0; g_flags.exec_error++; } break; case 4: v|=v2; break; case 5: v&=v2; break; case 6: v^=v2; break; @@ -656,7 +648,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) 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; + case 11: if (v2) v%=v2; else { v=0; g_flags.exec_error++; } break; } myitoa(p,v); } @@ -691,7 +683,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (!s) { log_printf("Pop: stack empty"); - exec_errorflag++; + g_flags.exec_error++; return 0; } mystrcpy(var0,s->text); @@ -729,7 +721,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) b4=(int)process_string_fromparm_tobuf(0x14); } - if (parm5>>2) exec_errorflag += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(LPDWORD)&v); + if (parm5>>2) g_flags.exec_error += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(LPDWORD)&v); else v=SendMessage(hwnd,msg,b3,b4); } else @@ -818,7 +810,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { int x; char *buf0=process_string_fromparm_tobuf(0x00); - char *buf1=process_string_fromparm_tobuf(0x11); + char *buf1=process_string_fromparm_tobuf(-0x11); char *buf2=process_string_fromparm_tobuf(0x22); wsprintf(buf3,"%s %s",buf0,buf1); update_status_text_from_lang(LANG_EXECSHELL, buf3); @@ -826,7 +818,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (x < 33) { log_printf5("ExecShell: warning: error (\"%s\": file:\"%s\" params:\"%s\")=%d",buf0,buf1,buf2,x); - exec_errorflag++; + g_flags.exec_error++; } else { @@ -860,13 +852,13 @@ static int NSISCALL ExecuteEntry(entry *entry_) GetExitCodeProcess(hProc, &lExitCode); if (parm2>=0) myitoa(var2,lExitCode); - else if (lExitCode) exec_errorflag++; + else if (lExitCode) g_flags.exec_error++; } CloseHandle( hProc ); } else { - exec_errorflag++; + g_flags.exec_error++; log_printf2("Exec: failed createprocess (\"%s\")",buf0); } } @@ -892,7 +884,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) else { *lowout=*highout=0; - exec_errorflag++; + g_flags.exec_error++; } } return 0; @@ -906,10 +898,10 @@ static int NSISCALL ExecuteEntry(entry *entry_) DWORD t[4]; // our two members are the 3rd and 4th.. VS_FIXEDFILEINFO *pvsf1=(VS_FIXEDFILEINFO*)t; DWORD d; - char *buf0=process_string_fromparm_tobuf(0x00); - s1=GetFileVersionInfoSize(buf0,&d); + char *buf1=process_string_fromparm_tobuf(-0x10); + s1=GetFileVersionInfoSize(buf1,&d); *lowout=*highout=0; - exec_errorflag++; + g_flags.exec_error++; if (s1) { void *b1; @@ -917,12 +909,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (b1) { UINT uLen; - if (GetFileVersionInfo(buf0,0,s1,b1) && VerQueryValue(b1,"\\",(void*)&pvsf1,&uLen)) + if (GetFileVersionInfo(buf1,0,s1,b1) && VerQueryValue(b1,"\\",(void*)&pvsf1,&uLen)) { myitoa(highout,pvsf1->dwFileVersionMS); myitoa(lowout,pvsf1->dwFileVersionLS); - exec_errorflag--; + g_flags.exec_error--; } GlobalFree(b1); } @@ -934,33 +926,25 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_REGISTERDLL: { HRESULT hres=OleInitialize(NULL); - exec_errorflag++; + g_flags.exec_error++; if (hres == S_FALSE || hres == S_OK) { HANDLE h; - char *buf0=process_string_fromparm_tobuf(0x00); - char *buf1=process_string_fromparm_tobuf(0x11); + char *buf1=process_string_fromparm_tobuf(-0x10); + char *buf0=process_string_fromparm_tobuf(0x01); - h=LoadLibrary(buf0); + h=LoadLibrary(buf1); if (h) { - FARPROC funke = GetProcAddress(h,buf1); + FARPROC funke = GetProcAddress(h,buf0); if (funke) { - exec_errorflag--; + g_flags.exec_error--; if (parm2) { char *buf2=process_string_fromparm_tobuf(0x22); - - // suggested by Kevin Gadd (janusfury) - mystrcpy(buf3, buf0); - trimslashtoend(buf3); - SetCurrentDirectory(buf3); - - update_status_text(buf2,buf0); - if (funke()) exec_errorflag++; - - SetCurrentDirectory(state_exe_directory); + update_status_text(buf2,buf1); + if (funke()) g_flags.exec_error++; } else { @@ -976,22 +960,22 @@ static int NSISCALL ExecuteEntry(entry *entry_) } else { - update_status_text_from_lang(LANG_CANNOTFINDSYMBOL,buf1); - log_printf3("Error registering DLL: %s not found in %s",buf1,buf0); + update_status_text_from_lang(LANG_CANNOTFINDSYMBOL,buf0); + log_printf3("Error registering DLL: %s not found in %s",buf0,buf1); } if (!parm3) while (FreeLibrary(h)); // saves 2 bytes - FreeLibrary((HANDLE)((unsigned long)h&(unsigned long)parm3)); } else { - update_status_text_from_lang(LANG_COULDNOTLOAD,buf0); - log_printf2("Error registering DLL: Could not load %s",buf0); + update_status_text_from_lang(LANG_COULDNOTLOAD,buf1); + log_printf2("Error registering DLL: Could not load %s",buf1); } OleUninitialize(); } else { - update_status_text_from_lang(LANG_NOOLE,buf0); + update_status_text_from_lang(LANG_NOOLE,buf1); log_printf("Error registering DLL: Could not initialize OLE"); } } @@ -999,10 +983,10 @@ static int NSISCALL ExecuteEntry(entry *entry_) #endif #ifdef NSIS_SUPPORT_CREATESHORTCUT case EW_CREATESHORTCUT: { - char *buf2=process_string_fromparm_tobuf(0x20); - char *buf1=process_string_fromparm_tobuf(0x11); + 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); + char *buf3=process_string_fromparm_tobuf(-0x33); char *buf4=process_string_fromparm_tobuf(0x45); HRESULT hres; @@ -1049,7 +1033,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (rv) { - exec_errorflag++; + g_flags.exec_error++; update_status_text_from_lang(LANG_ERRORCREATINGSHORTCUT,buf2); } else @@ -1083,14 +1067,14 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (res) { // some of these changes were from Edgewise (wiked_edge@yahoo.com) update_status_text_from_lang(LANG_COPYFAILED,""); - exec_errorflag++; + g_flags.exec_error++; } } return 0; #endif//NSIS_SUPPORT_COPYFILES #ifdef NSIS_SUPPORT_REBOOT case EW_REBOOT: - exec_errorflag++; + g_flags.exec_error++; { HANDLE h=LoadLibrary("advapi32.dll"); if (h) @@ -1122,8 +1106,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) return 0; } break; - case EW_IFREBOOTFLAG: return parms[!exec_rebootflag]; - case EW_SETREBOOTFLAG: exec_rebootflag=parm0; return 0; + case EW_IFREBOOTFLAG: return parms[!g_flags.exec_reboot]; #endif//NSIS_SUPPORT_REBOOT #ifdef NSIS_SUPPORT_INIFILES case EW_WRITEINI: @@ -1145,9 +1128,9 @@ static int NSISCALL ExecuteEntry(entry *entry_) { str=process_string_fromparm_tobuf(0x22); } - buf3=process_string_fromparm_tobuf(0x33); + buf3=process_string_fromparm_tobuf(-0x33); log_printf5("WriteINIStr: wrote [%s] %s=%s in %s",buf0,buf1,buf2,buf3); - if (!WritePrivateProfileString(sec,key,str,buf3)) exec_errorflag++; + if (!WritePrivateProfileString(sec,key,str,buf3)) g_flags.exec_error++; } return 0; case EW_READINISTR: @@ -1156,11 +1139,11 @@ static int NSISCALL ExecuteEntry(entry *entry_) char *p=var0; char *buf0=process_string_fromparm_tobuf(0x01); char *buf1=process_string_fromparm_tobuf(0x12); - char *buf2=process_string_fromparm_tobuf(0x23); + char *buf2=process_string_fromparm_tobuf(-0x23); GetPrivateProfileString(buf0,buf1,errstr,p,NSIS_MAX_STRLEN-1,buf2); if (*((int*)errstr) == *((int*)p)) { - exec_errorflag++; + g_flags.exec_error++; p[0]=0; } } @@ -1171,7 +1154,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { int rootkey=parm0; char *buf3=process_string_fromparm_tobuf(0x31); - exec_errorflag++; + g_flags.exec_error++; if (!parm3) { HKEY hKey; @@ -1179,14 +1162,14 @@ static int NSISCALL ExecuteEntry(entry *entry_) { char *buf0=process_string_fromparm_tobuf(0x02); log_printf4("DeleteRegValue: %d\\%s\\%s",rootkey,buf3,buf0); - if (RegDeleteValue(hKey,buf0) == ERROR_SUCCESS) exec_errorflag--; + if (RegDeleteValue(hKey,buf0) == ERROR_SUCCESS) g_flags.exec_error--; RegCloseKey(hKey); } } else { log_printf3("DeleteRegKey: %d\\%s",rootkey,buf3); - if (myRegDeleteKeyEx((HKEY)rootkey,buf3,parm3&2) == ERROR_SUCCESS) exec_errorflag--; + if (myRegDeleteKeyEx((HKEY)rootkey,buf3,parm3&2) == ERROR_SUCCESS) g_flags.exec_error--; } } return 0; @@ -1197,20 +1180,20 @@ static int NSISCALL ExecuteEntry(entry *entry_) int type=parm4; char *buf1=process_string_fromparm_tobuf(0x12); char *buf3=process_string_fromparm_tobuf(0x31); - exec_errorflag++; + g_flags.exec_error++; if (RegCreateKey((HKEY)rootkey,buf3,&hKey) == ERROR_SUCCESS) { if (type <= 1) { char *buf2=process_string_fromparm_tobuf(0x23); - if (RegSetValueEx(hKey,buf1,0,type==1?REG_SZ:REG_EXPAND_SZ,buf2,mystrlen(buf2)+1) == ERROR_SUCCESS) exec_errorflag--; + if (RegSetValueEx(hKey,buf1,0,type==1?REG_SZ:REG_EXPAND_SZ,buf2,mystrlen(buf2)+1) == ERROR_SUCCESS) g_flags.exec_error--; log_printf5("WriteRegStr: set %d\\%s\\%s to %s",rootkey,buf3,buf1,buf2); } else if (type == 2) { DWORD l; l=process_string_fromparm_toint(3); - if (RegSetValueEx(hKey,buf1,0,REG_DWORD,(unsigned char*)&l,4) == ERROR_SUCCESS) exec_errorflag--; + if (RegSetValueEx(hKey,buf1,0,REG_DWORD,(unsigned char*)&l,4) == ERROR_SUCCESS) g_flags.exec_error--; log_printf5("WriteRegDWORD: set %d\\%s\\%s to %d",rootkey,buf3,buf1,l); } else if (type == 3) @@ -1218,7 +1201,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) int len=GetCompressedDataFromDataBlockToMemory(parm3, buf2, NSIS_MAX_STRLEN); if (len >= 0) { - if (RegSetValueEx(hKey,buf1,0,REG_BINARY,buf2,len) == ERROR_SUCCESS) exec_errorflag--; + if (RegSetValueEx(hKey,buf1,0,REG_BINARY,buf2,len) == ERROR_SUCCESS) g_flags.exec_error--; } log_printf5("WriteRegBin: set %d\\%s\\%s with %d bytes",rootkey,buf3,buf1,len); @@ -1245,20 +1228,20 @@ static int NSISCALL ExecuteEntry(entry *entry_) (t != REG_DWORD && t != REG_SZ && t != REG_EXPAND_SZ)) { p[0]=0; - exec_errorflag++; + g_flags.exec_error++; } else { if (t==REG_DWORD) { - if (!parm4) exec_errorflag++; + if (!parm4) g_flags.exec_error++; myitoa(p,*((DWORD*)p)); } - else if (parm4) exec_errorflag++; + else if (parm4) g_flags.exec_error++; } RegCloseKey(hKey); } - else exec_errorflag++; + else g_flags.exec_error++; } return 0; case EW_REGENUM: @@ -1276,7 +1259,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) p[NSIS_MAX_STRLEN-1]=0; RegCloseKey(key); } - else exec_errorflag++; + else g_flags.exec_error++; } return 0; @@ -1292,12 +1275,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) { HANDLE h; char *handleout=var3; - char *buf0=process_string_fromparm_tobuf(0x00); - h=myOpenFile(buf0,parm1,parm2); + char *buf1=process_string_fromparm_tobuf(-0x10); + h=myOpenFile(buf1,parm1,parm2); if (h == INVALID_HANDLE_VALUE) { *handleout=0; - exec_errorflag++; + g_flags.exec_error++; } else { @@ -1321,7 +1304,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) } if (!*t || !WriteFile((HANDLE)myatoi(t),buf1,l,&dw,NULL)) { - exec_errorflag++; + g_flags.exec_error++; } } return 0; @@ -1360,7 +1343,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) } } textout[rpos]=0; - if (!rpos) exec_errorflag++; + if (!rpos) g_flags.exec_error++; } return 0; case EW_FSEEK: @@ -1396,7 +1379,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) } else { - exec_errorflag++; + g_flags.exec_error++; *textout=0; } @@ -1414,7 +1397,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { *handleout=0; *textout=0; - exec_errorflag++; + g_flags.exec_error++; } else { @@ -1439,6 +1422,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { lstrcat(addtrailingslash(mystrcpy(buf1,state_install_directory)),buf0); } + validate_filename(buf1); hFile=myOpenFile(buf1,GENERIC_WRITE,CREATE_ALWAYS); @@ -1454,13 +1438,11 @@ static int NSISCALL ExecuteEntry(entry *entry_) ReadSelfFile((char*)filebuf,g_filehdrsize); if (g_inst_header->uninstdata_offset != -1) { - // Changed by Amir Szekely 11th July 2002 unsigned char* seeker; unsigned char* unicon_data = seeker = (unsigned char*)my_GlobalAlloc(g_inst_header->uninsticon_size); if (unicon_data) { GetCompressedDataFromDataBlockToMemory(g_inst_header->uninstdata_offset, unicon_data,g_inst_header->uninsticon_size); - //for (i = 0; i < *(DWORD*)unicon_data; i++) { while (*seeker) { DWORD dwSize, dwOffset; dwSize = *(DWORD*)seeker; @@ -1484,7 +1466,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) { update_status_text_from_lang(LANG_ERRORCREATING,buf0); DeleteFile(buf1); - exec_errorflag++; + g_flags.exec_error++; } else update_status_text_from_lang(LANG_CREATEDUNINST,buf0); @@ -1507,6 +1489,13 @@ static int NSISCALL ExecuteEntry(entry *entry_) } return 0; #endif//NSIS_CONFIG_LOG +#ifdef NSIS_CONFIG_PLUGIN_SUPPORT + // Added by Ximon Eighteen 5th August 2002 + case EW_PLUGINCOMMANDPREP: + // $0 temp plug-ins dir + if (!*plugins_temp_dir) mystrcpy(plugins_temp_dir,g_usrvars[0]); + return 0; +#endif // NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_COMPONENTPAGE case EW_SECTIONSET: { @@ -1545,18 +1534,10 @@ static int NSISCALL ExecuteEntry(entry *entry_) myitoa(var2,g_inst_section[x].flags); } } - else exec_errorflag++; + else g_flags.exec_error++; } return 0; #endif//NSIS_CONFIG_COMPONENTPAGE - - // Added by Ximon Eighteen 5th August 2002 -#ifdef NSIS_CONFIG_PLUGIN_SUPPORT - case EW_PLUGINCOMMANDPREP: - // $0 temp plug-ins dir - if (!*plugins_temp_dir) mystrcpy(plugins_temp_dir,g_usrvars[0]); - return 0; -#endif // NSIS_CONFIG_PLUGIN_SUPPORT } my_MessageBox(LANG_STR(LANG_INSTCORRUPTED),MB_OK|MB_ICONSTOP); return EXEC_ERROR; diff --git a/Source/exehead/exec.h b/Source/exehead/exec.h index b39b12e1..8571e0b6 100644 --- a/Source/exehead/exec.h +++ b/Source/exehead/exec.h @@ -1,7 +1,18 @@ #ifndef _EXEC_H_ #define _EXEC_H_ +extern union flags { + struct { + int autoclose; + int all_user_var; + int exec_error; +#ifdef NSIS_SUPPORT_REBOOT + int exec_reboot; +#endif + }; + int flags[1]; +} g_flags; + int NSISCALL ExecuteCodeSegment(int pos, HWND hwndProgress); // returns 0 on success - #endif//_EXEC_H_ diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 40f9abe9..1d516e7b 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -39,15 +39,14 @@ enum EW_CALL, // Call: 1 [new address+1] EW_UPDATETEXT, // Update status text: 2 [update str, ui_st_updateflag=?ui_st_updateflag:this] EW_SLEEP, // Sleep: 1 [sleep time in milliseconds] - EW_SETSFCONTEXT, // SetShellVarContext: 1: [isAll] EW_HIDEWINDOW, // HideWindow: 0 EW_BRINGTOFRONT, // BringToFront: 0 - EW_SETWINDOWCLOSE, // SetWindowClose: 1 [0: no window close at end, 1: window close at end] EW_CHDETAILSVIEW, // SetDetailsView: 2 [listaction,buttonaction] EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes] EW_CREATEDIR, // Create directory: 2, [path, ?update$INSTDIR] EW_IFFILEEXISTS, // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists] - EW_IFERRORS, //a IfErrors: 3 [jump if error, jump if not error, new_erflag] + EW_IFERRORS, // IfErrors: 2 [jump if error, jump if not error] + EW_SETFLAG, // Sets a flag: 2 [id, data] #ifdef NSIS_SUPPORT_RENAME EW_RENAME, // Rename: 3 [old, new, rebootok] #endif @@ -132,7 +131,6 @@ enum #ifdef NSIS_SUPPORT_REBOOT EW_REBOOT, // Reboot: 0 EW_IFREBOOTFLAG, // IfRebootFlag: 2 [if reboot flag set, if not reboot flag] - EW_SETREBOOTFLAG, // SetRebootFlag: 1 [new value] #endif #ifdef NSIS_SUPPORT_INIFILES @@ -181,8 +179,14 @@ enum EW_GETLABELADDR, // both of these get converted to EW_ASSIGNVAR EW_GETFUNCTIONADDR, - EW_PLUGINCOMMANDPREP + // Saves 56 bytes, don't ask me how + EW_DUMMY, + EW_DUMMY2, + EW_DUMMY3, + EW_DUMMY4, + EW_DUMMY5, + EW_PLUGINCOMMANDPREP, }; #define FH_FLAGS_MASK 15 @@ -191,7 +195,6 @@ enum #ifdef NSIS_CONFIG_SILENT_SUPPORT #define FH_FLAGS_SILENT 4 #endif -// Added by Amir Szekely 23rd July 2002 #define FH_FLAGS_FORCE_CRC 8 #define FH_SIG 0xDEADBEEF diff --git a/Source/exehead/ui.h b/Source/exehead/ui.h index 96ae16f4..b0ccb536 100644 --- a/Source/exehead/ui.h +++ b/Source/exehead/ui.h @@ -10,7 +10,7 @@ void NSISCALL update_status_text_from_lang(int id, const char *text2); void NSISCALL update_status_text(const char *text1, const char *text2); extern int ui_st_updateflag; -extern int g_autoclose; +//extern int g_autoclose; extern void *g_inst_combinedheader; extern page *g_inst_page; extern section *g_inst_section; diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 24898e59..9f0dba09 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -5,6 +5,7 @@ #include "state.h" #include "config.h" #include "lang.h" +#include "exec.h" #include "fileform.h" #include "ui.h" @@ -42,17 +43,18 @@ HANDLE NSISCALL myCreateProcess(char *cmd, char *dir) return ProcInfo.hProcess; } -BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val) +/*BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val) { return SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)val); -} +}*/ BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val) { - return my_SetWindowText(GetDlgItem(dlg,idx),val); + return SetDlgItemText(dlg,idx,val); + //return my_SetWindowText(GetDlgItem(dlg,idx),val); } -int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size) +/*int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size) { return SendMessage(hWnd,WM_GETTEXT,size,(LPARAM)val); } @@ -60,7 +62,7 @@ int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size) int NSISCALL my_GetDialogItemText(HWND dlg, UINT idx, char *val, int size) { return my_GetWindowText(GetDlgItem(dlg,idx),val,size); -} +}*/ int NSISCALL my_MessageBox(const char *text, UINT type) { return MessageBox(g_hwnd, text, g_caption, type); @@ -163,10 +165,9 @@ int NSISCALL is_valid_instpath(char *s) return ivp; } -static char * NSISCALL findinmem(char *a, char *b, int len_of_a) +char * NSISCALL mystrstr(char *a, char *b) { - if (len_of_a<0) len_of_a=mystrlen(a); - len_of_a -= mystrlen(b); + int len_of_a = mystrlen(a) - mystrlen(b); while (*a && len_of_a >= 0) { char *t=a,*u=b; @@ -255,7 +256,7 @@ BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) if (pszWinInit != NULL) { - LPSTR pszRenameSecInFile = findinmem(pszWinInit, szRenameSec,-1); + LPSTR pszRenameSecInFile = mystrstr(pszWinInit, szRenameSec); if (pszRenameSecInFile == NULL) { mystrcpy(pszWinInit+dwFileSize, szRenameSec); @@ -265,7 +266,7 @@ BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) else { char *pszFirstRenameLine = pszRenameSecInFile+10; - char *pszNextSec = findinmem(pszFirstRenameLine,"\n[",-1); + char *pszNextSec = mystrstr(pszFirstRenameLine,"\n["); if (pszNextSec) { int l=dwFileSize - (pszNextSec - pszWinInit); @@ -314,14 +315,14 @@ void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *ou static char smwcvesf[]="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; -char g_all_user_var_flag; +//int g_all_user_var_flag; static void NSISCALL queryShellFolders(const char *name_, char *out) { static char name[20] = "Common "; mystrcpy(name + 7, name_); { - char f=g_all_user_var_flag; + char f=g_flags.all_user_var; again: @@ -345,7 +346,7 @@ char ps_tmpbuf[NSIS_MAX_STRLEN*2]; char * NSISCALL process_string_fromtab(char *out, int offs) { - return lstrcpyn(out,process_string(ps_tmpbuf,GetStringFromStringTab(offs)),NSIS_MAX_STRLEN); + return lstrcpyn(out,process_string(GetStringFromStringTab(offs)),NSIS_MAX_STRLEN); } void NSISCALL myitoa(char *s, int d) { wsprintf(s,"%d",d); } @@ -405,10 +406,10 @@ int NSISCALL mystrlen(const char *in) } // Dave Laundon's simplified process_string -char * NSISCALL process_string(char *out, const char *in) +char * NSISCALL process_string(const char *in) { - char *outsave = out; - while (*in && out - outsave < NSIS_MAX_STRLEN) + char *out = ps_tmpbuf; + while (*in && out - ps_tmpbuf < NSIS_MAX_STRLEN) { int nVarIdx = (unsigned char)*in++; if (nVarIdx < VAR_CODES_START) @@ -426,7 +427,7 @@ char * NSISCALL process_string(char *out, const char *in) { case VAR_CODES_START + 0: // HWNDPARENT myitoa(out, (unsigned int)g_hwnd); - break; + break; case VAR_CODES_START + 1: // 0 case VAR_CODES_START + 2: // 1 case VAR_CODES_START + 3: // 2 @@ -511,18 +512,40 @@ char * NSISCALL process_string(char *out, const char *in) #endif #endif //NSIS_CONFIG_PLUGIN_SUPPORT } // switch - // remove trailing slash - while (*out && *CharNext(out)) out++; - if (nVarIdx > 21+VAR_CODES_START && nVarIdx != VAR_CODES_START+25 && *out == '\\') // only if not $0 to $R9, $CMDLINE, $LANGUAGE, or $HWNDPARENT - *out = 0; - out=CharNext(out); + // validate the directory name + if (nVarIdx > 21+VAR_CODES_START) { // only if not $0 to $R9, $CMDLINE, or $HWNDPARENT + // ($LANGUAGE can't have trailing backslash anyway...) + validate_filename(out); + } + out+=mystrlen(out); } // >= VAR_CODES_START } // while *out = 0; - return outsave; + return ps_tmpbuf; +; } -#ifdef NSIS_CONFIG_LOG +char * NSISCALL validate_filename(char *in) { + char *nono = "*?|<>/\":"; + char *cur_char = " "; + char *out = in; + char *out_save = out; + int i = 0; + while (*cur_char = *in++) { + if (!mystrstr(nono, cur_char) || + (i == 1 && *(WORD*)out == CHAR2_TO_WORD(':','\\')) || + (i == 2 && *cur_char == '?' && *(DWORD*)in == CHAR4_TO_DWORD('\\','\\','?','\\')) + ) + *out++ = *cur_char; + i++; + } + do { + *out = 0; + } while (i && (*(--out) == ' ' || *out == '\\')); + return out_save; +} + +#ifdef NSIS_CONFIG_LOG char log_text[4096]; int log_dolog; void NSISCALL log_write(int close) @@ -554,6 +577,4 @@ void NSISCALL log_write(int close) } } } - - #endif \ No newline at end of file diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 33dbad73..338f396d 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -1,17 +1,22 @@ #include "config.h" extern char ps_tmpbuf[NSIS_MAX_STRLEN*2]; -char * NSISCALL process_string(char *out, const char *in); +char * NSISCALL process_string(const char *in); char * NSISCALL process_string_fromtab(char *out, int offs); void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out); int NSISCALL myatoi(char *s); void NSISCALL myitoa(char *s, int d); char * NSISCALL mystrcpy(char *out, const char *in); int NSISCALL mystrlen(const char *in); -BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); +char * NSISCALL mystrstr(char *a, char *b); + +//BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); +#define my_SetWindowText SetWindowText BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val); -int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size); -int NSISCALL my_GetDialogItemText(HWND dlg, UINT idx, char *val, int size); +//int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size); +#define my_GetWindowText GetWindowText +//int NSISCALL my_GetDialogItemText(HWND dlg, UINT idx, char *val, int size); +#define my_GetDialogItemText GetDlgItemText #ifdef NSIS_CONFIG_LOG extern char log_text[NSIS_MAX_STRLEN*4]; @@ -48,6 +53,7 @@ char NSISCALL lastchar(const char *str); void NSISCALL trimslashtoend(char *buf); char * NSISCALL scanendslash(const char *str); int NSISCALL is_valid_instpath(char *s); +char * NSISCALL validate_filename(char *fn); BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew); void * NSISCALL mini_memcpy(void *out, const void *in, int len); diff --git a/Source/script.cpp b/Source/script.cpp index 826e52a1..a92f341c 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -784,7 +784,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2)); if (p.showfunc>=0 && k) SCRIPT_MSG(" (show:%s)", line.gettoken_str(3)); - if (p.showfunc>=0 && k) + if (p.leavefunc>=0 && k) SCRIPT_MSG(" (leave:%s)", line.gettoken_str(4)); else if (p.caption && !k) SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3)); @@ -2241,9 +2241,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG("Goto: %s\n",line.gettoken_str(1)); return add_entry(&ent); case TOK_SETSHELLVARCONTEXT: - ent.which=EW_SETSFCONTEXT; - ent.offsets[0]=line.gettoken_enum(1,"current\0all\0"); - if (ent.offsets[0]<0) PRINTHELP() + ent.which=EW_SETFLAG; + ent.offsets[0]=1; + ent.offsets[1]=line.gettoken_enum(1,"current\0all\0"); + if (ent.offsets[1]<0) PRINTHELP() SCRIPT_MSG("SetShellVarContext: %s\n",line.gettoken_str(1)); return add_entry(&ent); case TOK_RET: @@ -2989,9 +2990,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG("SetDetailsPrint: %s\n",line.gettoken_str(1)); return add_entry(&ent); case TOK_SETAUTOCLOSE: - ent.which=EW_SETWINDOWCLOSE; - ent.offsets[0] = line.gettoken_enum(1,"false\0true\0"); - if (ent.offsets[0] < 0) PRINTHELP() + ent.which=EW_SETFLAG; + ent.offsets[0]=0; + ent.offsets[1]=line.gettoken_enum(1,"false\0true\0"); + if (ent.offsets[1] < 0) PRINTHELP() SCRIPT_MSG("SetAutoClose: %s\n",line.gettoken_str(1)); return add_entry(&ent); case TOK_IFERRORS: @@ -3001,12 +3003,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG("IfErrors ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); case TOK_CLEARERRORS: - ent.which=EW_IFERRORS; + ent.which=EW_SETFLAG; + ent.offsets[0]=2; + ent.offsets[1]=0; SCRIPT_MSG("ClearErrors\n"); return add_entry(&ent); case TOK_SETERRORS: - ent.which=EW_IFERRORS; - ent.offsets[2]=1; + ent.which=EW_SETFLAG; + ent.offsets[0]=2; + ent.offsets[1]=1; SCRIPT_MSG("SetErrors\n"); return add_entry(&ent); #ifdef NSIS_SUPPORT_STROPTS @@ -3726,9 +3731,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char SCRIPT_MSG("IfRebootFlag ?%s:%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); case TOK_SETREBOOTFLAG: - ent.which=EW_SETREBOOTFLAG; - ent.offsets[0]=line.gettoken_enum(1,"false\0true\0"); - if (ent.offsets[0] < 0) PRINTHELP() + ent.which=EW_SETFLAG; + ent.offsets[0]=3; + ent.offsets[1]=line.gettoken_enum(1,"false\0true\0"); + if (ent.offsets[1] < 0) PRINTHELP() return add_entry(&ent); #else//!NSIS_SUPPORT_REBOOT case TOK_REBOOT: diff --git a/TODO.txt b/TODO.txt index 5432e9b4..161fc09f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,12 +4,18 @@ TODO NSIS -* check for invalid chars/spaces in folder input +* fix $QUICKLAUNCH with all context + +* avaiable size not showing when directory doesn't exist -- NSIS 2 Beta 2 -- NSIS +* move more ui changes to compile time. + make progress bar flags be written directly in the UI (PBS_SMOOTH) + inst details could be changed in compile time too + * component page for uninstaller, multiple sections * more default texts in NLF language files @@ -18,6 +24,8 @@ NSIS * different color for the drive space when there is not enough space +* all installer strings should be language strings + DOCUMENTATION * user_vars should link to the user_vars section as in the old docs callbacks and