System: Minor x64 fixes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6260 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2012-09-10 22:56:41 +00:00
parent 2d99d7ad3e
commit 59be675382
2 changed files with 24 additions and 21 deletions

View file

@ -37,7 +37,8 @@ const int ParamSizeByType[7] = {
1, // PAT_STRING 1, // PAT_STRING
1, // PAT_WSTRING 1, // PAT_WSTRING
1, // PAT_GUID 1, // PAT_GUID
0}; // PAT_CALLBACK (Size will be equal to 1) 0}; // PAT_CALLBACK (Size will be equal to 1) //BUGBUG64?
const int PARAMSIZEBYTYPE_PTR = (4==sizeof(void*)) ? 1 : 2;
// Thomas needs to look at this. // Thomas needs to look at this.
const int ByteSizeByType[7] = { const int ByteSizeByType[7] = {
@ -48,7 +49,7 @@ const int ByteSizeByType[7] = {
2, // PAT_WSTRING (special case for &wN notation: N is a number of WCHAR, not a number of bytes) 2, // PAT_WSTRING (special case for &wN notation: N is a number of WCHAR, not a number of bytes)
1, // PAT_GUID 1, // PAT_GUID
1}; // PAT_CALLBACK 1}; // PAT_CALLBACK
int LastStackPlace; int LastStackPlace;
int LastStackReal; int LastStackReal;
DWORD LastError; DWORD LastError;
@ -58,7 +59,7 @@ CallbackThunk* CallbackThunkListHead;
HINSTANCE g_hInstance; HINSTANCE g_hInstance;
// Return to callback caller with stack restore // Return to callback caller with stack restore
char retexpr[4]; char retexpr[4]; //BUGBUG64?
HANDLE retaddr; HANDLE retaddr;
TCHAR *GetResultStr(SystemProc *proc) TCHAR *GetResultStr(SystemProc *proc)
@ -189,7 +190,7 @@ void * NSISGetProcAddress(HMODULE dllHandle, TCHAR* funcName)
#ifdef _UNICODE #ifdef _UNICODE
char* ansiName = NULL; char* ansiName = NULL;
int len; int len;
void* funcPtr = NULL; void* funcPtr;
len = WideCharToMultiByte(CP_ACP, 0, funcName, -1, ansiName, 0, NULL, NULL); len = WideCharToMultiByte(CP_ACP, 0, funcName, -1, ansiName, 0, NULL, NULL);
ansiName = (char*) GlobalAlloc(GPTR, len); ansiName = (char*) GlobalAlloc(GPTR, len);
@ -410,7 +411,8 @@ SystemProc *PrepareProc(BOOL NeedForCall)
ProcType = PT_NOTHING, // Default proc spec ProcType = PT_NOTHING, // Default proc spec
ChangesDone = 0, ChangesDone = 0,
ParamIndex = 0, ParamIndex = 0,
temp = 0, temp2, temp3, temp4; temp = 0, temp2, temp3;
INT_PTR temp4;
BOOL param_defined = FALSE; BOOL param_defined = FALSE;
SystemProc *proc = NULL; SystemProc *proc = NULL;
TCHAR *ibuf, *ib, *sbuf, *cbuf, *cb; TCHAR *ibuf, *ib, *sbuf, *cbuf, *cb;
@ -627,10 +629,10 @@ SystemProc *PrepareProc(BOOL NeedForCall)
case _T('.'): temp3++; break; // skip specifier case _T('.'): temp3++; break; // skip specifier
case _T('R'): case _T('R'):
temp4 = ((int) GetIntFromString(&ib))+1; temp4 = ((INT_PTR) GetIntFromString(&ib))+1;
if (temp4 < 11) temp4 += 10; if (temp4 < 11) temp4 += 10;
break; break;
case _T('r'): temp4 = ((int) GetIntFromString(&ib))+1; break; // Register case _T('r'): temp4 = ((INT_PTR) GetIntFromString(&ib))+1; break; // Register
case _T('-'): case _T('-'):
case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'): case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
@ -647,7 +649,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
{ {
ib--; ib--;
// It's stupid, I know, but I'm too lazy to do another thing // It's stupid, I know, but I'm too lazy to do another thing
myitoa64(GetIntFromString(&(ib)),(TCHAR *)(temp4 = BUGBUG64(int) AllocString())); myitoa64(GetIntFromString(&(ib)),(TCHAR *)(temp4 = (INT_PTR) AllocString()));
} }
break; break;
@ -664,7 +666,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
} }
// finish and save // finish and save
*cb = 0; *cb = 0;
temp4 = BUGBUG64(int) AllocStr(cbuf); temp4 = (INT_PTR) AllocStr(cbuf);
} }
break; break;
@ -685,10 +687,11 @@ SystemProc *PrepareProc(BOOL NeedForCall)
// Param type changed? // Param type changed?
if (temp2 != -1) if (temp2 != -1)
{ {
const int psbt = ParamSizeByType[temp2];
param_defined = TRUE; param_defined = TRUE;
proc->Params[ParamIndex].Type = temp2; proc->Params[ParamIndex].Type = temp2;
proc->Params[ParamIndex].Size = // If pointer, then 1, else by type proc->Params[ParamIndex].Size = // Pointer sized or from type
(temp == -1)?(1):((ParamSizeByType[temp2]>0)?(ParamSizeByType[temp2]):(1)); (temp == -1)?(PARAMSIZEBYTYPE_PTR):((psbt>0)?(psbt):(1)); //BUGBUG64: Is it safe to fallback to 1 for CALLBACK?
// Get the parameter real special option value // Get the parameter real special option value
if (temp == 1) temp = ((int) GetIntFromString(&ib)) + 1; if (temp == 1) temp = ((int) GetIntFromString(&ib)) + 1;
proc->Params[ParamIndex].Option = temp; proc->Params[ParamIndex].Option = temp;
@ -787,7 +790,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
case PT_VTABLEPROC: case PT_VTABLEPROC:
{ {
// Use direct system proc address // Use direct system proc address
int addr; INT_PTR addr;
proc->Dll = (HMODULE) StrToIntPtr(proc->DllName); proc->Dll = (HMODULE) StrToIntPtr(proc->DllName);
@ -797,20 +800,20 @@ SystemProc *PrepareProc(BOOL NeedForCall)
break; break;
} }
addr = (int) proc->Dll; addr = (INT_PTR) proc->Dll;
// fake-real parameter: for COM interfaces first param is Interface Pointer // fake-real parameter: for COM interfaces first param is Interface Pointer
proc->Params[1].Output = IOT_NONE; proc->Params[1].Output = IOT_NONE;
proc->Params[1].Input = BUGBUG64(int) AllocStr(proc->DllName); proc->Params[1].Input = BUGBUG64(int) AllocStr(proc->DllName);
proc->Params[1].Size = 1; proc->Params[1].Size = PARAMSIZEBYTYPE_PTR;
proc->Params[1].Type = PAT_INT; proc->Params[1].Type = PAT_PTR;
proc->Params[1].Option = 0; proc->Params[1].Option = 0;
// addr - pointer to interface vtable // addr - pointer to interface vtable
addr = *(BUGBUG64(int *)addr); addr = *((INT_PTR *)addr);
// now addr contains the pointer to first item at VTABLE // now addr contains the pointer to first item at VTABLE
// add the index of proc // add the index of proc
addr = addr + (int)(myatoi64(proc->ProcName)*4); //BUGBUG: sizeof(void*) on x64? addr = addr + (INT_PTR)(myatoi64(proc->ProcName)*sizeof(void*));
proc->Proc = *((HANDLE*)addr); proc->Proc = *((HANDLE*)addr);
} }
break; break;
@ -1129,7 +1132,7 @@ void CallStruct(SystemProc *proc)
} }
if (proc->Params[i].Option < 1) if (proc->Params[i].Option < 1)
structsize += proc->Params[i].Size * 4; //BUGBUG: Does this have to be sizeof(void*)? structsize += proc->Params[i].Size * 4;
else else
structsize += ByteSizeByType[proc->Params[i].Type] * (proc->Params[i].Option - 1); structsize += ByteSizeByType[proc->Params[i].Type] * (proc->Params[i].Option - 1);
} }
@ -1160,7 +1163,7 @@ void CallStruct(SystemProc *proc)
if (proc->Params[i].Option < 1) if (proc->Params[i].Option < 1)
{ {
// Normal // Normal
size = proc->Params[i].Size*4; //BUGBUG: sizeof(void*) on x64? size = proc->Params[i].Size*4;
ptr = (char*) &(proc->Params[i].Value); ptr = (char*) &(proc->Params[i].Value);
} }
else else
@ -1169,7 +1172,6 @@ void CallStruct(SystemProc *proc)
// Special // Special
size = (proc->Params[i].Option-1) * ByteSizeByType[proc->Params[i].Type]; size = (proc->Params[i].Option-1) * ByteSizeByType[proc->Params[i].Type];
ptr = NULL; ptr = NULL;
switch (proc->Params[i].Type) switch (proc->Params[i].Type)
{ {
@ -1178,7 +1180,7 @@ void CallStruct(SystemProc *proc)
// real structure size // real structure size
proc->Params[i].Value = structsize; proc->Params[i].Value = structsize;
proc->Params[i]._value = 0; proc->Params[i]._value = 0;
ssflag = TRUE; ssflag = TRUE; //Why does this have to be set?
case PAT_INT: case PAT_INT:
// clear unused value bits // clear unused value bits
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)]; proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];

View file

@ -52,6 +52,7 @@
#else #else
#define PAT_TSTRING PAT_STRING #define PAT_TSTRING PAT_STRING
#endif #endif
#define PAT_PTR ( (4==sizeof(void*)) ? PAT_INT : PAT_LONG )
// Input/Output Source/Destination // Input/Output Source/Destination
#define IOT_NONE 0 #define IOT_NONE 0