Initial groundwork for ARM64 support
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7001 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
bca384e691
commit
460b3f59a9
11 changed files with 101 additions and 51 deletions
|
@ -191,7 +191,9 @@ extern "C" BOOL APIENTRY DllMain(HINSTANCE _hModule, DWORD ul_reason_for_call,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#endif
|
||||
|
||||
int MulDiv64(int nNumber, __int64 nNumerator, __int64 nDenominator)
|
||||
{
|
||||
|
|
|
@ -77,13 +77,18 @@ void myitoa64(__int64 i, char *buffer)
|
|||
// Visual Studio 2015 (CLv19 x86) and some older versions of CLv14 x64 will optimize
|
||||
// our loop into a direct call to _memset and this fails to link because we don't use the CRT
|
||||
#if defined(_MSC_VER) && _MSC_VER+0 >= 1400
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER+0 >= 140050727
|
||||
#include <intrin.h>
|
||||
#else
|
||||
EXTERN_C void __stosb(BYTE*,BYTE,size_t);
|
||||
#endif //~ _MSC_FULL_VER >= 140050727
|
||||
#pragma intrinsic(__stosb)
|
||||
#define CRTINTRINSIC_memset(p,c,s) __stosb((BYTE*)(p),(BYTE)(c),(s))
|
||||
# if defined(_MSC_FULL_VER) && _MSC_FULL_VER+0 >= 140050727
|
||||
# include <intrin.h>
|
||||
# else
|
||||
EXTERN_C void __stosb(BYTE*,BYTE,size_t);
|
||||
# endif //~ _MSC_FULL_VER >= 140050727
|
||||
# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) // __stosb not available under _M_ARM nor _M_ARM64
|
||||
# pragma intrinsic(__stosb)
|
||||
# define CRTINTRINSIC_memset(p,c,s) __stosb((BYTE*)(p),(BYTE)(c),(s))
|
||||
# elif defined(_M_ARM) || defined(_M_ARM64) // For _MSC_VER=1914 (VS 15.7.27703.2026/CL 19.14.26430)
|
||||
EXTERN_C void* __cdecl memset(void *d, int v, size_t l) { char *p=(char*)d; while (l-- > 0) *p++=v; return d; }
|
||||
# pragma function(memset)
|
||||
# endif
|
||||
#endif //~ _MSC_VER
|
||||
|
||||
void mini_memset(void *o,char i,int l)
|
||||
|
|
|
@ -289,6 +289,32 @@ PLUGINFUNCTION(Get)
|
|||
} PLUGINFUNCTIONEND
|
||||
|
||||
|
||||
#ifdef SYSTEM_ARM64
|
||||
/*
|
||||
TODO: CallProc not implemeted.
|
||||
Fake the behavior of the System plugin for the LoadImage API function so MUI works.
|
||||
BUGBUG: MUI is leaking DeleteObject and failing GetClientRect
|
||||
*/
|
||||
SystemProc* CallProc(SystemProc *proc)
|
||||
{
|
||||
INT_PTR ret, *place;
|
||||
int cmp = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA"));
|
||||
if (!cmp)
|
||||
{
|
||||
ret = (INT_PTR) LoadImage((HINSTANCE)proc->Params[1].Value,
|
||||
(LPCTSTR)proc->Params[2].Value, (UINT)proc->Params[3].Value,
|
||||
(int)proc->Params[4].Value, (int)proc->Params[5].Value,
|
||||
(UINT)proc->Params[6].Value);
|
||||
LastError = GetLastError();
|
||||
}
|
||||
else
|
||||
proc->ProcResult = PR_ERROR, ret = 0, LastError = ERROR_INVALID_FUNCTION;
|
||||
place = (INT_PTR*) proc->Params[0].Value;
|
||||
if (proc->Params[0].Option != -1) place = (INT_PTR*) &(proc->Params[0].Value);
|
||||
if (place) *place = ret;
|
||||
return proc;
|
||||
}
|
||||
#endif //~ SYSTEM_ARM64
|
||||
#ifdef _WIN64
|
||||
/*
|
||||
BUGBUG: TODO: CallBack support not implemeted!
|
||||
|
@ -1158,7 +1184,7 @@ void ParamsOut(SystemProc *proc)
|
|||
|
||||
HANDLE CreateCallback(SystemProc *cbproc)
|
||||
{
|
||||
#ifdef SYSTEM_AMD64
|
||||
#if defined(SYSTEM_AMD64) || defined(SYSTEM_ARM64)
|
||||
return BUGBUG64(HANDLE) NULL;
|
||||
#else
|
||||
char *mem;
|
||||
|
@ -1357,7 +1383,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved)
|
|||
#ifdef SYSTEM_X86
|
||||
retexpr[0] = (char) 0xC2;
|
||||
retexpr[2] = 0x00;
|
||||
#elif defined(SYSTEM_AMD64)
|
||||
#elif defined(SYSTEM_AMD64) || defined(SYSTEM_ARM64)
|
||||
retexpr[0] = BUGBUG64(0);
|
||||
#else
|
||||
#error TODO
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
# define SYSTEM_AMD64
|
||||
#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_)
|
||||
# define SYSTEM_X86
|
||||
#elif defined(_M_ARM64)
|
||||
# define SYSTEM_ARM64
|
||||
#else
|
||||
# error "Unknown architecture!"
|
||||
#endif
|
||||
|
@ -147,7 +149,7 @@ struct tag_CallbackThunk
|
|||
#pragma pack(pop)
|
||||
*/
|
||||
char asm_code[10];
|
||||
#elif defined(SYSTEM_AMD64)
|
||||
#elif defined(SYSTEM_AMD64) || defined(SYSTEM_ARM64)
|
||||
char asm_code[BUGBUG64(1)]; // TODO: BUGBUG64
|
||||
#else
|
||||
#error "Asm thunk not implemeted for this architecture!"
|
||||
|
@ -159,7 +161,7 @@ struct tag_CallbackThunk
|
|||
// Free() only knows about pNext in CallbackThunk, it does not know anything about the assembly, that is where this helper comes in...
|
||||
#ifdef SYSTEM_X86
|
||||
# define GetAssociatedSysProcFromCallbackThunkPtr(pCbT) ( (SystemProc*) *(unsigned int*) (((char*)(pCbT))+1) )
|
||||
#elif defined(SYSTEM_AMD64)
|
||||
#elif defined(SYSTEM_AMD64) || defined(SYSTEM_ARM64)
|
||||
# define GetAssociatedSysProcFromCallbackThunkPtr(pCbT) BUGBUG64(NULL)
|
||||
#else
|
||||
# error "GetAssociatedSysProcFromCallbackThunkPtr not defined for the current architecture!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue