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

@ -320,9 +320,13 @@ end:
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
#ifndef _WIN64
OPT=myGetProcAddress(MGA_OpenProcessToken);
LPV=myGetProcAddress(MGA_LookupPrivilegeValue);
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
#else
OPT=OpenProcessToken, LPV=LookupPrivilegeValue, ATP=AdjustTokenPrivileges;
#endif
if (OPT && LPV && ATP)
{
HANDLE hToken;
@ -368,4 +372,7 @@ void NSISCALL CleanUp()
// Clean up after plug-ins
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
#ifdef _DEBUG
// GlobalFree(g_header); ?
#endif
}

View file

@ -236,7 +236,11 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
LANGID (WINAPI *GUDUIL)();
#ifndef _WIN64
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
#else
GUDUIL = GetUserDefaultUILanguage;
#endif
if (GUDUIL)
{
// Windows ME/2000+
@ -407,7 +411,7 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
#endif
{
int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
int ret=(int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
ExecuteCallbackFunction(CB_ONGUIEND);
#endif
@ -483,7 +487,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
#endif
};
m_delta = wParam;
m_delta = (int) wParam;
if (uMsg == WM_INITDIALOG)
{
@ -538,7 +542,6 @@ nextPage:
else
{
HWND hwndtmp;
int pflags = this_page->flags;
GetNSISString(state_click_next, this_page->clicknext);
@ -730,7 +733,7 @@ DWORD CALLBACK StreamLicenseRTF(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG
{
size_t len = lstrlen(((LPWSTR) dwCookie)+g_cbLicRead);
len = min(len, cb/sizeof(WCHAR));
*pcb=WideCharToMultiByte(CP_ACP,0,((LPWSTR) dwCookie)+g_cbLicRead,len,(char*)pbBuff,cb,NULL,NULL);
*pcb=WideCharToMultiByte(CP_ACP,0,((LPWSTR) dwCookie)+g_cbLicRead,(int)len,(char*)pbBuff,cb,NULL,NULL);
// RTF uses only ASCII characters, so we can assume "number of output bytes" = "number of source WChar consumed"
g_cbLicRead+=*pcb;
return 0;
@ -779,7 +782,7 @@ static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
}
if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !LicIgnoreWMCommand) {
if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) {
int is = SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED;
int is = (int) (SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED);
m_this_page->flags &= ~PF_LICENSE_SELECTED;
m_this_page->flags |= is;
EnableNext(is);
@ -1052,7 +1055,11 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
// Test for and use the GetDiskFreeSpaceEx API
{
BOOL (WINAPI *GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
#ifdef _WIN64
GetDiskFreeSpaceEx;
#else
myGetProcAddress(MGA_GetDiskFreeSpaceEx);
#endif
if (GDFSE)
{
ULARGE_INTEGER available64;
@ -1086,7 +1093,7 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
}
if (!available_set)
if (!available_set) // TODO: Can GetDiskFreeSpace succeed when ..Ex failed on x64?
{
DWORD spc, bps, fc, tc;
TCHAR *root;
@ -1252,7 +1259,7 @@ void NSISCALL ExecuteCallbackFunctionWithr0Int(int num,int r0)
static WNDPROC oldTreeWndProc;
static LPARAM last_selected_tree_item;
static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static LRESULT CALLBACK newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CHAR && wParam == VK_SPACE) {
NotifyCurWnd(WM_TREEVIEW_KEYHACK);
@ -1271,7 +1278,7 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
if (last_selected_tree_item != lParam)
{
last_selected_tree_item = lParam;
ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,lParam);
ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,(int)lParam);
}
}
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT
@ -1320,7 +1327,7 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
{
if (install_types[i])
{
int j;
LRESULT j;
if (i != NSIS_MAX_INST_TYPES) noCombo = 0;
j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetNSISStringTT(install_types[i]));
SendMessage(hwndCombo1,CB_SETITEMDATA,j,i);
@ -1453,10 +1460,10 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (uMsg == WM_COMMAND && LOWORD(wParam) == IDC_COMBO1 && HIWORD(wParam) == CBN_SELCHANGE)
{
int t = SendMessage(hwndCombo1,CB_GETCURSEL,0,0);
LRESULT t = SendMessage(hwndCombo1,CB_GETCURSEL,0,0);
if (t != CB_ERR)
{
int whichcfg = SendMessage(hwndCombo1, CB_GETITEMDATA, t, 0);
int whichcfg = (int) SendMessage(hwndCombo1, CB_GETITEMDATA, t, 0);
if (whichcfg == CB_ERR || !install_types[whichcfg])
whichcfg = NSIS_MAX_INST_TYPES;
@ -1492,7 +1499,7 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_COMPONENTPAGE)
if (wParam != 0)
{
int secid = wParam;
int secid = (int) wParam;
if (wParamSelChangeNotifyInstTypeChanged != secid) --secid;
ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid);
}
@ -1744,7 +1751,7 @@ static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
i = count;
while (i--)
// Add 2 for the CR/LF combination that must follow every line.
total += 2+SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
total += 2+(int)SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
// 2nd pass - store detail view strings on the clipboard
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE

View file

@ -172,8 +172,11 @@ static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyif
{
typedef LONG (WINAPI * RegDeleteKeyExPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
RegDeleteKeyExPtr RDKE = (RegDeleteKeyExPtr)
#ifdef _WIN64
RegDeleteKeyEx;
#else
myGetProcAddress(MGA_RegDeleteKeyEx);
#endif
if (RDKE)
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
else
@ -771,7 +774,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
HWND hwnd=GetHwndFromParm(1);
int msg=GetIntFromParm(2);
if (parm5>>2) exec_error += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(LPDWORD)&v);
if (parm5>>2) exec_error += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(PDWORD_PTR)&v);
// Jim Park: This sends script messages. Some messages require
// settings for Unicode. This means the user's script may need
// to change for Unicode NSIS.

View file

@ -398,14 +398,14 @@ int NSISCALL _dodecomp(int offset, HANDLE hFileOut, unsigned char *outbuf, int o
if (err<0) return -4;
u=(char*)g_inflate_stream.next_out - outbuffer;
u=BUGBUG64TRUNCATE(int, (char*)g_inflate_stream.next_out - outbuffer);
tc = GetTickCount();
tc=GetTickCount();
if (g_exec_flags.status_update & 1 && (tc - ltc > 200 || !input_len))
{
wsprintf(progress, _T("... %d%%"), MulDiv(input_len_total - input_len, 100, input_len_total));
update_status_text(0, progress);
ltc = tc;
ltc=tc;
}
// if there's no output, more input is needed

View file

@ -473,13 +473,31 @@ typedef struct {
COLORREF text;
COLORREF bkc;
UINT lbStyle;
#ifndef MAKENSIS
HBRUSH bkb;
#ifdef _WIN64
#error Should we swap lbStyle and bkb to get better alignment? If we are going to do it, now is our only chance before plugins in the wild start depending on the ctlcolors layout on x64
#else
INT32 bkb;
#endif
int bkmode;
int flags;
} ctlcolors;
} ctlcolors32;
typedef struct {
COLORREF text;
COLORREF bkc;
#ifndef MAKENSIS
HBRUSH bkb; // NOTE: Placed above lbStyle for better alignment
#else
INT64 bkb;
#endif
UINT lbStyle;
int bkmode;
int flags;
} ctlcolors64;
#if defined(_WIN64) && !defined(MAKENSIS)
# define ctlcolors ctlcolors64
#else
# define ctlcolors ctlcolors32
#endif
#pragma pack(pop)
// constants for myDelete (util.c)

View file

@ -404,16 +404,14 @@ char * NSISCALL mystrstriA(char *a, const char *b)
}
#ifndef _NSIS_NODEFLIB_CRTMEMCPY
// mini_memcpy takes the number of bytes to copy.
void NSISCALL mini_memcpy(void *out, const void *in, int len)
void NSISCALL mini_memcpy(void *out, const void *in, UINT_PTR cb)
{
char *c_out=(char*)out;
char *c_in=(char *)in;
while (len-- > 0)
{
*c_out++=*c_in++;
}
char *dst = (char*) out, *src = (char*) in;
while (cb-- > 0) *dst++ = *src++;
}
#endif
DWORD NSISCALL remove_ro_attr(LPCTSTR file)
{
@ -538,7 +536,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;
@ -570,13 +568,17 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
BOOL fOk = 0;
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
mfea_t mfea;
#ifdef _WIN64
mfea=MoveFileEx;
#else
mfea=(mfea_t) myGetProcAddress(MGA_MoveFileEx);
if (mfea)
#endif
{
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
}
if (!fOk)
if (!fOk && sizeof(void*) <= 4)
{
RenameViaWininit(pszExisting, pszNew);
}
@ -691,7 +693,7 @@ TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab)
// indexes into the language
TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab));
TCHAR *out = ps_tmpbuf;
// Still working within ps_tmpbuf, so set out to the
// current position that is passed in.
if (outbuf >= ps_tmpbuf &&
@ -1035,6 +1037,7 @@ struct MGA_FUNC
#ifdef _UNICODE
struct MGA_FUNC MGA_FUNCS[] = {
#ifndef _WIN64
{"KERNEL32", "GetDiskFreeSpaceExW"},
{"KERNEL32", "MoveFileExW"},
{"ADVAPI32", "RegDeleteKeyExW"},
@ -1042,6 +1045,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
{"ADVAPI32", "LookupPrivilegeValueW"},
{"ADVAPI32", "AdjustTokenPrivileges"},
{"KERNEL32", "GetUserDefaultUILanguage"},
#endif
{"SHLWAPI", "SHAutoComplete"},
{"SHFOLDER", "SHGetFolderPathW"}
};

View file

@ -108,11 +108,16 @@ void NSISCALL validate_filename(TCHAR *fn);
* @param pszNew The new name of the file.
*/
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
void NSISCALL mini_memcpy(void *out, const void *in, int len);
DWORD NSISCALL remove_ro_attr(LPCTSTR file);
#ifdef _NSIS_NODEFLIB_CRTMEMCPY
#define mini_memcpy memcpy
#else
void NSISCALL mini_memcpy(void *out, const void *in, UINT_PTR cb);
#endif
enum myGetProcAddressFunctions {
#ifndef _WIN64
MGA_GetDiskFreeSpaceEx,
MGA_MoveFileEx,
MGA_RegDeleteKeyEx,
@ -120,8 +125,9 @@ enum myGetProcAddressFunctions {
MGA_LookupPrivilegeValue,
MGA_AdjustTokenPrivileges,
MGA_GetUserDefaultUILanguage,
MGA_SHAutoComplete,
MGA_SHGetFolderPath,
#endif
MGA_SHAutoComplete, // x64 can link to shlwapi directly but as long as MGA_SHGetFolderPath is used we can stick with myGetProcAddress
MGA_SHGetFolderPath, // TODO: This can probably call something else directly on x64
};
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);