Added System plug-in B and H types
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6954 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
e3e6ee73bc
commit
ebfe3bf6d2
4 changed files with 42 additions and 21 deletions
|
@ -283,7 +283,7 @@ SystemProc* CallBack(SystemProc *proc)
|
|||
proc->ProcResult = PR_ERROR;
|
||||
return proc;
|
||||
}
|
||||
#endif // ~_WIN64
|
||||
#endif //~ _WIN64
|
||||
|
||||
|
||||
PLUGINFUNCTION(Call)
|
||||
|
@ -631,7 +631,10 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
|||
case _T('@'): temp2 = PAT_REGMEM; break;
|
||||
case _T('v'):
|
||||
case _T('V'): temp2 = PAT_VOID; break;
|
||||
|
||||
case 'B': // INT8/BYTE/BOOLEAN
|
||||
case 'b': temp2 = PAT_INT, temp = sizeof(BYTE) + 1; break;
|
||||
case 'H': // INT16/WORD/SHORT: 'h' AKA printf type length specifier
|
||||
case 'h': temp2 = PAT_INT, temp = sizeof(WORD) + 1; break;
|
||||
#ifndef _WIN64
|
||||
case _T('p'):
|
||||
#endif
|
||||
|
@ -1017,11 +1020,16 @@ void ParamsDeAllocate(SystemProc *proc)
|
|||
}
|
||||
}
|
||||
|
||||
#define GetSpecialParamTypeSize(pPP) ( (((pPP)->Option)-1) * ByteSizeByType[(pPP)->Type] )
|
||||
static const int g_intmask[4] = { 0xFFFFFFFF, 0x000000FF, 0x0000FFFF, 0x00FFFFFF };
|
||||
#define GetMaskedInt32Value(val, size) ( (val) & g_intmask[(((size) >= 0) && ((size) < 4))?((size)):(0)] )
|
||||
#define GetSpecialParamInt32Value(pPP, size) GetMaskedInt32Value((pPP)->Value, (size))
|
||||
|
||||
void ParamsOut(SystemProc *proc)
|
||||
{
|
||||
INT_PTR *place;
|
||||
LPWSTR wstr;
|
||||
int i;
|
||||
int i, intval, typsiz;
|
||||
TCHAR *realbuf = AllocString();
|
||||
|
||||
i = proc->ParamCount;
|
||||
|
@ -1043,7 +1051,13 @@ void ParamsOut(SystemProc *proc)
|
|||
case PAT_REGMEM:
|
||||
#endif
|
||||
case PAT_INT:
|
||||
wsprintf(realbuf, _T("%d"), (int)(*((INT_PTR*) place)));
|
||||
intval = (int)(*((INT_PTR*) place));
|
||||
if (proc->Params[i].Option > 0) // Note: We don't handle '*' pointers, "*h" and "*b" are not supported, use "*i" even on smaller types
|
||||
{
|
||||
typsiz = GetSpecialParamTypeSize(&proc->Params[i]);
|
||||
intval = GetMaskedInt32Value(intval, typsiz);
|
||||
}
|
||||
wsprintf(realbuf, _T("%d"), intval);
|
||||
break;
|
||||
#ifdef _WIN64
|
||||
case PAT_REGMEM:
|
||||
|
@ -1056,7 +1070,7 @@ void ParamsOut(SystemProc *proc)
|
|||
MultiByteToWideChar(CP_ACP, 0, *((char**) place), g_stringsize, realbuf, g_stringsize-1);
|
||||
realbuf[g_stringsize-1] = _T('\0'); // make sure we have a null terminator
|
||||
#else
|
||||
lstrcpyn(realbuf,*((TCHAR**) place), g_stringsize); // note: lstrcpyn always include a null terminator (unlike strncpy)
|
||||
lstrcpyn(realbuf,*((TCHAR**) place), g_stringsize); // note: lstrcpyn always includes a null terminator (unlike strncpy)
|
||||
#endif
|
||||
break;
|
||||
case PAT_GUID:
|
||||
|
@ -1181,7 +1195,7 @@ void CallStruct(SystemProc *proc)
|
|||
if (proc->Params[i].Option < 1)
|
||||
structsize += proc->Params[i].Size * 4;
|
||||
else
|
||||
structsize += ByteSizeByType[proc->Params[i].Type] * (proc->Params[i].Option - 1);
|
||||
structsize += GetSpecialParamTypeSize(&proc->Params[i]);
|
||||
}
|
||||
|
||||
// Struct exists?
|
||||
|
@ -1215,10 +1229,8 @@ void CallStruct(SystemProc *proc)
|
|||
}
|
||||
else
|
||||
{
|
||||
static const int intmask[4] = {0xFFFFFFFF, 0x000000FF, 0x0000FFFF, 0x00FFFFFF};
|
||||
|
||||
// Special
|
||||
size = (proc->Params[i].Option-1) * ByteSizeByType[proc->Params[i].Type];
|
||||
size = GetSpecialParamTypeSize(&proc->Params[i]);
|
||||
ptr = NULL;
|
||||
switch (proc->Params[i].Type)
|
||||
{
|
||||
|
@ -1231,8 +1243,7 @@ void CallStruct(SystemProc *proc)
|
|||
#endif
|
||||
ssflag = TRUE; // System::Call '*(...,&l.r0)'
|
||||
case PAT_INT:
|
||||
// clear unused value bits
|
||||
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
|
||||
proc->Params[i].Value = GetSpecialParamInt32Value(&proc->Params[i], size); // clears unused value bits
|
||||
// pointer
|
||||
ptr = (char*) &(proc->Params[i].Value);
|
||||
break;
|
||||
|
|
|
@ -157,9 +157,9 @@ extern void ParamsOut(SystemProc *proc);
|
|||
#ifdef SYSTEM_AMD64
|
||||
extern SystemProc* CallProc2(SystemProc *proc, UINT_PTR ParamCount);
|
||||
#define CallProc(p) CallProc2((p), (p)->ParamCount) // ParamCount is passed as a parameter so CallProc2 can determine the required stack size without a function call
|
||||
#else // !SYSTEM_AMD64
|
||||
#else //! SYSTEM_AMD64
|
||||
extern SystemProc* CallProc(SystemProc *proc);
|
||||
#endif // ~SYSTEM_AMD64
|
||||
#endif //~ SYSTEM_AMD64
|
||||
#ifndef SYSTEM_NOCALLBACKS
|
||||
extern SystemProc* CallBack(SystemProc *proc);
|
||||
extern SystemProc* RealCallBack();
|
||||
|
|
|
@ -254,12 +254,20 @@ DetailPrint $4
|
|||
<td>pointer (and other pointer sized types like handles and HWNDs)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>b</th>
|
||||
<td>int8, byte</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>h</th>
|
||||
<td>int16, short</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>i</th>
|
||||
<td>int (includes char, byte, short and so on)</td>
|
||||
<td>int32 (includes char, byte, short and so on when used as a pointer)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>l</th>
|
||||
<td>large integer, int64</td>
|
||||
<td>int64, large integer</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>m</th>
|
||||
|
@ -299,22 +307,22 @@ DetailPrint $4
|
|||
</tr>
|
||||
<tr>
|
||||
<th>&t<i>N</i></th>
|
||||
<td>array of <i>N</i> text characters TCHAR (structures only)</td>
|
||||
<td>array of <i>N</i> TCHAR text characters (structures only)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>&m<i>N</i></th>
|
||||
<td>array of <i>N</i> ANSI characters CHAR (structures only)</td>
|
||||
<td>array of <i>N</i> CHAR ANSI characters (structures only)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>&w<i>N</i></th>
|
||||
<td>array of <i>N</i> Unicode characters WCHAR (structures only)</td>
|
||||
<td>array of <i>N</i> WCHAR Unicode characters (structures only)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>&g<i>N</i></th>
|
||||
<td><i>N</i> bytes of GUID (structures only)</td>
|
||||
<th>&g<i>16</i></th>
|
||||
<td><i>16</i> bytes of GUID (structures only)</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Additionally, each type can be prefixed with an asterisk to denote a pointer. When using an asterisk, the System plug-in still expects the value of the parameter, rather than the pointer's address. To pass a direct address, use `p' with no asterisk. A <a href="#pointer">usage example</a> is available. <a href="#memfuncs">Alloc</a> returns addresses and its return value should therefore be used with `p', without an asterisk.</p>
|
||||
<p>Additionally, each type (except <i>b</i>, <i>h</i>, <i>k</i> and <i>@</i>) can be prefixed with an asterisk to denote a pointer. When using an asterisk, the System plug-in still expects the value of the parameter, rather than the pointer's address. To pass a direct address, use `p' with no asterisk. A <a href="#pointer">usage example</a> is available. <a href="#memfuncs">Alloc</a> returns addresses and its return value should therefore be used with `p', without an asterisk.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4>Available Sources and Destinations</h4>
|
||||
|
|
|
@ -20,6 +20,8 @@ Released on ??? ??rd, 20??
|
|||
|
||||
\S2{} Minor Changes
|
||||
|
||||
\b Added System plug-in B and H types
|
||||
|
||||
\b Added \R{intptrcmp}{IntPtrCmp}, IntPtrCmpU, and \R{intptrop}{IntPtrOp}
|
||||
|
||||
\b Added Int64Cmp, Int64CmpU and Int64Fmt (64-bit only)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue