diff --git a/Contrib/Banner/Banner.c b/Contrib/Banner/Banner.c index a391f906..3f69a6b2 100644 --- a/Contrib/Banner/Banner.c +++ b/Contrib/Banner/Banner.c @@ -11,7 +11,7 @@ BOOL bFailed; TCHAR buf[1024]; -BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { @@ -42,7 +42,7 @@ BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { DestroyWindow(hwndDlg); } - return 0; + return FALSE; } BOOL ProcessMessages() diff --git a/Contrib/ExDLL/pluginapi.c b/Contrib/ExDLL/pluginapi.c index 370f1561..5d878606 100644 --- a/Contrib/ExDLL/pluginapi.c +++ b/Contrib/ExDLL/pluginapi.c @@ -46,7 +46,7 @@ void NSISCALL pushstring(const TCHAR *str) *g_stacktop=th; } -TCHAR * NSISCALL getuservariable(const int varnum) +TCHAR* NSISCALL getuservariable(const int varnum) { if (varnum < 0 || varnum >= __INST_LAST) return NULL; return g_variables+varnum*g_stringsize; @@ -159,9 +159,9 @@ void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr) // playing with integers -int NSISCALL myatoi(const TCHAR *s) +INT_PTR NSISCALL nsishelper_str_to_ptr(const TCHAR *s) { - int v=0; + INT_PTR v=0; if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X'))) { s++; @@ -204,7 +204,7 @@ int NSISCALL myatoi(const TCHAR *s) return v; } -unsigned NSISCALL myatou(const TCHAR *s) +unsigned int NSISCALL myatou(const TCHAR *s) { unsigned int v=0; @@ -270,13 +270,12 @@ int NSISCALL myatoi_or(const TCHAR *s) return v; } -int NSISCALL popint() +INT_PTR NSISCALL popintptr() { TCHAR buf[128]; if (popstringn(buf,COUNTOF(buf))) return 0; - - return myatoi(buf); + return nsishelper_str_to_ptr(buf); } int NSISCALL popint_or() @@ -284,13 +283,12 @@ int NSISCALL popint_or() TCHAR buf[128]; if (popstringn(buf,COUNTOF(buf))) return 0; - return myatoi_or(buf); } -void NSISCALL pushint(int value) +void NSISCALL pushintptr(INT_PTR value) { - TCHAR buffer[1024]; - wsprintf(buffer, _T("%d"), value); + TCHAR buffer[30]; + wsprintf(buffer, sizeof(void*) > 4 ? _T("%Id") : _T("%d"), value); pushstring(buffer); } diff --git a/Contrib/ExDLL/pluginapi.h b/Contrib/ExDLL/pluginapi.h index e762bbfc..d6541123 100644 --- a/Contrib/ExDLL/pluginapi.h +++ b/Contrib/ExDLL/pluginapi.h @@ -56,16 +56,19 @@ extern unsigned int g_stringsize; extern stack_t **g_stacktop; extern TCHAR *g_variables; +void NSISCALL pushstring(const TCHAR *str); +void NSISCALL pushintptr(INT_PTR value); +#define pushint(v) pushintptr((INT_PTR)(v)) int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize -int NSISCALL popint(); // pops an integer +INT_PTR NSISCALL popintptr(); +#define popint() ( (int) popintptr() ) int NSISCALL popint_or(); // with support for or'ing (2|4|8) -int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer -unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only +INT_PTR NSISCALL nsishelper_str_to_ptr(const TCHAR *s); +#define myatoi(s) ( (int) nsishelper_str_to_ptr(s) ) // converts a string to an integer +unsigned int NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8) -void NSISCALL pushstring(const TCHAR *str); -void NSISCALL pushint(int value); -TCHAR * NSISCALL getuservariable(const int varnum); +TCHAR* NSISCALL getuservariable(const int varnum); void NSISCALL setuservariable(const int varnum, const TCHAR *var); #ifdef _UNICODE diff --git a/Contrib/LangDLL/LangDLL.c b/Contrib/LangDLL/LangDLL.c index 52192930..c9d02f0e 100644 --- a/Contrib/LangDLL/LangDLL.c +++ b/Contrib/LangDLL/LangDLL.c @@ -32,7 +32,7 @@ struct lang { UINT cp; } *langs; -BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int i, size; TCHAR *selected_language = NULL; diff --git a/Contrib/MakeLangId/MakeLangId.cpp b/Contrib/MakeLangId/MakeLangId.cpp index 876b3719..c9403ad5 100644 --- a/Contrib/MakeLangId/MakeLangId.cpp +++ b/Contrib/MakeLangId/MakeLangId.cpp @@ -193,7 +193,7 @@ line sub[] = { CBL(SUBLANG_UZBEK_CYRILLIC) }; -BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { +INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { size_t i; switch (uMsg) { case WM_INITDIALOG: @@ -222,7 +222,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { TCHAR *lang_id = (TCHAR *)GlobalLock(hMem); wsprintf(lang_id, _T("%u"), MAKELANGID(primary[SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0)].id, sub[SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0)].id)); GlobalUnlock(hMem); - if (!OpenClipboard(hwndDlg)) return 0; + if (!OpenClipboard(hwndDlg)) return FALSE; EmptyClipboard(); #ifdef _UNICODE SetClipboardData(CF_UNICODETEXT,hMem); @@ -234,7 +234,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { } break; } - return 0; + return FALSE; } NSIS_ENTRYPOINT_GUINOCRT diff --git a/Contrib/Makensisw/jnetlib/httpget.cpp b/Contrib/Makensisw/jnetlib/httpget.cpp index bc692151..0989fa5d 100644 --- a/Contrib/Makensisw/jnetlib/httpget.cpp +++ b/Contrib/Makensisw/jnetlib/httpget.cpp @@ -16,7 +16,7 @@ #include "util.h" #include "httpget.h" -void *operator new( unsigned int num_bytes ){return GlobalAlloc(GPTR,num_bytes);} +void *operator new( size_t num_bytes ){return GlobalAlloc(GPTR,num_bytes);} void operator delete( void *p ) { if (p) GlobalFree(p); } JNL_HTTPGet::JNL_HTTPGet(JNL_AsyncDNS *dns, int recvbufsize, char *proxy) diff --git a/Contrib/Makensisw/makensisw.xml b/Contrib/Makensisw/makensisw.xml index 69aa6811..2a36de38 100644 --- a/Contrib/Makensisw/makensisw.xml +++ b/Contrib/Makensisw/makensisw.xml @@ -1,10 +1,10 @@ - + MakeNSIS Wrapper - + diff --git a/Contrib/NSISdl/nsisdl.cpp b/Contrib/NSISdl/nsisdl.cpp index 206c9da5..1aa31cf7 100644 --- a/Contrib/NSISdl/nsisdl.cpp +++ b/Contrib/NSISdl/nsisdl.cpp @@ -30,7 +30,7 @@ #include // nsis plugin -void *operator new( unsigned int num_bytes ) +void *operator new( size_t num_bytes ) { return GlobalAlloc(GPTR,num_bytes); } diff --git a/Contrib/StartMenu/StartMenu.c b/Contrib/StartMenu/StartMenu.c index bda5d9bc..4a3a7e3d 100644 --- a/Contrib/StartMenu/StartMenu.c +++ b/Contrib/StartMenu/StartMenu.c @@ -25,8 +25,8 @@ WNDPROC lpWndProcOld; void (__stdcall *validate_filename)(TCHAR *); -BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); void AddFolderFromReg(int nFolder); static UINT_PTR PluginCallback(enum NSPIM msg) @@ -158,9 +158,9 @@ void __declspec(dllexport) Select(HWND hwndParent, int string_size, TCHAR *varia } } -static BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - BOOL bRes = CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam); + INT_PTR bRes = CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam); if (message == WM_NOTIFY_OUTER_NEXT && !bRes) { // if leave function didn't abort (lRes != 0 in that case) @@ -191,7 +191,7 @@ void AddRTLStyle(HWND hWnd, long dwStyle) \ y_offset += cy + 3; -BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hwLocation = GetDlgItem(hwndDlg, IDC_LOCATION); HWND hwDirList = GetDlgItem(hwndDlg, IDC_DIRLIST); @@ -424,7 +424,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) return SendMessage(hwParent, uMsg, wParam, lParam); break; } - return 0; + return FALSE; } BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) diff --git a/Contrib/System/SConscript b/Contrib/System/SConscript index bf14a27c..3ce52ac9 100644 --- a/Contrib/System/SConscript +++ b/Contrib/System/SConscript @@ -26,14 +26,17 @@ docs = Split(""" Import('BuildPlugin env') -conf = env.Configure() -if conf.TryCompile('END', '.S'): - files += ['Source/Call.S'] -elif conf.TryCompile('.end', '.sx'): - files += ['Source/Call.sx'] +if env['TARGET_ARCH'] != 'amd64': + conf = env.Configure() + if conf.TryCompile('END', '.S'): + files += ['Source/Call.S'] + elif conf.TryCompile('.end', '.sx'): + files += ['Source/Call.sx'] + else: + print 'WARNING: unable to find assembler for Call.S' + conf.Finish() else: - print 'WARNING: unable to find assembler for Call.S' -conf.Finish() + print 'WARNING: missing Win64 code, dynamic function calls not supported' BuildPlugin( target, diff --git a/Contrib/System/Source/Buffers.c b/Contrib/System/Source/Buffers.c index 5f066352..ab9d3fbc 100644 --- a/Contrib/System/Source/Buffers.c +++ b/Contrib/System/Source/Buffers.c @@ -15,8 +15,8 @@ TempStack *tempstack = NULL; static void AllocWorker(unsigned int mult) { - int size; - if ((size = popint()) == 0) + size_t size; + if ((size = popintptr()) == 0) { system_pushint(0); return; @@ -56,7 +56,7 @@ PLUGINFUNCTIONSHORT(Copy) // Ok, check the size if (size == 0) size = (SIZE_T) GlobalSize(source); // and the destinantion - if ((int) dest == 0) + if (!dest) { dest = GlobalAlloc((GPTR), size); system_pushintptr((INT_PTR) dest); diff --git a/Contrib/System/Source/Plugin.c b/Contrib/System/Source/Plugin.c index 212110c6..f4d8f636 100644 --- a/Contrib/System/Source/Plugin.c +++ b/Contrib/System/Source/Plugin.c @@ -134,20 +134,20 @@ void myitoa64(__int64 i, TCHAR *buffer) *buffer = 0; } -int system_popint() +INT_PTR system_popintptr() { - int value; + INT_PTR value; TCHAR *str; if ((str = system_popstring()) == NULL) return -1; - value = myatoi(str); + value = StrToIntPtr(str); GlobalFree(str); return value; } -void system_pushint(int value) +void system_pushintptr(INT_PTR value) { - TCHAR buffer[80]; - wsprintf(buffer, _T("%d"), value); + TCHAR buffer[50]; + wsprintf(buffer, sizeof(void*) > 4 ? _T("%Id") : _T("%d"), value); system_pushstring(buffer); } diff --git a/Contrib/System/Source/Plugin.h b/Contrib/System/Source/Plugin.h index a06fc08d..a7a98849 100644 --- a/Contrib/System/Source/Plugin.h +++ b/Contrib/System/Source/Plugin.h @@ -5,15 +5,17 @@ // Always use system* functions to keep the size down #define pushstring error(use system_pushstring) +#undef pushint #define pushint error(use system_pushint) +#define pushintptr error(use system_pushintptr) -#define popint system_popint +#undef myatoi #define myatoi(str) ( (int) myatoi64(str) ) +#define system_pushint(v) system_pushintptr((INT_PTR)(v)) +#define popintptr system_popintptr #ifdef _WIN64 -# error TODO +# define StrToIntPtr(str) ( (INT_PTR)myatoi64((str)) ) #else -# define system_pushintptr system_pushint -# define popintptr popint # define StrToIntPtr(str) ( (INT_PTR)myatoi((str)) ) #endif @@ -39,8 +41,8 @@ extern TCHAR *system_setuservariable(int varnum, TCHAR *var); extern TCHAR* system_popstring(); // NULL - stack empty extern TCHAR* system_pushstring(TCHAR *str); extern __int64 myatoi64(TCHAR *s); -extern int system_popint(); // -1 -> stack empty -extern void system_pushint(int value); +extern INT_PTR system_popintptr(); // -1 -> stack empty +extern void system_pushintptr(INT_PTR value); extern HANDLE GlobalCopy(HANDLE Old); extern void *copymem(void *output, void *input, size_t cbSize); diff --git a/Contrib/System/Source/System.c b/Contrib/System/Source/System.c index 5b085fdd..ddf4e110 100644 --- a/Contrib/System/Source/System.c +++ b/Contrib/System/Source/System.c @@ -30,18 +30,18 @@ #define PCD_PARAMS 2 #define PCD_DONE 3 // Just Continue +const int PARAMSIZEBYTYPE_PTR = (4==sizeof(void*)) ? 1 : 2; const int ParamSizeByType[7] = { - 0, // PAT_VOID (Size will be equal to 1) + 0, // PAT_VOID (Size will be equal to 1) //BUGBUG64? 1, // PAT_INT 2, // PAT_LONG - 1, // PAT_STRING - 1, // PAT_WSTRING - 1, // PAT_GUID + 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? -const int PARAMSIZEBYTYPE_PTR = (4==sizeof(void*)) ? 1 : 2; // Thomas needs to look at this. -const int ByteSizeByType[7] = { +static const int ByteSizeByType[7] = { 1, // PAT_VOID 1, // PAT_INT 1, // PAT_LONG @@ -55,7 +55,7 @@ int LastStackReal; DWORD LastError; volatile SystemProc *LastProc; int CallbackIndex; -CallbackThunk* CallbackThunkListHead; +CallbackThunk* g_CallbackThunkListHead; HINSTANCE g_hInstance; // Return to callback caller with stack restore @@ -145,7 +145,7 @@ PLUGINFUNCTION(Debug) GetLocalTime(&t); GetTimeFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, buftime, 1024); GetDateFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, bufdate, 1024); - wsprintf(buffer, _T("System, %s %s [build ") __TTIME__ _T(" ") __TDATE__ _T("]\n"), buftime, bufdate); + wsprintf(buffer, _T("System, %s %s [build %hs %hs]\n"), buftime, bufdate, __TIME__, __DATE__); WriteToLog(buffer); } else ; else @@ -207,9 +207,9 @@ PLUGINFUNCTIONSHORT(Free) { HANDLE memtofree = (HANDLE)popintptr(); - if (CallbackThunkListHead) + if (g_CallbackThunkListHead) { - CallbackThunk *pCb=CallbackThunkListHead,*pPrev=NULL; + CallbackThunk *pCb=g_CallbackThunkListHead,*pPrev=NULL; do { if (GetAssociatedSysProcFromCallbackThunkPtr(pCb) == (SystemProc*)memtofree) @@ -217,7 +217,7 @@ PLUGINFUNCTIONSHORT(Free) if (pPrev) pPrev->pNext=pCb->pNext; else - CallbackThunkListHead=pCb->pNext; + g_CallbackThunkListHead=pCb->pNext; --(CallbackIndex); VirtualFree(pCb,0,MEM_RELEASE); @@ -268,12 +268,45 @@ PLUGINFUNCTION(Get) } } PLUGINFUNCTIONEND + +#ifdef _WIN64 +/* +TODO: CallProc/Back not implemeted. +Fake the behavior of the System plugin for the LoadImage API function so MUI works. +BUGBUG: Leaking DeleteObject and failing GetClientRect +*/ +static SystemProc* CallProc(SystemProc *proc) +{ + INT_PTR ret, *place; + LastError = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA")); + if (!LastError) + { + 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; + 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; +} +static SystemProc* CallBack(SystemProc *proc) +{ + proc->ProcResult = PR_ERROR; + return proc; +} +#endif + + PLUGINFUNCTION(Call) { // Prepare input SystemProc *proc = PrepareProc(TRUE); - if (proc == NULL) - return; + if (proc == NULL) return; SYSTEM_LOG_ADD(_T("Call ")); SYSTEM_LOG_ADD(proc->DllName); @@ -281,8 +314,7 @@ PLUGINFUNCTION(Call) SYSTEM_LOG_ADD(proc->ProcName); //SYSTEM_LOG_ADD(_T("\n")); SYSTEM_LOG_POST; - if (proc->ProcResult != PR_CALLBACK) - ParamAllocate(proc); + if (proc->ProcResult != PR_CALLBACK) ParamAllocate(proc); ParamsIn(proc); // Make the call @@ -308,35 +340,30 @@ PLUGINFUNCTION(Call) // Always return flag set - return separate return and result ParamsOut(proc); GlobalFree(system_pushstring(GetResultStr(proc))); - } else + } + else { if (proc->ProcResult != PR_OK) { - ProcParameter pp; - // Save old return param - pp = proc->Params[0]; + ProcParameter pp = proc->Params[0]; // Save old return param // Return result instead of return value - proc->Params[0].Value = BUGBUG64(int) GetResultStr(proc); + proc->Params[0].Value = (INT_PTR) GetResultStr(proc); proc->Params[0].Type = PAT_TSTRING; - // Return all params - ParamsOut(proc); - // Restore old return param - proc->Params[0] = pp; - } else + ParamsOut(proc); // Return all params + proc->Params[0] = pp; // Restore old return param + } + else ParamsOut(proc); } if (proc->ProcResult != PR_CALLBACK) { - // Deallocate params if not callback ParamsDeAllocate(proc); // if not callback - check for unload library option - if ((proc->Options & POPT_UNLOAD) - && (proc->ProcType == PT_PROC) - && (proc->Dll != NULL)) + if ((proc->Options & POPT_UNLOAD) && proc->ProcType == PT_PROC && proc->Dll) FreeLibrary(proc->Dll); // and unload it :) // In case of POPT_ERROR - first pop will be proc error @@ -344,8 +371,7 @@ PLUGINFUNCTION(Call) } // If proc is permanent? - if ((proc->Options & POPT_PERMANENT) == 0) - GlobalFree((HANDLE) proc); // No, free it + if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HANDLE) proc); // No, free it } PLUGINFUNCTIONEND PLUGINFUNCTIONSHORT(Int64Op) @@ -602,13 +628,14 @@ SystemProc *PrepareProc(BOOL NeedForCall) case _T('v'): case _T('V'): temp2 = PAT_VOID; break; - #if !defined(SYSTEM_X86) - #error "TODO: handle p" - #else - case _T('p'): - #endif +#ifndef _WIN64 + case _T('p'): +#endif case _T('i'): case _T('I'): temp2 = PAT_INT; break; +#ifdef _WIN64 + case _T('p'): +#endif case _T('l'): case _T('L'): temp2 = PAT_LONG; break; case _T('m'): @@ -865,12 +892,9 @@ SystemProc *PrepareProc(BOOL NeedForCall) void ParamAllocate(SystemProc *proc) { int i; - for (i = 0; i <= proc->ParamCount; i++) - if (((HANDLE) proc->Params[i].Value == NULL) && (proc->Params[i].Option == -1)) - { - proc->Params[i].Value = BUGBUG64(int) GlobalAlloc(GPTR, 4*ParamSizeByType[proc->Params[i].Type]); - } + if (!proc->Params[i].Value && proc->Params[i].Option == -1) + proc->Params[i].Value = (INT_PTR) GlobalAlloc(GPTR, 4*ParamSizeByType[proc->Params[i].Type]); } void ParamsIn(SystemProc *proc) @@ -958,7 +982,7 @@ void ParamsIn(SystemProc *proc) #ifdef SYSTEM_LOG_DEBUG { TCHAR buf[666]; - wsprintf(buf, _T("\t\t\tParam In %d: type %d value 0x%08X value2 0x%08X"), i, + wsprintf(buf, _T("\t\t\tParam In %d: type %d value ")SYSFMT_HEXPTR _T(" value2 0x%08X"), i, par->Type, par->Value, par->_value); SYSTEM_LOG_ADD(buf); SYSTEM_LOG_POST; @@ -974,18 +998,18 @@ void ParamsIn(SystemProc *proc) void ParamsDeAllocate(SystemProc *proc) { int i; - for (i = proc->ParamCount; i >= 0; i--) - if (((HANDLE) proc->Params[i].Value != NULL) && (proc->Params[i].Option == -1)) + if (proc->Params[i].Value && proc->Params[i].Option == -1) { GlobalFree((HANDLE) (proc->Params[i].Value)); - proc->Params[i].Value = (int) NULL; + proc->Params[i].Value = 0; } } void ParamsOut(SystemProc *proc) { - int i, *place; + INT_PTR *place; + int i; TCHAR *realbuf; LPWSTR wstr; @@ -993,8 +1017,8 @@ void ParamsOut(SystemProc *proc) do { // Retreive pointer to place - if (proc->Params[i].Option == -1) place = BUGBUG64(int*) proc->Params[i].Value; - else place = BUGBUG64(int*) &(proc->Params[i].Value); + if (proc->Params[i].Option == -1) place = (INT_PTR*) proc->Params[i].Value; + else place = (INT_PTR*) &(proc->Params[i].Value); realbuf = AllocString(); @@ -1005,7 +1029,7 @@ void ParamsOut(SystemProc *proc) lstrcpy(realbuf,_T("")); break; case PAT_INT: - wsprintf(realbuf, _T("%d"), *((int*) place)); + wsprintf(realbuf, _T("%d"), (int)(*((INT_PTR*) place))); break; case PAT_LONG: myitoa64(*((__int64*) place), realbuf); @@ -1038,7 +1062,7 @@ void ParamsOut(SystemProc *proc) #endif break; case PAT_CALLBACK: - wsprintf(realbuf, _T("%d"), proc->Params[i].Value); + wsprintf(realbuf, _T("%d"), BUGBUG64(proc->Params[i].Value)); break; } @@ -1083,6 +1107,9 @@ void ParamsOut(SystemProc *proc) HANDLE CreateCallback(SystemProc *cbproc) { +#ifdef SYSTEM_X64 + return BUGBUG64(HANDLE) NULL; +#else char *mem; if (cbproc->Proc == NULL) @@ -1093,8 +1120,8 @@ HANDLE CreateCallback(SystemProc *cbproc) mem = (char *) (cbproc->Proc = VirtualAlloc(NULL, sizeof(CallbackThunk), MEM_COMMIT, PAGE_EXECUTE_READWRITE)); - ((CallbackThunk*)mem)->pNext=CallbackThunkListHead; - CallbackThunkListHead=(CallbackThunk*)mem; + ((CallbackThunk*)mem)->pNext=g_CallbackThunkListHead; + g_CallbackThunkListHead=(CallbackThunk*)mem; #ifdef SYSTEM_X86 *(mem++) = (char) 0xB8; // Mov eax, const @@ -1111,6 +1138,7 @@ HANDLE CreateCallback(SystemProc *cbproc) // Return proc address return cbproc->Proc; +#endif } void CallStruct(SystemProc *proc) @@ -1215,7 +1243,7 @@ void CallStruct(SystemProc *proc) SYSTEM_LOG_POST; // Proc virtual return - pointer to memory struct - proc->Params[0].Value = (int) proc->Proc; + proc->Params[0].Value = BUGBUG64(int) proc->Proc; } /* @@ -1231,25 +1259,28 @@ the same means as used for the _RPT0 macro. This leads to an endless recursion. BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved) { - g_hInstance=hInst; - - if (DLL_PROCESS_ATTACH == fdwReason) - { - // change the protection of return command - VirtualProtect(&retexpr, sizeof(retexpr), PAGE_EXECUTE_READWRITE, (PDWORD)&LastStackPlace); + g_hInstance=hInst; - // initialize some variables - LastStackPlace = 0; - LastStackReal = 0; - LastError = 0; - LastProc = NULL; - CallbackIndex = 0; - CallbackThunkListHead = NULL; - retexpr[0] = (char) 0xC2; - retexpr[2] = 0x00; - } + if (DLL_PROCESS_ATTACH == fdwReason) + { + // change the protection of return command + VirtualProtect(&retexpr, sizeof(retexpr), PAGE_EXECUTE_READWRITE, (PDWORD)&LastStackPlace); - return TRUE; + // initialize some variables + LastStackPlace = 0, LastStackReal = 0; + LastError = 0; + LastProc = NULL; + CallbackIndex = 0, g_CallbackThunkListHead = NULL; +#ifdef SYSTEM_X86 + retexpr[0] = (char) 0xC2; + retexpr[2] = 0x00; +#elif defined(SYSTEM_X64) + retexpr[0] = BUGBUG64(0); +#else +#error TODO +#endif + } + return TRUE; } /* diff --git a/Contrib/System/Source/System.h b/Contrib/System/Source/System.h index f65953fd..9527f7e3 100644 --- a/Contrib/System/Source/System.h +++ b/Contrib/System/Source/System.h @@ -10,7 +10,11 @@ #else # error "Unknown architecture!" #endif - +#ifdef _WIN64 +#define SYSFMT_HEXPTR _T("0x%016IX") +#else +#define SYSFMT_HEXPTR _T("0x%08X") +#endif // The following ifdef block is the standard way of creating macros which make exporting @@ -76,8 +80,8 @@ typedef struct { int Type; int Option; // -1 -> Pointer, 1-... -> Special+1 - int Value; // it can hold any 4 byte value BUGBUG: What about pointers on Win64? - int _value; // value buffer for structures > 4 bytes (I hope 8 bytes will be enough) + INT_PTR Value; // it can hold any pointer sized value + int _value; // value buffer for structures > 4 bytes (I hope 8 bytes will be enough) BUGBUG: Does Win64 need this? int Size; // Value real size (should be either 1 or 2 (the number of pushes)) int Input; //BUGBUG: What about pointers on Win64? int Output; @@ -119,6 +123,8 @@ struct tag_CallbackThunk #pragma pack(pop) */ char asm_code[10]; + #elif defined(SYSTEM_X64) + char asm_code[BUGBUG64(1)]; // TODO: BUGBUG64 #else #error "Asm thunk not implemeted for this architecture!" #endif @@ -129,6 +135,8 @@ 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_X64) +# define GetAssociatedSysProcFromCallbackThunkPtr(pCbT) BUGBUG64(NULL) #else # error "GetAssociatedSysProcFromCallbackThunkPtr not defined for the current architecture!" #endif diff --git a/Contrib/System/System.nsh b/Contrib/System/System.nsh index 86df4734..f8098419 100644 --- a/Contrib/System/System.nsh +++ b/Contrib/System/System.nsh @@ -14,105 +14,105 @@ ; ------------- Functions -------------- ; LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -!define sysWNDPROC "(i.s, i.s, i.s, i.s) iss" +!define sysWNDPROC "(p.s, i.s, p.s, p.s) pss" ; LRESULT DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -!define sysDefWindowProc "user32::DefWindowProc(i, i, i, i) i" +!define sysDefWindowProc "user32::DefWindowProc(p, i, p, p) p" -!define sysMessageBox "user32::MessageBox(i, t, t, i) i" +!define sysMessageBox "user32::MessageBox(p, t, t, i) i" !define sysMessageBeep "user32::MessageBeep(i) i" -!define sysMessageBoxIndirect 'user32::MessageBoxIndirect(i) i' +!define sysMessageBoxIndirect 'user32::MessageBoxIndirect(p) i' ; HMODULE GetModuleHandle(LPCTSTR lpModuleName); !define sysGetModuleHandle "kernel32::GetModuleHandle(t) i" ; HMODULE LoadLibrary(LPCTSTR lpFileName); -!define sysLoadLibrary "kernel32::LoadLibrary(t) i" +!define sysLoadLibrary "kernel32::LoadLibrary(t) p" ; BOOL FreeLibrary(HMODULE hModule); -!define sysFreeLibrary "kernel32::FreeLibrary(i) i" +!define sysFreeLibrary "kernel32::FreeLibrary(p) i" ; HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName); -!define sysLoadCursor "user32::LoadCursor(i, t) i" +!define sysLoadCursor "user32::LoadCursor(p, t) p" ; ATOM RegisterClass(CONST WNDCLASS *lpWndClass); -!define sysRegisterClass "user32::RegisterClass(i) i" +!define sysRegisterClass "user32::RegisterClass(p) i" ; HANDLE LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, ; int cxDesired, int cyDesired, UINT fuLoad); -!define sysLoadImage "user32::LoadImage(i, t, i, i, i, i) i" +!define sysLoadImage "user32::LoadImage(p, t, i, i, i, i) p" ; BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound); -!define sysPlaySound "winmm.dll::PlaySound(t, i, i) i" +!define sysPlaySound "winmm.dll::PlaySound(t, p, i) i" ; HWND CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, ; DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, ; HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); -!define sysCreateWindowEx "user32::CreateWindowEx(i, t, t, i, i, i, i, i, i, i, i, i) i" +!define sysCreateWindowEx "user32::CreateWindowEx(i, t, t, i, i, i, i, i, p, p, p, p) p" ; BOOL IsWindow(HWND hWnd); -!define sysIsWindow "user32::IsWindow(i) i" +!define sysIsWindow "user32::IsWindow(p) i" ; LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong); -!define sysSetWindowLong "user32::SetWindowLong(i, i, i) i" +!define sysSetWindowLong "user32::SetWindowLong(p, i, p) p" ; BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags); -!define sysSetWindowPos "user32::SetWindowPos(i, i, i, i, i, i, i) i" +!define sysSetWindowPos "user32::SetWindowPos(p, p, i, i, i, i, i) i" ; BOOL ShowWindow(HWND hWnd, int nCmdShow); -!define sysShowWindow "user32::ShowWindow(i, i) i" +!define sysShowWindow "user32::ShowWindow(p, i) i" ; BOOL DestroyWindow(HWND hWnd); -!define sysDestroyWindow "user32::DestroyWindow(i) i" +!define sysDestroyWindow "user32::DestroyWindow(p) i" ; BOOL GetClientRect(HWND hWnd, LPRECT lpRect); -!define sysGetClientRect "user32::GetClientRect(i, i) i" +!define sysGetClientRect "user32::GetClientRect(p, p) i" ; BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax); -!define sysGetMessage "user32::GetMessage(i, i, i, i) i" +!define sysGetMessage "user32::GetMessage(p, p, i, i) i" ; LRESULT DispatchMessage(CONST MSG *lpmsg); -!define sysDispatchMessage "user32::DispatchMessage(i) i" +!define sysDispatchMessage "user32::DispatchMessage(p) p" ; BOOL DeleteObject(HGDIOBJ hObject); -!define sysDeleteObject "gdi32::DeleteObject(i) i" +!define sysDeleteObject "gdi32::DeleteObject(p) i" ; int GetObject(HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject); -!define sysGetObject "gdi32::GetObject(i, i, i) i" +!define sysGetObject "gdi32::GetObject(p, i, p) i" ; HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj); -!define sysSelectObject "gdi32::SelectObject(i, i) i" +!define sysSelectObject "gdi32::SelectObject(p, p) p" ; HDC CreateCompatibleDC(HDC hdc); -!define sysCreateCompatibleDC "gdi32::CreateCompatibleDC(i) i" +!define sysCreateCompatibleDC "gdi32::CreateCompatibleDC(p) p" ; BOOL DeleteDC(HDC hdc); -!define sysDeleteDC "gdi32::DeleteDC(i) i" +!define sysDeleteDC "gdi32::DeleteDC(p) i" ; BOOL BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, ; HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop); -!define sysBitBlt "gdi32::BitBlt(i, i, i, i, i, i, i, i, i) i" +!define sysBitBlt "gdi32::BitBlt(p, i, i, i, i, p, i, i, i) i" ; proposed by abgandar ; int AddFontResource(LPCTSTR lpszFilename); !define sysAddFontResource "gdi32::AddFontResource(t) i" ; HDC BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint); -!define sysBeginPaint "user32::BeginPaint(i, i) i" +!define sysBeginPaint "user32::BeginPaint(p, p) p" ; BOOL EndPaint(HWND hWnd, CONST PAINTSTRUCT *lpPaint); -!define sysEndPaint "user32::EndPaint(i, i) i" +!define sysEndPaint "user32::EndPaint(p, p) i" ; BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); -!define sysSystemParametersInfo "user32::SystemParametersInfo(i, i, i, i) i" +!define sysSystemParametersInfo "user32::SystemParametersInfo(i, i, p, i) i" ; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc); -!define sysSetTimer "user32::SetTimer(i, i, i, k) i" +!define sysSetTimer "user32::SetTimer(p, p, i, k) i" ; DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR LpBuffer); -!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStrings(i, i) i' +!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStrings(i, p) i' !define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceEx(t, *l, *l, *l) i' @@ -120,14 +120,14 @@ !define sysGetDriveType 'kernel32::GetDriveType(t) i' ; HANDLE FindFirstFile(LPCTSTR lpFileName,LPWIN32_FIND_DATA lpFindFileData); -!define sysFindFirstFile 'kernel32::FindFirstFile(t, i) i' +!define sysFindFirstFile 'kernel32::FindFirstFile(t, p) p' ; BOOL FindClose(HANDLE hFindFile); -!define sysFindClose 'kernel32::FindClose(i) i' +!define sysFindClose 'kernel32::FindClose(p) i' ; BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime, ; LPSYSTEMTIME lpSystemTime); -!define sysFileTimeToSystemTime 'kernel32::FileTimeToSystemTime(*l, i) i' +!define sysFileTimeToSystemTime 'kernel32::FileTimeToSystemTime(*l, p) i' ; BOOL FileTimeToLocalFileTime( ; CONST FILETIME *lpFileTime, @@ -136,7 +136,7 @@ ; BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone, ; LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime); -!define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(i, i, i) i' +!define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(p, p, p) i' !define syslstrlen 'kernel32::lstrlen(t) i' @@ -157,7 +157,7 @@ ; LPCTSTR lpszMenuName; ; LPCTSTR lpszClassName; ; } WNDCLASS, *PWNDCLASS; -!define stWNDCLASS "(i, k, i, i, i, i, i, i, t, t) i" +!define stWNDCLASS "(i, k, i, i, p, p, p, p, t, t) p" ; typedef struct tagMSG { ; HWND hwnd; @@ -167,7 +167,7 @@ ; DWORD time; ; POINT pt; -> will be presented as two separate px and py ; } MSG, *PMSG; -!define stMSG "(i, i, i, i, i, i, i) i" +!define stMSG "(p, i, p, p, i, i, i) p" ; typedef struct tagBITMAP { ; LONG bmType; @@ -178,7 +178,7 @@ ; WORD bmBitsPixel; ; LPVOID bmBits; ; } BITMAP, *PBITMAP; -!define stBITMAP "(i, i, i, i, i, i, i) i" +!define stBITMAP "(i, i, i, i, i, i, p) p" ; typedef struct _RECT { ; LONG left; @@ -186,7 +186,7 @@ ; LONG right; ; LONG bottom; ; } RECT, *PRECT; -!define stRECT "(i, i, i, i) i" +!define stRECT "(i, i, i, i) p" ; typedef struct tagPAINTSTRUCT { ; HDC hdc; @@ -196,7 +196,7 @@ ; BOOL fIncUpdate; ; BYTE rgbReserved[32]; ; } PAINTSTRUCT, *PPAINTSTRUCT; -!define stPAINTSTRUCT "(i, i, i, i, i, i, i, i, &v32) i" +!define stPAINTSTRUCT "(p, i, i, i, i, i, i, i, &v32) p" ; typedef struct { ; UINT cbSize; @@ -210,7 +210,7 @@ ; MSGBOXCALLBACK lpfnMsgBoxCallback; ; DWORD dwLanguageId; ; } MSGBOXPARAMS, *PMSGBOXPARAMS; -!define stMSGBOXPARAMS '(&l4, i, i, t, t, i, t, i, k, i) i' +!define stMSGBOXPARAMS '(&l4, p, p, t, t, i, t, p, k, i) p' ; typedef struct _SYSTEMTIME { ; WORD wYear; @@ -222,7 +222,7 @@ ; WORD wSecond; ; WORD wMilliseconds; ; } SYSTEMTIME, *PSYSTEMTIME; -!define stSYSTEMTIME '(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i' +!define stSYSTEMTIME '(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) p' ; Maximal windows path !define /ifndef MAX_PATH 260 @@ -239,7 +239,7 @@ ; TCHAR cFileName[ MAX_PATH ]; ; TCHAR cAlternateFileName[ 14 ]; ; } WIN32_FIND_DATA, *PWIN32_FIND_DATA; -!define stWIN32_FIND_DATA '(i, l, l, l, i, i, i, i, &t${MAX_PATH}, &t14) i' +!define stWIN32_FIND_DATA '(i, l, l, l, i, i, i, i, &t${MAX_PATH}, &t14) p' ; ------------- Constants -------------- diff --git a/Contrib/System/System.nsi b/Contrib/System/System.nsi index ef70cdc9..cdd4c17d 100644 --- a/Contrib/System/System.nsi +++ b/Contrib/System/System.nsi @@ -73,7 +73,7 @@ enumex: ; End of drives or user cancel ; ----- Sample 3 ----- Direct proc defenition ----- ; Direct specification demo - System::Call 'user32::MessageBox(i $HWNDPARENT, t "Just direct MessageBox specification demo ;)", t "System Example 3", i ${MB_OK}) i.s' + System::Call 'user32::MessageBox(p $HWNDPARENT, t "Just direct MessageBox specification demo ;)", t "System Example 3", i ${MB_OK}) i.s' Pop $0 ; ----- Sample 4 ----- Int64, mixed definition demo ----- diff --git a/Contrib/UIs/ui.c b/Contrib/UIs/ui.c index 2d3c8a55..aabb4d4e 100644 --- a/Contrib/UIs/ui.c +++ b/Contrib/UIs/ui.c @@ -18,7 +18,7 @@ const TCHAR* windows[] = { MAKEINTRESOURCE(IDD_UNINST) }; -BOOL CALLBACK GenericProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { +INT_PTR CALLBACK GenericProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { static LOGBRUSH b = {BS_SOLID, RGB(255,0,0), 0}; static HBRUSH red; @@ -27,26 +27,26 @@ BOOL CALLBACK GenericProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_CTLCOLORSTATIC: - return (int)red; + return (INT_PTR)red; } - return 0; + return FALSE; } -BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { +INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { static int i = -1; - switch (uMsg) { - case WM_INITDIALOG: - SetWindowText(hwndDlg, _T("NSIS User Interface - Testing")); - SetWindowText(GetDlgItem(hwndDlg, IDC_VERSTR), _T("NSIS version")); - SetWindowText(GetDlgItem(hwndDlg, IDC_BACK), _T("< Back")); - SetWindowText(GetDlgItem(hwndDlg, IDOK), _T("Next >")); - SetWindowText(GetDlgItem(hwndDlg, IDCANCEL), _T("Cancel")); - ShowWindow(GetDlgItem(hwndDlg, IDC_BACK), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW); + switch (uMsg) { + case WM_INITDIALOG: + SetWindowText(hwndDlg, _T("NSIS User Interface - Testing")); + SetWindowText(GetDlgItem(hwndDlg, IDC_VERSTR), _T("NSIS version")); + SetWindowText(GetDlgItem(hwndDlg, IDC_BACK), _T("< Back")); + SetWindowText(GetDlgItem(hwndDlg, IDOK), _T("Next >")); + SetWindowText(GetDlgItem(hwndDlg, IDCANCEL), _T("Cancel")); + ShowWindow(GetDlgItem(hwndDlg, IDC_BACK), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW); SendMessage(hwndDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0); - ShowWindow(hwndDlg, SW_SHOW); - break; - case WM_COMMAND: + ShowWindow(hwndDlg, SW_SHOW); + break; + case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDC_BACK: @@ -77,7 +77,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { } break; } - return 0; + return FALSE; } NSIS_ENTRYPOINT_SIMPLEGUI diff --git a/Contrib/nsDialogs/example.nsi b/Contrib/nsDialogs/example.nsi index 242735c4..ef704089 100644 --- a/Contrib/nsDialogs/example.nsi +++ b/Contrib/nsDialogs/example.nsi @@ -58,7 +58,7 @@ Function OnChange Pop $0 # HWND - System::Call user32::GetWindowText(i$EDIT,t.r0,i${NSIS_MAX_STRLEN}) + System::Call user32::GetWindowText(p$EDIT,t.r0,i${NSIS_MAX_STRLEN}) ${If} $0 == "hello there" MessageBox MB_OK "right back at ya" diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index 4a5b175c..6ce7d1e8 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -32,9 +32,9 @@ struct nsControl* NSDFUNC GetControl(HWND hwCtl) return &g_dialog.controls[id - 1]; } -BOOL CALLBACK ParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK ParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - BOOL res; + INT_PTR res; if (message == WM_NOTIFY_OUTER_NEXT) { @@ -76,7 +76,7 @@ LRESULT CALLBACK LinkWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar return CallWindowProc(ctl->oldWndProc, hwnd, message, wParam, lParam); } -BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { @@ -93,7 +93,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onClick) { - pushint((int) hwCtl); + pushintptr((INT_PTR) hwCtl); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); } } @@ -101,7 +101,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); + pushintptr((INT_PTR) hwCtl); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); } } @@ -109,7 +109,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); + pushintptr((INT_PTR) hwCtl); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); } } @@ -118,7 +118,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); + pushintptr((INT_PTR) hwCtl); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); } } @@ -126,7 +126,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onClick) { - pushint((int) hwCtl); + pushintptr((INT_PTR) hwCtl); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); } } @@ -145,9 +145,9 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (!ctl->callbacks.onNotify) break; - pushint((int) nmhdr); - pushint(nmhdr->code); - pushint((int) nmhdr->hwndFrom); + pushintptr((INT_PTR) nmhdr); + pushintptr(nmhdr->code); + pushintptr((INT_PTR) nmhdr->hwndFrom); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0); } @@ -287,7 +287,7 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, TCHAR *varia g_dialog.callbacks.onBack = 0; - pushint((int) g_dialog.hwDialog); + pushintptr((INT_PTR) g_dialog.hwDialog); } void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) @@ -393,7 +393,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, TCHAR // push back result - pushint((int) hwItem); + pushintptr((INT_PTR) hwItem); // done @@ -413,11 +413,11 @@ void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, TCHAR * // get info from stack - hwCtl = (HWND) popint(); + hwCtl = (HWND) popintptr(); if (!IsWindow(hwCtl)) { - popint(); // remove user data from stack + popintptr(); // remove user data from stack return; } @@ -440,7 +440,7 @@ void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, TCHAR * // get info from stack - hwCtl = (HWND) popint(); + hwCtl = (HWND) popintptr(); if (!IsWindow(hwCtl)) { @@ -513,7 +513,7 @@ void NSDFUNC SetControlCallback(size_t callbackIdx) // get info from stack - hwCtl = (HWND) popint(); + hwCtl = (HWND) popintptr(); callback = (nsFunction) popint(); if (!IsWindow(hwCtl)) diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index 68c64875..ac528574 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -354,9 +354,9 @@ Header file for creating custom installer pages with nsDialogs !macro _NSD_GWLAddFlags GWL HWND DATA - System::Call "user32::GetWindowLong(i${HWND},i${GWL})i.s" + System::Call "user32::GetWindowLong(p${HWND},i${GWL})p.s" System::Int64Op "${DATA}" | - System::Call "user32::SetWindowLong(i${HWND},i${GWL},is)" + System::Call "user32::SetWindowLong(p${HWND},p${GWL},ps)" !macroend @@ -365,7 +365,7 @@ Header file for creating custom installer pages with nsDialogs !macro __NSD_GetText CONTROL VAR - System::Call user32::GetWindowText(i${CONTROL},t.s,i${NSIS_MAX_STRLEN}) + System::Call user32::GetWindowText(p${CONTROL},t.s,i${NSIS_MAX_STRLEN}) Pop ${VAR} !macroend @@ -422,7 +422,7 @@ Header file for creating custom installer pages with nsDialogs !macro __NSD_SetFocus HWND - System::Call "user32::SetFocus(i${HWND})" + System::Call "user32::SetFocus(p${HWND})" !macroend @@ -492,7 +492,7 @@ Header file for creating custom installer pages with nsDialogs !macro __NSD_LB_GetSelection CONTROL VAR SendMessage ${CONTROL} ${LB_GETCURSEL} 0 0 ${VAR} - System::Call 'user32::SendMessage(i ${CONTROL}, i ${LB_GETTEXT}, i ${VAR}, t .s)' + System::Call 'user32::SendMessage(p ${CONTROL}, i ${LB_GETTEXT}, p ${VAR}, t .s)' Pop ${VAR} !macroend @@ -511,10 +511,10 @@ Header file for creating custom installer pages with nsDialogs !if "${_LIHINSTMODE}" == "exeresource" !undef _LIHINSTSRC # If (internal?) _* macro params starts using $0, !define _LIHINSTSRC r0 # _LIHINSTSRC can be changed to s - System::Call 'kernel32::GetModuleHandle(i0)i.${_LIHINSTSRC}' + System::Call 'kernel32::GetModuleHandle(p0)p.${_LIHINSTSRC}' !endif - System::Call 'user32::LoadImage(i ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS}) i.r0' + System::Call 'user32::LoadImage(p ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS})p.r0' SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0 Pop $R0 @@ -549,25 +549,19 @@ Header file for creating custom installer pages with nsDialogs StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0 - StrCpy $1 "" - StrCpy $2 "" - - System::Call '*(i, i, i, i) i.s' - Pop $0 - + # Allocate a RECT in $0 and initialize $1 and $2 to 0 + System::Call '*(i0r1, i0r2, i, i)p.r0' ${If} $0 <> 0 - - System::Call 'user32::GetClientRect(iR0, ir0)' + System::Call 'user32::GetClientRect(pR0, pr0)' System::Call '*$0(i, i, i .s, i .s)' System::Free $0 Pop $1 Pop $2 - ${EndIf} - System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) i.s' "${IMAGE}" + System::Call 'user32::LoadImage(p0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) p.s' "${IMAGE}" Pop $0 - SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0 + SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0 Pop $R0 Pop $2 @@ -583,9 +577,7 @@ Header file for creating custom installer pages with nsDialogs !macro __NSD_FreeImage IMAGE ${If} ${IMAGE} <> 0 - - System::Call gdi32::DeleteObject(is) ${IMAGE} - + System::Call gdi32::DeleteObject(ps) ${IMAGE} ${EndIf} !macroend @@ -594,7 +586,7 @@ Header file for creating custom installer pages with nsDialogs !define NSD_FreeBitmap `${NSD_FreeImage}` !macro __NSD_FreeIcon IMAGE - System::Call user32::DestroyIcon(is) ${IMAGE} + System::Call user32::DestroyIcon(ps) ${IMAGE} !macroend !define NSD_FreeIcon `!insertmacro __NSD_FreeIcon` diff --git a/Contrib/nsDialogs/welcome.nsi b/Contrib/nsDialogs/welcome.nsi index 29a90e71..cee2ec89 100644 --- a/Contrib/nsDialogs/welcome.nsi +++ b/Contrib/nsDialogs/welcome.nsi @@ -96,7 +96,7 @@ Function nsDialogsWelcome Pop $IMAGECTL StrCpy $0 $PLUGINSDIR\welcome.bmp - System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s' + System::Call 'user32::LoadImage(p 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE})p.s' Pop $IMAGE SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE @@ -119,7 +119,7 @@ Function nsDialogsWelcome Call ShowControls - System::Call gdi32::DeleteObject(i$IMAGE) + System::Call gdi32::DeleteObject(p$IMAGE) FunctionEnd @@ -198,7 +198,7 @@ Function DirChange GetDlgItem $0 $HWNDPARENT 1 - System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN}) + System::Call user32::GetWindowText(p$DIRECTORY,t.d,i${NSIS_MAX_STRLEN}) ${If} ${FileExists} $INSTDIR\makensis.exe EnableWindow $0 1 diff --git a/Contrib/zip2exe/main.cpp b/Contrib/zip2exe/main.cpp index 4f64a17d..c2e6c39c 100644 --- a/Contrib/zip2exe/main.cpp +++ b/Contrib/zip2exe/main.cpp @@ -76,7 +76,7 @@ int g_zipfile_size; bool g_made; -static BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); NSIS_ENTRYPOINT_SIMPLEGUI int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int ShowCmd) @@ -600,7 +600,7 @@ void SetZip(HWND hwndDlg, TCHAR *path) } } -BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int ids[]={IDC_INFO,IDC_NSISICON,IDC_SZIPFRAME,IDC_BROWSE,IDC_ZIPFILE,IDC_ZIPINFO_SUMMARY,IDC_ZIPINFO_FILES,IDC_OFRAME,IDC_INAMEST, IDC_INSTNAME,IDC_INSTPATH,IDC_OEFST,IDC_OUTFILE,IDC_BROWSE2,IDC_COMPRESSOR,IDC_ZLIB,IDC_BZIP2,IDC_LZMA,IDC_SOLID,IDC_INTERFACE,IDC_MODERNUI,IDC_CLASSICUI,IDC_UNICODE}; @@ -783,5 +783,5 @@ BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; } - return 0; + return FALSE; } diff --git a/Docs/src/usefulfunc.but b/Docs/src/usefulfunc.but index 9e653780..1b8d0836 100644 --- a/Docs/src/usefulfunc.but +++ b/Docs/src/usefulfunc.but @@ -141,14 +141,14 @@ \H{installerfilename} Get Installer Filename -\c System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' +\c System::Call 'kernel32::GetModuleFileName(p 0, t .R0, i 1024) i r1' \c ;$R0 will contain the installer filename \H{multipleinstances} Prevent Multiple Instances Put the following code in your \R{oninit}{.onInit function}: -\c System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' +\c System::Call 'kernel32::CreateMutex(p 0, i 0, t "myMutex") p .r1 ?e' \c Pop $R0 \c \c StrCmp $R0 0 +3 diff --git a/Docs/src/usefulinfos.but b/Docs/src/usefulinfos.but index 9f23dae9..5bf04d4d 100644 --- a/Docs/src/usefulinfos.but +++ b/Docs/src/usefulinfos.but @@ -234,10 +234,10 @@ Here is the function: \c System::StrAlloc ${NSIS_MAX_STRLEN} \c Pop $3 \c StrCpy $2 0 -\c System::Call "*(i, i, i, i, i, i, i, i, i) i \ +\c System::Call "*(i, i, i, i, i, i, i, i, i) p \ \c (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" \c loop: StrCmp $2 $6 done -\c System::Call "User32::SendMessage(i, i, i, i) i \ +\c System::Call "User32::SendMessage(p, i, p, p) i \ \c ($0, ${LVM_GETITEMTEXT}, $2, r1)" \c System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" \c FileWrite $5 "$4$\r$\n" @@ -286,10 +286,10 @@ Here's the function to generate a Unicode file if you're building a \R{intro-uni \c System::StrAlloc ${NSIS_MAX_STRLEN} \c Pop $3 \c StrCpy $2 0 -\c System::Call "*(i, i, i, i, i, i, i, i, i) i \ +\c System::Call "*(i, i, i, i, i, i, i, i, i) p \ \c (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" \c loop: StrCmp $2 $6 done -\c System::Call "User32::SendMessageW(i, i, i, i) i \ +\c System::Call "User32::SendMessageW(p, i, p, p) i \ \c ($0, ${LVM_GETITEMTEXT}, $2, r1)" \c System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" \c FileWriteUTF16LE $5 "$4$\r$\n" diff --git a/Examples/makensis.nsi b/Examples/makensis.nsi index 10300a50..d07c03ca 100644 --- a/Examples/makensis.nsi +++ b/Examples/makensis.nsi @@ -11,12 +11,20 @@ ;-------------------------------- ;Configuration -!ifdef OUTFILE - OutFile "${OUTFILE}" +!ifdef NSIS_MAKENSIS64 + !define BITS 64 + !define NAMESUFFIX " (64 bit)" !else - OutFile ..\nsis-${VERSION}-setup.exe + !define BITS 32 + !define NAMESUFFIX "" !endif +!ifndef OUTFILE + !define OUTFILE "..\nsis${BITS}-${VERSION}-setup.exe" + !searchreplace OUTFILE "${OUTFILE}" nsis32 nsis +!endif + +OutFile "${OUTFILE}" Unicode true SetCompressor /SOLID lzma @@ -24,7 +32,7 @@ InstType "Full" InstType "Lite" InstType "Minimal" -InstallDir $PROGRAMFILES\NSIS +InstallDir $PROGRAMFILES${BITS}\NSIS InstallDirRegKey HKLM Software\NSIS "" RequestExecutionLevel admin @@ -49,7 +57,7 @@ RequestExecutionLevel admin ;Names Name "NSIS" -Caption "NSIS ${VERSION} Setup" +Caption "NSIS ${VERSION}${NAMESUFFIX} Setup" !define REG_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" @@ -114,11 +122,17 @@ VIAddVersionKey "LegalCopyright" "http://nsis.sf.net/License" !macro InstallPlugin pi File "/oname=$InstDir\Plugins\x86-ansi\${pi}.dll" ..\Plugins\x86-ansi\${pi}.dll File "/oname=$InstDir\Plugins\x86-unicode\${pi}.dll" ..\Plugins\x86-unicode\${pi}.dll + !ifdef NSIS_MAKENSIS64 + File "/oname=$InstDir\Plugins\amd64-unicode\${pi}.dll" ..\Plugins\amd64-unicode\${pi}.dll + !endif !macroend !macro InstallStub stub File ..\Stubs\${stub}-x86-ansi File ..\Stubs\${stub}-x86-unicode + !ifdef NSIS_MAKENSIS64 + File ..\Stubs\${stub}-amd64-unicode + !endif !macroend ${MementoSection} "NSIS Core Files (required)" SecCore @@ -218,6 +232,9 @@ ${MementoSection} "NSIS Core Files (required)" SecCore CreateDirectory $INSTDIR\Plugins\x86-ansi CreateDirectory $INSTDIR\Plugins\x86-unicode + !ifdef NSIS_MAKENSIS64 + CreateDirectory $INSTDIR\Plugins\amd64-unicode + !endif !insertmacro InstallPlugin TypeLib ReadRegStr $R0 HKCR ".nsi" "" @@ -330,10 +347,10 @@ ${MementoSection} "Desktop Shortcut" SecShortcuts SectionIn 1 2 SetOutPath $INSTDIR !ifndef NO_STARTMENUSHORTCUTS - CreateShortCut "$SMPROGRAMS\NSIS.lnk" "$INSTDIR\NSIS.exe" + CreateShortCut "$SMPROGRAMS\NSIS${NAMESUFFIX}.lnk" "$INSTDIR\NSIS.exe" !endif - CreateShortCut "$DESKTOP\NSIS.lnk" "$INSTDIR\NSIS.exe" + CreateShortCut "$DESKTOP\NSIS${NAMESUFFIX}.lnk" "$INSTDIR\NSIS.exe" ${MementoSectionEnd} @@ -797,7 +814,7 @@ Section -post WriteRegExpandStr HKLM "${REG_UNINST_KEY}" "UninstallString" '"$INSTDIR\uninst-nsis.exe"' WriteRegExpandStr HKLM "${REG_UNINST_KEY}" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayName" "Nullsoft Install System" + WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayName" "Nullsoft Install System${NAMESUFFIX}" WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayIcon" "$INSTDIR\NSIS.exe,0" WriteRegStr HKLM "${REG_UNINST_KEY}" "DisplayVersion" "${VERSION}" !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD @@ -1032,8 +1049,8 @@ Section Uninstall DetailPrint "Deleting Files..." SetDetailsPrint listonly - Delete $SMPROGRAMS\NSIS.lnk - Delete $DESKTOP\NSIS.lnk + Delete "$SMPROGRAMS\NSIS${NAMESUFFIX}.lnk" + Delete "$DESKTOP\NSIS${NAMESUFFIX}.lnk" Delete $INSTDIR\makensis.exe Delete $INSTDIR\makensisw.exe Delete $INSTDIR\NSIS.exe diff --git a/Include/FileFunc.nsh b/Include/FileFunc.nsh index a6ba591b..76f4cbe8 100644 --- a/Include/FileFunc.nsh +++ b/Include/FileFunc.nsh @@ -1107,22 +1107,22 @@ RefreshShellIcons FileFunc_GetTime_getfile: IfFileExists $0 0 FileFunc_GetTime_error - System::Call '*(i,l,l,l,i,i,i,i,&t260,&t14) i .r6' - System::Call 'kernel32::FindFirstFile(t,i)i(r0,r6) .r2' + System::Call '*(i,l,l,l,i,i,i,i,&t260,&t14) p .r6' + System::Call 'kernel32::FindFirstFile(t,p)p(r0,r6) .r2' System::Call 'kernel32::FindClose(i)i(r2)' FileFunc_GetTime_gettime: - System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r7' + System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) p .r7' StrCmp $1 'L' 0 FileFunc_GetTime_systemtime - System::Call 'kernel32::GetLocalTime(i)i(r7)' + System::Call 'kernel32::GetLocalTime(p)i(r7)' goto FileFunc_GetTime_convert FileFunc_GetTime_systemtime: StrCmp $1 'LS' 0 FileFunc_GetTime_filetime - System::Call 'kernel32::GetSystemTime(i)i(r7)' + System::Call 'kernel32::GetSystemTime(p)i(r7)' goto FileFunc_GetTime_convert FileFunc_GetTime_filetime: - System::Call '*$6(i,l,l,l,i,i,i,i,&t260,&t14)i(,.r4,.r3,.r2)' + System::Call '*$6(i,l,l,l,i,i,i,i,&t260,&t14)p(,.r4,.r3,.r2)' System::Free $6 StrCmp $1 'A' 0 +3 StrCpy $2 $3 @@ -1146,7 +1146,7 @@ RefreshShellIcons System::Call 'kernel32::FileTimeToSystemTime(*l,i)i(r3,r7)' FileFunc_GetTime_convert: - System::Call '*$7(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)i(.r5,.r6,.r4,.r0,.r3,.r2,.r1,)' + System::Call '*$7(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)p(.r5,.r6,.r4,.r0,.r3,.r2,.r1,)' System::Free $7 IntCmp $0 9 0 0 +2 @@ -1398,7 +1398,7 @@ RefreshShellIcons Push $0 Push $1 Push $2 - System::Call 'kernel32::GetModuleFileName(i 0, t .r0, i 1024)' + System::Call 'kernel32::GetModuleFileName(p 0, t .r0, i 1024)' System::Call 'kernel32::GetLongPathName(t r0, t .r1, i 1024)i .r2' StrCmp $2 error +2 StrCpy $0 $1 diff --git a/Include/StrFunc.nsh b/Include/StrFunc.nsh index 64f91c11..e8c9b70e 100644 --- a/Include/StrFunc.nsh +++ b/Include/StrFunc.nsh @@ -285,7 +285,7 @@ o-----------------------------------------------------------------------------o ; Else convert to lower case. ;Use "IsCharAlpha" for the job - System::Call "*(&t1 r7) i .r8" + System::Call "*(&t1 r7) p .r8" System::Call "*$8(&i1 .r7)" System::Free $8 System::Call "user32::IsCharAlpha(i r7) i .r8" @@ -325,7 +325,7 @@ o-----------------------------------------------------------------------------o ; Switch all characters cases to their inverse case. ;Use "IsCharUpper" for the job - System::Call "*(&t1 r6) i .r8" + System::Call "*(&t1 r6) p .r8" System::Call "*$8(&i1 .r7)" System::Free $8 System::Call "user32::IsCharUpper(i r7) i .r8" @@ -395,7 +395,7 @@ o-----------------------------------------------------------------------------o StrCpy $4 "" ;Open the clipboard to do the operations the user chose (kichik's fix) - System::Call 'user32::OpenClipboard(i $HWNDPARENT)' + System::Call 'user32::OpenClipboard(p $HWNDPARENT)' ${If} $1 == ">" ;Set @@ -405,44 +405,44 @@ o-----------------------------------------------------------------------------o ;Step 2: Allocate global heap StrLen $2 $0 IntOp $2 $2 + 1 - IntOp $2 $2 * ${NSIS_CHAR_SIZE} - System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' + IntOp $2 $2 * ${NSIS_CHAR_SIZE} + System::Call 'kernel32::GlobalAlloc(i 2, i r2) p.r2' ;Step 3: Lock the handle - System::Call 'kernel32::GlobalLock(i r2) i.r3' + System::Call 'kernel32::GlobalLock(p r2) i.r3' ;Step 4: Copy the text to locked clipboard buffer - System::Call 'kernel32::lstrcpy(i r3, t r0)' + System::Call 'kernel32::lstrcpy(p r3, t r0)' ;Step 5: Unlock the handle again - System::Call 'kernel32::GlobalUnlock(i r2)' + System::Call 'kernel32::GlobalUnlock(p r2)' ;Step 6: Set the information to the clipboard - System::Call 'user32::SetClipboardData(i 1, i r2)' + System::Call 'user32::SetClipboardData(i 1, p r2)' StrCpy $0 "" ${ElseIf} $1 == "<" ;Get ;Step 1: Get clipboard data - System::Call 'user32::GetClipboardData(i 1) i .r2' + System::Call 'user32::GetClipboardData(i 1) p .r2' ;Step 2: Lock and copy data (kichik's fix) - System::Call 'kernel32::GlobalLock(i r2) t .r0' + System::Call 'kernel32::GlobalLock(p r2) t .r0' ;Step 3: Unlock (kichik's fix) - System::Call 'kernel32::GlobalUnlock(i r2)' + System::Call 'kernel32::GlobalUnlock(p r2)' ${ElseIf} $1 == "<>" ;Swap ;Step 1: Get clipboard data - System::Call 'user32::GetClipboardData(i 1) i .r2' + System::Call 'user32::GetClipboardData(i 1) p .r2' ;Step 2: Lock and copy data (kichik's fix) - System::Call 'kernel32::GlobalLock(i r2) t .r4' + System::Call 'kernel32::GlobalLock(p r2) t .r4' ;Step 3: Unlock (kichik's fix) - System::Call 'kernel32::GlobalUnlock(i r2)' + System::Call 'kernel32::GlobalUnlock(p r2)' ;Step 4: Clear the clipboard System::Call 'user32::EmptyClipboard()' @@ -451,19 +451,19 @@ o-----------------------------------------------------------------------------o StrLen $2 $0 IntOp $2 $2 + 1 IntOp $2 $2 * ${NSIS_CHAR_SIZE} - System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' + System::Call 'kernel32::GlobalAlloc(i 2, i r2) p.r2' ;Step 6: Lock the handle - System::Call 'kernel32::GlobalLock(i r2) i.r3' + System::Call 'kernel32::GlobalLock(p r2) i.r3' ;Step 7: Copy the text to locked clipboard buffer - System::Call 'kernel32::lstrcpy(i r3, t r0)' + System::Call 'kernel32::lstrcpy(p r3, t r0)' ;Step 8: Unlock the handle again - System::Call 'kernel32::GlobalUnlock(i r2)' + System::Call 'kernel32::GlobalUnlock(p r2)' ;Step 9: Set the information to the clipboard - System::Call 'user32::SetClipboardData(i 1, i r2)' + System::Call 'user32::SetClipboardData(i 1, p r2)' StrCpy $0 $4 ${Else} ;Clear diff --git a/Include/TextFunc.nsh b/Include/TextFunc.nsh index 67678207..230835b6 100644 --- a/Include/TextFunc.nsh +++ b/Include/TextFunc.nsh @@ -1043,12 +1043,12 @@ TrimNewLines System::Alloc $6 Pop $0 FileSeek $3 $5 SET - System::Call 'kernel32::ReadFile(i r3, i r0, i $6, t.,)' + System::Call 'kernel32::ReadFile(p r3, p r0, i $6, t.,)' FileSeek $3 $4 SET StrCmp${_TEXTFUNC_S} $2 '' +2 FileWrite $3 '$1$2$\r$\n' - System::Call 'kernel32::WriteFile(i r3, i r0, i $6, t.,)' - System::Call 'kernel32::SetEndOfFile(i r3)' + System::Call 'kernel32::WriteFile(p r3, p r0, i $6, t.,)' + System::Call 'kernel32::SetEndOfFile(p r3)' System::Free $0 StrCmp${_TEXTFUNC_S} $2 '' +3 StrCpy $0 CHANGED @@ -1153,10 +1153,10 @@ TrimNewLines System::Alloc $3 Pop $4 FileSeek $2 0 SET - System::Call 'kernel32::ReadFile(i r2, i r4, i $3, t.,)' - System::Call 'user32::$1Buff(i r4, i r4, i $3)' + System::Call 'kernel32::ReadFile(p r2, p r4, i $3, t.,)' + System::Call 'user32::$1Buff(p r4, p r4, i $3)' FileSeek $2 0 SET - System::Call 'kernel32::WriteFile(i r2, i r4, i $3, t.,)' + System::Call 'kernel32::WriteFile(p r2, p r4, i $3, t.,)' System::Free $4 FileClose $2 goto TextFunc_FileRecode_end diff --git a/Include/x64.nsh b/Include/x64.nsh index e694c1e6..a35e0990 100644 --- a/Include/x64.nsh +++ b/Include/x64.nsh @@ -27,8 +27,8 @@ !macro _RunningX64 _a _b _t _f !insertmacro _LOGICLIB_TEMP - System::Call kernel32::GetCurrentProcess()i.s - System::Call kernel32::IsWow64Process(is,*i.s) + System::Call kernel32::GetCurrentProcess()p.s + System::Call kernel32::IsWow64Process(ps,*i.s) Pop $_LOGICLIB_TEMP !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}` !macroend diff --git a/SConstruct b/SConstruct index e6203579..b4b047d5 100644 --- a/SConstruct +++ b/SConstruct @@ -66,16 +66,17 @@ doctypes = [ path = ARGUMENTS.get('PATH', '') toolset = ARGUMENTS.get('TOOLSET', '') +arch = ARGUMENTS.get('TARGET_ARCH', 'x86') if toolset and path: - defenv = Environment(TARGET_ARCH = 'x86', ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) + defenv = Environment(TARGET_ARCH = arch, ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) else: if path: - defenv = Environment(TARGET_ARCH = 'x86', ENV = {'PATH' : path}) + defenv = Environment(TARGET_ARCH = arch, ENV = {'PATH' : path}) if toolset: - defenv = Environment(TARGET_ARCH = 'x86', TOOLS = toolset.split(',') + ['zip']) + defenv = Environment(TARGET_ARCH = arch, TOOLS = toolset.split(',') + ['zip']) if not toolset and not path: - defenv = Environment(TARGET_ARCH = 'x86') + defenv = Environment(TARGET_ARCH = arch) Export('defenv') @@ -170,6 +171,7 @@ opts.Add(('PATH', 'A colon-separated list of system paths instead of the default opts.Add(('TOOLSET', 'A comma-separated list of specific tools used for building instead of the default', None)) opts.Add(BoolVariable('MSTOOLKIT', 'Use Microsoft Visual C++ Toolkit', 'no')) opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', os.environ.get('MSVS_VERSION'), allowed_values=('6.0', '7.0', '7.1', '8.0', '8.0Exp', '9.0', '9.0Exp', '10.0', '10.0Exp'))) +opts.Add(EnumVariable('TARGET_ARCH', 'Target processor architecture', 'x86', allowed_values=('x86', 'amd64'))) opts.Add(ListVariable('DOCTYPES', 'A list of document types that will be built', default_doctype, doctypes)) opts.Add(PathVariable('APPEND_CPPPATH', 'Additional paths to search for include files', None)) opts.Add(PathVariable('APPEND_LIBPATH', 'Additional paths to search for libraries', None)) @@ -196,6 +198,9 @@ opts.Add(('PREFIX_PLUGINAPI_LIB','Path to install plugin static library to.', No opts.Update(defenv) Help(opts.GenerateHelpText(defenv)) +if defenv['TARGET_ARCH'] != 'x86': + defenv['UNICODE'] = True + # add prefixes defines if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))]) @@ -324,6 +329,8 @@ defenv['INSTDISTDIR'] = defenv.Dir('#.instdist') defenv['TESTDISTDIR'] = defenv.Dir('#.test') defenv['DISTSUFFIX'] = '' +if defenv['TARGET_ARCH'] == 'amd64': + defenv['DISTSUFFIX'] += '-amd64' if defenv.has_key('CODESIGNER'): defenv['DISTSUFFIX'] = '-signed' @@ -609,6 +616,7 @@ for stub in stubs: if GetArcCPU(defenv)=='x86': BuildStub(stub, False, False) BuildStub(stub, True, False) + # BUGBUG64: Should build x86 stubs on x64? defenv.DistributeStubs('Source/exehead/uninst.ico',names='uninst') diff --git a/Source/Tests/winver.nsi b/Source/Tests/winver.nsi index a5b21e50..8e60bb9c 100644 --- a/Source/Tests/winver.nsi +++ b/Source/Tests/winver.nsi @@ -20,7 +20,7 @@ # System::Alloc 156 # Pop $0 # System::Call *$0(ir1) -# System::Call kernel32::GetVersionEx(ir0)i.R0 +# System::Call kernel32::GetVersionEx(pr0)i.R0 # # DetailPrint 'StrCpy $2_RES $R0' # diff --git a/Source/build.cpp b/Source/build.cpp index ff19264a..b976b434 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -149,6 +149,7 @@ CEXEBuild::CEXEBuild() : #ifdef _UNICODE definedlist.add(_T("NSIS_UNICODE_MAKENSIS")); // This define might go away once makensis.exe is always unicode #endif + if (sizeof(void*) > 4) definedlist.add(_T("NSIS_MAKENSIS64")); db_opt_save=db_comp_save=db_full_size=db_opt_save_u=db_comp_save_u=db_full_size_u=0; @@ -3645,6 +3646,7 @@ void CEXEBuild::set_target_architecture_predefines() { definedlist.del(_T("NSIS_UNICODE")); definedlist.del(_T("NSIS_CHAR_SIZE")); + definedlist.del(_T("NSIS_PTR_SIZE")); if (build_unicode) { definedlist.add(_T("NSIS_UNICODE")); @@ -3654,6 +3656,7 @@ void CEXEBuild::set_target_architecture_predefines() { definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1")); } + definedlist.add(_T("NSIS_PTR_SIZE"), m_target_type <= TARGET_X86UNICODE ? _T("4") : _T("8")); } int CEXEBuild::change_target_architecture() @@ -3664,7 +3667,7 @@ int CEXEBuild::change_target_architecture() return PS_ERROR; } - m_target_type = build_unicode ? TARGET_X86UNICODE : TARGET_X86ANSI; + m_target_type = build_unicode ? TARGET_X86UNICODE : TARGET_X86ANSI; // BUGBUG64 set_target_architecture_predefines(); int ec = load_stub(); @@ -3708,6 +3711,9 @@ const TCHAR* CEXEBuild::get_target_suffix(CEXEBuild::TARGETTYPE tt) const { case TARGET_X86ANSI :return _T("x86-ansi"); case TARGET_X86UNICODE:return _T("x86-unicode"); +#if !defined(_WIN32) || defined(_WIN64) + case TARGET_AMD64 :return _T("amd64-unicode"); +#endif default:return _T("?"); } } diff --git a/Source/build.h b/Source/build.h index 81499774..8e169f6c 100644 --- a/Source/build.h +++ b/Source/build.h @@ -120,6 +120,7 @@ class CEXEBuild { TARGETFIRST, TARGET_X86ANSI = TARGETFIRST, TARGET_X86UNICODE, + TARGET_AMD64, // Always Unicode TARGET_UNKNOWN, TARGETCOUNT = (TARGET_UNKNOWN-TARGETFIRST) } TARGETTYPE; diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 323ea0a7..dad7fc49 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -16,13 +16,12 @@ * Unicode support by Jim Park -- 08/10/2007 */ +#include "../Platform.h" #include #include #include #include -#include "../Platform.h" - #include "resource.h" #include "fileform.h" @@ -65,15 +64,15 @@ static void NSISCALL outernotify(int delta) { } #ifdef NSIS_CONFIG_VISIBLE_SUPPORT -BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); #ifdef NSIS_CONFIG_LICENSEPAGE -static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); #endif -static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); #endif//NSIS_CONFIG_VISIBLE_SUPPORT static DWORD WINAPI install_thread(LPVOID p); @@ -119,7 +118,7 @@ static void NSISCALL NotifyCurWnd(UINT uNotifyCode) #ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT #define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam) -static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) { if ((uMsg - WM_CTLCOLOREDIT) <= (WM_CTLCOLORSTATIC - WM_CTLCOLOREDIT)) { @@ -151,7 +150,7 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara c->bkb = CreateBrushIndirect(&lh); } - return (BOOL)c->bkb; + return (INT_PTR)c->bkb; } } return 0; @@ -464,7 +463,7 @@ static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lPara return 0; } -BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT) { @@ -738,7 +737,7 @@ DWORD CALLBACK StreamLicenseRTF(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG } #endif -static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { page *m_this_page=g_this_page; HWND hwLicense; @@ -847,7 +846,7 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM #endif #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT -static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { @@ -909,7 +908,7 @@ static int NSISCALL _sumsecsfield(int idx) #define sumsecsfield(x) _sumsecsfield(SECTION_OFFSET(x)) -static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int dontsetdefstyle; page *thispage = g_this_page; @@ -1279,7 +1278,7 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l return CallWindowProc(oldTreeWndProc,hwnd,uMsg,wParam,lParam); } -static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { const int wParamSelChangeNotifyInstTypeChanged = -1; static HTREEITEM *hTreeItems; @@ -1636,7 +1635,7 @@ static DWORD WINAPI install_thread(LPVOID p) #ifdef NSIS_CONFIG_VISIBLE_SUPPORT -static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND linsthwnd=insthwnd; if (uMsg == WM_INITDIALOG) @@ -1724,24 +1723,14 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa HMENU menu = CreatePopupMenu(); POINT pt; AppendMenu(menu,MF_STRING,1,GetNSISStringTT(LANG_COPYDETAILS)); - if (lParam == ((UINT)-1)) + pt.x = GET_X_LPARAM(lParam), pt.y = GET_Y_LPARAM(lParam); + if (lParam == ((UINT)-1)) // BUGBUG64? { RECT r; - GetWindowRect(linsthwnd, &r); - pt.x = r.left; - pt.y = r.top; + GetWindowRect(linsthwnd,&r); + pt.x = r.left, pt.y = r.top; } - else - { - pt.x = GET_X_LPARAM(lParam); - pt.y = GET_Y_LPARAM(lParam); - } - if (1==TrackPopupMenu( - menu, - TPM_NONOTIFY|TPM_RETURNCMD, - pt.x, - pt.y, - 0,hwndDlg,0)) + if (1==TrackPopupMenu(menu,TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,0,hwndDlg,0)) { int i,total = 1; // 1 for the null char LVITEM item; diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index 2d3dcb48..ba655f67 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -83,7 +83,7 @@ static int NSISCALL calc_percent() #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #if defined(NSIS_CONFIG_CRC_SUPPORT) || defined(NSIS_COMPRESS_WHOLE) -BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { @@ -99,13 +99,11 @@ BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) #else TCHAR *msg=_LANG_VERIFYINGINST; #endif - wsprintf(bt,msg,percent); - my_SetWindowText(hwndDlg,bt); my_SetDialogItemText(hwndDlg,IDC_STR,bt); } - return 0; + return FALSE; } DWORD verify_time; @@ -460,8 +458,8 @@ static char _inbuffer[IBUFSIZE]; static char _outbuffer[OBUFSIZE]; extern int m_length; extern int m_pos; -extern BOOL CALLBACK verProc(HWND, UINT, WPARAM, LPARAM); -extern BOOL CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM); +extern INT_PTR CALLBACK verProc(HWND, UINT, WPARAM, LPARAM); +extern INT_PTR CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM); static int NSISCALL __ensuredata(int amount) { int needed=amount-(dbd_size-dbd_pos); diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 562a0b0b..9b30720a 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -468,6 +468,7 @@ typedef struct #define CC_BK_SYS 8 #define CC_BKB 16 +#pragma pack(push, 4) typedef struct { COLORREF text; COLORREF bkc; @@ -476,6 +477,7 @@ typedef struct { int bkmode; int flags; } ctlcolors; +#pragma pack(pop) // constants for myDelete (util.c) #define DEL_DIR 1 diff --git a/Source/script.cpp b/Source/script.cpp index dca3b467..68a565ba 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -877,8 +877,8 @@ int CEXEBuild::includeScript(const TCHAR *f, NStreamEncoding&enc) { NIStream incstrm; const bool openok = incstrm.OpenFileForReading(f,enc); - if ( // !include defaults to UTF-8 after "Unicode true" - NStreamEncoding::AUTO == enc.GetCodepage() && build_unicode && + if (NStreamEncoding::AUTO == enc.GetCodepage() && // !include defaults to UTF-8 after "Unicode true" + build_unicode && !enc.IsUnicodeCodepage(enc.GetPlatformDefaultCodepage()) && enc.GetPlatformDefaultCodepage() == incstrm.StreamEncoding().GetCodepage() ) incstrm.StreamEncoding().SetCodepage(NStreamEncoding::UTF8); enc = incstrm.StreamEncoding();