1. David Golub
  2. nsis64


gol...@212acab6-be3b-0410-9dea-997c60f758d6  committed 0b13ec9

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

  • Participants
  • Parent commits 205abbe
  • Branches default

Comments (0)

Files changed (14)

File Contrib/MakeLangId/MakeLangId.cpp

View file
  • Ignore whitespace
-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) {

File Contrib/Makensisw/jnetlib/httpget.cpp

View file
  • Ignore whitespace
 #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)

File Contrib/Makensisw/makensisw.cpp

View file
  • Ignore whitespace
-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:
       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

File Contrib/Makensisw/makensisw.h

View file
  • Ignore whitespace
 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);
 BOOL CALLBACK  DialogResize(HWND hWnd, LPARAM /* unused*/);
 BOOL CALLBACK  AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);

File Contrib/NSISdl/nsisdl.cpp

View file
  • Ignore whitespace
 #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);

File Contrib/System/SConscript

View file
  • Ignore whitespace
 Import('BuildPlugin env')
-conf = env.Configure()
-if conf.TryCompile('END', '.S'):
-	files += ['Source/Call.S']
-elif conf.TryCompile('.end', '.sx'):
-	files += ['Source/Call.sx']
-	print 'WARNING: unable to find assembler for Call.S'
+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()

File Contrib/System/Source/Plugin.c

View file
  • Ignore whitespace
+__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;

File Contrib/System/Source/Plugin.h

View file
  • Ignore whitespace
 // 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)) )
 #	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);

File Contrib/System/Source/System.c

View file
  • Ignore whitespace
 DWORD LastError;
 volatile SystemProc *LastProc;
 int CallbackIndex;
+#ifndef SYSTEM_X64
 CallbackThunk* CallbackThunkListHead;
 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 );
+#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
+    ParamsOut(proc);
+    system_pushintptr(0);
             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;
             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;
+    // Not yet implemented
+    return NULL;
 void CallStruct(SystemProc *proc)
             LastError = 0;
             LastProc = NULL;
             CallbackIndex = 0;
+#ifndef SYSTEM_X64
             CallbackThunkListHead = NULL;
             retexpr[0] = (char) 0xC2;
             retexpr[2] = 0x00;

File Contrib/System/Source/System.h

View file
  • Ignore whitespace
     SystemProc *Clone;
+#ifndef SYSTEM_X64
 typedef struct tag_CallbackThunk CallbackThunk;
 struct tag_CallbackThunk
     CallbackThunk* pNext;
 // 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) )
 #   error "GetAssociatedSysProcFromCallbackThunkPtr not defined for the current architecture!"
 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);
 extern SystemProc *RealCallBack();
 extern void CallStruct(SystemProc *proc);

File Contrib/zip2exe/main.cpp

View file
  • Ignore whitespace
 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)
-      SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
+      SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)hIcon);

File SCons/Config/ms

View file
  • Ignore whitespace
 	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
 		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')

File SConstruct

View file
  • Ignore whitespace
 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'])
 	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)
 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'

File Source/exehead/Ui.c

View file
  • Ignore whitespace
-      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