- Plug-in command can now come in any order in the script
- Second plug-in DLL doesn't produce errors anymore - Infinite loop bug fixed (again) git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@678 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
bc6494155b
commit
0b31694486
8 changed files with 153 additions and 83 deletions
|
@ -1,5 +1,5 @@
|
||||||
!define VER_MAJOR 2
|
!define VER_MAJOR 2
|
||||||
!define VER_MINOR 0a5
|
!define VER_MINOR 0a6
|
||||||
|
|
||||||
!ifdef NO_COMPRESSION
|
!ifdef NO_COMPRESSION
|
||||||
SetCompress off
|
SetCompress off
|
||||||
|
|
|
@ -113,9 +113,9 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
|
||||||
char *name = (char*)exports + names[j] - ExportDirVA;
|
char *name = (char*)exports + names[j] - ExportDirVA;
|
||||||
wsprintf(signature, "%s::%s", dllName, name);
|
wsprintf(signature, "%s::%s", dllName, name);
|
||||||
m_commands.add(signature, pathToDll);
|
m_commands.add(signature, pathToDll);
|
||||||
DLL newDll = {new char[lstrlen(dllName)], false};
|
char *dll = new char[lstrlen(dllName)];
|
||||||
lstrcpy(newDll.name, dllName);
|
lstrcpy(dll, dllName);
|
||||||
m_storedDLLs.push_back(newDll);
|
m_storedDLLs.push_back(dll);
|
||||||
if (displayInfo)
|
if (displayInfo)
|
||||||
fprintf(g_output, " - %s\n", signature);
|
fprintf(g_output, " - %s\n", signature);
|
||||||
}
|
}
|
||||||
|
@ -156,22 +156,32 @@ char* Plugins::GetPluginDll(char* command)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugins::DLLStored(char* dllName)
|
void Plugins::StoreInstDLL(char* dllName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_storedDLLs.size(); i++) {
|
for (int i = 0; i < m_installDLLs.size(); i++)
|
||||||
if (!strcmp(m_storedDLLs[i].name, dllName)) {
|
if (!strcmp(m_installDLLs[i], dllName))
|
||||||
m_storedDLLs[i].stored = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
m_installDLLs.push_back(strdup(dllName));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plugins::IsDLLStored(char* dllName)
|
void Plugins::StoreUninstDLL(char* dllName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_storedDLLs.size(); i++)
|
for (int i = 0; i < m_uninstallDLLs.size(); i++)
|
||||||
if (!strcmp(m_storedDLLs[i].name, dllName))
|
if (!strcmp(m_uninstallDLLs[i], dllName))
|
||||||
return m_storedDLLs[i].stored;
|
return;
|
||||||
return false;
|
m_uninstallDLLs.push_back(strdup(dllName));
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Plugins::GetInstDLL(int i)
|
||||||
|
{
|
||||||
|
if (i >= 0 && i < m_installDLLs.size()) return m_installDLLs[i];
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Plugins::GetUninstDLL(int i)
|
||||||
|
{
|
||||||
|
if (i >= 0 && i < m_uninstallDLLs.size()) return m_uninstallDLLs[i];
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -9,23 +9,22 @@
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct DLL {
|
|
||||||
char *name;
|
|
||||||
bool stored;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Plugins
|
class Plugins
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void FindCommands(char*,bool);
|
void FindCommands(char*,bool);
|
||||||
bool IsPluginCommand(char*);
|
bool IsPluginCommand(char*);
|
||||||
char* GetPluginDll(char*);
|
char* GetPluginDll(char*);
|
||||||
void DLLStored(char*);
|
void StoreInstDLL(char*);
|
||||||
bool IsDLLStored(char*);
|
void StoreUninstDLL(char*);
|
||||||
|
char* GetInstDLL(int);
|
||||||
|
char* GetUninstDLL(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DefineList m_commands;
|
DefineList m_commands;
|
||||||
std::vector<DLL> m_storedDLLs;
|
std::vector<char*> m_storedDLLs;
|
||||||
|
std::vector<char*> m_installDLLs;
|
||||||
|
std::vector<char*> m_uninstallDLLs;
|
||||||
|
|
||||||
void GetExports(char*,bool);
|
void GetExports(char*,bool);
|
||||||
};
|
};
|
||||||
|
|
101
Source/build.cpp
101
Source/build.cpp
|
@ -1054,6 +1054,12 @@ int CEXEBuild::write_output(void)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
// Added by Amir Szekely 9th August 2002
|
||||||
|
int err=add_plugin_initializer();
|
||||||
|
if (err != PS_OK) return err;
|
||||||
|
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
|
||||||
// Added by Amir Szekely 3rd August 2002
|
// Added by Amir Szekely 3rd August 2002
|
||||||
if (WriteStringTables() == PS_ERROR) return PS_ERROR;
|
if (WriteStringTables() == PS_ERROR) return PS_ERROR;
|
||||||
|
|
||||||
|
@ -1849,4 +1855,99 @@ void CEXEBuild::build_plugin_table(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEXEBuild::add_plugin_initializer(void)
|
||||||
|
{
|
||||||
|
if (!plugin_used) return PS_OK;
|
||||||
|
|
||||||
|
SCRIPT_MSG("Adding plug-ins initializing function...\n");
|
||||||
|
|
||||||
|
bool uninstall = false;
|
||||||
|
|
||||||
|
int ret, i;
|
||||||
|
entry ent;
|
||||||
|
int zero_offset;
|
||||||
|
|
||||||
|
ret=add_function("Initialize_____Plugins");
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
again:
|
||||||
|
zero_offset=add_string("$0");
|
||||||
|
// StrCmp $PLUGINSDIR ""
|
||||||
|
ent.which=EW_STRCMP;
|
||||||
|
ent.offsets[0]=add_string("$PLUGINSDIR");
|
||||||
|
ent.offsets[1]=add_string("");
|
||||||
|
ent.offsets[2]=0;
|
||||||
|
ent.offsets[3]=ns_label.add("Initialize_____Plugins_done",0);
|
||||||
|
ret=add_entry(&ent);
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
// 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;
|
||||||
|
// Copy $0 to $PLUGINSDIR
|
||||||
|
ent.which=EW_PLUGINCOMMANDPREP;
|
||||||
|
ret=add_entry(&ent);
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
int files_added;
|
||||||
|
if (uninstall) {
|
||||||
|
char* dll;
|
||||||
|
for (i = 0; dll = m_plugins.GetUninstDLL(i); i++) {
|
||||||
|
char tempPath[NSIS_MAX_STRLEN];
|
||||||
|
wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\'));
|
||||||
|
ret=do_add_file(dll,0,0,0,&files_added,tempPath);
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char* dll;
|
||||||
|
for (i = 0; dll = m_plugins.GetInstDLL(i); i++) {
|
||||||
|
char tempPath[NSIS_MAX_STRLEN];
|
||||||
|
wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\'));
|
||||||
|
ret=do_add_file(dll,0,0,0,&files_added,tempPath);
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (add_label("Initialize_____Plugins_done")) return PS_ERROR;
|
||||||
|
|
||||||
|
ret=function_end();
|
||||||
|
if (ret != PS_OK) return ret;
|
||||||
|
|
||||||
|
if (uninstaller_writes_used && !uninstall) {
|
||||||
|
add_function("un.Initialize_____Plugins");
|
||||||
|
uninstall = true;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPT_MSG("Done!\n");
|
||||||
|
|
||||||
|
return PS_OK;
|
||||||
|
}
|
||||||
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
|
@ -85,6 +85,11 @@ class CEXEBuild {
|
||||||
int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0);
|
int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0);
|
||||||
GrowBuf m_linebuild; // used for concatenating lines
|
GrowBuf m_linebuild; // used for concatenating lines
|
||||||
|
|
||||||
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
// Added by Amir Szekely 9th August 2002
|
||||||
|
int add_plugin_initializer(void);
|
||||||
|
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
|
||||||
void ERROR_MSG(const char *s, ...);
|
void ERROR_MSG(const char *s, ...);
|
||||||
void SCRIPT_MSG(const char *s, ...);
|
void SCRIPT_MSG(const char *s, ...);
|
||||||
void INFO_MSG(const char *s, ...);
|
void INFO_MSG(const char *s, ...);
|
||||||
|
|
|
@ -300,7 +300,7 @@ int ui_doinstall(void)
|
||||||
{
|
{
|
||||||
// Added by Amir Szekely 3rd August 2002
|
// Added by Amir Szekely 3rd August 2002
|
||||||
// Multilingual support
|
// Multilingual support
|
||||||
char pa=1;
|
char pa=0;
|
||||||
int num=g_inst_header->str_tables_num;
|
int num=g_inst_header->str_tables_num;
|
||||||
LANGID user_lang=GetUserDefaultLangID();
|
LANGID user_lang=GetUserDefaultLangID();
|
||||||
int size=num*sizeof(common_strings);
|
int size=num*sizeof(common_strings);
|
||||||
|
@ -327,14 +327,14 @@ lang_again:
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
cur_uninstall_strings_table+=size;
|
cur_uninstall_strings_table+=size;
|
||||||
#endif
|
#endif
|
||||||
pa--;
|
pa++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
common_strings_tables[size].lang_id&=0x3ff; // primary lang
|
common_strings_tables[size].lang_id&=0x3ff; // primary lang
|
||||||
}
|
}
|
||||||
if (pa) {
|
if (!pa) {
|
||||||
user_lang&=0x3ff; // primary lang
|
user_lang&=0x3ff; // primary lang
|
||||||
pa--;
|
pa++;
|
||||||
goto lang_again;
|
goto lang_again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const char *NSIS_VERSION="v2.0a5";
|
const char *NSIS_VERSION="v2.0a6";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Nullsoft "SuperPimp" Installation System - makensis.cpp - installer compiler code
|
Nullsoft "SuperPimp" Installation System - makensis.cpp - installer compiler code
|
||||||
|
|
|
@ -3296,71 +3296,26 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
case TOK__PLUGINCOMMAND:
|
case TOK__PLUGINCOMMAND:
|
||||||
{
|
{
|
||||||
static int zero_offset;
|
|
||||||
if (!zero_offset) zero_offset=add_string("$0");
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
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) {
|
plugin_used = true;
|
||||||
// If no plugin was called up until now init the plugin stuff
|
|
||||||
// Push $0
|
ent.which=EW_CALL;
|
||||||
ent.which=EW_PUSHPOP;
|
ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0);
|
||||||
ent.offsets[0]=zero_offset;
|
ret=add_entry(&ent);
|
||||||
ent.offsets[1]=0;
|
if (ret != PS_OK) return ret;
|
||||||
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;
|
|
||||||
// Copy $0 to $PLUGINSDIR
|
|
||||||
ent.which=EW_PLUGINCOMMANDPREP;
|
|
||||||
ret=add_entry(&ent);
|
|
||||||
if (ret != PS_OK) return ret;
|
|
||||||
// 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;
|
|
||||||
// We need to do all of this only once
|
|
||||||
plugin_used = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DLL name on the user machine
|
// DLL name on the user machine
|
||||||
char tempDLL[NSIS_MAX_STRLEN];
|
char tempDLL[NSIS_MAX_STRLEN];
|
||||||
wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\'));
|
wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\'));
|
||||||
int tempDLLtab = add_string(tempDLL);
|
int tempDLLtab = add_string(tempDLL);
|
||||||
|
|
||||||
// Add the DLL if not already added
|
// Store the DLL
|
||||||
if (!m_plugins.IsDLLStored(strrchr(dllPath,'\\')+1))
|
if (uninstall_mode) m_plugins.StoreUninstDLL(dllPath);
|
||||||
{
|
else m_plugins.StoreInstDLL(dllPath);
|
||||||
int error;
|
|
||||||
int files_added;
|
|
||||||
if (PS_OK != (error = do_add_file(dllPath,0,0,0,&files_added,tempDLL)))
|
|
||||||
{
|
|
||||||
ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_plugins.DLLStored(strrchr(dllPath,'\\')+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally call the DLL
|
// Finally call the DLL
|
||||||
char* command = strstr(line.gettoken_str(0),"::");
|
char* command = strstr(line.gettoken_str(0),"::");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue