Improved Sunjammer's code

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@666 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-08-08 15:04:45 +00:00
parent 8976cc3e61
commit c3c52d4f4c
15 changed files with 178 additions and 206 deletions

View file

@ -1,5 +1,5 @@
!define VER_MAJOR 2 !define VER_MAJOR 2
!define VER_MINOR 0a4 !define VER_MINOR 0a5
!ifdef NO_COMPRESSION !ifdef NO_COMPRESSION
SetCompress off SetCompress off

View file

@ -1834,6 +1834,7 @@ void CEXEBuild::print_warnings()
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
void CEXEBuild::build_plugin_table(void) void CEXEBuild::build_plugin_table(void)
{ {
plugin_used = false;
char* nsisdir = definedlist.find("NSISDIR"); char* nsisdir = definedlist.find("NSISDIR");
if (nsisdir) if (nsisdir)
{ {

View file

@ -55,6 +55,7 @@ class CEXEBuild {
void build_plugin_table(void); void build_plugin_table(void);
#endif //NSIS_CONFIG_PLUGIN_SUPPORT #endif //NSIS_CONFIG_PLUGIN_SUPPORT
// process a script (you can process as many scripts as you want, // process a script (you can process as many scripts as you want,
// it is as if they are concatenated) // it is as if they are concatenated)
int process_script(FILE *fp, char *curfilename, int *lineptr); int process_script(FILE *fp, char *curfilename, int *lineptr);
@ -109,6 +110,7 @@ class CEXEBuild {
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
// Added by Ximon Eighteen 5th August 2002 // Added by Ximon Eighteen 5th August 2002
Plugins m_plugins; Plugins m_plugins;
bool plugin_used;
#endif //NSIS_CONFIG_PLUGIN_SUPPORT #endif //NSIS_CONFIG_PLUGIN_SUPPORT
// build.cpp functions used mostly within build.cpp // build.cpp functions used mostly within build.cpp

View file

@ -33,10 +33,6 @@
#include "ui.h" #include "ui.h"
#include "lang.h" #include "lang.h"
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
#include "dllpaths.h"
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
extern unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len); extern unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
#if !defined(NSIS_CONFIG_VISIBLE_SUPPORT) && !defined(NSIS_CONFIG_SILENT_SUPPORT) #if !defined(NSIS_CONFIG_VISIBLE_SUPPORT) && !defined(NSIS_CONFIG_SILENT_SUPPORT)
@ -62,6 +58,10 @@ HWND g_hwnd;
static int m_length; static int m_length;
static int m_pos; static int m_pos;
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
extern char plugins_temp_dir[NSIS_MAX_STRLEN];
#endif
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
#ifdef NSIS_CONFIG_CRC_SUPPORT #ifdef NSIS_CONFIG_CRC_SUPPORT
static BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@ -364,7 +364,9 @@ end:
if (m_Err) MessageBox(NULL,m_Err,g_caption,MB_OK|MB_ICONSTOP); if (m_Err) MessageBox(NULL,m_Err,g_caption,MB_OK|MB_ICONSTOP);
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
DllPathsCleanup(); // Clean up after plug-ins
MessageBox(0, plugins_temp_dir, "delete", MB_OK);
if (plugins_temp_dir[0]) doRMDir(plugins_temp_dir,1);
#endif // NSIS_CONFIG_PLUGIN_SUPPORT #endif // NSIS_CONFIG_PLUGIN_SUPPORT
ExitProcess(ret); ExitProcess(ret);

View file

@ -40,11 +40,13 @@
// Added by Amir Szekely 3rd August 2002 // Added by Amir Szekely 3rd August 2002
installer_strings *install_strings_tables; installer_strings *install_strings_tables;
common_strings *common_strings_tables;
uninstall_strings *uninstall_strings_tables;
installer_strings *cur_install_strings_table; installer_strings *cur_install_strings_table;
common_strings *common_strings_tables;
common_strings *cur_common_strings_table; common_strings *cur_common_strings_table;
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
uninstall_strings *uninstall_strings_tables;
uninstall_strings *cur_uninstall_strings_table; uninstall_strings *cur_uninstall_strings_table;
#endif
int g_quit_flag; // set when Quit has been called (meaning bail out ASAP) int g_quit_flag; // set when Quit has been called (meaning bail out ASAP)
@ -304,26 +306,32 @@ int ui_doinstall(void)
// Multilingual support // Multilingual support
char c=0; char c=0;
LANGID user_lang=GetUserDefaultLangID(); LANGID user_lang=GetUserDefaultLangID();
int size=g_inst_header->common.str_tables_num*sizeof(common_strings); int size=g_inst_header->str_tables_num*sizeof(common_strings);
cur_common_strings_table=common_strings_tables=(common_strings*)GlobalAlloc(GPTR,size); cur_common_strings_table=common_strings_tables=(common_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size); GetCompressedDataFromDataBlockToMemory(g_inst_header->common.str_tables,(char*)common_strings_tables,size);
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
if (!g_is_uninstaller) { if (!g_is_uninstaller) {
#endif
size=g_inst_header->str_tables_num*sizeof(installer_strings); size=g_inst_header->str_tables_num*sizeof(installer_strings);
cur_install_strings_table=install_strings_tables=(installer_strings*)GlobalAlloc(GPTR,size); cur_install_strings_table=install_strings_tables=(installer_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)install_strings_tables,size); GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)install_strings_tables,size);
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
} }
else { else {
size=g_inst_header->str_tables_num*sizeof(uninstall_strings); size=g_inst_uninstheader->str_tables_num*sizeof(uninstall_strings);
cur_uninstall_strings_table=uninstall_strings_tables=(uninstall_strings*)GlobalAlloc(GPTR,size); cur_uninstall_strings_table=uninstall_strings_tables=(uninstall_strings*)GlobalAlloc(GPTR,size);
GetCompressedDataFromDataBlockToMemory(g_inst_header->str_tables,(char*)uninstall_strings_tables,size); GetCompressedDataFromDataBlockToMemory(g_inst_uninstheader->str_tables,(char*)uninstall_strings_tables,size);
} }
#endif
lang_again: lang_again:
for (size=0; size<g_inst_header->str_tables_num; size++) { for (size=0; size<g_inst_header->str_tables_num; size++) {
if (user_lang == common_strings_tables[size].lang_id if (user_lang == common_strings_tables[size].lang_id
|| (c && PRIMARYLANGID(user_lang) == PRIMARYLANGID(common_strings_tables[size].lang_id))) { || (c && PRIMARYLANGID(user_lang) == PRIMARYLANGID(common_strings_tables[size].lang_id))) {
cur_install_strings_table = &install_strings_tables[size]; cur_install_strings_table = &install_strings_tables[size];
cur_common_strings_table = &common_strings_tables[size]; cur_common_strings_table = &common_strings_tables[size];
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
cur_uninstall_strings_table = &uninstall_strings_tables[size]; cur_uninstall_strings_table = &uninstall_strings_tables[size];
#endif
break; break;
} }
} }
@ -373,6 +381,7 @@ int ui_doinstall(void)
#ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_CODECALLBACKS
ExecuteCodeSegment(g_inst_entry,g_inst_cmnheader->code_onInstSuccess,NULL); ExecuteCodeSegment(g_inst_entry,g_inst_cmnheader->code_onInstSuccess,NULL);
#endif//NSIS_SUPPORT_CODECALLBACKS #endif//NSIS_SUPPORT_CODECALLBACKS
return 0; return 0;
} }
#endif//NSIS_CONFIG_SILENT_SUPPORT #endif//NSIS_CONFIG_SILENT_SUPPORT
@ -1138,20 +1147,23 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
int ui_st_updateflag=0x3; int ui_st_updateflag=0x3;
void update_status_text_from_tab(int texttab, const char *text2)
{
update_status_text(STR(texttab), text2);
}
void update_status_text(const char *text1, const char *text2) void update_status_text(const char *text1, const char *text2)
{ {
static LVITEM new_item = {LVIF_TEXT,}; static LVITEM new_item = {LVIF_TEXT,0,0,0,0,ps_tmpbuf};
RECT r; RECT r;
if (insthwnd) if (insthwnd)
{ {
if (lstrlen(text1)+lstrlen(text2) >= sizeof(ps_tmpbuf)) return; if (lstrlen(text1)+lstrlen(text2) >= sizeof(ps_tmpbuf)) return;
lstrcpy(ps_tmpbuf,text1); lstrcpy(ps_tmpbuf,text1);
lstrcat(ps_tmpbuf,text2); lstrcat(ps_tmpbuf,text2);
if ((ui_st_updateflag&1)) if ((ui_st_updateflag&1))
{ {
// Changed by Amir Szekely 26th July 2002 // Changed by Amir Szekely 26th July 2002
new_item.pszText=ps_tmpbuf;
new_item.iItem=ListView_GetItemCount(insthwnd); new_item.iItem=ListView_GetItemCount(insthwnd);
ListView_InsertItem(insthwnd, &new_item); ListView_InsertItem(insthwnd, &new_item);
ListView_EnsureVisible(insthwnd, new_item.iItem, 0); ListView_EnsureVisible(insthwnd, new_item.iItem, 0);
@ -1288,7 +1300,7 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
ShowWindow(g_hwnd,SW_SHOWNA); ShowWindow(g_hwnd,SW_SHOWNA);
lstrcpy(g_tmp,g_caption); lstrcpy(g_tmp,g_caption);
process_string_fromtab(g_tmp+lstrlen(g_caption),COMMON_STR(subcaptions[g_max_page+1])); process_string_fromtab(g_tmp+lstrlen(g_caption),COMMON_STR(subcaptions[g_max_page+1]));
update_status_text(STR(LANG_COMPLETED),""); update_status_text_from_tab(LANG_COMPLETED,"");
SetWindowText(h2,g_tmp); SetWindowText(h2,g_tmp);
SetFocus(h); SetFocus(h);
} }

View file

@ -9,10 +9,6 @@
#include "lang.h" #include "lang.h"
#include "resource.h" #include "resource.h"
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
#include "dllpaths.h"
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
#define EXEC_ERROR 0x7FFFFFFF #define EXEC_ERROR 0x7FFFFFFF
#ifdef NSIS_CONFIG_COMPONENTPAGE #ifdef NSIS_CONFIG_COMPONENTPAGE
@ -37,6 +33,11 @@ static int exec_rebootflag;
HBITMAP g_hBrandingBitmap = 0; HBITMAP g_hBrandingBitmap = 0;
#endif #endif
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
char plugins_temp_dir[NSIS_MAX_STRLEN]="";
char plugin[NSIS_MAX_STRLEN]="";
#endif
extern HWND m_curwnd; extern HWND m_curwnd;
static WIN32_FIND_DATA *file_exists(char *buf) static WIN32_FIND_DATA *file_exists(char *buf)
@ -52,46 +53,6 @@ static WIN32_FIND_DATA *file_exists(char *buf)
return NULL; return NULL;
} }
#ifdef NSIS_SUPPORT_RMDIR
static void doRMDir(char *buf, int recurse)
{
if (recurse && is_valid_instpath(buf))
{
int i=lstrlen(buf);
HANDLE h;
WIN32_FIND_DATA fd;
lstrcat(buf,"\\*.*");
h = FindFirstFile(buf,&fd);
if (h != INVALID_HANDLE_VALUE)
{
do
{
if (fd.cFileName[0] != '.' ||
(fd.cFileName[1] != '.' && fd.cFileName[1]))
{
lstrcpy(buf+i+1,fd.cFileName);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse);
else
{
update_status_text(STR(LANG_DELETEFILE),buf);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
SetFileAttributes(buf,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY);
DeleteFile(buf);
}
}
} while (FindNextFile(h,&fd));
FindClose(h);
}
buf[i]=0; // fix buffer
}
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
update_status_text(STR(LANG_REMOVEDIR),buf);
RemoveDirectory(buf);
}
#endif//NSIS_SUPPORT_RMDIR
#ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS #ifdef NSIS_SUPPORT_REGISTRYFUNCTIONS
// based loosely on code from Tim Kosse // based loosely on code from Tim Kosse
// in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys), // in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys),
@ -240,10 +201,10 @@ static int ExecuteEntry(entry *entries, int pos)
log_printf3("CreateDirectory: \"%s\" (%d)",buf2,parms[1]); log_printf3("CreateDirectory: \"%s\" (%d)",buf2,parms[1]);
if (parms[1]) if (parms[1])
{ {
update_status_text(STR(LANG_OUTPUTDIR),buf2); update_status_text_from_tab(LANG_OUTPUTDIR,buf2);
lstrcpy(state_output_directory,buf2); lstrcpy(state_output_directory,buf2);
} }
else update_status_text(STR(LANG_CREATEDIR),buf2); else update_status_text_from_tab(LANG_CREATEDIR,buf2);
recursive_create_directory(buf2); recursive_create_directory(buf2);
return 0; return 0;
case EW_IFFILEEXISTS: case EW_IFFILEEXISTS:
@ -279,7 +240,7 @@ static int ExecuteEntry(entry *entries, int pos)
log_printf2("Rename: %s",buf4); log_printf2("Rename: %s",buf4);
if (MoveFile(buf,buf2)) if (MoveFile(buf,buf2))
{ {
update_status_text(STR(LANG_RENAME),buf4); update_status_text_from_tab(LANG_RENAME,buf4);
} }
else else
{ {
@ -290,7 +251,7 @@ static int ExecuteEntry(entry *entries, int pos)
exec_rebootflag++; exec_rebootflag++;
#endif #endif
MoveFileOnReboot(buf,buf2); MoveFileOnReboot(buf,buf2);
update_status_text(STR(LANG_RENAMEONREBOOT),buf4); update_status_text_from_tab(LANG_RENAMEONREBOOT,buf4);
log_printf2("Rename on reboot: %s",buf4); log_printf2("Rename on reboot: %s",buf4);
} }
else else
@ -390,7 +351,7 @@ static int ExecuteEntry(entry *entries, int pos)
{ {
if (overwriteflag) if (overwriteflag)
{ {
update_status_text(STR(LANG_SKIPPED),buf4); update_status_text_from_tab(LANG_SKIPPED,buf4);
if (overwriteflag==2) exec_errorflag++; if (overwriteflag==2) exec_errorflag++;
log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf,overwriteflag); log_printf3("File: skipped: \"%s\" (overwriteflag=%d)",buf,overwriteflag);
return 0; return 0;
@ -413,12 +374,12 @@ static int ExecuteEntry(entry *entries, int pos)
return 0; return 0;
default: default:
log_printf("File: error, user abort"); log_printf("File: error, user abort");
update_status_text(STR(LANG_CANTWRITE),buf); update_status_text_from_tab(LANG_CANTWRITE,buf);
return EXEC_ERROR; return EXEC_ERROR;
} }
} }
update_status_text(STR(LANG_EXTRACT),buf4); update_status_text_from_tab(LANG_EXTRACT,buf4);
ret=GetCompressedDataFromDataBlock(parms[2],hOut); ret=GetCompressedDataFromDataBlock(parms[2],hOut);
log_printf3("File: wrote %d to \"%s\"",ret,buf); log_printf3("File: wrote %d to \"%s\"",ret,buf);
@ -468,7 +429,7 @@ static int ExecuteEntry(entry *entries, int pos)
if (DeleteFile(buf2)) if (DeleteFile(buf2))
{ {
log_printf2("Delete: DeleteFile(\"%s\")",buf2); log_printf2("Delete: DeleteFile(\"%s\")",buf2);
update_status_text(STR(LANG_DELETEFILE),buf2); update_status_text_from_tab(LANG_DELETEFILE,buf2);
} }
else else
{ {
@ -479,7 +440,7 @@ static int ExecuteEntry(entry *entries, int pos)
exec_rebootflag++; exec_rebootflag++;
#endif #endif
log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf2); log_printf2("Delete: DeleteFile on Reboot(\"%s\")",buf2);
update_status_text(STR(LANG_DELETEONREBOOT),buf2); update_status_text_from_tab(LANG_DELETEONREBOOT,buf2);
MoveFileOnReboot(buf2,NULL); MoveFileOnReboot(buf2,NULL);
} }
else else
@ -714,7 +675,7 @@ static int ExecuteEntry(entry *entries, int pos)
lstrcpy(buf4,buf); lstrcpy(buf4,buf);
lstrcat(buf4," "); lstrcat(buf4," ");
lstrcat(buf4,buf2); lstrcat(buf4,buf2);
update_status_text(STR(LANG_EXECSHELL), buf4); update_status_text_from_tab(LANG_EXECSHELL, buf4);
x=(int)ShellExecute(g_hwnd,buf[0]?buf:NULL,buf2,buf3[0]?buf3:NULL,state_output_directory,parms[3]); x=(int)ShellExecute(g_hwnd,buf[0]?buf:NULL,buf2,buf3[0]?buf3:NULL,state_output_directory,parms[3]);
if (x < 33) if (x < 33)
{ {
@ -734,7 +695,7 @@ static int ExecuteEntry(entry *entries, int pos)
HANDLE hProc; HANDLE hProc;
process_string_fromtab(buf,parms[0]); process_string_fromtab(buf,parms[0]);
log_printf2("Exec: command=\"%s\"",buf); log_printf2("Exec: command=\"%s\"",buf);
update_status_text(STR(LANG_EXECUTE),buf); update_status_text_from_tab(LANG_EXECUTE,buf);
hProc=myCreateProcess(buf,*state_output_directory?state_output_directory:NULL); hProc=myCreateProcess(buf,*state_output_directory?state_output_directory:NULL);
@ -831,6 +792,10 @@ static int ExecuteEntry(entry *entries, int pos)
if (hres == S_FALSE || hres == S_OK) if (hres == S_FALSE || hres == S_OK)
{ {
HANDLE h; HANDLE h;
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
if (!parms[0]) lstrcpy(buf,plugin);
else
#endif
process_string_fromtab(buf,parms[0]); process_string_fromtab(buf,parms[0]);
process_string_fromtab(buf2,parms[1]); process_string_fromtab(buf2,parms[1]);
@ -861,21 +826,21 @@ static int ExecuteEntry(entry *entries, int pos)
} }
else else
{ {
update_status_text(STR(LANG_CANNOTFINDSYMBOL),buf2); update_status_text_from_tab(LANG_CANNOTFINDSYMBOL,buf2);
log_printf3("Error registering DLL: %s not found in %s",buf2,buf); log_printf3("Error registering DLL: %s not found in %s",buf2,buf);
} }
FreeLibrary(h); FreeLibrary(h);
} }
else else
{ {
update_status_text(STR(LANG_COULDNOTLOAD),buf); update_status_text_from_tab(LANG_COULDNOTLOAD,buf);
log_printf2("Error registering DLL: Could not load %s",buf); log_printf2("Error registering DLL: Could not load %s",buf);
} }
OleUninitialize(); OleUninitialize();
} }
else else
{ {
update_status_text(STR(LANG_NOOLE),buf); update_status_text_from_tab(LANG_NOOLE,buf);
log_printf("Error registering DLL: Could not initialize OLE"); log_printf("Error registering DLL: Could not initialize OLE");
} }
} }
@ -895,11 +860,11 @@ static int ExecuteEntry(entry *entries, int pos)
state_output_directory,(parms[4]&0xff00)>>8,parms[4]>>16)) state_output_directory,(parms[4]&0xff00)>>8,parms[4]>>16))
{ {
exec_errorflag++; exec_errorflag++;
update_status_text(STR(LANG_ERRORCREATINGSHORTCUT),buf3); update_status_text_from_tab(LANG_ERRORCREATINGSHORTCUT,buf3);
} }
else else
{ {
update_status_text(STR(LANG_CREATESHORTCUT),buf3); update_status_text_from_tab(LANG_CREATESHORTCUT,buf3);
} }
return 0; return 0;
#endif//NSIS_SUPPORT_CREATESHORTCUT #endif//NSIS_SUPPORT_CREATESHORTCUT
@ -927,7 +892,7 @@ static int ExecuteEntry(entry *entries, int pos)
res=SHFileOperation(&op); res=SHFileOperation(&op);
if (res) if (res)
{ // some of these changes were from Edgewise (wiked_edge@yahoo.com) { // some of these changes were from Edgewise (wiked_edge@yahoo.com)
update_status_text(STR(LANG_COPYFAILED),""); update_status_text_from_tab(LANG_COPYFAILED,"");
exec_errorflag++; exec_errorflag++;
} }
} }
@ -1332,11 +1297,11 @@ static int ExecuteEntry(entry *entries, int pos)
log_printf3("created uninstaller: %d, \"%s\"",ret,buf2); log_printf3("created uninstaller: %d, \"%s\"",ret,buf2);
if (ret < 0) if (ret < 0)
{ {
update_status_text(STR(LANG_ERRORCREATING),buf); update_status_text_from_tab(LANG_ERRORCREATING,buf);
DeleteFile(buf2); DeleteFile(buf2);
} }
else else
update_status_text(STR(LANG_CREATEDUNINST),buf); update_status_text_from_tab(LANG_CREATEDUNINST,buf);
} }
return 0; return 0;
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT #endif//NSIS_CONFIG_UNINSTALL_SUPPORT
@ -1427,68 +1392,11 @@ static int ExecuteEntry(entry *entries, int pos)
// Added by Ximon Eighteen 5th August 2002 // Added by Ximon Eighteen 5th August 2002
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT #ifdef NSIS_CONFIG_PLUGIN_SUPPORT
case EW_PLUGINCOMMANDPREP: case EW_PLUGINCOMMANDPREP:
{ // parms[0] = dll name
// parms[0] - dll name
// parms[1] - function name
// parms[2] - compressed data handle
char* dllPath = DllPathsDetermined(parms[0]);
if (!dllPath)
{
HANDLE hOut;
if (!GetTempPath(NSIS_MAX_STRLEN,buf2) || if (!*plugins_temp_dir) lstrcpy(plugins_temp_dir,g_usrvars[0]);
!GetTempFileName(buf2,"nst",0,buf)) lstrcpy(plugin,plugins_temp_dir);
{ process_string_fromtab(plugin+lstrlen(plugins_temp_dir),parms[0]);
exec_errorflag++;
return 0;
}
hOut = myOpenFile(buf,GENERIC_WRITE,CREATE_ALWAYS);
GetCompressedDataFromDataBlock(parms[2],hOut);
CloseHandle(hOut);
DllPathsAdd(parms[0],buf);
}
else
lstrcpy(buf,dllPath);
// leave buf containing the dll path
// and buf2 containing the function name
process_string_fromtab(buf2,parms[1]);
}
return 0;
case EW_PLUGINCOMMAND:
{
// parms contain command arguments
FARPROC funke;
HANDLE h;
int i;
// Place the command arguments on the stack, then invoke a CallInstDLL
// command on behalf of the user. Error handling needs improving, this
// won't fail gracefully, instead it could leave the stack in a state
// the user script won't expect.
for (i = 0; parms[i] != -1 && i < MAX_ENTRY_OFFSETS; i++)
{
stack_t* s = (stack_t*)GlobalAlloc(GPTR,sizeof(stack_t));
process_string_fromtab(s->text,parms[i]);
s->next = g_st;
g_st = s;
}
h = LoadLibrary(buf);
if (h)
{
funke = GetProcAddress(h,buf2);
if (funke)
{
void (*func)(HWND,int,char*,void*);
func = (void*)funke;
func(g_hwnd,NSIS_MAX_STRLEN,(char*)g_usrvars,(void*)&g_st);
}
FreeLibrary(h);
}
}
return 0; return 0;
#endif // NSIS_CONFIG_PLUGIN_SUPPORT #endif // NSIS_CONFIG_PLUGIN_SUPPORT
} }

View file

@ -152,10 +152,6 @@ SOURCE=..\crc32.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\dllpaths.c
# End Source File
# Begin Source File
SOURCE=.\exec.c SOURCE=.\exec.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -184,10 +180,6 @@ SOURCE=.\config.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\dllpaths.h
# End Source File
# Begin Source File
SOURCE=.\exec.h SOURCE=.\exec.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -152,10 +152,6 @@ SOURCE=..\crc32.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\dllpaths.c
# End Source File
# Begin Source File
SOURCE=.\exec.c SOURCE=.\exec.c
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -122,8 +122,7 @@ enum
EW_GETLABELADDR, // both of these get converted to EW_ASSIGNVAR EW_GETLABELADDR, // both of these get converted to EW_ASSIGNVAR
EW_GETFUNCTIONADDR, EW_GETFUNCTIONADDR,
EW_PLUGINCOMMANDPREP, EW_PLUGINCOMMANDPREP
EW_PLUGINCOMMAND
}; };
@ -225,7 +224,6 @@ typedef struct
// Settings common to both installers and uninstallers // Settings common to both installers and uninstallers
typedef struct typedef struct
{ {
int str_tables_num; // number of strings tables in array
int str_tables; // offset to tables array int str_tables; // offset to tables array
int num_entries; // total number of entries int num_entries; // total number of entries

View file

@ -7,6 +7,7 @@ extern common_strings *cur_common_strings_table;
extern uninstall_strings *cur_uninstall_strings_table; extern uninstall_strings *cur_uninstall_strings_table;
int ui_doinstall(void); int ui_doinstall(void);
void update_status_text_from_tab(int texttab, const char *text2);
void update_status_text(const char *text1, const char *text2); void update_status_text(const char *text1, const char *text2);
extern int ui_st_updateflag; extern int ui_st_updateflag;

View file

@ -3,6 +3,7 @@
#include "util.h" #include "util.h"
#include "state.h" #include "state.h"
#include "config.h" #include "config.h"
#include "lang.h"
#include "fileform.h" #include "fileform.h"
#include "ui.h" #include "ui.h"
@ -26,6 +27,43 @@ HANDLE myCreateProcess(char *cmd, char *dir)
return ProcInfo.hProcess; return ProcInfo.hProcess;
} }
#ifdef NSIS_SUPPORT_RMDIR
void doRMDir(char *buf, int recurse)
{
if (recurse && is_valid_instpath(buf))
{
int i=lstrlen(buf);
HANDLE h;
WIN32_FIND_DATA fd;
lstrcat(buf,"\\*.*");
h = FindFirstFile(buf,&fd);
if (h != INVALID_HANDLE_VALUE)
{
do
{
if (fd.cFileName[0] != '.' ||
(fd.cFileName[1] != '.' && fd.cFileName[1]))
{
lstrcpy(buf+i+1,fd.cFileName);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) doRMDir(buf,recurse);
else
{
update_status_text_from_tab(LANG_DELETEFILE,buf);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
SetFileAttributes(buf,fd.dwFileAttributes^FILE_ATTRIBUTE_READONLY);
DeleteFile(buf);
}
}
} while (FindNextFile(h,&fd));
FindClose(h);
}
buf[i]=0; // fix buffer
}
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
update_status_text_from_tab(LANG_REMOVEDIR,buf);
RemoveDirectory(buf);
}
#endif//NSIS_SUPPORT_RMDIR
void addtrailingslash(char *str) void addtrailingslash(char *str)
{ {

View file

@ -10,7 +10,6 @@ void myRegGetStr(HKEY root, const char *sub, const char *name, char *out);
int myatoi(char *s); int myatoi(char *s);
void myitoa(char *s, int d); void myitoa(char *s, int d);
#ifdef NSIS_CONFIG_LOG #ifdef NSIS_CONFIG_LOG
extern char log_text[NSIS_MAX_STRLEN*4]; extern char log_text[NSIS_MAX_STRLEN*4];
void log_write(int close); void log_write(int close);
@ -34,6 +33,8 @@ extern char g_log_file[1024];
#endif #endif
HANDLE myCreateProcess(char *cmd, char *dir); HANDLE myCreateProcess(char *cmd, char *dir);
void doRMDir(char *buf, int recurse);
HANDLE myOpenFile(const char *fn, DWORD da, DWORD cd); HANDLE myOpenFile(const char *fn, DWORD da, DWORD cd);
int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey); int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey);

View file

@ -202,7 +202,6 @@ int CEXEBuild::WriteStringTables() {
GrowBuf cst; GrowBuf cst;
for (i = 0; i < st_num; i++) for (i = 0; i < st_num; i++)
cst.add(&string_tables[i]->common, sizeof(common_strings)); cst.add(&string_tables[i]->common, sizeof(common_strings));
build_header.common.str_tables_num = st_num;
build_header.common.str_tables = add_data((char*)cst.get(), st_num*sizeof(common_strings), &build_datablock); build_header.common.str_tables = add_data((char*)cst.get(), st_num*sizeof(common_strings), &build_datablock);
GrowBuf ust; GrowBuf ust;
@ -214,7 +213,6 @@ int CEXEBuild::WriteStringTables() {
GrowBuf ucst; GrowBuf ucst;
for (i = 0; i < st_num; i++) for (i = 0; i < st_num; i++)
ucst.add(&string_tables[i]->ucommon, sizeof(common_strings)); ucst.add(&string_tables[i]->ucommon, sizeof(common_strings));
build_uninst.common.str_tables_num = st_num;
build_uninst.common.str_tables = add_data((char*)ucst.get(), st_num*sizeof(common_strings), &ubuild_datablock); build_uninst.common.str_tables = add_data((char*)ucst.get(), st_num*sizeof(common_strings), &ubuild_datablock);
return PS_OK; return PS_OK;

View file

@ -1,4 +1,4 @@
const char *NSIS_VERSION="v2.0a4"; const char *NSIS_VERSION="v2.0a5";
/* /*
Nullsoft "SuperPimp" Installation System - makensis.cpp - installer compiler code Nullsoft "SuperPimp" Installation System - makensis.cpp - installer compiler code

View file

@ -3296,20 +3296,53 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
return PS_ERROR; return PS_ERROR;
case TOK__PLUGINCOMMAND: case TOK__PLUGINCOMMAND:
{ {
if (line.getnumtokens()-1 > MAX_ENTRY_OFFSETS) static int zero_offset;
{ if (!zero_offset) zero_offset=add_string("$0");
ERROR_MSG("Error: Too many arguments (%d max) to command %s!\n",MAX_ENTRY_OFFSETS,line.gettoken_str(0)); int ret;
return PS_ERROR;
}
char* dllPath = m_plugins.GetPluginDll(line.gettoken_str(0)); char* dllPath = m_plugins.GetPluginDll(line.gettoken_str(0));
if (dllPath) if (dllPath)
{ {
if (!plugin_used) {
// If no plugin was called up until now init the plugin stuff
// Push $0
ent.which=EW_PUSHPOP;
ent.offsets[0]=zero_offset;
ent.offsets[1]=0;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
// Get temp file name
ent.which=EW_GETTEMPFILENAME;
ent.offsets[0]=0; // $0
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
// Delete the temp file created
ent.which=EW_DELETEFILE;
ent.offsets[0]=zero_offset;
ent.offsets[1]=0;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
// Craete a dir instead of that temp file
ent.which=EW_CREATEDIR;
ent.offsets[0]=zero_offset;
ent.offsets[1]=0;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
}
// Make DLL name (on user machine)
ent.which=EW_PLUGINCOMMANDPREP;
ent.offsets[0]=add_string(strrchr(dllPath,'\\'));
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
// Add the DLL if not already added
int dataHandle = m_plugins.GetDllDataHandle(dllPath); int dataHandle = m_plugins.GetDllDataHandle(dllPath);
if (dataHandle == -1) if (dataHandle == -1)
{ {
int error; int error;
if (PS_OK != (error = do_add_file(dllPath,0,0,-1,&dataHandle,0))) char file[NSIS_MAX_STRLEN];
wsprintf(file,"$0\\%s",strrchr(dllPath,'\\')+1);
if (PS_OK != (error = do_add_file(dllPath,0,0,0,&dataHandle,file)))
{ {
ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath); ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath);
return error; return error;
@ -3318,35 +3351,43 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
m_plugins.StoreDllDataHandle(line.gettoken_str(0),dataHandle); m_plugins.StoreDllDataHandle(line.gettoken_str(0),dataHandle);
} }
// Create the runtime command to execute the custom instruction if (!plugin_used) {
// Strip any dllname.dll:: signature part off the command // Pop $0
ent.which=EW_PUSHPOP;
ent.offsets[0]=0; // $0
ent.offsets[1]=1;
ent.offsets[2]=0;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
}
plugin_used = true;
// Finally call the DLL
char* command = strstr(line.gettoken_str(0),"::"); char* command = strstr(line.gettoken_str(0),"::");
if (command) command += 2; if (command) command += 2;
else command = line.gettoken_str(0); else command = line.gettoken_str(0);
ent.which = EW_PLUGINCOMMANDPREP;
ent.offsets[0] = add_string(dllPath);
ent.offsets[1] = add_string(command);
ent.offsets[2] = dataHandle;
add_entry(&ent);
SCRIPT_MSG("Plugin Command: %s",command); SCRIPT_MSG("Plugin Command: %s",command);
ent.which = EW_PLUGINCOMMAND;
for (int i = 0; i < MAX_ENTRY_OFFSETS && i+1 < line.getnumtokens(); i++) // First push dll args
{ for (int i = 1; i < line.getnumtokens(); i++) {
ent.offsets[i] = add_string(line.gettoken_str(i+1)); ent.which=EW_PUSHPOP;
SCRIPT_MSG(" %s",line.gettoken_str(i+1)); ent.offsets[0]=add_string(line.gettoken_str(i));
ent.offsets[1]=0;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
SCRIPT_MSG(" %s",line.gettoken_str(i));
} }
SCRIPT_MSG("\n"); SCRIPT_MSG("\n");
// since the runtime code won't know how many arguments to expect (why // next, call it
// should it, an arbitrary command is being executed so it has no way ent.which=EW_REGISTERDLL;
// of knowing) if it's less than the max ent.offsets[0]=0;
if (i < MAX_ENTRY_OFFSETS) ent.offsets[1]=add_string(command);
ent.offsets[i] = -1; ent.offsets[2]=-1;
ret=add_entry(&ent);
if (ret != PS_OK) return ret;
return add_entry(&ent); return PS_OK;
} }
else else
ERROR_MSG("Error: Plugin dll for command \"%s\" not found.\n",line.gettoken_str(0)); ERROR_MSG("Error: Plugin dll for command \"%s\" not found.\n",line.gettoken_str(0));
@ -3368,9 +3409,6 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
return PS_ERROR; return PS_ERROR;
} }
// If linecnt == -1 no decompress command will be created in the installer,
// instead some action during execution of the installer should cause the file
// to be decompressed manually - Ximon Eighteen 5th August 2002
int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override) int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override)
{ {
char dir[1024]; char dir[1024];
@ -3503,9 +3541,6 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
section_add_size_kb((len+1023)/1024); section_add_size_kb((len+1023)/1024);
if (name_override) SCRIPT_MSG("File: \"%s\"->\"%s\"",d.cFileName,name_override); if (name_override) SCRIPT_MSG("File: \"%s\"->\"%s\"",d.cFileName,name_override);
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
else if (linecnt == -1) SCRIPT_MSG("File: Auto included \"%s\"",d.cFileName);
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
else SCRIPT_MSG("File: \"%s\"",d.cFileName); else SCRIPT_MSG("File: \"%s\"",d.cFileName);
if (!build_compress_whole) if (!build_compress_whole)
if (build_compress) SCRIPT_MSG(" [compress]"); if (build_compress) SCRIPT_MSG(" [compress]");
@ -3574,23 +3609,11 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
CloseHandle(hFile); CloseHandle(hFile);
int a; int a=add_entry(&ent);
// Only insert a EW_EXTRACTFILE command into the installer for this if (a != PS_OK)
// file if linecnt is NOT -1. This has nothing to do with line counts
// - linecnt was just a handy value to use since this function doesn't
// appear to be using it anywhere else for anything :-)
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
if (-1 == linecnt)
*total_files = ent.offsets[2];
else
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
{ {
a=add_entry(&ent); FindClose(h);
if (a != PS_OK) return a;
{
FindClose(h);
return a;
}
} }
if (attrib) if (attrib)
{ {