System::Call can call exports by ordinal with dll::#123 syntax

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6420 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-12-09 01:17:55 +00:00
parent f9fae88303
commit 18c0cbe3ec
2 changed files with 14 additions and 3 deletions

View file

@ -465,7 +465,12 @@ SystemProc *PrepareProc(BOOL NeedForCall)
switch (*ib) switch (*ib)
{ {
case 0x0: SectionType = -1; break; case 0x0: SectionType = -1; break;
case _T('#'): SectionType = PST_PROC; ProcType = PT_NOTHING; break; case _T('#'): // "...#" redefines proc unless preceded by ":", then it's an ordinal (dll::#123)
if (ib <= ibuf || *(ib-1) != _T(':') || PST_PROC != SectionType)
SectionType = PST_PROC, ProcType = PT_NOTHING;
else
changed = FALSE;
break;
case _T('('): case _T('('):
SectionType = PST_PARAMS; SectionType = PST_PARAMS;
// fake-real parameter: for COM interfaces first param is Interface Pointer // fake-real parameter: for COM interfaces first param is Interface Pointer
@ -862,6 +867,12 @@ SystemProc *PrepareProc(BOOL NeedForCall)
// Get proc address // Get proc address
proc->Proc = NSISGetProcAddress(proc->Dll, proc->ProcName); proc->Proc = NSISGetProcAddress(proc->Dll, proc->ProcName);
if (!proc->Proc && *proc->ProcName == _T('#'))
{
int ordinal = myatoi(proc->ProcName+1);
if (ordinal && IS_INTRESOURCE(ordinal))
proc->Proc = GetProcAddress(proc->Dll, MAKEINTRESOURCEA(ordinal));
}
if (UsedTString || !proc->Proc) if (UsedTString || !proc->Proc)
{ {
FARPROC tproc; FARPROC tproc;
@ -876,7 +887,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
if (tproc) if (tproc)
proc->Proc = tproc; proc->Proc = tproc;
else else
proc->ProcResult = PR_ERROR; if (!proc->Proc) proc->ProcResult = PR_ERROR;
} }
} }
break; break;

View file

@ -187,7 +187,7 @@ DetailPrint $4
<p><i>PARAMS</i>, <i>RETURN</i> and <i>OPTIONS</i> can be repeated many times in one Get/Call line. When repeating, a lot can be omitted, and only what you wish to change can be used. <i>Type</i>, <i>source</i> and/or <i>destination</i> can be omitted for each parameter, even the return value. Options can be added or removed. This allows you to define function prototypes and save on some typing. The <a href="#repeat">last two examples</a> show this.</p> <p><i>PARAMS</i>, <i>RETURN</i> and <i>OPTIONS</i> can be repeated many times in one Get/Call line. When repeating, a lot can be omitted, and only what you wish to change can be used. <i>Type</i>, <i>source</i> and/or <i>destination</i> can be omitted for each parameter, even the return value. Options can be added or removed. This allows you to define function prototypes and save on some typing. The <a href="#repeat">last two examples</a> show this.</p>
<p><i>PROC</i> can also be repeated but must be prefixed with a hash sign (`#').</p> <p><i>PROC</i> can also be repeated but must be prefixed with a hash sign (`#') except if the hash sign is preceded by a double colon (<code>shell32::#18</code>).</p>
<h4>Possible <i>PROC</i> Values and Meanings</h4> <h4>Possible <i>PROC</i> Values and Meanings</h4>