From 9d7de707eaac121fef706978c9c68bc3d669940a Mon Sep 17 00:00:00 2001 From: kichik Date: Wed, 10 Sep 2003 16:39:06 +0000 Subject: [PATCH] - Fixed uninstaller refusal to start when on the root directory (note that AllowRootDirInstall true is still required) - Some touch ups regarding NSIS_CONFIG_VISIBLE_SUPPORT git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2896 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Main.c | 27 +++++++++++++++++++-------- Source/exehead/Ui.c | 2 ++ Source/exehead/exec.c | 16 ++++++++++++---- Source/exehead/state.h | 8 +++++++- Source/exehead/util.c | 2 -- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index 0f7937c4..78710d8b 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -44,7 +44,10 @@ extern HANDLE dbd_hFile; char g_caption[NSIS_MAX_STRLEN*2]; int g_filehdrsize; +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT HWND g_hwnd; +HANDLE g_hInstance; +#endif int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, int nCmdShow) { @@ -89,7 +92,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, lstrcpyn(state_command_line, GetCommandLine(), NSIS_MAX_STRLEN); +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT g_hInstance = GetModuleHandle(NULL); +#endif//NSIS_CONFIG_VISIBLE_SUPPORT cmdline = state_command_line; if (*cmdline == '\"') seekchar = *cmdline++; @@ -139,6 +144,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--; + m_Err = _LANG_UNINSTINITERROR; + if (p >= cmdline) { *(p-1)=0; // terminate before the " _?=" @@ -147,20 +154,20 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, { mystrcpy(state_install_directory, p); mystrcpy(state_output_directory, p); + m_Err = 0; } else { - m_Err = _LANG_UNINSTINITERROR; goto end; } } else { - int x,done=0; + int x; for (x = 0; x < 26; x ++) { - // File name need slash before coz temp dir was changed by validate_filename(...) + // File name need slash before because temp dir was changed by validate_filename static char s[]="\\A~NSISu_.exe"; static char buf2[NSIS_MAX_STRLEN*2]; static char ibuf[NSIS_MAX_STRLEN]; @@ -171,7 +178,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, DeleteFile(buf2+1); // clean up after all the other ones if they are there - if (!done) + if (m_Err) // not done yet { // get current name int l=GetModuleFileName(g_hInstance,ibuf,sizeof(ibuf)); @@ -187,19 +194,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, #endif if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory); else trimslashtoend(ibuf); - done++; lstrcat(buf2,"\" "); lstrcat(buf2,realcmds); lstrcat(buf2," _?="); lstrcat(buf2,ibuf); + // add a trailing backslash to make sure is_valid_instpath will not fail when it shouldn't + lstrcat(buf2,"\\"); hProc=myCreateProcess(buf2,state_temp_dir); - if (hProc) CloseHandle(hProc); - else m_Err = _LANG_UNINSTINITERROR; + if (hProc) + { + CloseHandle(hProc); + // success + m_Err = 0; + } } } s[0]++; } - if (!done) m_Err = _LANG_UNINSTINITERROR; goto end; } } diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 827ccb95..5010e5b9 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -37,7 +37,9 @@ #define LB_ICONWIDTH 20 #define LB_ICONHEIGHT 20 +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT HICON g_hIcon; +#endif int dlg_offset; diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 65aee770..19ca8109 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -191,10 +191,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) Sleep(max(x,1)); } break; +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT case EW_BRINGTOFRONT: log_printf("BringToFront"); SetForegroundWindow(g_hwnd); break; +#endif//NSIS_CONFIG_VISIBLE_SUPPORT case EW_SETFLAG: g_exec_flags.flags[parm0]=GetIntFromParm(1); break; @@ -207,10 +209,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_GETFLAG: myitoa(var0,g_exec_flags.flags[parm1]); break; +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT case EW_CHDETAILSVIEW: if (insthwndbutton) ShowWindow(insthwndbutton,parm1); if (insthwnd) ShowWindow(insthwnd,parm0); break; +#endif//NSIS_CONFIG_VISIBLE_SUPPORT case EW_SETFILEATTRIBUTES: { char *buf1=GetStringFromParm(-0x10); log_printf3("SetFileAttributes: \"%s\":%08X",buf1,parm1); @@ -944,12 +948,16 @@ static int NSISCALL ExecuteEntry(entry *entry_) { void (*func)(HWND,int,char*,void*); func=(void*)funke; - func(g_hwnd,NSIS_MAX_STRLEN,(char*)g_usrvars, + func( + g_hwnd, + NSIS_MAX_STRLEN, + (char*)g_usrvars, #ifdef NSIS_SUPPORT_STACK - (void*)&g_st); + (void*)&g_st #else - NULL); -#endif + NULL +#endif//NSIS_SUPPORT_STACK + ); } } else diff --git a/Source/exehead/state.h b/Source/exehead/state.h index 3beff527..52a3822c 100644 --- a/Source/exehead/state.h +++ b/Source/exehead/state.h @@ -16,7 +16,13 @@ #endif extern char g_caption[NSIS_MAX_STRLEN*2]; +#ifdef NSIS_CONFIG_VISIBLE_SUPPORT extern HWND g_hwnd; extern HANDLE g_hInstance; extern HWND insthwnd,insthwndbutton; -extern HICON g_hIcon; \ No newline at end of file +extern HICON g_hIcon; +#else +#define g_hwnd 0 +#define g_hInstance 0 +#define g_hIcon 0 +#endif//NSIS_CONFIG_VISIBLE_SUPPORT \ No newline at end of file diff --git a/Source/exehead/util.c b/Source/exehead/util.c index f3e082c9..03425a38 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -40,8 +40,6 @@ char g_log_file[1024]; char *state_plugins_dir=g_usrvars[36]; #endif -HANDLE g_hInstance; - #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif