diff --git a/Source/build.cpp b/Source/build.cpp index 0167788b..3dbe6f8d 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -1892,7 +1892,11 @@ again: p->parms[1] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1, NLF_UCOMP_SUBTEXT1)); if (!p->parms[2]) p->parms[2] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT2, NLF_UCOMP_SUBTEXT2)); - if (!p->parms[4]) + if (!p->parms[3] && !uninstall_mode && HasUserDefined(NLF_COMP_SUBTEXT1)) + p->parms[3] = p->parms[1]; + if (!p->parms[4] && !uninstall_mode && HasUserDefined(NLF_COMP_SUBTEXT2)) + p->parms[4] = p->parms[2]; + else if (!p->parms[4]) p->parms[4] = DefineInnerLangString(LS(NLF_COMP_SUBTEXT1_NO_INST_TYPES, NLF_UCOMP_SUBTEXT1_NO_INST_TYPES)); DefineInnerLangString(NLF_SPACE_REQ); diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index f2db742c..d19175ae 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -110,6 +110,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, if (cmdline[0] != '/') break; cmdline++; +// this only works with spaces because they have just one bit on #define END_OF_ARG(c) (((c)|' ')==' ') #if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT) diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 517d0dd1..6ddfd43c 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -171,6 +171,8 @@ int NSISCALL ui_doinstall(void) static WNDCLASS wc; // richedit subclassing and bgbg creation g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; + set_language(); + if (!is_valid_instpath(state_install_directory)) { if (header->install_reg_key_ptr) @@ -201,8 +203,9 @@ int NSISCALL ui_doinstall(void) d=GetFileAttributes(p); if (d == (DWORD)-1 || !(d&FILE_ATTRIBUTE_DIRECTORY)) { - e=scanendslash(p); - if (e>=p) *e=0; + // if there is no back-slash, the string will become empty, but that's ok because + // it would make an invalid instdir anyway + trimslashtoend(p); } } } @@ -224,8 +227,6 @@ int NSISCALL ui_doinstall(void) } #endif - set_language(); - #ifdef NSIS_CONFIG_VISIBLE_SUPPORT g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); #ifdef NSIS_SUPPORT_BGBG @@ -790,6 +791,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START) { static char s[NSIS_MAX_STRLEN]; + char *p; int is_valid_path; int x; int total=0, available=-1; @@ -799,16 +801,9 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar is_valid_path=is_valid_instpath(dir); mystrcpy(s,dir); - if (s[1] == ':') s[3]=0; - else if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path - { - char *p = mystrstr(s+2,"\\"); - if (p) { - p = mystrstr(p+1,"\\"); - if (p) *p = 0; - } - addtrailingslash(s); - } + p=skip_root(s); + if (p) + *p=0; if (GetDiskFreeSpace(s,&spc,&bps,&fc,&tc)) { diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 19ca8109..0d6ef8d9 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -229,21 +229,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) char *buf1=GetStringFromParm(-0x10); log_printf3("CreateDirectory: \"%s\" (%d)",buf1,parm1); { - char *tp=CharNext(buf1); char *p=buf1; char c='c'; if (*p) { - if (*(WORD*)tp == CHAR2_TO_WORD(':','\\')) p=tp+2; - else if (*(WORD*)p == CHAR2_TO_WORD('\\','\\')) - { - int x=4; - while (x--) - { - while (*p != '\\' && *p) p=CharNext(p); // skip host then share - p=CharNext(p); - } - } - else break; + p = skip_root(buf1); + if (!p) + break; while (c) { WIN32_FIND_DATA *fd; @@ -767,8 +758,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) 0, GetStringFromParm(0x00), IMAGE_BITMAP, - parm2?r.right:0, - parm2?r.bottom:0, + parm2*r.right, + parm2*r.bottom, LR_LOADFROMFILE ); hImage = (HANDLE)SendMessage( @@ -924,6 +915,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_REGISTERDLL: { exec_error++; + SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); if (SUCCEEDED(g_hres)) { HANDLE h; @@ -978,6 +970,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) update_status_text(LANG_NOOLE,buf1); log_printf("Error registering DLL: Could not initialize OLE"); } + SetErrorMode(0); } break; #endif diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 03425a38..a9c66f94 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -133,24 +133,15 @@ char *NSISCALL addtrailingslash(char *str) void NSISCALL trimslashtoend(char *buf) { - char *p=scanendslash(buf); - if (p buf); + + *p = 0; } int NSISCALL validpathspec(char *ubuf) @@ -158,34 +149,48 @@ int NSISCALL validpathspec(char *ubuf) return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (ubuf[0] && *CharNext(ubuf)==':')); } -int NSISCALL is_valid_instpath(char *s) +char * NSISCALL skip_root(char *path) { - int ivp=0; - // if CH_FLAGS_NO_ROOT_DIR is set, req is 0, which means rootdirs are not allowed. - int req=!(g_flags&CH_FLAGS_NO_ROOT_DIR); - if (*(WORD*)s == CHAR2_TO_WORD('\\','\\')) // \\ path + char *p = CharNext(path); + char *p2 = CharNext(p); + + if (*path && *(WORD*)p == CHAR2_TO_WORD(':', '\\')) { - if (lastchar(s)!='\\') ivp++; - while (*s) + return CharNext(p2); + } + else if (*(WORD*)path == CHAR2_TO_WORD('\\','\\')) + { + // skip host and share name + int x = 2; + while (x--) { - if (*s == '\\') ivp++; - s=CharNext(s); + while (*p2 != '\\') + { + if (!*p2) + return NULL; + p2 = CharNext(p2); + } + p2 = CharNext(p2); } - ivp/=5-req; + + return p2; } else + return NULL; +} + +int NSISCALL is_valid_instpath(char *s) +{ + int ret = 0; + char *p = skip_root(s); + if (p && ((*p && *p != '\\') || !(g_flags & CH_FLAGS_NO_ROOT_DIR))) { - if (*s) - { - s=CharNext(s); - if (*(WORD*)s == CHAR2_TO_WORD(':','\\')) - { - s+=2; - if (req || (*s && *s != '\\')) ivp++; - } - } + char pb = *p; + *p = 0; + ret = GetFileAttributes(s) != (DWORD)-1; + *p = pb; } - return ivp; + return ret; } char * NSISCALL mystrstr(char *a, char *b) @@ -674,13 +679,13 @@ char * NSISCALL validate_filename(char *in) { char *out; char *out_save; while (*in == ' ') in=CharNext(in); - if (in[0] && in[1] && in[2]) { + if (in[0] == '\\' && in[1] == '\\' && in[2] == '?' && in[3] == '\\') { // at least four bytes - if (*(DWORD*)in == CHAR4_TO_DWORD('\\', '\\', '?', '\\')) in += 4; + in += 4; } if (*in) { // at least two bytes - if (in[0] && validpathspec(in)) in += 2; + if (validpathspec(in)) in += 2; } out = out_save = in; while (*(char*)&cur_char = *in) { diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 31253d76..3f1b0b5d 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -56,7 +56,7 @@ char * NSISCALL addtrailingslash(char *str); //char NSISCALL lastchar(const char *str); #define lastchar(str) *CharPrev(str,str+mystrlen(str)) void NSISCALL trimslashtoend(char *buf); -char * NSISCALL scanendslash(const char *str); +char * NSISCALL skip_root(char *path); int NSISCALL is_valid_instpath(char *s); char * NSISCALL validate_filename(char *fn); void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);