Sunjammer's code is now fully optimized
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@668 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9a6e21556f
commit
93a5fa4c1c
3 changed files with 26 additions and 20 deletions
|
@ -111,8 +111,11 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
|
||||||
for (unsigned long j = 0; j < exports->NumberOfNames; j++)
|
for (unsigned long j = 0; j < exports->NumberOfNames; j++)
|
||||||
{
|
{
|
||||||
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};
|
||||||
|
lstrcpy(newDll.name, dllName);
|
||||||
|
m_storedDLLs.push_back(newDll);
|
||||||
if (displayInfo)
|
if (displayInfo)
|
||||||
fprintf(g_output, " - %s\n", signature);
|
fprintf(g_output, " - %s\n", signature);
|
||||||
}
|
}
|
||||||
|
@ -153,23 +156,22 @@ char* Plugins::GetPluginDll(char* command)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugins::StoreDllDataHandle(char* signature,int handle)
|
void Plugins::DLLStored(char* dllName)
|
||||||
{
|
{
|
||||||
int idx = -1;
|
for (int i = 0; i < m_storedDLLs.size(); i++) {
|
||||||
m_commands.defines.find(signature,0,&idx);
|
if (!strcmp(m_storedDLLs[i].name, dllName)) {
|
||||||
if (idx > -1)
|
m_storedDLLs[i].stored = true;
|
||||||
{
|
return;
|
||||||
m_dataHandles.reserve(idx+1);
|
}
|
||||||
m_dataHandles[idx] = handle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Plugins::GetDllDataHandle(char* signature)
|
bool Plugins::IsDLLStored(char* dllName)
|
||||||
{
|
{
|
||||||
int idx = -1;
|
for (int i = 0; i < m_storedDLLs.size(); i++)
|
||||||
if (-1 != m_commands.defines.find(signature,0,&idx))
|
if (!strcmp(m_storedDLLs[i].name, dllName))
|
||||||
return m_dataHandles[idx];
|
return m_storedDLLs[i].stored;
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -9,6 +9,10 @@
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct DLL {
|
||||||
|
char *name;
|
||||||
|
bool stored;
|
||||||
|
};
|
||||||
|
|
||||||
class Plugins
|
class Plugins
|
||||||
{
|
{
|
||||||
|
@ -16,12 +20,12 @@ class Plugins
|
||||||
void FindCommands(char*,bool);
|
void FindCommands(char*,bool);
|
||||||
bool IsPluginCommand(char*);
|
bool IsPluginCommand(char*);
|
||||||
char* GetPluginDll(char*);
|
char* GetPluginDll(char*);
|
||||||
int GetDllDataHandle(char*);
|
void DLLStored(char*);
|
||||||
void StoreDllDataHandle(char*,int);
|
bool IsDLLStored(char*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DefineList m_commands;
|
DefineList m_commands;
|
||||||
std::vector<int> m_dataHandles;
|
std::vector<DLL> m_storedDLLs;
|
||||||
|
|
||||||
void GetExports(char*,bool);
|
void GetExports(char*,bool);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3336,19 +3336,19 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
||||||
if (ret != PS_OK) return ret;
|
if (ret != PS_OK) return ret;
|
||||||
|
|
||||||
// Add the DLL if not already added
|
// Add the DLL if not already added
|
||||||
int dataHandle = m_plugins.GetDllDataHandle(dllPath);
|
if (!m_plugins.IsDLLStored(strrchr(dllPath,'\\')+1))
|
||||||
if (dataHandle == -1)
|
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
int files_added;
|
||||||
char file[NSIS_MAX_STRLEN];
|
char file[NSIS_MAX_STRLEN];
|
||||||
wsprintf(file,"$0\\%s",strrchr(dllPath,'\\')+1);
|
wsprintf(file,"$0\\%s",strrchr(dllPath,'\\')+1);
|
||||||
if (PS_OK != (error = do_add_file(dllPath,0,0,0,&dataHandle,file)))
|
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);
|
ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_plugins.StoreDllDataHandle(line.gettoken_str(0),dataHandle);
|
m_plugins.DLLStored(strrchr(dllPath,'\\')+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin_used) {
|
if (!plugin_used) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue