Commits

Anonymous committed 0b13ec9

Basic changes to get NSIS to compile on 64-bit Windows.

  • Participants
  • Parent commits 205abbe

Comments (0)

Files changed (14)

Contrib/MakeLangId/MakeLangId.cpp

 	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:

Contrib/Makensisw/jnetlib/httpget.cpp

 #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)

Contrib/Makensisw/makensisw.cpp

     GlobalFree(argv);
 }
 
-BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
   switch (msg) {
     case WM_INITDIALOG:
     {
       g_sdata.hwnd=hwndDlg;
       HICON hIcon = LoadIcon(g_sdata.hInstance,MAKEINTRESOURCE(IDI_ICON));
-      SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)hIcon);
       // Altered by Darren Owen (DrO) on 29/9/2003
       // Added in receiving of mouse and key events from the richedit control
       SendMessage(GetDlgItem(hwndDlg,IDC_LOGWIN),EM_SETEVENTMASK,(WPARAM)NULL,ENM_SELCHANGE|ENM_MOUSEEVENTS|ENM_KEYEVENTS);

Contrib/Makensisw/makensisw.h

 extern const TCHAR* NSISW_VERSION;
 
 int WINAPI     _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int cmdShow);
-BOOL           CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR        CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 DWORD WINAPI   MakeNSISProc(LPVOID p);
 BOOL CALLBACK  DialogResize(HWND hWnd, LPARAM /* unused*/);
 BOOL CALLBACK  AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);

Contrib/NSISdl/nsisdl.cpp

 
 #include <nsis/pluginapi.h> // nsis plugin
 
-void *operator new( unsigned int num_bytes )
+void *operator new( size_t num_bytes )
 {
   return GlobalAlloc(GPTR,num_bytes);
 }

Contrib/System/SConscript

 
 Import('BuildPlugin env')
 
-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()
+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()
 
 BuildPlugin(
 	target,

Contrib/System/Source/Plugin.c

     system_pushstring(buffer);
 }
 
+__int64 system_popint64()
+{
+    __int64 value;
+    TCHAR *str;
+    if ((str = system_popstring()) == NULL) return -1;
+    value = myatoi64(str);
+    GlobalFree(str);
+    return value;
+}
+
+void system_pushint64(__int64 value)
+{
+    TCHAR buffer[80];
+    wsprintf(buffer, _T("%I64d"), value);
+    system_pushstring(buffer);
+}
+
 void *copymem(void *output, void *input, size_t cbSize)
 {
   BYTE *out = (BYTE*) output;

Contrib/System/Source/Plugin.h

 // Always use system* functions to keep the size down
 #define pushstring error(use system_pushstring)
 #define pushint error(use system_pushint)
+#define pushint64 error(use system_pushint64)
 
 #define popint system_popint
+#define popint64 system_popint64
 #define myatoi(str) ( (int) myatoi64(str) ) 
 #ifdef _WIN64
-#	error TODO
+#	define system_pushintptr system_pushint64
+#	define popintptr popint64
+#	define StrToIntPtr(str) ( (INT_PTR)myatoi64((str)) )
 #else
 #	define system_pushintptr system_pushint
 #	define popintptr popint
 extern __int64 myatoi64(TCHAR *s);
 extern int system_popint();  // -1 -> stack empty
 extern void system_pushint(int value);
+extern __int64 system_popint64();
+extern void system_pushint64(__int64 value);
 
 extern HANDLE GlobalCopy(HANDLE Old);
 extern void *copymem(void *output, void *input, size_t cbSize);

Contrib/System/Source/System.c

 DWORD LastError;
 volatile SystemProc *LastProc;
 int CallbackIndex;
+#ifndef SYSTEM_X64
 CallbackThunk* CallbackThunkListHead;
+#endif
 HINSTANCE g_hInstance;
 
 // Return to callback caller with stack restore
 {
     HANDLE memtofree = (HANDLE)popintptr();
 
+#ifndef SYSTEM_X64
     if (CallbackThunkListHead)
     {
         CallbackThunk *pCb=CallbackThunkListHead,*pPrev=NULL;
         }
         while( pCb != NULL );
     }
+#endif
 
     GlobalFree(memtofree);
 }
         ParamAllocate(proc);
     ParamsIn(proc);
 
+#ifndef SYSTEM_X64
     // Make the call
     if (proc->ProcResult != PR_ERROR)
     {
     // If proc is permanent?
     if ((proc->Options & POPT_PERMANENT) == 0)
         GlobalFree((HANDLE) proc); // No, free it
+#else
+    ParamsOut(proc);
+    system_pushintptr(0);
+#endif
 } PLUGINFUNCTIONEND
 
 PLUGINFUNCTIONSHORT(Int64Op)
             case _T('v'):
             case _T('V'): temp2 = PAT_VOID; break;
 
-            #if !defined(SYSTEM_X86)
-                #error "TODO: handle p"
-            #else
-                case _T('p'):
+            #if defined(SYSTEM_X64)
+            case _T('p'): temp2 = PAT_LONG; break;
+            #elif defined(SYSTEM_X86)
+            case _T('p'): temp2 = PAT_INT; break;
             #endif
             case _T('i'):
             case _T('I'): temp2 = PAT_INT; break;
 
 HANDLE CreateCallback(SystemProc *cbproc)
 {
+#ifndef SYSTEM_X64
     char *mem;
 
     if (cbproc->Proc == NULL)
 
     // Return proc address
     return cbproc->Proc;
+#else
+    // Not yet implemented
+    return NULL;
+#endif
 }
 
 void CallStruct(SystemProc *proc)
             LastError = 0;
             LastProc = NULL;
             CallbackIndex = 0;
+#ifndef SYSTEM_X64
             CallbackThunkListHead = NULL;
+#endif
             retexpr[0] = (char) 0xC2;
             retexpr[2] = 0x00;
         }

Contrib/System/Source/System.h

     SystemProc *Clone;
 };
 
+#ifndef SYSTEM_X64
 typedef struct tag_CallbackThunk CallbackThunk;
 struct tag_CallbackThunk
 {
 
     CallbackThunk* pNext;
 };
+#endif
 
 // Free() only knows about pNext in CallbackThunk, it does not know anything about the assembly, that is where this helper comes in...
+#ifndef SYSTEM_X64
 #ifdef SYSTEM_X86
 #   define GetAssociatedSysProcFromCallbackThunkPtr(pCbT) ( (SystemProc*)  *(unsigned int*) (((char*)(pCbT))+1) )
 #else
 #   error "GetAssociatedSysProcFromCallbackThunkPtr not defined for the current architecture!"
 #endif
+#endif
 
 
 extern const int ParamSizeByType[];   // Size of every parameter type (*4 bytes)
 extern void ParamsDeAllocate(SystemProc *proc);
 extern void ParamsIn(SystemProc *proc);
 extern void ParamsOut(SystemProc *proc);
+#ifndef SYSTEM_X64
 extern SystemProc *CallProc(SystemProc *proc);
 extern SystemProc *CallBack(SystemProc *proc);
+#endif
 extern SystemProc *RealCallBack();
 extern void CallStruct(SystemProc *proc);
 

Contrib/zip2exe/main.cpp

 
 const TCHAR *g_options=_T("");//_T("/V3");
 
-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);
 
 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
                    LPTSTR lpszCmdParam, int nCmdShow)
   }
 }
 
-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};
       SetDlgItemText(hwndDlg,IDC_INSTPATH,gp_poi);
 
       hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON1));
-      SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)hIcon);
 
       hFont=CreateFont(15,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,
               OUT_CHARACTER_PRECIS,
 
 	return result
 
-def add_file_to_emitter(env, emitter_name, file):
+def add_file_to_emitter(env, emitter_name, file, obj_name=None):
+	if obj_name is None:
+		obj_name = emitter_name
 	try:
 		original_emitter = env[emitter_name]
 		if type(original_emitter) == list:
 		if '$NODEFLIBS_FLAG' not in env['LINKFLAGS']:
 			return target, source
 
-		return target, source + env.Object(emitter_name, file)
+		return target, source + env.Object(obj_name, file)
 
 	env[emitter_name] = emitter
 
-def add_file(file):
+def add_file(file, obj_name=None):
 	file = File(file)
-	add_file_to_emitter(stub_env, 'PROGEMITTER', file)
-	add_file_to_emitter(stub_uenv, 'PROGEMITTER', file)
-	add_file_to_emitter(util_env, 'PROGEMITTER', file)
-	add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file)
-	add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file)
+	add_file_to_emitter(stub_env, 'PROGEMITTER', file, obj_name)
+	add_file_to_emitter(stub_uenv, 'PROGEMITTER', file, obj_name)
+	add_file_to_emitter(util_env, 'PROGEMITTER', file, obj_name)
+	add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file, obj_name)
+	add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file, obj_name)
 
 #
 # MSVC 6 SP6 doesn't like direct shifting of 64-bit integers.
 
 conf = defenv.Configure(custom_tests = { 'CheckRequirement' : check_requirement })
 
-if conf.CheckRequirement('memset', 'char c[128] = "test";'):
-	add_file('memset.c')
+if conf.CheckRequirement('memset', 'char c[128] = "test"; printf("%s", c);'):
+	add_file('memset.c', 'memset')
+memcpy_test = """
+struct foo {
+	int a;
+	int b;
+	int c;
+	int d;
+};
+struct foo foo1 = {0,0,0,0};
+struct foo foo2 = foo1;
+printf("%d", foo2.a);
+"""
+if conf.CheckRequirement('memcpy', memcpy_test):
+	add_file('memcpy.c', 'memcpy')
 
 conf.Finish()	
 
 
 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')
 
 opts.Add(BoolVariable('STRIP', 'Strips executables of any unrequired data such as symbols', 'yes'))
 opts.Add(BoolVariable('STRIP_CP', 'Strips cross-platform executables of any unrequired data such as symbols', 'yes'))
 opts.Add(BoolVariable('STRIP_W32', 'Strips Win32 executables of any unrequired data such as symbols', 'yes'))
+opts.Add(EnumVariable('TARGET_ARCH', 'Target processor architecture', 'x86', allowed_values=('x86', 'amd64')))
 # path related build options
 opts.Add(('PREFIX_DEST', 'Intermediate installation prefix (extra install time prefix)', dirs['dest']))
 opts.Add(('PREFIX_CONF', 'Path to install nsisconf.nsh to', dirs['conf']))
 
 if defenv.has_key('CODESIGNER'):
 	defenv['DISTSUFFIX'] = '-signed'
+if defenv['TARGET_ARCH'] == 'amd64':
+	defenv['DISTSUFFIX'] += '-x64'
 
 defenv.Execute(Delete('$ZIPDISTDIR'))
 defenv.Execute(Delete('$INSTDISTDIR'))

Source/exehead/Ui.c

       m_hwndOK=GetDlgItem(hwndDlg,IDOK);
       m_hwndCancel=GetDlgItem(hwndDlg,IDCANCEL);
       SetDlgItemTextFromLang(hwndDlg,IDC_VERSTR,LANG_BRANDING);
-      SetClassLong(hwndDlg,GCL_HICON,(long)g_hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)g_hIcon);
       // use the following line instead of the above, if .rdata needs shirking
       //SendMessage(hwndDlg,WM_SETICON,ICON_BIG,(LPARAM)g_hIcon);
 #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)