Implemented :: syntax to specify which dll contains the comamd to run (in cases where more than one dll has the same command, OR the command is the same name as a built-in command)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@652 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
sunjammerx 2002-08-05 20:40:14 +00:00
parent caa131db8c
commit f79499a946
2 changed files with 35 additions and 10 deletions

View file

@ -147,7 +147,6 @@ void Plugins::FindCommands(char* path,bool displayInfo)
{
WIN32_FIND_DATA data;
HANDLE handle;
char* slashPtr;
if (path[length-1] == '\\' ||
path[length-1] == '/')
@ -191,6 +190,7 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
long dlldatalen = 0;
bool loaded = false;
char dllName[100];
char signature[256];
dllName[0] = 0;
char* ptr = strrchr(pathToDll,'\\');
@ -296,9 +296,12 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
for (unsigned long i = 0; i < exports->NumberOfNamePointers; i++)
{
char* namePointer = (char*)(ptr+(*nameTableEntry)-section->VirtualAddress);
m_commands.add(namePointer,pathToDll);
strcpy(signature,dllName);
strcat(signature,"::");
strcat(signature,namePointer);
m_commands.add(signature,pathToDll);
if (displayInfo)
fprintf(g_output," - %s::%s\n",dllName,namePointer);
fprintf(g_output," - %s\n",signature);
nameTableEntry++;
}
}
@ -324,13 +327,30 @@ bool Plugins::IsPluginCommand(char* token)
char* Plugins::GetPluginDll(char* command)
{
return m_commands.find(command);
if (strstr(command,"::"))
return m_commands.find(command);
// slow & stupid but it doesn't matter
int i = 0,pos = 0;
char* signatures = m_commands.defines.get();
while (pos != -1)
{
pos = m_commands.defines.idx2pos(i++);
if (pos >= 0)
{
char* cmd = strstr(signatures+pos,"::");
if (cmd && strcmp(cmd+2,command) == 0)
return m_commands.find(signatures+pos);
}
}
return 0;
}
void Plugins::StoreDllDataHandle(char* command,int handle)
void Plugins::StoreDllDataHandle(char* signature,int handle)
{
int idx = -1;
m_commands.defines.find(command,0,&idx);
m_commands.defines.find(signature,0,&idx);
if (idx > -1)
{
m_dataHandles.reserve(idx+1);
@ -338,10 +358,10 @@ void Plugins::StoreDllDataHandle(char* command,int handle)
}
}
int Plugins::GetDllDataHandle(char* command)
int Plugins::GetDllDataHandle(char* signature)
{
int idx = -1;
if (-1 != m_commands.defines.find(command,0,&idx))
if (-1 != m_commands.defines.find(signature,0,&idx))
return m_dataHandles[idx];
return -1;
}

View file

@ -3226,13 +3226,18 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
// Create the runtime command to execute the custom instruction
// Strip any dllname.dll:: signature part off the command
char* command = strstr(line.gettoken_str(0),"::");
if (command) command += 2;
else command = line.gettoken_str(0);
ent.which = EW_PLUGINCOMMANDPREP;
ent.offsets[0] = add_string(dllPath);
ent.offsets[1] = add_string(line.gettoken_str(0));
ent.offsets[1] = add_string(command);
ent.offsets[2] = dataHandle;
add_entry(&ent);
SCRIPT_MSG("Plugin Command: %s",line.gettoken_str(0));
SCRIPT_MSG("Plugin Command: %s",command);
ent.which = EW_PLUGINCOMMAND;
for (int i = 0; i < MAX_ENTRY_OFFSETS && i+1 < line.getnumtokens(); i++)