Added System::Call direct register memory access type

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6505 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-06-27 14:27:32 +00:00
parent d43e3a717c
commit 2fb86bfa29
6 changed files with 47 additions and 22 deletions

View file

@ -15,8 +15,10 @@
#define popintptr system_popintptr
#ifdef _WIN64
# define StrToIntPtr(str) ( (INT_PTR)myatoi64((str)) )
# define IntPtrToStr(p,buf) myitoa64((p),(buf))
#else
# define StrToIntPtr(str) ( (INT_PTR)myatoi((str)) )
# define IntPtrToStr(p,buf) myitoa64((p),(buf))
#endif
#define BUGBUG64(brokencast) (brokencast) // Cast that needs fixing on x64
@ -36,7 +38,8 @@
extern TCHAR *AllocStr(TCHAR *str);
extern void myitoa64(__int64 i, TCHAR *buffer);
extern TCHAR *AllocString();
extern TCHAR *system_getuservariable(int varnum);
#define system_getuservariableptr(varnum) ( (g_variables)+(varnum)*(g_stringsize) )
extern TCHAR *system_getuservariable(int varnum); // NOTE: This dupes with GlobalAlloc!
extern TCHAR *system_setuservariable(int varnum, TCHAR *var);
extern TCHAR* system_popstring(); // NULL - stack empty
extern TCHAR* system_pushstring(TCHAR *str);

View file

@ -31,24 +31,28 @@
#define PCD_DONE 3 // Just Continue
const int PARAMSIZEBYTYPE_PTR = (4==sizeof(void*)) ? 1 : 2;
const int ParamSizeByType[7] = {
static const int ParamSizeByType[8] = {
0, // PAT_VOID (Size will be equal to 1) //BUGBUG64?
1, // PAT_INT
2, // PAT_LONG
sizeof(void*) / 4, // PAT_STRING //BUGBUG64?
sizeof(void*) / 4, // PAT_WSTRING //BUGBUG64?
sizeof(void*) / 4, // PAT_GUID //BUGBUG64?
0}; // PAT_CALLBACK (Size will be equal to 1) //BUGBUG64?
0, // PAT_CALLBACK (Size will be equal to 1) //BUGBUG64?
1 // PAT_REGMEM
};
// Thomas needs to look at this.
static const int ByteSizeByType[7] = {
static const int ByteSizeByType[8] = {
1, // PAT_VOID
1, // PAT_INT
1, // PAT_LONG
1, // PAT_STRING
2, // PAT_WSTRING (special case for &wN notation: N is a number of WCHAR, not a number of bytes)
1, // PAT_GUID
1}; // PAT_CALLBACK
1, // PAT_CALLBACK
1 // PAT_REGMEM
};
int LastStackPlace;
int LastStackReal;
@ -648,6 +652,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
temp = -1; break; // Pointer parameter option
// Types
case _T('@'): temp2 = PAT_REGMEM; break;
case _T('v'):
case _T('V'): temp2 = PAT_VOID; break;
@ -996,6 +1001,12 @@ void ParamsIn(SystemProc *proc)
if (lstrlen(realbuf) > 0)
par->Value = (INT_PTR) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
break;
case PAT_REGMEM:
(LPTSTR)place = system_getuservariableptr(par->Input - 1);
par->Value = (INT_PTR) place;
par->Value += sizeof(void*) > 4 ? sizeof(_T("-9223372036854775807")) : sizeof(_T("-2147483647"));
IntPtrToStr(par->Value, (LPTSTR)place);
break;
}
GlobalFree(realbuf);
@ -1051,9 +1062,15 @@ void ParamsOut(SystemProc *proc)
case PAT_VOID:
*realbuf = _T('\0');
break;
#ifndef _WIN64
case PAT_REGMEM:
#endif
case PAT_INT:
wsprintf(realbuf, _T("%d"), (int)(*((INT_PTR*) place)));
break;
#ifdef _WIN64
case PAT_REGMEM:
#endif
case PAT_LONG:
myitoa64(*((__int64*) place), realbuf);
break;

View file

@ -52,6 +52,7 @@
#define PAT_WSTRING 4
#define PAT_GUID 5
#define PAT_CALLBACK 6
#define PAT_REGMEM 7
#ifdef _UNICODE
#define PAT_TSTRING PAT_WSTRING
#else