diff --git a/Source/build.cpp b/Source/build.cpp index 01940fcc..1c0b9a92 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -328,6 +328,7 @@ int CEXEBuild::preprocess_string(char *out, const char *in) "WINDIR\0" // 32 "SYSDIR\0" // 33 "LANGUAGE\0" // 34 + "PLUGINSDIR\0" // 35 ; const char *p=in; diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index c5adaf20..c84ab6e4 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -789,10 +789,6 @@ static int ExecuteEntry(entry *entries, int pos) if (hres == S_FALSE || hres == S_OK) { HANDLE h; -#ifdef NSIS_CONFIG_PLUGIN_SUPPORT - if (!parms[0]) lstrcpy(buf,plugin); - else -#endif process_string_fromtab(buf,parms[0]); process_string_fromtab(buf2,parms[1]); @@ -1390,8 +1386,6 @@ static int ExecuteEntry(entry *entries, int pos) // parms[0] = dll name if (!*plugins_temp_dir) lstrcpy(plugins_temp_dir,g_usrvars[0]); - lstrcpy(plugin,plugins_temp_dir); - process_string_fromtab(plugin+lstrlen(plugins_temp_dir),parms[0]); return 0; #endif // NSIS_CONFIG_PLUGIN_SUPPORT } diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 46c8b01f..5a03eefc 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -416,7 +416,7 @@ int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut); int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len); // $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value. -#define VAR_CODES_START (256 - 36) +#define VAR_CODES_START (256 - 37) #endif //_FILEFORM_H_ diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 18484498..0aa178b4 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -12,6 +12,10 @@ char g_log_file[1024]; #endif +#ifdef NSIS_CONFIG_PLUGIN_SUPPORT +extern char plugins_temp_dir[NSIS_MAX_STRLEN]; +#endif + char g_usrvars[24][NSIS_MAX_STRLEN]; HANDLE g_hInstance; @@ -497,6 +501,10 @@ void process_string(char *out, const char *in) wsprintf(out, "%u", cur_install_strings_table->lang_id); break; + case VAR_CODES_START + 35: // PLUGINSDIR + lstrcpy(out, plugins_temp_dir); + break; + #if VAR_CODES_START + 34 >= 255 #error "Too many variables! Extend VAR_CODES_START!" #endif diff --git a/Source/script.cpp b/Source/script.cpp index a4fe8074..b09fab5b 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -3328,30 +3328,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char 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 - if (!m_plugins.IsDLLStored(strrchr(dllPath,'\\')+1)) - { - int error; - int files_added; - char file[NSIS_MAX_STRLEN]; - wsprintf(file,"$0\\%s",strrchr(dllPath,'\\')+1); - if (PS_OK != (error = do_add_file(dllPath,0,0,0,&files_added,file))) - { - ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath); - return error; - } - - m_plugins.DLLStored(strrchr(dllPath,'\\')+1); - } - - if (!plugin_used) { + // 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 @@ -3359,8 +3339,28 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char 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 + char tempDLL[NSIS_MAX_STRLEN]; + wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\')); + int tempDLLtab = add_string(tempDLL); + + // Add the DLL if not already added + if (!m_plugins.IsDLLStored(strrchr(dllPath,'\\')+1)) + { + 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); } - plugin_used = true; // Finally call the DLL char* command = strstr(line.gettoken_str(0),"::"); @@ -3381,7 +3381,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char // next, call it ent.which=EW_REGISTERDLL; - ent.offsets[0]=0; + ent.offsets[0]=tempDLLtab; ent.offsets[1]=add_string(command); ent.offsets[2]=-1; ret=add_entry(&ent);