Basic Win64 support (MSVC)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6439 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-02-08 00:13:52 +00:00
parent 204f371097
commit d799ee53d7
52 changed files with 380 additions and 247 deletions

View file

@ -132,8 +132,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call,
return TRUE;
}
void CALLBACK TimeProc(UINT uID,
UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
{
int call = -1;
switch (state) {
@ -251,11 +250,15 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
// Set transparency / key color
if (nt50) {
#ifndef _WIN64
// Get blending proc address
HANDLE user32 = GetModuleHandle(_T("user32"));
SetLayeredWindowAttributesProc =
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
"SetLayeredWindowAttributes");
#else
#define SetLayeredWindowAttributesProc SetLayeredWindowAttributes
#endif
// Use win2k method
SetLayeredWindowAttributesProc(myWnd, keycolor,
(BYTE) ((fadein_val > 0) ? (0) : (255)),

View file

@ -40,7 +40,7 @@ typedef wchar_t TCHAR;
// printfs
#define _ftprintf fwprintf
#define _sntprintf _snwprintf
#if (defined(_MSC_VER) && (_MSC_VER<=1310)) || defined(__MINGW32__)
#if (defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)) || defined(__MINGW32__)
# define _stprintf swprintf
#else
# define _stprintf _swprintf

View file

@ -221,7 +221,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
bool INLINE ValidateFields() {
int nIdx;
int nLength;
INT_PTR nLength;
// In the unlikely event we can't allocate memory, go ahead and return true so we can get out of here.
// May cause problems for the install script, but no memory is problems for us.
@ -290,7 +290,7 @@ bool WINAPI SaveSettings(void) {
if (!pszItem) return false;
*pszBuffer = _T('\0');
int nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
INT_PTR nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
for (int nIdx2 = 0; nIdx2 < nNumItems; nIdx2++) {
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
if (*pszBuffer) lstrcat(pszBuffer, _T("|"));
@ -308,7 +308,7 @@ bool WINAPI SaveSettings(void) {
case FIELD_DIRREQUEST:
case FIELD_COMBOBOX:
{
int nLength = mySendMessage(pField->hwnd, WM_GETTEXTLENGTH, 0, 0);
int nLength = (int) mySendMessage(pField->hwnd, WM_GETTEXTLENGTH, 0, 0);
if (nLength > nBufLen) {
FREE(pszBuffer);
// add a bit extra so we do this less often
@ -346,7 +346,7 @@ bool WINAPI SaveSettings(void) {
// CharNext()'s behavior at terminating null char. But still
// definitely, unsafe.
default:
lstrcpyn(p2, p1, CharNext(p1) - p1 + 1);
lstrcpyn(p2, p1, (int)(CharNext(p1) - p1) + 1);
break;
}
}
@ -820,7 +820,7 @@ INT_PTR CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
#endif
// pFields[nIdx].nParentIdx is used to store original windowproc
int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int StaticField = FindControlIdx(GetDlgCtrlID(hWin));
if (StaticField < 0)
@ -869,7 +869,7 @@ int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lPar
}
#endif
int WINAPI NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int nIdx = FindControlIdx(GetDlgCtrlID(hWin));
if (nIdx < 0)
@ -1275,7 +1275,7 @@ int WINAPI createCfgDlg()
*pszEnd = _T('\0');
if (*pszStart)
{
int nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
INT_PTR nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
if (nItem != LB_ERR)
mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
}
@ -1288,7 +1288,7 @@ int WINAPI createCfgDlg()
}
}
else {
int nItem = mySendMessage(hwCtrl, nFindMsg, (WPARAM)-1, (LPARAM)pField->pszState);
INT_PTR nItem = mySendMessage(hwCtrl, nFindMsg, (WPARAM)-1, (LPARAM)pField->pszState);
if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
}
@ -1300,7 +1300,7 @@ int WINAPI createCfgDlg()
case FIELD_ICON:
case FIELD_BITMAP:
{
WPARAM nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
UINT nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
LPARAM nImage = 0;
if (pField->pszText) {

View file

@ -14,6 +14,7 @@
#include <nsis/pluginapi.h> // nsis plugin
#define NSIS_DECLSPEC_DLLEXPORT __declspec(dllexport) // BUGBUG: Compiler specific
HINSTANCE g_hInstance;
HWND g_hwndParent;
@ -34,14 +35,15 @@ struct lang {
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int i, size;
INT_PTR i;
int size;
TCHAR *selected_language = NULL;
static HFONT font;
switch (uMsg) {
case WM_INITDIALOG:
case WM_INITDIALOG:
// add languages
for (i = visible_langs_num - 1; i >= 0; i--) {
int cbi;
INT_PTR cbi;
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
@ -82,7 +84,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDOK:
// push result on the stack
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
@ -113,7 +115,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
return TRUE; // message processed
}
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
void NSIS_DECLSPEC_DLLEXPORT LangDialog(HWND hwndParent, int string_size,
TCHAR *variables, stack_t **stacktop)
{
g_hwndParent=hwndParent;
@ -240,5 +242,5 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
g_hInstance=hInst;
return TRUE;
return TRUE;
}

View file

@ -345,7 +345,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
*pEnd-- = *p--;
}
dwRenameLinePos = pszNextSec - pszWinInit + 1; // +1 for the \n
dwRenameLinePos = BUGBUG64TRUNCATE(DWORD, pszNextSec - pszWinInit) + 1; // +1 for the \n
}
// rename section is last, stick item at end of file
else dwRenameLinePos = dwFileSize;

View file

@ -157,7 +157,7 @@ void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent
FD_SET(m_socket,&f[2]);
struct timeval tv;
memset(&tv,0,sizeof(tv));
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
if (select((int)(m_socket+1),&f[0],&f[1],&f[2],&tv)==-1)
{
m_errorstr="connecting to host (calling select())";
m_state=STATE_ERROR;

View file

@ -605,11 +605,13 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
case IDM_EDITSCRIPT:
{
if (g_sdata.input_script) {
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
LPCTSTR verb = _T("open"); // BUGBUG: Should not force the open verb?
HINSTANCE hi = ShellExecute(g_sdata.hwnd,verb,g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL);
if ((UINT_PTR)hi <= 32) {
TCHAR path[MAX_PATH];
if (GetWindowsDirectory(path,sizeof(path))) {
lstrcat(path,_T("\\notepad.exe"));
ShellExecute(g_sdata.hwnd,_T("open"),path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,verb,path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
}
}
}

View file

@ -75,9 +75,15 @@ void CreateToolBar()
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LPARAM) &tbbs);
// For Comctl32.dll version detection
#ifndef _WIN64
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
const FARPROC hasCC4_70 = GetProcAddress(hMod, "InitCommonControlsEx");
const FARPROC hasCC4_71 = GetProcAddress(hMod, "DllGetVersion");
#else
const bool hasCC4_70 = true, hasCC4_71 = true;
#endif
if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
if (hasCC4_70) { // Version 4.70
// Modern toolbar, 24-bit bitmaps
g_toolbar.imagelist = ImageList_LoadImage(g_sdata.hInstance, MAKEINTRESOURCE(IDB_TOOLBAR24), 16, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
@ -88,8 +94,7 @@ void CreateToolBar()
SendMessage(g_toolbar.hwnd, TB_SETDISABLEDIMAGELIST, 0, (LPARAM) g_toolbar.imagelistd);
SendMessage(g_toolbar.hwnd, TB_SETHOTIMAGELIST, 0, (LPARAM) g_toolbar.imagelisth);
// Version 4.71
if (GetProcAddress(hMod, "DllGetVersion")) {
if (hasCC4_71) { // Version 4.71
SendMessage(g_toolbar.hwnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
}

View file

@ -155,7 +155,7 @@ void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent
FD_SET(m_socket,&f[2]);
struct timeval tv;
memset(&tv,0,sizeof(tv));
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
if (select((int)(m_socket+1),&f[0],&f[1],&f[2],&tv)==-1)
{
m_errorstr="connecting to host (calling select())";
m_state=STATE_ERROR;

View file

@ -118,9 +118,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
NULL
);
long c;
c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
LRESULT c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
SendMessage(hwndP, PBM_SETBARCOLOR, 0, c);
SendMessage(pb, PBM_SETBARCOLOR, 0, c);
@ -129,7 +127,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
SendMessage(pb, PBM_SETBKCOLOR, 0, c);
// set font
long hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0);
LRESULT hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0);
SendMessage(pb, WM_SETFONT, hFont, 0);
SendMessage(s, WM_SETFONT, hFont, 0);

View file

@ -171,7 +171,7 @@ static INT_PTR CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
void AddRTLStyle(HWND hWnd, long dwStyle)
{
long s;
LONG_PTR s;
s = GetWindowLongPtr(hWnd, GWL_STYLE);
SetWindowLongPtr(hWnd, GWL_STYLE, s | dwStyle);

View file

@ -33,10 +33,10 @@ if env['TARGET_ARCH'] != 'amd64':
elif conf.TryCompile('.end', '.sx'):
files += ['Source/Call.sx']
else:
print 'WARNING: unable to find assembler for Call.S'
print 'WARNING: System.dll: unable to find assembler for Call.S'
conf.Finish()
else:
print 'WARNING: missing Win64 code, dynamic function calls not supported'
print 'WARNING: System.dll: missing Win64 code, dynamic function calls not supported'
BuildPlugin(
target,

View file

@ -38,7 +38,7 @@ PLUGINFUNCTIONEND
PLUGINFUNCTIONSHORT(Copy)
{
int size = 0;
SIZE_T size = 0;
HANDLE source, dest;
TCHAR *str;
// Get the string
@ -47,10 +47,10 @@ PLUGINFUNCTIONSHORT(Copy)
// Check for size option
if (str[0] == _T('/'))
{
size = (SIZE_T) myatoi(str+1);
size = (SIZE_T) StrToIntPtr(str+1);
dest = (HANDLE) popintptr();
}
else dest = (HANDLE) myatoi(str);
else dest = (HANDLE) StrToIntPtr(str);
source = (HANDLE) popintptr();
// Ok, check the size

View file

@ -273,9 +273,9 @@ PLUGINFUNCTION(Get)
/*
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
BUGBUG: MUI is leaking DeleteObject and failing GetClientRect
*/
static SystemProc* CallProc(SystemProc *proc)
SystemProc* CallProc(SystemProc *proc)
{
INT_PTR ret, *place;
LastError = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA"));
@ -294,7 +294,7 @@ static SystemProc* CallProc(SystemProc *proc)
if (place) *place = ret;
return proc;
}
static SystemProc* CallBack(SystemProc *proc)
SystemProc* CallBack(SystemProc *proc)
{
proc->ProcResult = PR_ERROR;
return proc;
@ -741,10 +741,10 @@ SystemProc *PrepareProc(BOOL NeedForCall)
// it may contain previous inline input
if (!((proc->Params[ParamIndex].Input > -1) && (proc->Params[ParamIndex].Input <= __INST_LAST)))
GlobalFree((HANDLE) proc->Params[ParamIndex].Input);
proc->Params[ParamIndex].Input = temp4;
proc->Params[ParamIndex].Input = BUGBUG64(int) temp4;
}
if (temp3 == 1)
proc->Params[ParamIndex].Output = temp4;
proc->Params[ParamIndex].Output = BUGBUG64(int) temp4;
// Next parameter is output or something else
#ifdef __GNUC__
#pragma GCC diagnostic push
@ -985,7 +985,7 @@ void ParamsIn(SystemProc *proc)
case PAT_CALLBACK:
// Generate new or use old callback
if (lstrlen(realbuf) > 0)
par->Value = BUGBUG64(int) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
par->Value = (INT_PTR) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
break;
}
GlobalFree(realbuf);
@ -1254,7 +1254,7 @@ void CallStruct(SystemProc *proc)
SYSTEM_LOG_POST;
// Proc virtual return - pointer to memory struct
proc->Params[0].Value = BUGBUG64(int) proc->Proc;
proc->Params[0].Value = (INT_PTR) proc->Proc;
}
/*

View file

@ -3,7 +3,7 @@
// This should probably be moved to platform.h at some point
#if defined(_M_X64) || defined(__amd64__)
#if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__)
# define SYSTEM_X64
#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_)
# define SYSTEM_X86

View file

@ -86,6 +86,6 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
InitCommonControls();
g_hInstance = hInst;
LoadLibrary(_T("RichEd32.dll"));
return DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
return (int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
}

View file

@ -67,8 +67,12 @@ TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
if (CheckTokenForGroupDeny)
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
_CheckTokenMembership=
#ifndef _WIN64
(CHECKTOKENMEMBERSHIP) GetProcAddress(
GetModuleHandle(_T("ADVAPI32")), "CheckTokenMembership");
#else
_CheckTokenMembership = CheckTokenMembership;
#endif
// Use "old school" membership check?
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)

View file

@ -466,7 +466,7 @@ void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, TCHAR *
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
// we use a timer proc instead of WM_TIMER to make sure no one messes with the ids but us
g_pluginParms->ExecuteCodeSegment(idEvent - 1, 0);
g_pluginParms->ExecuteCodeSegment((int)(idEvent - 1), 0);
}
void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)

View file

@ -176,7 +176,7 @@ void ExecScript(int log) {
// WinMain will have the address of the WinMain function in memory.
// Getting the difference gets you the relative location of the
// WinMain function.
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD_PTR)AsExeWinMain - (DWORD_PTR)g_hInst;
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD) ((DWORD_PTR)AsExeWinMain - (DWORD_PTR)g_hInst);
UnmapViewOfFile(pMapView);
}
CloseHandle(hMapping);
@ -414,7 +414,7 @@ void LogMessage(const TCHAR *pStr, BOOL bOEM) {
#ifndef _UNICODE
if (bOEM == TRUE) OemToCharBuff(pStr, (char*)pStr, lstrlen(pStr));
#endif
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
nItemCount=(int) SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
item.mask=LVIF_TEXT;
item.pszText=(TCHAR *)pStr;
item.cchTextMax=0;

View file

@ -203,7 +203,7 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn)
// was zip created on MS-DOS/Windows?
if ((info.version & 0xFF00) == 0)
{
OemToCharBuffA(filenameA, filenameA, strlen(filenameA));
OemToCharBuffA(filenameA, filenameA, (DWORD)strlen(filenameA));
}
#ifdef _UNICODE