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:
parent
204f371097
commit
d799ee53d7
52 changed files with 380 additions and 247 deletions
|
@ -132,8 +132,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK TimeProc(UINT uID,
|
void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||||
UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
|
|
||||||
{
|
{
|
||||||
int call = -1;
|
int call = -1;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -251,11 +250,15 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
|
|
||||||
// Set transparency / key color
|
// Set transparency / key color
|
||||||
if (nt50) {
|
if (nt50) {
|
||||||
|
#ifndef _WIN64
|
||||||
// Get blending proc address
|
// Get blending proc address
|
||||||
HANDLE user32 = GetModuleHandle(_T("user32"));
|
HANDLE user32 = GetModuleHandle(_T("user32"));
|
||||||
SetLayeredWindowAttributesProc =
|
SetLayeredWindowAttributesProc =
|
||||||
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
|
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
|
||||||
"SetLayeredWindowAttributes");
|
"SetLayeredWindowAttributes");
|
||||||
|
#else
|
||||||
|
#define SetLayeredWindowAttributesProc SetLayeredWindowAttributes
|
||||||
|
#endif
|
||||||
// Use win2k method
|
// Use win2k method
|
||||||
SetLayeredWindowAttributesProc(myWnd, keycolor,
|
SetLayeredWindowAttributesProc(myWnd, keycolor,
|
||||||
(BYTE) ((fadein_val > 0) ? (0) : (255)),
|
(BYTE) ((fadein_val > 0) ? (0) : (255)),
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef wchar_t TCHAR;
|
||||||
// printfs
|
// printfs
|
||||||
#define _ftprintf fwprintf
|
#define _ftprintf fwprintf
|
||||||
#define _sntprintf _snwprintf
|
#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
|
# define _stprintf swprintf
|
||||||
#else
|
#else
|
||||||
# define _stprintf _swprintf
|
# define _stprintf _swprintf
|
||||||
|
|
|
@ -221,7 +221,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
|
||||||
|
|
||||||
bool INLINE ValidateFields() {
|
bool INLINE ValidateFields() {
|
||||||
int nIdx;
|
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.
|
// 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.
|
// 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;
|
if (!pszItem) return false;
|
||||||
|
|
||||||
*pszBuffer = _T('\0');
|
*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++) {
|
for (int nIdx2 = 0; nIdx2 < nNumItems; nIdx2++) {
|
||||||
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
|
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
|
||||||
if (*pszBuffer) lstrcat(pszBuffer, _T("|"));
|
if (*pszBuffer) lstrcat(pszBuffer, _T("|"));
|
||||||
|
@ -308,7 +308,7 @@ bool WINAPI SaveSettings(void) {
|
||||||
case FIELD_DIRREQUEST:
|
case FIELD_DIRREQUEST:
|
||||||
case FIELD_COMBOBOX:
|
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) {
|
if (nLength > nBufLen) {
|
||||||
FREE(pszBuffer);
|
FREE(pszBuffer);
|
||||||
// add a bit extra so we do this less often
|
// 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
|
// CharNext()'s behavior at terminating null char. But still
|
||||||
// definitely, unsafe.
|
// definitely, unsafe.
|
||||||
default:
|
default:
|
||||||
lstrcpyn(p2, p1, CharNext(p1) - p1 + 1);
|
lstrcpyn(p2, p1, (int)(CharNext(p1) - p1) + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ INT_PTR CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pFields[nIdx].nParentIdx is used to store original windowproc
|
// 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));
|
int StaticField = FindControlIdx(GetDlgCtrlID(hWin));
|
||||||
if (StaticField < 0)
|
if (StaticField < 0)
|
||||||
|
@ -869,7 +869,7 @@ int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
}
|
}
|
||||||
#endif
|
#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));
|
int nIdx = FindControlIdx(GetDlgCtrlID(hWin));
|
||||||
if (nIdx < 0)
|
if (nIdx < 0)
|
||||||
|
@ -1275,7 +1275,7 @@ int WINAPI createCfgDlg()
|
||||||
*pszEnd = _T('\0');
|
*pszEnd = _T('\0');
|
||||||
if (*pszStart)
|
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)
|
if (nItem != LB_ERR)
|
||||||
mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
|
mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
|
||||||
}
|
}
|
||||||
|
@ -1288,7 +1288,7 @@ int WINAPI createCfgDlg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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
|
if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
|
||||||
mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
|
mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
|
||||||
}
|
}
|
||||||
|
@ -1300,7 +1300,7 @@ int WINAPI createCfgDlg()
|
||||||
case FIELD_ICON:
|
case FIELD_ICON:
|
||||||
case FIELD_BITMAP:
|
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;
|
LPARAM nImage = 0;
|
||||||
|
|
||||||
if (pField->pszText) {
|
if (pField->pszText) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
#define NSIS_DECLSPEC_DLLEXPORT __declspec(dllexport) // BUGBUG: Compiler specific
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
|
@ -34,14 +35,15 @@ struct lang {
|
||||||
|
|
||||||
INT_PTR 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;
|
INT_PTR i;
|
||||||
|
int size;
|
||||||
TCHAR *selected_language = NULL;
|
TCHAR *selected_language = NULL;
|
||||||
static HFONT font;
|
static HFONT font;
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// add languages
|
// add languages
|
||||||
for (i = visible_langs_num - 1; i >= 0; i--) {
|
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);
|
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
|
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;
|
break;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
// push result on the stack
|
// push result on the stack
|
||||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
||||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 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
|
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)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
g_hwndParent=hwndParent;
|
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)
|
BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
g_hInstance=hInst;
|
g_hInstance=hInst;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||||
*pEnd-- = *p--;
|
*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
|
// rename section is last, stick item at end of file
|
||||||
else dwRenameLinePos = dwFileSize;
|
else dwRenameLinePos = dwFileSize;
|
||||||
|
|
|
@ -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]);
|
FD_SET(m_socket,&f[2]);
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
memset(&tv,0,sizeof(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_errorstr="connecting to host (calling select())";
|
||||||
m_state=STATE_ERROR;
|
m_state=STATE_ERROR;
|
||||||
|
|
|
@ -605,11 +605,13 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
||||||
case IDM_EDITSCRIPT:
|
case IDM_EDITSCRIPT:
|
||||||
{
|
{
|
||||||
if (g_sdata.input_script) {
|
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];
|
TCHAR path[MAX_PATH];
|
||||||
if (GetWindowsDirectory(path,sizeof(path))) {
|
if (GetWindowsDirectory(path,sizeof(path))) {
|
||||||
lstrcat(path,_T("\\notepad.exe"));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,15 @@ void CreateToolBar()
|
||||||
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LPARAM) &tbbs);
|
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LPARAM) &tbbs);
|
||||||
|
|
||||||
// For Comctl32.dll version detection
|
// For Comctl32.dll version detection
|
||||||
|
#ifndef _WIN64
|
||||||
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
|
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
|
// 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);
|
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_SETDISABLEDIMAGELIST, 0, (LPARAM) g_toolbar.imagelistd);
|
||||||
SendMessage(g_toolbar.hwnd, TB_SETHOTIMAGELIST, 0, (LPARAM) g_toolbar.imagelisth);
|
SendMessage(g_toolbar.hwnd, TB_SETHOTIMAGELIST, 0, (LPARAM) g_toolbar.imagelisth);
|
||||||
|
|
||||||
// Version 4.71
|
if (hasCC4_71) { // Version 4.71
|
||||||
if (GetProcAddress(hMod, "DllGetVersion")) {
|
|
||||||
SendMessage(g_toolbar.hwnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
|
SendMessage(g_toolbar.hwnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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]);
|
FD_SET(m_socket,&f[2]);
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
memset(&tv,0,sizeof(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_errorstr="connecting to host (calling select())";
|
||||||
m_state=STATE_ERROR;
|
m_state=STATE_ERROR;
|
||||||
|
|
|
@ -118,9 +118,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
long c;
|
LRESULT c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
|
||||||
|
|
||||||
c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
|
|
||||||
SendMessage(hwndP, PBM_SETBARCOLOR, 0, c);
|
SendMessage(hwndP, PBM_SETBARCOLOR, 0, c);
|
||||||
SendMessage(pb, 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);
|
SendMessage(pb, PBM_SETBKCOLOR, 0, c);
|
||||||
|
|
||||||
// set font
|
// 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(pb, WM_SETFONT, hFont, 0);
|
||||||
SendMessage(s, WM_SETFONT, hFont, 0);
|
SendMessage(s, WM_SETFONT, hFont, 0);
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ static INT_PTR CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
||||||
|
|
||||||
void AddRTLStyle(HWND hWnd, long dwStyle)
|
void AddRTLStyle(HWND hWnd, long dwStyle)
|
||||||
{
|
{
|
||||||
long s;
|
LONG_PTR s;
|
||||||
|
|
||||||
s = GetWindowLongPtr(hWnd, GWL_STYLE);
|
s = GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||||
SetWindowLongPtr(hWnd, GWL_STYLE, s | dwStyle);
|
SetWindowLongPtr(hWnd, GWL_STYLE, s | dwStyle);
|
||||||
|
|
|
@ -33,10 +33,10 @@ if env['TARGET_ARCH'] != 'amd64':
|
||||||
elif conf.TryCompile('.end', '.sx'):
|
elif conf.TryCompile('.end', '.sx'):
|
||||||
files += ['Source/Call.sx']
|
files += ['Source/Call.sx']
|
||||||
else:
|
else:
|
||||||
print 'WARNING: unable to find assembler for Call.S'
|
print 'WARNING: System.dll: unable to find assembler for Call.S'
|
||||||
conf.Finish()
|
conf.Finish()
|
||||||
else:
|
else:
|
||||||
print 'WARNING: missing Win64 code, dynamic function calls not supported'
|
print 'WARNING: System.dll: missing Win64 code, dynamic function calls not supported'
|
||||||
|
|
||||||
BuildPlugin(
|
BuildPlugin(
|
||||||
target,
|
target,
|
||||||
|
|
|
@ -38,7 +38,7 @@ PLUGINFUNCTIONEND
|
||||||
|
|
||||||
PLUGINFUNCTIONSHORT(Copy)
|
PLUGINFUNCTIONSHORT(Copy)
|
||||||
{
|
{
|
||||||
int size = 0;
|
SIZE_T size = 0;
|
||||||
HANDLE source, dest;
|
HANDLE source, dest;
|
||||||
TCHAR *str;
|
TCHAR *str;
|
||||||
// Get the string
|
// Get the string
|
||||||
|
@ -47,10 +47,10 @@ PLUGINFUNCTIONSHORT(Copy)
|
||||||
// Check for size option
|
// Check for size option
|
||||||
if (str[0] == _T('/'))
|
if (str[0] == _T('/'))
|
||||||
{
|
{
|
||||||
size = (SIZE_T) myatoi(str+1);
|
size = (SIZE_T) StrToIntPtr(str+1);
|
||||||
dest = (HANDLE) popintptr();
|
dest = (HANDLE) popintptr();
|
||||||
}
|
}
|
||||||
else dest = (HANDLE) myatoi(str);
|
else dest = (HANDLE) StrToIntPtr(str);
|
||||||
source = (HANDLE) popintptr();
|
source = (HANDLE) popintptr();
|
||||||
|
|
||||||
// Ok, check the size
|
// Ok, check the size
|
||||||
|
|
|
@ -273,9 +273,9 @@ PLUGINFUNCTION(Get)
|
||||||
/*
|
/*
|
||||||
TODO: CallProc/Back not implemeted.
|
TODO: CallProc/Back not implemeted.
|
||||||
Fake the behavior of the System plugin for the LoadImage API function so MUI works.
|
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;
|
INT_PTR ret, *place;
|
||||||
LastError = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA"));
|
LastError = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA"));
|
||||||
|
@ -294,7 +294,7 @@ static SystemProc* CallProc(SystemProc *proc)
|
||||||
if (place) *place = ret;
|
if (place) *place = ret;
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
static SystemProc* CallBack(SystemProc *proc)
|
SystemProc* CallBack(SystemProc *proc)
|
||||||
{
|
{
|
||||||
proc->ProcResult = PR_ERROR;
|
proc->ProcResult = PR_ERROR;
|
||||||
return proc;
|
return proc;
|
||||||
|
@ -741,10 +741,10 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
// it may contain previous inline input
|
// it may contain previous inline input
|
||||||
if (!((proc->Params[ParamIndex].Input > -1) && (proc->Params[ParamIndex].Input <= __INST_LAST)))
|
if (!((proc->Params[ParamIndex].Input > -1) && (proc->Params[ParamIndex].Input <= __INST_LAST)))
|
||||||
GlobalFree((HANDLE) proc->Params[ParamIndex].Input);
|
GlobalFree((HANDLE) proc->Params[ParamIndex].Input);
|
||||||
proc->Params[ParamIndex].Input = temp4;
|
proc->Params[ParamIndex].Input = BUGBUG64(int) temp4;
|
||||||
}
|
}
|
||||||
if (temp3 == 1)
|
if (temp3 == 1)
|
||||||
proc->Params[ParamIndex].Output = temp4;
|
proc->Params[ParamIndex].Output = BUGBUG64(int) temp4;
|
||||||
// Next parameter is output or something else
|
// Next parameter is output or something else
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -985,7 +985,7 @@ void ParamsIn(SystemProc *proc)
|
||||||
case PAT_CALLBACK:
|
case PAT_CALLBACK:
|
||||||
// Generate new or use old callback
|
// Generate new or use old callback
|
||||||
if (lstrlen(realbuf) > 0)
|
if (lstrlen(realbuf) > 0)
|
||||||
par->Value = BUGBUG64(int) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
|
par->Value = (INT_PTR) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GlobalFree(realbuf);
|
GlobalFree(realbuf);
|
||||||
|
@ -1254,7 +1254,7 @@ void CallStruct(SystemProc *proc)
|
||||||
SYSTEM_LOG_POST;
|
SYSTEM_LOG_POST;
|
||||||
|
|
||||||
// Proc virtual return - pointer to memory struct
|
// Proc virtual return - pointer to memory struct
|
||||||
proc->Params[0].Value = BUGBUG64(int) proc->Proc;
|
proc->Params[0].Value = (INT_PTR) proc->Proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// This should probably be moved to platform.h at some point
|
// 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
|
# define SYSTEM_X64
|
||||||
#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_)
|
#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_)
|
||||||
# define SYSTEM_X86
|
# define SYSTEM_X86
|
||||||
|
|
|
@ -86,6 +86,6 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
g_hInstance = hInst;
|
g_hInstance = hInst;
|
||||||
LoadLibrary(_T("RichEd32.dll"));
|
LoadLibrary(_T("RichEd32.dll"));
|
||||||
return DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
|
return (int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,12 @@ TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
||||||
if (CheckTokenForGroupDeny)
|
if (CheckTokenForGroupDeny)
|
||||||
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
|
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
|
||||||
_CheckTokenMembership=
|
_CheckTokenMembership=
|
||||||
|
#ifndef _WIN64
|
||||||
(CHECKTOKENMEMBERSHIP) GetProcAddress(
|
(CHECKTOKENMEMBERSHIP) GetProcAddress(
|
||||||
GetModuleHandle(_T("ADVAPI32")), "CheckTokenMembership");
|
GetModuleHandle(_T("ADVAPI32")), "CheckTokenMembership");
|
||||||
|
#else
|
||||||
|
_CheckTokenMembership = CheckTokenMembership;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Use "old school" membership check?
|
// Use "old school" membership check?
|
||||||
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)
|
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)
|
||||||
|
|
|
@ -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)
|
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
|
// 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)
|
void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
|
|
|
@ -176,7 +176,7 @@ void ExecScript(int log) {
|
||||||
// WinMain will have the address of the WinMain function in memory.
|
// WinMain will have the address of the WinMain function in memory.
|
||||||
// Getting the difference gets you the relative location of the
|
// Getting the difference gets you the relative location of the
|
||||||
// WinMain function.
|
// 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);
|
UnmapViewOfFile(pMapView);
|
||||||
}
|
}
|
||||||
CloseHandle(hMapping);
|
CloseHandle(hMapping);
|
||||||
|
@ -414,7 +414,7 @@ void LogMessage(const TCHAR *pStr, BOOL bOEM) {
|
||||||
#ifndef _UNICODE
|
#ifndef _UNICODE
|
||||||
if (bOEM == TRUE) OemToCharBuff(pStr, (char*)pStr, lstrlen(pStr));
|
if (bOEM == TRUE) OemToCharBuff(pStr, (char*)pStr, lstrlen(pStr));
|
||||||
#endif
|
#endif
|
||||||
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
nItemCount=(int) SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||||
item.mask=LVIF_TEXT;
|
item.mask=LVIF_TEXT;
|
||||||
item.pszText=(TCHAR *)pStr;
|
item.pszText=(TCHAR *)pStr;
|
||||||
item.cchTextMax=0;
|
item.cchTextMax=0;
|
||||||
|
|
|
@ -203,7 +203,7 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn)
|
||||||
// was zip created on MS-DOS/Windows?
|
// was zip created on MS-DOS/Windows?
|
||||||
if ((info.version & 0xFF00) == 0)
|
if ((info.version & 0xFF00) == 0)
|
||||||
{
|
{
|
||||||
OemToCharBuffA(filenameA, filenameA, strlen(filenameA));
|
OemToCharBuffA(filenameA, filenameA, (DWORD)strlen(filenameA));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
|
|
|
@ -150,7 +150,7 @@
|
||||||
;
|
;
|
||||||
; For details, see http://nsis.sourceforge.net/wiki/SetSectionInInstType%2C_ClearSectionInInstType
|
; For details, see http://nsis.sourceforge.net/wiki/SetSectionInInstType%2C_ClearSectionInInstType
|
||||||
;
|
;
|
||||||
; Use the defines below for the WANTED_INSTTYPE paramter.
|
; Use the defines below for the WANTED_INSTTYPE parameter.
|
||||||
|
|
||||||
!define INSTTYPE_1 1
|
!define INSTTYPE_1 1
|
||||||
!define INSTTYPE_2 2
|
!define INSTTYPE_2 2
|
||||||
|
|
|
@ -145,6 +145,9 @@ if defenv['UNICODE']:
|
||||||
|
|
||||||
plugin_env = defenv.Clone(no_import_lib = 1)
|
plugin_env = defenv.Clone(no_import_lib = 1)
|
||||||
|
|
||||||
|
if defenv['TARGET_ARCH'] == 'amd64':
|
||||||
|
plugin_env.Append(LINKFLAGS = ['/MACHINE:AMD64']) # Contrib\System\Resource will not link without this
|
||||||
|
|
||||||
if not defenv['DEBUG']:
|
if not defenv['DEBUG']:
|
||||||
plugin_env.Append(CCFLAGS = ['/O1']) # optimize for size
|
plugin_env.Append(CCFLAGS = ['/O1']) # optimize for size
|
||||||
plugin_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
plugin_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
||||||
|
@ -201,7 +204,9 @@ def check_requirement(ctx, func, trigger):
|
||||||
|
|
||||||
return result
|
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:
|
try:
|
||||||
original_emitter = env[emitter_name]
|
original_emitter = env[emitter_name]
|
||||||
if type(original_emitter) == list:
|
if type(original_emitter) == list:
|
||||||
|
@ -216,17 +221,17 @@ def add_file_to_emitter(env, emitter_name, file):
|
||||||
if '$NODEFLIBS_FLAG' not in env['LINKFLAGS']:
|
if '$NODEFLIBS_FLAG' not in env['LINKFLAGS']:
|
||||||
return target, source
|
return target, source
|
||||||
|
|
||||||
return target, source + env.Object(emitter_name, file)
|
return target, source + env.Object(obj_name, file)
|
||||||
|
|
||||||
env[emitter_name] = emitter
|
env[emitter_name] = emitter
|
||||||
|
|
||||||
def add_file(file):
|
def add_file(file, obj_name=None):
|
||||||
file = File(file)
|
file = File(file)
|
||||||
add_file_to_emitter(stub_env, 'PROGEMITTER', file)
|
add_file_to_emitter(stub_env, 'PROGEMITTER', file, obj_name)
|
||||||
add_file_to_emitter(stub_uenv, 'PROGEMITTER', file)
|
add_file_to_emitter(stub_uenv, 'PROGEMITTER', file, obj_name)
|
||||||
add_file_to_emitter(util_env, 'PROGEMITTER', file)
|
add_file_to_emitter(util_env, 'PROGEMITTER', file, obj_name)
|
||||||
add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file)
|
add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file, obj_name)
|
||||||
add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file)
|
add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file, obj_name)
|
||||||
|
|
||||||
#
|
#
|
||||||
# MSVC 6 SP6 doesn't like direct shifting of 64-bit integers.
|
# MSVC 6 SP6 doesn't like direct shifting of 64-bit integers.
|
||||||
|
@ -253,12 +258,21 @@ conf.Finish()
|
||||||
|
|
||||||
#
|
#
|
||||||
# MSVC 2005 requires the memset CRT function to be present
|
# MSVC 2005 requires the memset CRT function to be present
|
||||||
|
# and the stubs might need memcpy (entry struct copy on x64)
|
||||||
|
# BUGBUG: The tests are currently broken on x64 and designed to fail!
|
||||||
#
|
#
|
||||||
|
|
||||||
conf = defenv.Configure(custom_tests = { 'CheckRequirement' : check_requirement })
|
conf = defenv.Configure(custom_tests = { 'CheckRequirement' : check_requirement })
|
||||||
|
if conf.CheckRequirement('memset', 'char c[128] = "test";switch(sizeof(void*)){case 8:break;case sizeof(void*):return 1;}'):
|
||||||
|
add_file('memset.c', 'memset')
|
||||||
|
|
||||||
if conf.CheckRequirement('memset', 'char c[128] = "test";'):
|
memcpy_test = """
|
||||||
add_file('memset.c')
|
switch(sizeof(void*)){case 8:break;case sizeof(void*):return 1;}
|
||||||
|
"""
|
||||||
|
if conf.CheckRequirement('memcpy', memcpy_test):
|
||||||
|
add_file('memcpy.c', 'memcpy')
|
||||||
|
stub_env.Append(CPPDEFINES = ['_NSIS_NODEFLIB_CRTMEMCPY'])
|
||||||
|
stub_uenv.Append(CPPDEFINES = ['_NSIS_NODEFLIB_CRTMEMCPY'])
|
||||||
|
|
||||||
conf.Finish()
|
conf.Finish()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
EnsureSConsVersion(1,2)
|
EnsureSConsVersion(1,2)
|
||||||
|
|
||||||
stubs = [
|
stubs = [
|
||||||
'bzip2',
|
'bzip2',
|
||||||
'lzma',
|
'lzma',
|
||||||
|
@ -260,7 +260,7 @@ if (not defenv.has_key('VER_PACKED')) and defenv.has_key('VER_MAJOR') and defenv
|
||||||
if defenv.has_key('VER_PACKED'):
|
if defenv.has_key('VER_PACKED'):
|
||||||
f.write('#define NSIS_PACKEDVERSION _T("%s")\n' % defenv['VER_PACKED'])
|
f.write('#define NSIS_PACKEDVERSION _T("%s")\n' % defenv['VER_PACKED'])
|
||||||
|
|
||||||
if defenv.has_key('VER_MAJOR') and not defenv.has_key('VERSION'):
|
if defenv.has_key('VER_MAJOR') and defenv.get('VERSION','') == '':
|
||||||
defenv['VERSION'] = defenv['VER_MAJOR']
|
defenv['VERSION'] = defenv['VER_MAJOR']
|
||||||
if defenv.has_key('VER_MINOR'):
|
if defenv.has_key('VER_MINOR'):
|
||||||
defenv['VERSION'] += '.' + defenv['VER_MINOR']
|
defenv['VERSION'] += '.' + defenv['VER_MINOR']
|
||||||
|
@ -694,7 +694,9 @@ for plugin in plugin_libs + plugins:
|
||||||
|
|
||||||
srcpath = 'Contrib/' + plugin
|
srcpath = 'Contrib/' + plugin
|
||||||
build_dir = '$BUILD_PREFIX/' + plugin
|
build_dir = '$BUILD_PREFIX/' + plugin
|
||||||
pvariants = [{'e':plugin_env.Clone()}] # BUGBUG64: Only build unicode plugins
|
pvariants = []
|
||||||
|
if GetArcCPU(defenv) == 'x86':
|
||||||
|
pvariants += [{'e':plugin_env.Clone()}]
|
||||||
if defenv['UNICODE']:
|
if defenv['UNICODE']:
|
||||||
pvariants += [{'e':plugin_uenv.Clone()}]
|
pvariants += [{'e':plugin_uenv.Clone()}]
|
||||||
for pvariant in pvariants:
|
for pvariant in pvariants:
|
||||||
|
|
|
@ -92,9 +92,9 @@ public:
|
||||||
_streamPos -= subValue;
|
_streamPos -= subValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NeedMove(UInt32 numCheckBytes)
|
bool NeedMove(size_t numCheckBytes)
|
||||||
{
|
{
|
||||||
UInt32 reserv = _pointerToLastSafePosition - (_buffer + _pos);
|
size_t reserv = _pointerToLastSafePosition - (_buffer + _pos);
|
||||||
return (reserv <= numCheckBytes);
|
return (reserv <= numCheckBytes);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,7 +85,7 @@ void ReadVarLenArr(LPBYTE &seeker, WINWCHAR* &readInto, unsigned int uCodePage)
|
||||||
seeker += sizeof(WORD);
|
seeker += sizeof(WORD);
|
||||||
|
|
||||||
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
// A macro that adds the size of x (which can be a string a number, or nothing) to dwSize
|
||||||
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (WinWStrLen(x) + 1) * sizeof(WINWCHAR)) : sizeof(WORD)
|
#define AddStringOrIdSize(x) dwSize += x ? (IS_INTRESOURCE(x) ? sizeof(DWORD) : (DWORD)((WinWStrLen(x) + 1) * sizeof(WINWCHAR))) : sizeof(WORD)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
|
@ -381,7 +381,7 @@ SIZE CDialogTemplate::GetStringSize(WORD id, TCHAR *str) {
|
||||||
SelectObject(memDC, font);
|
SelectObject(memDC, font);
|
||||||
|
|
||||||
SIZE size;
|
SIZE size;
|
||||||
GetTextExtentPoint32(memDC, str, _tcslen(str), &size);
|
GetTextExtentPoint32(memDC, str, (int) _tcslen(str), &size);
|
||||||
|
|
||||||
DestroyWindow(hDlg);
|
DestroyWindow(hDlg);
|
||||||
DeleteObject(font);
|
DeleteObject(font);
|
||||||
|
|
|
@ -130,7 +130,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
#if defined(_MSC_VER) && (_MSC_VER <= 1200 || (defined(_MIN)&&_MSC_FULL_VER<=140040310))
|
||||||
#define STD_MIN std::_MIN
|
#define STD_MIN std::_MIN
|
||||||
#define STD_MAX std::_MAX
|
#define STD_MAX std::_MAX
|
||||||
#else
|
#else
|
||||||
|
@ -146,16 +146,27 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __BIG_ENDIAN__
|
#ifndef __BIG_ENDIAN__
|
||||||
|
# define FIX_ENDIAN_INT64(x) (x)
|
||||||
# define FIX_ENDIAN_INT32_INPLACE(x) ((void)(x))
|
# define FIX_ENDIAN_INT32_INPLACE(x) ((void)(x))
|
||||||
# define FIX_ENDIAN_INT32(x) (x)
|
# define FIX_ENDIAN_INT32(x) (x)
|
||||||
# define FIX_ENDIAN_INT16_INPLACE(x) ((void)(x))
|
# define FIX_ENDIAN_INT16_INPLACE(x) ((void)(x))
|
||||||
# define FIX_ENDIAN_INT16(x) (x)
|
# define FIX_ENDIAN_INT16(x) (x)
|
||||||
#else
|
#else
|
||||||
|
# define FIX_ENDIAN_INT64(x) SWAP_ENDIAN_INT64(x)
|
||||||
# define FIX_ENDIAN_INT32_INPLACE(x) ((x) = SWAP_ENDIAN_INT32(x))
|
# define FIX_ENDIAN_INT32_INPLACE(x) ((x) = SWAP_ENDIAN_INT32(x))
|
||||||
# define FIX_ENDIAN_INT32(x) SWAP_ENDIAN_INT32(x)
|
# define FIX_ENDIAN_INT32(x) SWAP_ENDIAN_INT32(x)
|
||||||
# define FIX_ENDIAN_INT16_INPLACE(x) ((x) = SWAP_ENDIAN_INT16(x))
|
# define FIX_ENDIAN_INT16_INPLACE(x) ((x) = SWAP_ENDIAN_INT16(x))
|
||||||
# define FIX_ENDIAN_INT16(x) SWAP_ENDIAN_INT16(x)
|
# define FIX_ENDIAN_INT16(x) SWAP_ENDIAN_INT16(x)
|
||||||
#endif
|
#endif
|
||||||
|
#define SWAP_ENDIAN_INT64(x) ( \
|
||||||
|
(((x)&0xFF00000000000000) >> 56) | \
|
||||||
|
(((x)&0x00FF000000000000) >> 40) | \
|
||||||
|
(((x)&0x0000FF0000000000) >> 24) | \
|
||||||
|
(((x)&0x000000FF00000000) >> 8) | \
|
||||||
|
(((x)&0x00000000FF000000) << 8) | \
|
||||||
|
(((x)&0x0000000000FF0000) << 24) | \
|
||||||
|
(((x)&0x000000000000FF00) << 40) | \
|
||||||
|
(((x)&0x00000000000000FF) << 56) )
|
||||||
#define SWAP_ENDIAN_INT32(x) ( \
|
#define SWAP_ENDIAN_INT32(x) ( \
|
||||||
(((x)&0xFF000000) >> 24) | \
|
(((x)&0xFF000000) >> 24) | \
|
||||||
(((x)&0x00FF0000) >> 8) | \
|
(((x)&0x00FF0000) >> 8) | \
|
||||||
|
@ -993,6 +1004,7 @@ typedef struct tagVS_FIXEDFILEINFO {
|
||||||
|
|
||||||
|
|
||||||
#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications
|
#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications
|
||||||
|
#define BUGBUG64TRUNCATE(cast,xpr) ( (cast) (xpr) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
_tprintf on Windows/MSVCRT treats %s as TCHAR* and on POSIX %s is always char*!
|
_tprintf on Windows/MSVCRT treats %s as TCHAR* and on POSIX %s is always char*!
|
||||||
|
|
|
@ -129,7 +129,7 @@ void read_file(const tstring& filename, vector<unsigned char>& data)
|
||||||
rewind(file);
|
rewind(file);
|
||||||
data.resize(filesize);
|
data.resize(filesize);
|
||||||
size_t cbio = fread(reinterpret_cast<char*>(&data[0]), 1, filesize, file);
|
size_t cbio = fread(reinterpret_cast<char*>(&data[0]), 1, filesize, file);
|
||||||
succ = cbio == (unsigned)filesize;
|
succ = cbio == (size_t)filesize;
|
||||||
}
|
}
|
||||||
if (!succ) throw NSISException(_T("Couldn't read entire file '") + filename + _T("'"));
|
if (!succ) throw NSISException(_T("Couldn't read entire file '") + filename + _T("'"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,7 +669,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
||||||
crd->m_ulWrittenAt = (ULONG_PTR)(seeker);
|
crd->m_ulWrittenAt = (ULONG_PTR)(seeker);
|
||||||
seeker += sizeof(IMAGE_RESOURCE_DIRECTORY);
|
seeker += sizeof(IMAGE_RESOURCE_DIRECTORY);
|
||||||
|
|
||||||
for (int i = 0; i < crd->CountEntries(); i++) {
|
for (unsigned int i = 0; i < crd->CountEntries(); i++) {
|
||||||
if (crd->GetEntry(i)->HasName())
|
if (crd->GetEntry(i)->HasName())
|
||||||
qStrings.push(crd->GetEntry(i));
|
qStrings.push(crd->GetEntry(i));
|
||||||
if (crd->GetEntry(i)->IsDataDirectory())
|
if (crd->GetEntry(i)->IsDataDirectory())
|
||||||
|
@ -718,7 +718,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
||||||
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_ulWrittenAt)->UName.NameString.NameOffset = ConvertEndianness((DWORD) (seeker - pbRsrcSec));
|
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_ulWrittenAt)->UName.NameString.NameOffset = ConvertEndianness((DWORD) (seeker - pbRsrcSec));
|
||||||
|
|
||||||
WINWCHAR* szName = cRDirE->GetName();
|
WINWCHAR* szName = cRDirE->GetName();
|
||||||
WORD iLen = WinWStrLen(szName) + 1;
|
WORD iLen = (WORD) WinWStrLen(szName) + 1;
|
||||||
|
|
||||||
*(WORD*)seeker = ConvertEndianness(iLen);
|
*(WORD*)seeker = ConvertEndianness(iLen);
|
||||||
CopyMemory(seeker + sizeof(WORD), szName, iLen*sizeof(WINWCHAR));
|
CopyMemory(seeker + sizeof(WORD), szName, iLen*sizeof(WINWCHAR));
|
||||||
|
@ -751,7 +751,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
||||||
|
|
||||||
// Sets the offsets in directory entries
|
// Sets the offsets in directory entries
|
||||||
void CResourceEditor::SetOffsets(CResourceDirectory* resDir, ULONG_PTR newResDirAt) {
|
void CResourceEditor::SetOffsets(CResourceDirectory* resDir, ULONG_PTR newResDirAt) {
|
||||||
for (int i = 0; i < resDir->CountEntries(); i++) {
|
for (unsigned int i = 0; i < resDir->CountEntries(); i++) {
|
||||||
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY rde = PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(resDir->GetEntry(i)->m_ulWrittenAt);
|
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY rde = PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(resDir->GetEntry(i)->m_ulWrittenAt);
|
||||||
if (resDir->GetEntry(i)->IsDataDirectory()) {
|
if (resDir->GetEntry(i)->IsDataDirectory()) {
|
||||||
rde->UOffset.DirectoryOffset.DataIsDirectory = 1;
|
rde->UOffset.DirectoryOffset.DataIsDirectory = 1;
|
||||||
|
@ -860,8 +860,8 @@ void CResourceDirectory::RemoveEntry(int i) {
|
||||||
m_vEntries.erase(m_vEntries.begin() + i);
|
m_vEntries.erase(m_vEntries.begin() + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CResourceDirectory::CountEntries() {
|
unsigned int CResourceDirectory::CountEntries() {
|
||||||
return m_vEntries.size();
|
return BUGBUG64TRUNCATE(unsigned int,m_vEntries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the index of a directory entry with the specified name
|
// Returns the index of a directory entry with the specified name
|
||||||
|
@ -987,7 +987,7 @@ WINWCHAR* CResourceDirectoryEntry::GetName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CResourceDirectoryEntry::GetNameLength() {
|
int CResourceDirectoryEntry::GetNameLength() {
|
||||||
return WinWStrLen(m_szName);
|
return (int) WinWStrLen(m_szName);
|
||||||
}
|
}
|
||||||
|
|
||||||
WORD CResourceDirectoryEntry::GetId() {
|
WORD CResourceDirectoryEntry::GetId() {
|
||||||
|
|
|
@ -212,7 +212,7 @@ public:
|
||||||
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
||||||
bool AddEntry(CResourceDirectoryEntry* entry);
|
bool AddEntry(CResourceDirectoryEntry* entry);
|
||||||
void RemoveEntry(int i);
|
void RemoveEntry(int i);
|
||||||
int CountEntries();
|
unsigned int CountEntries();
|
||||||
int Find(const WINWCHAR* szName);
|
int Find(const WINWCHAR* szName);
|
||||||
int Find(WORD wId);
|
int Find(WORD wId);
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,12 @@ CEXEBuild::CEXEBuild() :
|
||||||
definedlist.add(_T("NSIS_PACKEDVERSION"), NSIS_PACKEDVERSION);
|
definedlist.add(_T("NSIS_PACKEDVERSION"), NSIS_PACKEDVERSION);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
build_unicode=false;
|
|
||||||
build_lockedunicodetarget=false;
|
|
||||||
m_target_type=TARGET_X86ANSI;
|
m_target_type=TARGET_X86ANSI;
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (sizeof(void*) > 4) m_target_type = TARGET_AMD64; // BUGBUG: There is no instuction to select it so we force
|
||||||
|
#endif
|
||||||
|
build_unicode=TARGET_X86ANSI != m_target_type;
|
||||||
|
build_lockedunicodetarget=false;
|
||||||
|
|
||||||
// automatically generated header file containing all defines
|
// automatically generated header file containing all defines
|
||||||
#include <nsis-defines.h>
|
#include <nsis-defines.h>
|
||||||
|
@ -379,7 +382,6 @@ CEXEBuild::CEXEBuild() :
|
||||||
|
|
||||||
set_uninstall_mode(0);
|
set_uninstall_mode(0);
|
||||||
set_code_type_predefines();
|
set_code_type_predefines();
|
||||||
set_target_architecture_predefines();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::initialize(const TCHAR *makensis_path)
|
void CEXEBuild::initialize(const TCHAR *makensis_path)
|
||||||
|
@ -403,7 +405,7 @@ void CEXEBuild::initialize(const TCHAR *makensis_path)
|
||||||
stubs_dir = nsis_dir;
|
stubs_dir = nsis_dir;
|
||||||
stubs_dir += PLATFORM_PATH_SEPARATOR_STR _T("Stubs");
|
stubs_dir += PLATFORM_PATH_SEPARATOR_STR _T("Stubs");
|
||||||
|
|
||||||
if (set_compressor(_T("zlib"), false) != PS_OK)
|
if (set_compressor(_T("zlib"), false) != PS_OK || set_target_architecture_data() != PS_OK)
|
||||||
{
|
{
|
||||||
throw runtime_error("error setting default stub");
|
throw runtime_error("error setting default stub");
|
||||||
}
|
}
|
||||||
|
@ -2303,7 +2305,7 @@ void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
|
||||||
lang_table_writer::write_block(cur_langtables, &sink, cur_header->langtable_size);
|
lang_table_writer::write_block(cur_langtables, &sink, cur_header->langtable_size);
|
||||||
|
|
||||||
cur_header->blocks[NB_CTLCOLORS].offset = sizeof(header) + blocks_buf.getlen();
|
cur_header->blocks[NB_CTLCOLORS].offset = sizeof(header) + blocks_buf.getlen();
|
||||||
ctlcolors_writer::write_block(cur_ctlcolors, &sink);
|
ctlcolors_writer::write_block(cur_ctlcolors, &sink, build_unicode, is_target_64bit());
|
||||||
|
|
||||||
#ifdef NSIS_SUPPORT_BGBG
|
#ifdef NSIS_SUPPORT_BGBG
|
||||||
if (cur_header->bg_color1 != -1)
|
if (cur_header->bg_color1 != -1)
|
||||||
|
@ -2357,7 +2359,7 @@ int CEXEBuild::SetManifest()
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
|
||||||
// Saved directly as binary into the exe.
|
// Saved directly as binary into the exe.
|
||||||
res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), (DWORD)manifest.length());
|
||||||
}
|
}
|
||||||
catch (exception& err) {
|
catch (exception& err) {
|
||||||
ERROR_MSG(_T("Error setting manifest: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
ERROR_MSG(_T("Error setting manifest: %") NPRIs _T("\n"), CtoTStrParam(err.what()));
|
||||||
|
@ -2520,6 +2522,7 @@ int CEXEBuild::pack_exe_header()
|
||||||
|
|
||||||
int CEXEBuild::write_output(void)
|
int CEXEBuild::write_output(void)
|
||||||
{
|
{
|
||||||
|
if (sizeof(void*)>4 && lowercase(get_file_name(stub_filename)).c_str()[0]=='z') warning(_T("ZLIB is broken?!\n"));
|
||||||
#ifndef NSIS_CONFIG_CRC_SUPPORT
|
#ifndef NSIS_CONFIG_CRC_SUPPORT
|
||||||
build_crcchk=0;
|
build_crcchk=0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2618,9 +2621,9 @@ int CEXEBuild::write_output(void)
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||||
#ifdef NSIS_CONFIG_CRC_ANAL
|
#ifdef NSIS_CONFIG_CRC_ANAL
|
||||||
crc=CRC32(crc,m_exehead,m_exehead_size);
|
crc=CRC32(crc,m_exehead,(DWORD)m_exehead_size);
|
||||||
#else
|
#else
|
||||||
crc=CRC32(crc,m_exehead+512,m_exehead_size-512);
|
crc=CRC32(crc,m_exehead+512,(DWORD)m_exehead_size-512);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2776,8 +2779,8 @@ int CEXEBuild::write_output(void)
|
||||||
|
|
||||||
if (db_opt_save)
|
if (db_opt_save)
|
||||||
{
|
{
|
||||||
int total_out_size_estimate=
|
int total_out_size_estimate=BUGBUG64TRUNCATE(int, // BUGBUG: This should be UINT64 or at least unsigned
|
||||||
m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(crc32_t):0);
|
m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(crc32_t):0));
|
||||||
int pc=(int)(((INT64)db_opt_save*1000)/(db_opt_save+total_out_size_estimate));
|
int pc=(int)(((INT64)db_opt_save*1000)/(db_opt_save+total_out_size_estimate));
|
||||||
INFO_MSG(_T("Datablock optimizer saved %d bytes (~%d.%d%%).\n"),db_opt_save,
|
INFO_MSG(_T("Datablock optimizer saved %d bytes (~%d.%d%%).\n"),db_opt_save,
|
||||||
pc/10,pc%10);
|
pc/10,pc%10);
|
||||||
|
@ -2787,7 +2790,7 @@ int CEXEBuild::write_output(void)
|
||||||
INFO_MSG(_T("\nUsing %") NPRIs _T("%") NPRIs _T(" compression.\n\n"), compressor->GetName(), build_compress_whole?_T(" (compress whole)"):_T(""));
|
INFO_MSG(_T("\nUsing %") NPRIs _T("%") NPRIs _T(" compression.\n\n"), compressor->GetName(), build_compress_whole?_T(" (compress whole)"):_T(""));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int total_usize=m_exehead_original_size;
|
unsigned int total_usize=(unsigned int) m_exehead_original_size;
|
||||||
|
|
||||||
INFO_MSG(_T("EXE header size: %10u / %u bytes\n"),m_exehead_size,m_exehead_original_size);
|
INFO_MSG(_T("EXE header size: %10u / %u bytes\n"),m_exehead_size,m_exehead_original_size);
|
||||||
|
|
||||||
|
@ -2912,7 +2915,7 @@ int CEXEBuild::write_output(void)
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char buf[32768];
|
char buf[32768];
|
||||||
int l=fread(buf,1,sizeof(buf),fp);
|
unsigned int l=(unsigned int)fread(buf,1,sizeof(buf),fp);
|
||||||
if (!l) break;
|
if (!l) break;
|
||||||
crc=CRC32(crc,(unsigned char *)buf,l);
|
crc=CRC32(crc,(unsigned char *)buf,l);
|
||||||
}
|
}
|
||||||
|
@ -2949,7 +2952,7 @@ int CEXEBuild::write_output(void)
|
||||||
TCHAR *arg = _tcsstr(cmdstr, _T("%1"));
|
TCHAR *arg = _tcsstr(cmdstr, _T("%1"));
|
||||||
if (arg) // if found, replace %1 by build_output_filename
|
if (arg) // if found, replace %1 by build_output_filename
|
||||||
{
|
{
|
||||||
const UINT cchbldoutfile = _tcslen(build_output_filename);
|
const size_t cchbldoutfile = _tcslen(build_output_filename);
|
||||||
cmdstrbuf = (TCHAR*) malloc( (_tcslen(cmdstr) + cchbldoutfile + 1)*sizeof(TCHAR) );
|
cmdstrbuf = (TCHAR*) malloc( (_tcslen(cmdstr) + cchbldoutfile + 1)*sizeof(TCHAR) );
|
||||||
if (!cmdstrbuf)
|
if (!cmdstrbuf)
|
||||||
{
|
{
|
||||||
|
@ -3000,7 +3003,7 @@ int CEXEBuild::deflateToFile(FILE *fp, char *buf, int len) // len==0 to flush
|
||||||
int l=compressor->GetNextOut()-obuf;
|
int l=compressor->GetNextOut()-obuf;
|
||||||
if (l)
|
if (l)
|
||||||
{
|
{
|
||||||
if (fwrite(obuf,1,l,fp) != (unsigned)l)
|
if (fwrite(obuf,1,l,fp) != (size_t)l)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: deflateToFile fwrite(%d) failed\n"),l);
|
ERROR_MSG(_T("Error: deflateToFile fwrite(%d) failed\n"),l);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3062,7 +3065,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
if (ent->which == EW_WRITEUNINSTALLER)
|
if (ent->which == EW_WRITEUNINSTALLER)
|
||||||
{
|
{
|
||||||
ent->offsets[1] = uninstdata_offset;
|
ent->offsets[1] = uninstdata_offset;
|
||||||
ent->offsets[2] = m_unicon_size;
|
ent->offsets[2] = (int) m_unicon_size;
|
||||||
uns--;
|
uns--;
|
||||||
if (!uns)
|
if (!uns)
|
||||||
break;
|
break;
|
||||||
|
@ -3099,9 +3102,9 @@ int CEXEBuild::uninstall_generate()
|
||||||
delete [] unicon_data;
|
delete [] unicon_data;
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_CRC_ANAL
|
#ifdef NSIS_CONFIG_CRC_ANAL
|
||||||
crc=CRC32(crc, uninst_header, m_exehead_size);
|
crc=CRC32(crc, uninst_header, (DWORD)m_exehead_size);
|
||||||
#else
|
#else
|
||||||
crc=CRC32(crc, uninst_header + 512, m_exehead_size - 512);
|
crc=CRC32(crc, uninst_header + 512, (DWORD)m_exehead_size - 512);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(uninst_header);
|
free(uninst_header);
|
||||||
|
@ -3242,7 +3245,7 @@ int CEXEBuild::uninstall_generate()
|
||||||
udata.clear();
|
udata.clear();
|
||||||
|
|
||||||
//uninstall_size_full=fh.length_of_all_following_data + sizeof(int) + unicondata_size - 32 + sizeof(int);
|
//uninstall_size_full=fh.length_of_all_following_data + sizeof(int) + unicondata_size - 32 + sizeof(int);
|
||||||
uninstall_size_full=fh.length_of_all_following_data+m_unicon_size;
|
uninstall_size_full=fh.length_of_all_following_data+(int)m_unicon_size;
|
||||||
|
|
||||||
// compressed size
|
// compressed size
|
||||||
uninstall_size=build_datablock.getlen()-uninstdata_offset;
|
uninstall_size=build_datablock.getlen()-uninstdata_offset;
|
||||||
|
@ -3409,7 +3412,7 @@ void CEXEBuild::notify(MakensisAPI::notify_e code, const TCHAR *data) const
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (notify_hwnd)
|
if (notify_hwnd)
|
||||||
{
|
{
|
||||||
COPYDATASTRUCT cds = {(DWORD)code, (_tcslen(data)+1)*sizeof(TCHAR), (void *) data};
|
COPYDATASTRUCT cds = {(DWORD)code, (UINT32)(_tcslen(data)+1)*sizeof(TCHAR), (void *) data};
|
||||||
SendMessage(notify_hwnd, WM_COPYDATA, 0, (LPARAM)&cds);
|
SendMessage(notify_hwnd, WM_COPYDATA, 0, (LPARAM)&cds);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3529,7 +3532,7 @@ void CEXEBuild::init_res_editor()
|
||||||
{
|
{
|
||||||
build_compressor_set = true;
|
build_compressor_set = true;
|
||||||
if (!res_editor)
|
if (!res_editor)
|
||||||
res_editor = new CResourceEditor(m_exehead, m_exehead_size);
|
res_editor = new CResourceEditor(m_exehead, (DWORD)m_exehead_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::close_res_editor()
|
void CEXEBuild::close_res_editor()
|
||||||
|
@ -3569,7 +3572,7 @@ int CEXEBuild::DeclaredUserVar(const TCHAR *szVarName)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
const TCHAR *pVarName = szVarName;
|
const TCHAR *pVarName = szVarName;
|
||||||
int iVarLen = _tcslen(szVarName);
|
size_t iVarLen = _tcslen(szVarName);
|
||||||
|
|
||||||
if (iVarLen > 60)
|
if (iVarLen > 60)
|
||||||
{
|
{
|
||||||
|
@ -3638,8 +3641,10 @@ void CEXEBuild::VerifyDeclaredUserVarRefs(UserVarsStringList *pVarsStringList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXEBuild::set_target_architecture_predefines()
|
int CEXEBuild::set_target_architecture_data()
|
||||||
{
|
{
|
||||||
|
build_strlist.setunicode(build_unicode), ubuild_strlist.setunicode(build_unicode);
|
||||||
|
|
||||||
definedlist.del(_T("NSIS_UNICODE"));
|
definedlist.del(_T("NSIS_UNICODE"));
|
||||||
definedlist.del(_T("NSIS_CHAR_SIZE"));
|
definedlist.del(_T("NSIS_CHAR_SIZE"));
|
||||||
definedlist.del(_T("NSIS_PTR_SIZE"));
|
definedlist.del(_T("NSIS_PTR_SIZE"));
|
||||||
|
@ -3652,23 +3657,27 @@ void CEXEBuild::set_target_architecture_predefines()
|
||||||
{
|
{
|
||||||
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1"));
|
definedlist.add(_T("NSIS_CHAR_SIZE"), _T("1"));
|
||||||
}
|
}
|
||||||
definedlist.add(_T("NSIS_PTR_SIZE"), m_target_type <= TARGET_X86UNICODE ? _T("4") : _T("8"));
|
definedlist.add(_T("NSIS_PTR_SIZE"), is_target_64bit() ? _T("8") : _T("4"));
|
||||||
|
|
||||||
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEXEBuild::change_target_architecture()
|
int CEXEBuild::change_target_architecture(TARGETTYPE tt)
|
||||||
{
|
{
|
||||||
if (build_compressor_set)
|
const bool wide = TARGET_X86ANSI != tt;
|
||||||
|
if (build_compressor_set || (build_unicode != wide && build_lockedunicodetarget))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("Error: Can't change target architecture after data already got compressed!\n"));
|
ERROR_MSG(_T("Error: Can't change target architecture after data already got compressed!\n"));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_target_type = build_unicode ? TARGET_X86UNICODE : TARGET_X86ANSI; // BUGBUG64
|
m_target_type = tt;
|
||||||
set_target_architecture_predefines();
|
build_unicode = wide;
|
||||||
|
|
||||||
int ec = load_stub();
|
int ec = set_target_architecture_data();
|
||||||
|
if (PS_OK == ec) ec = load_stub();
|
||||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
if (PS_OK==ec) ec = initialize_default_plugins(true);
|
if (PS_OK == ec) ec = initialize_default_plugins(true);
|
||||||
#endif
|
#endif
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
@ -3677,10 +3686,9 @@ int CEXEBuild::change_target_architecture()
|
||||||
int CEXEBuild::set_target_charset(bool unicode)
|
int CEXEBuild::set_target_charset(bool unicode)
|
||||||
{
|
{
|
||||||
if (build_lockedunicodetarget) return PS_ERROR;
|
if (build_lockedunicodetarget) return PS_ERROR;
|
||||||
build_unicode = unicode;
|
TARGETTYPE tt = unicode ? m_target_type : TARGET_X86ANSI;
|
||||||
build_strlist.setunicode(unicode);
|
if (TARGET_X86ANSI == tt && unicode) tt = TARGET_X86UNICODE;
|
||||||
ubuild_strlist.setunicode(unicode);
|
return change_target_architecture(tt);
|
||||||
return change_target_architecture();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ class CEXEBuild {
|
||||||
TARGETTYPE get_target_type(const TCHAR*s) const;
|
TARGETTYPE get_target_type(const TCHAR*s) const;
|
||||||
const TCHAR* get_target_suffix(CEXEBuild::TARGETTYPE tt) const;
|
const TCHAR* get_target_suffix(CEXEBuild::TARGETTYPE tt) const;
|
||||||
const TCHAR* get_target_suffix() const {return get_target_suffix(m_target_type);}
|
const TCHAR* get_target_suffix() const {return get_target_suffix(m_target_type);}
|
||||||
|
bool is_target_64bit() const { return TARGET_AMD64 == m_target_type; }
|
||||||
|
|
||||||
void set_default_output_filename(const tstring& filename);
|
void set_default_output_filename(const tstring& filename);
|
||||||
|
|
||||||
|
@ -239,8 +240,8 @@ class CEXEBuild {
|
||||||
DefineList *searchParseString(const TCHAR *source_string, LineParser&line, int parmOffs, bool ignCase, bool noErrors, UINT*failParam = 0);
|
DefineList *searchParseString(const TCHAR *source_string, LineParser&line, int parmOffs, bool ignCase, bool noErrors, UINT*failParam = 0);
|
||||||
|
|
||||||
// build.cpp functions used mostly by script.cpp
|
// build.cpp functions used mostly by script.cpp
|
||||||
void set_target_architecture_predefines();
|
int set_target_architecture_data();
|
||||||
int change_target_architecture();
|
int change_target_architecture(TARGETTYPE tt);
|
||||||
void set_code_type_predefines(const TCHAR *value = NULL);
|
void set_code_type_predefines(const TCHAR *value = NULL);
|
||||||
int getcurdbsize();
|
int getcurdbsize();
|
||||||
int add_section(const TCHAR *secname, const TCHAR *defname, int expand=0);
|
int add_section(const TCHAR *secname, const TCHAR *defname, int expand=0);
|
||||||
|
@ -257,6 +258,7 @@ class CEXEBuild {
|
||||||
int add_entry_direct(int which, int o0=0, int o1=0, int o2=0, int o3=0, int o4=0, int o5=0);
|
int add_entry_direct(int which, int o0=0, int o1=0, int o2=0, int o3=0, int o4=0, int o5=0);
|
||||||
int add_db_data(IMMap *map); // returns offset
|
int add_db_data(IMMap *map); // returns offset
|
||||||
int add_db_data(const char *data, int length); // returns offset
|
int add_db_data(const char *data, int length); // returns offset
|
||||||
|
int add_db_data(const char *data, size_t length) { assert(length <= 0x7FFFFFFF); return add_db_data(data, (int)length); }
|
||||||
int add_data(const char *data, int length, IGrowBuf *dblock); // returns offset
|
int add_data(const char *data, int length, IGrowBuf *dblock); // returns offset
|
||||||
int add_string(const TCHAR *string, int process=1, UINT codepage=-2); // returns offset (in string table)
|
int add_string(const TCHAR *string, int process=1, UINT codepage=-2); // returns offset (in string table)
|
||||||
int add_asciistring(const TCHAR *string, int process=1); // For hardcoded 7bit/ASCII strings
|
int add_asciistring(const TCHAR *string, int process=1); // For hardcoded 7bit/ASCII strings
|
||||||
|
|
|
@ -260,7 +260,7 @@ void generateMTFValues ( EState* s )
|
||||||
*ryy_j = rtmp2;
|
*ryy_j = rtmp2;
|
||||||
};
|
};
|
||||||
yy[0] = rtmp;
|
yy[0] = rtmp;
|
||||||
j = ryy_j - &(yy[0]);
|
j = BUGBUG64TRUNCATE(Int32, ryy_j - &(yy[0]));
|
||||||
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
|
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,9 +320,13 @@ end:
|
||||||
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
||||||
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
||||||
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
||||||
|
#ifndef _WIN64
|
||||||
OPT=myGetProcAddress(MGA_OpenProcessToken);
|
OPT=myGetProcAddress(MGA_OpenProcessToken);
|
||||||
LPV=myGetProcAddress(MGA_LookupPrivilegeValue);
|
LPV=myGetProcAddress(MGA_LookupPrivilegeValue);
|
||||||
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
|
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
|
||||||
|
#else
|
||||||
|
OPT=OpenProcessToken, LPV=LookupPrivilegeValue, ATP=AdjustTokenPrivileges;
|
||||||
|
#endif
|
||||||
if (OPT && LPV && ATP)
|
if (OPT && LPV && ATP)
|
||||||
{
|
{
|
||||||
HANDLE hToken;
|
HANDLE hToken;
|
||||||
|
@ -368,4 +372,7 @@ void NSISCALL CleanUp()
|
||||||
// Clean up after plug-ins
|
// Clean up after plug-ins
|
||||||
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
|
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
|
||||||
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
||||||
|
#ifdef _DEBUG
|
||||||
|
// GlobalFree(g_header); ?
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,11 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
||||||
|
|
||||||
LANGID (WINAPI *GUDUIL)();
|
LANGID (WINAPI *GUDUIL)();
|
||||||
|
|
||||||
|
#ifndef _WIN64
|
||||||
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
||||||
|
#else
|
||||||
|
GUDUIL = GetUserDefaultUILanguage;
|
||||||
|
#endif
|
||||||
if (GUDUIL)
|
if (GUDUIL)
|
||||||
{
|
{
|
||||||
// Windows ME/2000+
|
// Windows ME/2000+
|
||||||
|
@ -407,7 +411,7 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
||||||
#endif
|
#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)
|
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
|
||||||
ExecuteCallbackFunction(CB_ONGUIEND);
|
ExecuteCallbackFunction(CB_ONGUIEND);
|
||||||
#endif
|
#endif
|
||||||
|
@ -483,7 +487,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
m_delta = wParam;
|
m_delta = (int) wParam;
|
||||||
|
|
||||||
if (uMsg == WM_INITDIALOG)
|
if (uMsg == WM_INITDIALOG)
|
||||||
{
|
{
|
||||||
|
@ -538,7 +542,6 @@ nextPage:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWND hwndtmp;
|
HWND hwndtmp;
|
||||||
|
|
||||||
int pflags = this_page->flags;
|
int pflags = this_page->flags;
|
||||||
|
|
||||||
GetNSISString(state_click_next, this_page->clicknext);
|
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);
|
size_t len = lstrlen(((LPWSTR) dwCookie)+g_cbLicRead);
|
||||||
len = min(len, cb/sizeof(WCHAR));
|
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"
|
// RTF uses only ASCII characters, so we can assume "number of output bytes" = "number of source WChar consumed"
|
||||||
g_cbLicRead+=*pcb;
|
g_cbLicRead+=*pcb;
|
||||||
return 0;
|
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 (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !LicIgnoreWMCommand) {
|
||||||
if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) {
|
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 &= ~PF_LICENSE_SELECTED;
|
||||||
m_this_page->flags |= is;
|
m_this_page->flags |= is;
|
||||||
EnableNext(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
|
// Test for and use the GetDiskFreeSpaceEx API
|
||||||
{
|
{
|
||||||
BOOL (WINAPI *GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
|
BOOL (WINAPI *GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
|
||||||
|
#ifdef _WIN64
|
||||||
|
GetDiskFreeSpaceEx;
|
||||||
|
#else
|
||||||
myGetProcAddress(MGA_GetDiskFreeSpaceEx);
|
myGetProcAddress(MGA_GetDiskFreeSpaceEx);
|
||||||
|
#endif
|
||||||
if (GDFSE)
|
if (GDFSE)
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER available64;
|
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;
|
DWORD spc, bps, fc, tc;
|
||||||
TCHAR *root;
|
TCHAR *root;
|
||||||
|
@ -1252,7 +1259,7 @@ void NSISCALL ExecuteCallbackFunctionWithr0Int(int num,int r0)
|
||||||
|
|
||||||
static WNDPROC oldTreeWndProc;
|
static WNDPROC oldTreeWndProc;
|
||||||
static LPARAM last_selected_tree_item;
|
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) {
|
if (uMsg == WM_CHAR && wParam == VK_SPACE) {
|
||||||
NotifyCurWnd(WM_TREEVIEW_KEYHACK);
|
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)
|
if (last_selected_tree_item != lParam)
|
||||||
{
|
{
|
||||||
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
|
#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])
|
if (install_types[i])
|
||||||
{
|
{
|
||||||
int j;
|
LRESULT j;
|
||||||
if (i != NSIS_MAX_INST_TYPES) noCombo = 0;
|
if (i != NSIS_MAX_INST_TYPES) noCombo = 0;
|
||||||
j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetNSISStringTT(install_types[i]));
|
j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetNSISStringTT(install_types[i]));
|
||||||
SendMessage(hwndCombo1,CB_SETITEMDATA,j,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)
|
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)
|
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])
|
if (whichcfg == CB_ERR || !install_types[whichcfg])
|
||||||
whichcfg = NSIS_MAX_INST_TYPES;
|
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 defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_COMPONENTPAGE)
|
||||||
if (wParam != 0)
|
if (wParam != 0)
|
||||||
{
|
{
|
||||||
int secid = wParam;
|
int secid = (int) wParam;
|
||||||
if (wParamSelChangeNotifyInstTypeChanged != secid) --secid;
|
if (wParamSelChangeNotifyInstTypeChanged != secid) --secid;
|
||||||
ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid);
|
ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid);
|
||||||
}
|
}
|
||||||
|
@ -1744,7 +1751,7 @@ static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
i = count;
|
i = count;
|
||||||
while (i--)
|
while (i--)
|
||||||
// Add 2 for the CR/LF combination that must follow every line.
|
// 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
|
// 2nd pass - store detail view strings on the clipboard
|
||||||
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE
|
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE
|
||||||
|
|
|
@ -172,8 +172,11 @@ static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyif
|
||||||
{
|
{
|
||||||
typedef LONG (WINAPI * RegDeleteKeyExPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
|
typedef LONG (WINAPI * RegDeleteKeyExPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
|
||||||
RegDeleteKeyExPtr RDKE = (RegDeleteKeyExPtr)
|
RegDeleteKeyExPtr RDKE = (RegDeleteKeyExPtr)
|
||||||
|
#ifdef _WIN64
|
||||||
|
RegDeleteKeyEx;
|
||||||
|
#else
|
||||||
myGetProcAddress(MGA_RegDeleteKeyEx);
|
myGetProcAddress(MGA_RegDeleteKeyEx);
|
||||||
|
#endif
|
||||||
if (RDKE)
|
if (RDKE)
|
||||||
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
|
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
|
||||||
else
|
else
|
||||||
|
@ -771,7 +774,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
HWND hwnd=GetHwndFromParm(1);
|
HWND hwnd=GetHwndFromParm(1);
|
||||||
int msg=GetIntFromParm(2);
|
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
|
// Jim Park: This sends script messages. Some messages require
|
||||||
// settings for Unicode. This means the user's script may need
|
// settings for Unicode. This means the user's script may need
|
||||||
// to change for Unicode NSIS.
|
// to change for Unicode NSIS.
|
||||||
|
|
|
@ -398,14 +398,14 @@ int NSISCALL _dodecomp(int offset, HANDLE hFileOut, unsigned char *outbuf, int o
|
||||||
|
|
||||||
if (err<0) return -4;
|
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))
|
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));
|
wsprintf(progress, _T("... %d%%"), MulDiv(input_len_total - input_len, 100, input_len_total));
|
||||||
update_status_text(0, progress);
|
update_status_text(0, progress);
|
||||||
ltc = tc;
|
ltc=tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there's no output, more input is needed
|
// if there's no output, more input is needed
|
||||||
|
|
|
@ -473,13 +473,31 @@ typedef struct {
|
||||||
COLORREF text;
|
COLORREF text;
|
||||||
COLORREF bkc;
|
COLORREF bkc;
|
||||||
UINT lbStyle;
|
UINT lbStyle;
|
||||||
|
#ifndef MAKENSIS
|
||||||
HBRUSH bkb;
|
HBRUSH bkb;
|
||||||
#ifdef _WIN64
|
#else
|
||||||
#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
|
INT32 bkb;
|
||||||
#endif
|
#endif
|
||||||
int bkmode;
|
int bkmode;
|
||||||
int flags;
|
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)
|
#pragma pack(pop)
|
||||||
|
|
||||||
// constants for myDelete (util.c)
|
// constants for myDelete (util.c)
|
||||||
|
|
|
@ -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.
|
// 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 *dst = (char*) out, *src = (char*) in;
|
||||||
char *c_in=(char *)in;
|
while (cb-- > 0) *dst++ = *src++;
|
||||||
while (len-- > 0)
|
|
||||||
{
|
|
||||||
*c_out++=*c_in++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DWORD NSISCALL remove_ro_attr(LPCTSTR file)
|
DWORD NSISCALL remove_ro_attr(LPCTSTR file)
|
||||||
{
|
{
|
||||||
|
@ -538,7 +536,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
||||||
*pEnd-- = *p--;
|
*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
|
// rename section is last, stick item at end of file
|
||||||
else dwRenameLinePos = dwFileSize;
|
else dwRenameLinePos = dwFileSize;
|
||||||
|
@ -570,13 +568,17 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
||||||
BOOL fOk = 0;
|
BOOL fOk = 0;
|
||||||
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
||||||
mfea_t mfea;
|
mfea_t mfea;
|
||||||
|
#ifdef _WIN64
|
||||||
|
mfea=MoveFileEx;
|
||||||
|
#else
|
||||||
mfea=(mfea_t) myGetProcAddress(MGA_MoveFileEx);
|
mfea=(mfea_t) myGetProcAddress(MGA_MoveFileEx);
|
||||||
if (mfea)
|
if (mfea)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fOk)
|
if (!fOk && sizeof(void*) <= 4)
|
||||||
{
|
{
|
||||||
RenameViaWininit(pszExisting, pszNew);
|
RenameViaWininit(pszExisting, pszNew);
|
||||||
}
|
}
|
||||||
|
@ -691,7 +693,7 @@ TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab)
|
||||||
// indexes into the language
|
// indexes into the language
|
||||||
TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab));
|
TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab));
|
||||||
TCHAR *out = ps_tmpbuf;
|
TCHAR *out = ps_tmpbuf;
|
||||||
|
|
||||||
// Still working within ps_tmpbuf, so set out to the
|
// Still working within ps_tmpbuf, so set out to the
|
||||||
// current position that is passed in.
|
// current position that is passed in.
|
||||||
if (outbuf >= ps_tmpbuf &&
|
if (outbuf >= ps_tmpbuf &&
|
||||||
|
@ -1035,6 +1037,7 @@ struct MGA_FUNC
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
struct MGA_FUNC MGA_FUNCS[] = {
|
struct MGA_FUNC MGA_FUNCS[] = {
|
||||||
|
#ifndef _WIN64
|
||||||
{"KERNEL32", "GetDiskFreeSpaceExW"},
|
{"KERNEL32", "GetDiskFreeSpaceExW"},
|
||||||
{"KERNEL32", "MoveFileExW"},
|
{"KERNEL32", "MoveFileExW"},
|
||||||
{"ADVAPI32", "RegDeleteKeyExW"},
|
{"ADVAPI32", "RegDeleteKeyExW"},
|
||||||
|
@ -1042,6 +1045,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
||||||
{"ADVAPI32", "LookupPrivilegeValueW"},
|
{"ADVAPI32", "LookupPrivilegeValueW"},
|
||||||
{"ADVAPI32", "AdjustTokenPrivileges"},
|
{"ADVAPI32", "AdjustTokenPrivileges"},
|
||||||
{"KERNEL32", "GetUserDefaultUILanguage"},
|
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||||
|
#endif
|
||||||
{"SHLWAPI", "SHAutoComplete"},
|
{"SHLWAPI", "SHAutoComplete"},
|
||||||
{"SHFOLDER", "SHGetFolderPathW"}
|
{"SHFOLDER", "SHGetFolderPathW"}
|
||||||
};
|
};
|
||||||
|
|
|
@ -108,11 +108,16 @@ void NSISCALL validate_filename(TCHAR *fn);
|
||||||
* @param pszNew The new name of the file.
|
* @param pszNew The new name of the file.
|
||||||
*/
|
*/
|
||||||
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
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);
|
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 {
|
enum myGetProcAddressFunctions {
|
||||||
|
#ifndef _WIN64
|
||||||
MGA_GetDiskFreeSpaceEx,
|
MGA_GetDiskFreeSpaceEx,
|
||||||
MGA_MoveFileEx,
|
MGA_MoveFileEx,
|
||||||
MGA_RegDeleteKeyEx,
|
MGA_RegDeleteKeyEx,
|
||||||
|
@ -120,8 +125,9 @@ enum myGetProcAddressFunctions {
|
||||||
MGA_LookupPrivilegeValue,
|
MGA_LookupPrivilegeValue,
|
||||||
MGA_AdjustTokenPrivileges,
|
MGA_AdjustTokenPrivileges,
|
||||||
MGA_GetUserDefaultUILanguage,
|
MGA_GetUserDefaultUILanguage,
|
||||||
MGA_SHAutoComplete,
|
#endif
|
||||||
MGA_SHGetFolderPath,
|
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);
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
||||||
|
|
|
@ -146,14 +146,25 @@ void page_writer::write(const page *data)
|
||||||
m_sink->write_int_array(data->parms, 5);
|
m_sink->write_int_array(data->parms, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctlcolors_writer::write(const ctlcolors *data)
|
void ctlcolors_writer::writeplatformitem(const void *data, bool wide, bool x64)
|
||||||
{
|
{
|
||||||
m_sink->write_int(data->text);
|
assert(sizeof(int) == 4 && sizeof(ctlcolors64) > sizeof(ctlcolors32));
|
||||||
m_sink->write_int(data->bkc);
|
ctlcolors *p = (ctlcolors*) data;
|
||||||
m_sink->write_int(data->lbStyle);
|
m_sink->write_int(p->text);
|
||||||
m_sink->write_int((INT_PTR) data->bkb);
|
m_sink->write_int(p->bkc);
|
||||||
m_sink->write_int(data->bkmode);
|
if (x64)
|
||||||
m_sink->write_int(data->flags);
|
{
|
||||||
|
assert(!p->bkb);
|
||||||
|
m_sink->write_int64(p->bkb);
|
||||||
|
m_sink->write_int(p->lbStyle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sink->write_int(p->lbStyle);
|
||||||
|
m_sink->write_int(p->bkb);
|
||||||
|
}
|
||||||
|
m_sink->write_int(p->bkmode);
|
||||||
|
m_sink->write_int(p->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOGFONT_writer::write(const LOGFONT *data)
|
void LOGFONT_writer::write(const LOGFONT *data)
|
||||||
|
|
|
@ -40,13 +40,26 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DECLARE_PLATFORMITEMWRITER(x) class x##_writer : public writer \
|
||||||
|
{ public: \
|
||||||
|
x##_writer(writer_sink *sink) : writer(sink) {} \
|
||||||
|
void writeplatformitem(const void *data, bool wide, bool x64); \
|
||||||
|
static void write_block(IGrowBuf *pGB, writer_sink *pS, bool wide, bool x64) \
|
||||||
|
{ \
|
||||||
|
x##_writer writer(pS); \
|
||||||
|
for (size_t l = pGB->getlen() / sizeof(x), i = 0; i < l; i++) \
|
||||||
|
writer.writeplatformitem(&(((x*)pGB->get())[i]), wide, x64); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DECLARE_WRITER(firstheader);
|
DECLARE_WRITER(firstheader);
|
||||||
DECLARE_WRITER(block_header);
|
DECLARE_WRITER(block_header);
|
||||||
DECLARE_WRITER(header);
|
DECLARE_WRITER(header);
|
||||||
DECLARE_WRITER(section);
|
DECLARE_WRITER(section);
|
||||||
DECLARE_WRITER(entry);
|
DECLARE_WRITER(entry);
|
||||||
DECLARE_WRITER(page);
|
DECLARE_WRITER(page);
|
||||||
DECLARE_WRITER(ctlcolors);
|
DECLARE_PLATFORMITEMWRITER(ctlcolors);
|
||||||
DECLARE_WRITER(LOGFONT);
|
DECLARE_WRITER(LOGFONT);
|
||||||
|
|
||||||
class lang_table_writer : public writer
|
class lang_table_writer : public writer
|
||||||
|
|
|
@ -213,7 +213,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
||||||
FIX_ENDIAN_INT32(sorted_icons1[i].meta.dwRawSize),
|
FIX_ENDIAN_INT32(sorted_icons1[i].meta.dwRawSize),
|
||||||
FIX_ENDIAN_INT32(sorted_icons2[i].meta.dwRawSize)
|
FIX_ENDIAN_INT32(sorted_icons2[i].meta.dwRawSize)
|
||||||
);
|
);
|
||||||
pair.size_index = i;
|
pair.size_index = BUGBUG64TRUNCATE(unsigned int,i);
|
||||||
|
|
||||||
result.push_back(pair);
|
result.push_back(pair);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
||||||
pair.index1 = sorted_icons1[i].index;
|
pair.index1 = sorted_icons1[i].index;
|
||||||
pair.index2 = 0xffff;
|
pair.index2 = 0xffff;
|
||||||
pair.size = FIX_ENDIAN_INT32(sorted_icons1[i].meta.dwRawSize);
|
pair.size = FIX_ENDIAN_INT32(sorted_icons1[i].meta.dwRawSize);
|
||||||
pair.size_index = i;
|
pair.size_index = BUGBUG64TRUNCATE(unsigned int,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < sorted_icons2.size())
|
if (i < sorted_icons2.size())
|
||||||
|
@ -235,7 +235,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
||||||
pair.index2 = sorted_icons2[i].index;
|
pair.index2 = sorted_icons2[i].index;
|
||||||
pair.index1 = 0xffff;
|
pair.index1 = 0xffff;
|
||||||
pair.size = FIX_ENDIAN_INT32(sorted_icons2[i].meta.dwRawSize);
|
pair.size = FIX_ENDIAN_INT32(sorted_icons2[i].meta.dwRawSize);
|
||||||
pair.size_index = i;
|
pair.size_index = BUGBUG64TRUNCATE(unsigned int,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push_back(pair);
|
result.push_back(pair);
|
||||||
|
@ -256,7 +256,7 @@ static LPBYTE generate_icon_group(IconGroup icon, IconPairs order, bool first)
|
||||||
|
|
||||||
header->wReserved = 0;
|
header->wReserved = 0;
|
||||||
header->wIsIcon = FIX_ENDIAN_INT16(1);
|
header->wIsIcon = FIX_ENDIAN_INT16(1);
|
||||||
header->wCount = FIX_ENDIAN_INT16(icon.size());
|
header->wCount = FIX_ENDIAN_INT16((WORD)icon.size());
|
||||||
|
|
||||||
order = sort_pairs(order, first);
|
order = sort_pairs(order, first);
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void set_icon(CResourceEditor* re, WORD wIconId, IconGroup icon1, IconGroup icon
|
||||||
size_t group_size = sizeof(IconGroupHeader) // header
|
size_t group_size = sizeof(IconGroupHeader) // header
|
||||||
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
+ order.size() * SIZEOF_RSRC_ICON_GROUP_ENTRY; // entries
|
||||||
|
|
||||||
re->UpdateResource(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG, group1, group_size);
|
re->UpdateResource(RT_GROUP_ICON, wIconId, NSIS_DEFAULT_LANG, group1, (DWORD)group_size);
|
||||||
destroy_icon_group(group1);
|
destroy_icon_group(group1);
|
||||||
|
|
||||||
// delete old icons
|
// delete old icons
|
||||||
|
@ -343,7 +343,7 @@ unsigned char* generate_uninstall_icon_data(IconGroup icon1, IconGroup icon2, si
|
||||||
LPBYTE seeker = uninst_data;
|
LPBYTE seeker = uninst_data;
|
||||||
|
|
||||||
// fill group header
|
// fill group header
|
||||||
*(LPDWORD) seeker = FIX_ENDIAN_INT32(group_size);
|
*(LPDWORD) seeker = FIX_ENDIAN_INT32((UINT32)group_size);
|
||||||
seeker += sizeof(DWORD);
|
seeker += sizeof(DWORD);
|
||||||
*(LPDWORD) seeker = 0;
|
*(LPDWORD) seeker = 0;
|
||||||
seeker += sizeof(DWORD);
|
seeker += sizeof(DWORD);
|
||||||
|
@ -382,7 +382,7 @@ int generate_unicons_offsets(LPBYTE exeHeader, size_t exeHeaderSize, LPBYTE unin
|
||||||
DWORD offset;
|
DWORD offset;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
|
|
||||||
CResourceEditor re(exeHeader, exeHeaderSize, false);
|
CResourceEditor re(exeHeader, (DWORD)exeHeaderSize, false);
|
||||||
|
|
||||||
LPBYTE seeker = uninstIconData;
|
LPBYTE seeker = uninstIconData;
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ int StringsArray::set(int idx, const TCHAR *str)
|
||||||
int old = ((int*) m_offsets.get())[idx];
|
int old = ((int*) m_offsets.get())[idx];
|
||||||
|
|
||||||
// Need to store the TCHAR index so we divide the return value of add by sizeof(TCHAR).
|
// Need to store the TCHAR index so we divide the return value of add by sizeof(TCHAR).
|
||||||
((int*)m_offsets.get())[idx] = m_strings.add(str, (_tcslen(str)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
((int*)m_offsets.get())[idx] = m_strings.add(str, (DWORD)(_tcslen(str)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
@ -1014,7 +1014,7 @@ l_readerr:
|
||||||
// set ^Language
|
// set ^Language
|
||||||
nlf->m_szStrings[NLF_LANGUAGE] = _tcsdup(nlf->m_szName);
|
nlf->m_szStrings[NLF_LANGUAGE] = _tcsdup(nlf->m_szName);
|
||||||
|
|
||||||
int temp;
|
size_t temp;
|
||||||
|
|
||||||
// Get font
|
// Get font
|
||||||
if (!GetNextNLFLine(lr, buf, NSIS_MAX_STRLEN, errlr)) goto l_readerr;
|
if (!GetNextNLFLine(lr, buf, NSIS_MAX_STRLEN, errlr)) goto l_readerr;
|
||||||
|
|
|
@ -343,7 +343,7 @@ int CEXEBuild::doParse(const TCHAR *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new line to line buffer
|
// add new line to line buffer
|
||||||
const size_t cchstr = _tcslen(str);
|
const unsigned int cchstr = (unsigned int) _tcslen(str);
|
||||||
m_linebuild.add(str,(cchstr+1)*sizeof(TCHAR));
|
m_linebuild.add(str,(cchstr+1)*sizeof(TCHAR));
|
||||||
|
|
||||||
// keep waiting for more lines if this line ends with a backslash
|
// keep waiting for more lines if this line ends with a backslash
|
||||||
|
@ -651,7 +651,7 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
|
||||||
|
|
||||||
if (t-in > 1) // handle multibyte chars (no escape)
|
if (t-in > 1) // handle multibyte chars (no escape)
|
||||||
{
|
{
|
||||||
linedata.add((void*)in,(t-in)*sizeof(TCHAR));
|
linedata.add((void*)in,BUGBUG64TRUNCATE(int,(t-in)*sizeof(TCHAR)));
|
||||||
in=t;
|
in=t;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1134,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
ERROR_MSG(_T("!macro: macro named \"%") NPRIs _T("\" already found!\n"),macroname);
|
ERROR_MSG(_T("!macro: macro named \"%") NPRIs _T("\" already found!\n"),macroname);
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
m_macros.add(macroname,(_tcslen(macroname)+1)*sizeof(TCHAR));
|
m_macros.add(macroname,(int)(_tcslen(macroname)+1)*sizeof(TCHAR));
|
||||||
|
|
||||||
int pc;
|
int pc;
|
||||||
for (pc=2; pc < line.getnumtokens(); pc ++)
|
for (pc=2; pc < line.getnumtokens(); pc ++)
|
||||||
|
@ -1154,7 +1154,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_macros.add(line.gettoken_str(pc),(_tcslen(line.gettoken_str(pc))+1)*sizeof(TCHAR));
|
m_macros.add(line.gettoken_str(pc),(int)(_tcslen(line.gettoken_str(pc))+1)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
m_macros.add(_T(""),sizeof(_T("")));
|
m_macros.add(_T(""),sizeof(_T("")));
|
||||||
|
|
||||||
|
@ -1198,7 +1198,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (str[0]) m_macros.add(str,(_tcslen(str)+1)*sizeof(TCHAR));
|
if (str[0]) m_macros.add(str,(int)(_tcslen(str)+1)*sizeof(TCHAR));
|
||||||
else m_macros.add(_T(" "),sizeof(_T(" ")));
|
else m_macros.add(_T(" "),sizeof(_T(" ")));
|
||||||
linecnt++;
|
linecnt++;
|
||||||
}
|
}
|
||||||
|
@ -1220,9 +1220,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
}
|
}
|
||||||
TCHAR *mbufb=(TCHAR*)m_macros.get();
|
TCHAR *mbufb=(TCHAR*)m_macros.get();
|
||||||
const unsigned int mcb=(mend-mbeg)*sizeof(TCHAR), mbufcb=m_macros.getlen();
|
const unsigned int mcb=BUGBUG64TRUNCATE(unsigned int, (mend-mbeg)*sizeof(TCHAR)), mbufcb=m_macros.getlen();
|
||||||
memmove(mbeg,mend+sizeof(TCHAR),mbufcb-(mcb+(mbeg-mbufb)));
|
memmove(mbeg,mend+sizeof(TCHAR),mbufcb-(mcb+(mbeg-mbufb)));
|
||||||
m_macros.resize(mbufcb-(mcb+sizeof(TCHAR)));
|
m_macros.resize((int)(mbufcb-(mcb+sizeof(TCHAR))));
|
||||||
SCRIPT_MSG(_T("!macroundef: %") NPRIs _T("\n"),mname);
|
SCRIPT_MSG(_T("!macroundef: %") NPRIs _T("\n"),mname);
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
@ -1251,7 +1251,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
l_define_saves.add(t,v);
|
l_define_saves.add(t,v);
|
||||||
definedlist.del(t);
|
definedlist.del(t);
|
||||||
}
|
}
|
||||||
l_define_names.add(t,(_tcslen(t)+1)*sizeof(TCHAR));
|
l_define_names.add(t,(int)(_tcslen(t)+1)*sizeof(TCHAR));
|
||||||
definedlist.add(t,line.gettoken_str(npr+2));
|
definedlist.add(t,line.gettoken_str(npr+2));
|
||||||
|
|
||||||
npr++;
|
npr++;
|
||||||
|
@ -3132,9 +3132,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
} else if (!_tcscmp(mathop,_T("<<")) || !_tcscmp(mathop,_T("<<<")) ) {
|
} else if (!_tcscmp(mathop,_T("<<")) || !_tcscmp(mathop,_T("<<<")) ) {
|
||||||
_stprintf(value,_T("%d"),value1<<value2);
|
_stprintf(value,_T("%d"),value1<<value2);
|
||||||
} else if (!_tcscmp(mathop,_T(">>"))) {
|
} else if (!_tcscmp(mathop,_T(">>"))) {
|
||||||
_stprintf(value,_T("%d"),(signed)value1>>(signed)value2);
|
_stprintf(value,_T("%d"),(signed int)value1>>(signed int)value2);
|
||||||
} else if (!_tcscmp(mathop,_T(">>>"))) {
|
} else if (!_tcscmp(mathop,_T(">>>"))) {
|
||||||
_stprintf(value,_T("%d"),(unsigned)value1>>(unsigned)value2);
|
_stprintf(value,_T("%d"),(unsigned int)value1>>(unsigned int)value2);
|
||||||
} else if (!_tcscmp(mathop,_T("/"))) {
|
} else if (!_tcscmp(mathop,_T("/"))) {
|
||||||
if (value2==0) {
|
if (value2==0) {
|
||||||
ERROR_MSG(_T("!define /math: division by zero! (\"%i / %i\")\n"),value1,value2);
|
ERROR_MSG(_T("!define /math: division by zero! (\"%i / %i\")\n"),value1,value2);
|
||||||
|
@ -3155,7 +3155,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
value=line.gettoken_str(2);
|
value=line.gettoken_str(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dupemode==2)definedlist.del(define);
|
if (dupemode==2) definedlist.del(define);
|
||||||
if (definedlist.add(define,value))
|
if (definedlist.add(define,value))
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("!define: \"%") NPRIs _T("\" already defined!\n"),define);
|
ERROR_MSG(_T("!define: \"%") NPRIs _T("\" already defined!\n"),define);
|
||||||
|
@ -3453,7 +3453,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
delete tlist;
|
delete tlist;
|
||||||
// parse line
|
// parse line
|
||||||
}
|
}
|
||||||
if ((unsigned)-1 != fail_parm && !noErrors)
|
if ((UINT)-1 != fail_parm && !noErrors)
|
||||||
{
|
{
|
||||||
const TCHAR *msgprefix=!fail_parm ? _T("starting ") : _T("");
|
const TCHAR *msgprefix=!fail_parm ? _T("starting ") : _T("");
|
||||||
TCHAR *p=line.gettoken_str(parmOffs + (fail_parm*2));
|
TCHAR *p=line.gettoken_str(parmOffs + (fail_parm*2));
|
||||||
|
@ -3493,8 +3493,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
TCHAR *src = line.gettoken_str(2+ignoreCase);
|
TCHAR *src = line.gettoken_str(2+ignoreCase);
|
||||||
TCHAR *search = line.gettoken_str(3+ignoreCase);
|
TCHAR *search = line.gettoken_str(3+ignoreCase);
|
||||||
TCHAR *replace = line.gettoken_str(4+ignoreCase);
|
TCHAR *replace = line.gettoken_str(4+ignoreCase);
|
||||||
int searchlen=_tcslen(search);
|
int searchlen=(int)_tcslen(search), replacelen=(int)_tcslen(replace);
|
||||||
int replacelen=_tcslen(replace);
|
|
||||||
if (!searchlen)
|
if (!searchlen)
|
||||||
{
|
{
|
||||||
ERROR_MSG(_T("!searchreplace: search string must not be empty for search/replace!\n"));
|
ERROR_MSG(_T("!searchreplace: search string must not be empty for search/replace!\n"));
|
||||||
|
@ -4332,8 +4331,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
TCHAR *np=p;
|
TCHAR *np=p;
|
||||||
while (*np && *np != _T('|')) np++;
|
while (*np && *np != _T('|')) np++;
|
||||||
if (*np) *np++=0;
|
if (*np) *np++=0;
|
||||||
for (x = 0 ; (unsigned) x < COUNTOF(list) && _tcsicmp(list[x].str, p); x++);
|
for (x = 0 ; (size_t) x < COUNTOF(list) && _tcsicmp(list[x].str, p); x++);
|
||||||
if ((unsigned) x < COUNTOF(list))
|
if ((size_t) x < COUNTOF(list))
|
||||||
{
|
{
|
||||||
r|=list[x].id;
|
r|=list[x].id;
|
||||||
}
|
}
|
||||||
|
@ -6735,7 +6734,7 @@ int CEXEBuild::add_file(const tstring& dir, const tstring& file, int attrib, con
|
||||||
ent.offsets[4]=0;
|
ent.offsets[4]=0;
|
||||||
ent.offsets[5]=0;
|
ent.offsets[5]=0;
|
||||||
|
|
||||||
if (INVALID_FILE_ATTRIBUTES != (unsigned)ent.offsets[1])
|
if (INVALID_FILE_ATTRIBUTES != (DWORD)ent.offsets[1])
|
||||||
{
|
{
|
||||||
a=add_entry(&ent);
|
a=add_entry(&ent);
|
||||||
if (a != PS_OK)
|
if (a != PS_OK)
|
||||||
|
@ -6800,7 +6799,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&
|
||||||
tok = 0, maxlen = -1; // No more tokens to search for, save the rest of the string
|
tok = 0, maxlen = -1; // No more tokens to search for, save the rest of the string
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toklen = _tcslen(tok);
|
toklen = (int) _tcslen(tok);
|
||||||
while (*source_string && (ignCase?_tcsnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++;
|
while (*source_string && (ignCase?_tcsnicmp(source_string,tok,toklen):_tcsncmp(source_string,tok,toklen))) source_string++;
|
||||||
maxlen = source_string - src_start; // Length of previous string
|
maxlen = source_string - src_start; // Length of previous string
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ unsigned int ExeHeadStringList::getnum() const
|
||||||
{
|
{
|
||||||
char *p = (char*) m_gr.get();
|
char *p = (char*) m_gr.get();
|
||||||
if (!p) return 1; // The empty string always exists
|
if (!p) return 1; // The empty string always exists
|
||||||
unsigned int cbList = gettotalsize(), cb = 0, num = 1, pos;
|
unsigned int num = 1;
|
||||||
|
size_t cbList = gettotalsize(), cb = 0, pos;
|
||||||
pos = 1 + !!m_wide, p += pos; // Skip empty string
|
pos = 1 + !!m_wide, p += pos; // Skip empty string
|
||||||
if (m_wide)
|
if (m_wide)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +94,7 @@ unsigned int ExeHeadStringList::find(const TCHAR *str, WORD codepage, bool proce
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return find(str,_tcslen(str),codepage,processed,ppBufMB);
|
return find(str,(unsigned int)_tcslen(str),codepage,processed,ppBufMB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD codepage, bool processed, char**ppBufMB) const
|
unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD codepage, bool processed, char**ppBufMB) const
|
||||||
|
@ -140,7 +141,7 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if (pos+=cb >= cbList) break;
|
if (pos+=cb >= cbList) break;
|
||||||
cb = strlen(p+=cb) + 1;
|
cb = (unsigned int) strlen(p+=cb) + 1;
|
||||||
if (cb < cbF) continue;
|
if (cb < cbF) continue;
|
||||||
if (byte_rev_match(p,find,cbF)) { retval = pos; break; }
|
if (byte_rev_match(p,find,cbF)) { retval = pos; break; }
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,7 @@ int ExeHeadStringList::add(const TCHAR *str, WORD codepage, bool processed)
|
||||||
|
|
||||||
char *bufMB = 0;
|
char *bufMB = 0;
|
||||||
unsigned int pos = find(str,codepage,processed,m_wide ? 0 : &bufMB);
|
unsigned int pos = find(str,codepage,processed,m_wide ? 0 : &bufMB);
|
||||||
if ((unsigned)-1 != pos)
|
if ((unsigned int)-1 != pos)
|
||||||
{
|
{
|
||||||
delete[] bufMB;
|
delete[] bufMB;
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -180,7 +181,7 @@ int ExeHeadStringList::add(const TCHAR *str, WORD codepage, bool processed)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int cbMB = strlen(bufMB) + 1;
|
unsigned int cbMB = (unsigned int) strlen(bufMB) + 1;
|
||||||
pos = m_gr.add(bufMB,cbMB);
|
pos = m_gr.add(bufMB,cbMB);
|
||||||
delete[] bufMB;
|
delete[] bufMB;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ int StringList::add(const TCHAR *str, int case_sensitive)
|
||||||
{
|
{
|
||||||
int a=find(str,case_sensitive);
|
int a=find(str,case_sensitive);
|
||||||
if (a >= 0 && case_sensitive!=-1) return a;
|
if (a >= 0 && case_sensitive!=-1) return a;
|
||||||
return m_gr.add(str,(_tcslen(str)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
return m_gr.add(str,BUGBUG64TRUNCATE(int, (_tcslen(str)+1)*sizeof(TCHAR)))/sizeof(TCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use 2 for case sensitive end-of-string matches too
|
// use 2 for case sensitive end-of-string matches too
|
||||||
|
@ -222,9 +223,9 @@ int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) co
|
||||||
str_slen < offs_slen && // check for end of string
|
str_slen < offs_slen && // check for end of string
|
||||||
!_tcscmp(s + offs + offs_slen - str_slen,str))
|
!_tcscmp(s + offs + offs_slen - str_slen,str))
|
||||||
{
|
{
|
||||||
return offs + offs_slen - str_slen;
|
return BUGBUG64TRUNCATE(int, offs + offs_slen - str_slen);
|
||||||
}
|
}
|
||||||
offs += offs_slen + 1;
|
offs += BUGBUG64TRUNCATE(int, offs_slen + 1);
|
||||||
|
|
||||||
if (idx) (*idx)++;
|
if (idx) (*idx)++;
|
||||||
}
|
}
|
||||||
|
@ -235,12 +236,12 @@ int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) co
|
||||||
void StringList::delbypos(int pos)
|
void StringList::delbypos(int pos)
|
||||||
{
|
{
|
||||||
TCHAR *s=(TCHAR*) m_gr.get();
|
TCHAR *s=(TCHAR*) m_gr.get();
|
||||||
int len=_tcslen(s+pos)+1;
|
int len=(int)_tcslen(s+pos)+1;
|
||||||
|
|
||||||
if (pos+len < getcount())
|
if (pos+len < getcount())
|
||||||
{
|
{
|
||||||
// Move everything after the string position to the current position.
|
// Move everything after the string position to the current position.
|
||||||
memcpy(s+pos,s+pos+len, (getcount()-pos+len)*sizeof(TCHAR));
|
memcpy(s+pos,s+pos+len, (getcount()-pos+len)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
m_gr.resize(m_gr.getlen()-len*sizeof(TCHAR));
|
m_gr.resize(m_gr.getlen()-len*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
|
@ -254,7 +255,7 @@ int StringList::idx2pos(int idx) const
|
||||||
if (idx>=0) while (offs < getcount())
|
if (idx>=0) while (offs < getcount())
|
||||||
{
|
{
|
||||||
if (cnt++ == idx) return offs;
|
if (cnt++ == idx) return offs;
|
||||||
offs+=_tcslen(s+offs)+1;
|
offs+=(int)_tcslen(s+offs)+1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +268,7 @@ int StringList::getnum() const
|
||||||
int idx=0;
|
int idx=0;
|
||||||
while (offs < ml)
|
while (offs < ml)
|
||||||
{
|
{
|
||||||
offs+=_tcslen(s+offs)+1;
|
offs+=(int)_tcslen(s+offs)+1;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
|
|
|
@ -164,10 +164,10 @@ template <class T>
|
||||||
class SortedStringList
|
class SortedStringList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Jim Park: Note that SortedStringList actually <b>owns</b> T.name.
|
* Jim Park: Note that SortedStringList actually <b>owns</b> T.name.
|
||||||
* Yes, this violates all kinds of encapsulation ideas.
|
* Yes, this violates all kinds of encapsulation ideas.
|
||||||
*/
|
*/
|
||||||
virtual ~SortedStringList()
|
virtual ~SortedStringList()
|
||||||
{
|
{
|
||||||
T *s=(T*) m_gr.get();
|
T *s=(T*) m_gr.get();
|
||||||
|
@ -178,22 +178,22 @@ class SortedStringList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function adds a new T struct with a copy of TCHAR *name into
|
* This function adds a new T struct with a copy of TCHAR *name into
|
||||||
* T.name. But adds it into a sorted position. All calls to
|
* T.name. But adds it into a sorted position. All calls to
|
||||||
* add must be done with the same value for case_sensitive or you
|
* add must be done with the same value for case_sensitive or you
|
||||||
* can get random behavior.
|
* can get random behavior.
|
||||||
*
|
*
|
||||||
* @param name The name which is the "key" to finding the instance of T.
|
* @param name The name which is the "key" to finding the instance of T.
|
||||||
* @param case_sensitive 1 means case sensitive, 0 insensitive.
|
* @param case_sensitive 1 means case sensitive, 0 insensitive.
|
||||||
* @return Returns -1 when name already exists and pos if added.
|
* @return Returns -1 when name already exists and pos if added.
|
||||||
*/
|
*/
|
||||||
int add(const TCHAR *name, int case_sensitive=0)
|
int add(const TCHAR *name, int case_sensitive=0)
|
||||||
{
|
{
|
||||||
T newstruct={0,};
|
T newstruct={0,};
|
||||||
int pos=find(name,case_sensitive,1);
|
int pos=find(name,case_sensitive,1);
|
||||||
if (pos==-1) return -1;
|
if (pos==-1) return -1;
|
||||||
const UINT cbName=(_tcslen(name)+1)*sizeof(TCHAR);
|
const unsigned long cbName=(unsigned long) (_tcslen(name)+1)*sizeof(TCHAR);
|
||||||
newstruct.name=(TCHAR*)malloc(cbName);
|
newstruct.name=(TCHAR*)malloc(cbName);
|
||||||
if (!newstruct.name)
|
if (!newstruct.name)
|
||||||
{
|
{
|
||||||
|
@ -215,22 +215,22 @@ class SortedStringList
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function does a binary search for the T in the buffer that
|
* This function does a binary search for the T in the buffer that
|
||||||
* contains str as its T.name. It then returns the position of the found
|
* contains str as its T.name. It then returns the position of the found
|
||||||
* T, not in its byte position, but its T position (valid offset to T*).
|
* T, not in its byte position, but its T position (valid offset to T*).
|
||||||
*
|
*
|
||||||
* @param str The string to search for in T.name.
|
* @param str The string to search for in T.name.
|
||||||
*
|
*
|
||||||
* @param case_sensitive If 1, do a case sensitive search, otherwise, case insensitive.
|
* @param case_sensitive If 1, do a case sensitive search, otherwise, case insensitive.
|
||||||
*
|
*
|
||||||
* @param returnbestpos If 1, then the function changes behavior. Instead
|
* @param returnbestpos If 1, then the function changes behavior. Instead
|
||||||
* of looking for the string str in the Ts, it tries to find the best
|
* of looking for the string str in the Ts, it tries to find the best
|
||||||
* sorted position to insert str into the buffer.
|
* sorted position to insert str into the buffer.
|
||||||
*
|
*
|
||||||
* @return Returns -1 if not found, position if found. If returnbestpos=1
|
* @return Returns -1 if not found, position if found. If returnbestpos=1
|
||||||
* returns -1 if found, best pos to insert if not found
|
* returns -1 if found, best pos to insert if not found
|
||||||
*/
|
*/
|
||||||
int find(const TCHAR *str, int case_sensitive=0, int returnbestpos=0)
|
int find(const TCHAR *str, int case_sensitive=0, int returnbestpos=0)
|
||||||
{
|
{
|
||||||
T *data=(T *) m_gr.get();
|
T *data=(T *) m_gr.get();
|
||||||
|
@ -254,12 +254,12 @@ class SortedStringList
|
||||||
return returnbestpos ? nextpos : -1;
|
return returnbestpos ? nextpos : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function looks for str in T.name and deletes the T in the
|
* This function looks for str in T.name and deletes the T in the
|
||||||
* buffer.
|
* buffer.
|
||||||
*
|
*
|
||||||
* @return Returns 0 on success, 1 on failure.
|
* @return Returns 0 on success, 1 on failure.
|
||||||
*/
|
*/
|
||||||
int del(const TCHAR *str, int case_sensitive=0)
|
int del(const TCHAR *str, int case_sensitive=0)
|
||||||
{
|
{
|
||||||
int pos=find(str, case_sensitive);
|
int pos=find(str, case_sensitive);
|
||||||
|
@ -332,7 +332,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
if (pos==-1) return alwaysreturnpos ? where : -1;
|
if (pos==-1) return alwaysreturnpos ? where : -1;
|
||||||
|
|
||||||
// Note that .name is set with the TCHAR* offset into m_strings.
|
// Note that .name is set with the TCHAR* offset into m_strings.
|
||||||
newstruct.name=m_strings.add(name,(_tcslen(name)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
newstruct.name=m_strings.add(name,((unsigned int)_tcslen(name)+1)*sizeof(TCHAR))/sizeof(TCHAR);
|
||||||
|
|
||||||
m_gr.add(&newstruct,sizeof(T));
|
m_gr.add(&newstruct,sizeof(T));
|
||||||
T *s=(T*) m_gr.get();
|
T *s=(T*) m_gr.get();
|
||||||
|
@ -403,7 +403,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int pCurr_len = _tcslen(pCurr);
|
unsigned int pCurr_len = (unsigned int) _tcslen(pCurr);
|
||||||
if (case_sensitive)
|
if (case_sensitive)
|
||||||
res = _tcsncmp(str, pCurr, STD_MIN((unsigned int) n_chars, pCurr_len));
|
res = _tcsncmp(str, pCurr, STD_MIN((unsigned int) n_chars, pCurr_len));
|
||||||
else
|
else
|
||||||
|
@ -444,8 +444,8 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
||||||
* Structure stored by DefineList.
|
* Structure stored by DefineList.
|
||||||
*/
|
*/
|
||||||
struct define {
|
struct define {
|
||||||
TCHAR *name; // key
|
TCHAR *name; // key
|
||||||
TCHAR *value; // value stored
|
TCHAR *value; // value stored
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -459,11 +459,11 @@ class DefineList : public SortedStringList<struct define>
|
||||||
void operator=(const DefineList&);
|
void operator=(const DefineList&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Empty default constructor */
|
/* Empty default constructor */
|
||||||
DefineList() {} // VC6 complains otherwise
|
DefineList() {} // VC6 complains otherwise
|
||||||
virtual ~DefineList();
|
virtual ~DefineList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a name-value pair, case insensitively.
|
* Add a name-value pair, case insensitively.
|
||||||
*
|
*
|
||||||
* @param name The name of the variable or key to search by. In a
|
* @param name The name of the variable or key to search by. In a
|
||||||
|
@ -473,8 +473,8 @@ class DefineList : public SortedStringList<struct define>
|
||||||
* of the pair.
|
* of the pair.
|
||||||
*
|
*
|
||||||
* @return Returns 0 if successful, 1 if already exists. Errors cause
|
* @return Returns 0 if successful, 1 if already exists. Errors cause
|
||||||
* general program exit with error logging.
|
* general program exit with error logging.
|
||||||
*/
|
*/
|
||||||
int add(const TCHAR *name, const TCHAR *value=_T(""));
|
int add(const TCHAR *name, const TCHAR *value=_T(""));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef wchar_t TCHAR, _TUCHAR;
|
||||||
// printfs
|
// printfs
|
||||||
#define _ftprintf fwprintf
|
#define _ftprintf fwprintf
|
||||||
#define _sntprintf _snwprintf
|
#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
|
# define _stprintf swprintf
|
||||||
#else
|
#else
|
||||||
# define _stprintf _swprintf
|
# define _stprintf _swprintf
|
||||||
|
@ -243,5 +243,9 @@ typedef unsigned char _TUCHAR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// is functions (the same in Unicode / ANSI)
|
// is functions (the same in Unicode / ANSI)
|
||||||
|
#ifndef _istgraph
|
||||||
#define _istgraph isgraph
|
#define _istgraph isgraph
|
||||||
|
#endif
|
||||||
|
#ifndef _istascii
|
||||||
#define _istascii __isascii
|
#define _istascii __isascii
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
UINT StrLenUTF16(const void*str)
|
UINT StrLenUTF16(const void*str)
|
||||||
{
|
{
|
||||||
return sizeof(wchar_t) == 2 ? wcslen((wchar_t*)str) : InlineStrLenUTF16(str);
|
return sizeof(wchar_t) == 2 ? (UINT)wcslen((wchar_t*)str) : InlineStrLenUTF16(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StrSetUTF16LE(tstring&dest, const void*src)
|
bool StrSetUTF16LE(tstring&dest, const void*src)
|
||||||
|
@ -204,10 +204,10 @@ void* CharEncConv::Convert(const void*Src, size_t cbSrc, size_t*cbOut)
|
||||||
{
|
{
|
||||||
if (NStreamEncoding::UTF16BE == m_TE) goto l_swapUTF16;
|
if (NStreamEncoding::UTF16BE == m_TE) goto l_swapUTF16;
|
||||||
cbSrc /= sizeof(wchar_t);
|
cbSrc /= sizeof(wchar_t);
|
||||||
UINT cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, cbSrc, 0, 0, 0, 0);
|
UINT cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, (int)cbSrc, 0, 0, 0, 0);
|
||||||
char *p = (char*) realloc(m_Result, (cbDest + 1) * sizeof(char));
|
char *p = (char*) realloc(m_Result, (cbDest + 1) * sizeof(char));
|
||||||
if (p) m_Result = p; else return 0;
|
if (p) m_Result = p; else return 0;
|
||||||
if (!(cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, cbSrc, p, cbDest, 0, 0))) return 0;
|
if (!(cbDest = WideCharToMultiByte(m_TE, 0, (wchar_t*)Src, (int)cbSrc, p, (int)cbDest, 0, 0))) return 0;
|
||||||
if (p[--cbDest]) p[++cbDest] = '\0'; // Always \0 terminate
|
if (p[--cbDest]) p[++cbDest] = '\0'; // Always \0 terminate
|
||||||
if (cbOut) *cbOut = cbDest; // cbOut never includes the \0 terminator
|
if (cbOut) *cbOut = cbDest; // cbOut never includes the \0 terminator
|
||||||
}
|
}
|
||||||
|
@ -220,16 +220,16 @@ l_swapUTF16:
|
||||||
char *p = (char*) realloc(m_Result, cbSrc + sizeof(wchar_t));
|
char *p = (char*) realloc(m_Result, cbSrc + sizeof(wchar_t));
|
||||||
if (p) m_Result = p; else return 0;
|
if (p) m_Result = p; else return 0;
|
||||||
memcpy(p, Src, cbSrc);
|
memcpy(p, Src, cbSrc);
|
||||||
cchDest = cbSrc / sizeof(wchar_t);
|
cchDest = (UINT) (cbSrc / sizeof(wchar_t));
|
||||||
UTF16InplaceEndianSwap(p, cchDest);
|
UTF16InplaceEndianSwap(p, cchDest);
|
||||||
if (!cchDest) *((WORD*)p) = 0, ++cchDest; // For "--cchDest" during \0 termination
|
if (!cchDest) *((WORD*)p) = 0, ++cchDest; // For "--cchDest" during \0 termination
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cchDest = MultiByteToWideChar(m_FE, 0, (char*)Src, cbSrc, 0, 0);
|
cchDest = MultiByteToWideChar(m_FE, 0, (char*)Src, (int)cbSrc, 0, 0);
|
||||||
char *p = (char*) realloc(m_Result, (cchDest + 1) * sizeof(wchar_t));
|
char *p = (char*) realloc(m_Result, (cchDest + 1) * sizeof(wchar_t));
|
||||||
if (p) m_Result = p; else return 0;
|
if (p) m_Result = p; else return 0;
|
||||||
if (!(cchDest = MultiByteToWideChar(m_FE, 0, (char*)Src, cbSrc, (LPWSTR)p, cchDest))) return 0;
|
if (!(cchDest = MultiByteToWideChar(m_FE, 0, (char*)Src, (int)cbSrc, (LPWSTR)p, (int)cchDest))) return 0;
|
||||||
if (NStreamEncoding::UTF16BE == m_TE) UTF16InplaceEndianSwap(p, cchDest);
|
if (NStreamEncoding::UTF16BE == m_TE) UTF16InplaceEndianSwap(p, cchDest);
|
||||||
}
|
}
|
||||||
if (((WORD*)m_Result)[--cchDest]) ((WORD*)m_Result)[++cchDest] = '\0';
|
if (((WORD*)m_Result)[--cchDest]) ((WORD*)m_Result)[++cchDest] = '\0';
|
||||||
|
|
|
@ -787,7 +787,7 @@ size_t ExpandoStrFmtVaList(wchar_t*Stack, size_t cchStack, wchar_t**ppMalloc, co
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
cch = ExpandoStrFmtVaList_vsnwprintf(dest, cchAvail, FmtStr, Args);
|
cch = ExpandoStrFmtVaList_vsnwprintf(dest, cchAvail, FmtStr, Args);
|
||||||
if ((unsigned)-1 == cch)
|
if ((size_t)-1 == cch)
|
||||||
{
|
{
|
||||||
cch = 0;
|
cch = 0;
|
||||||
if (cansizecalc) break; // vswprintf error, abort!
|
if (cansizecalc) break; // vswprintf error, abort!
|
||||||
|
@ -818,7 +818,7 @@ int RunChildProcessRedirected(LPCWSTR cmdprefix, LPCWSTR cmdmain)
|
||||||
UINT cp = CP_UTF8, mbtwcf = MB_ERR_INVALID_CHARS;
|
UINT cp = CP_UTF8, mbtwcf = MB_ERR_INVALID_CHARS;
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
if (!cmdprefix) cmdprefix = _T("");
|
if (!cmdprefix) cmdprefix = _T("");
|
||||||
UINT cch1 = _tcslen(cmdprefix), cch2 = _tcslen(cmdmain);
|
size_t cch1 = _tcslen(cmdprefix), cch2 = _tcslen(cmdmain);
|
||||||
WCHAR *cmd = (WCHAR*) malloc( (cch1 + cch2 + 1) * sizeof(WCHAR) );
|
WCHAR *cmd = (WCHAR*) malloc( (cch1 + cch2 + 1) * sizeof(WCHAR) );
|
||||||
if (!cmd) return -1;
|
if (!cmd) return -1;
|
||||||
_tcscpy(cmd, cmdprefix);
|
_tcscpy(cmd, cmdprefix);
|
||||||
|
@ -995,7 +995,7 @@ bool WINAPI WinStdIO_OStreamInit(WINSIO_OSDATA&osd, FILE*strm, WORD cp, int bom)
|
||||||
}
|
}
|
||||||
bool WINAPI WinStdIO_OStreamWrite(WINSIO_OSDATA&osd, const wchar_t *Str, UINT cch)
|
bool WINAPI WinStdIO_OStreamWrite(WINSIO_OSDATA&osd, const wchar_t *Str, UINT cch)
|
||||||
{
|
{
|
||||||
if ((unsigned)-1 == cch) cch = _tcslen(Str);
|
if ((UINT)-1 == cch) cch = (UINT)_tcslen(Str);
|
||||||
DWORD cbio;
|
DWORD cbio;
|
||||||
if (WinStdIO_IsConsole(osd))
|
if (WinStdIO_IsConsole(osd))
|
||||||
return !!WriteConsoleW(osd.hNative, Str, cch, &cbio, 0) || !cch;
|
return !!WriteConsoleW(osd.hNative, Str, cch, &cbio, 0) || !cch;
|
||||||
|
@ -1024,7 +1024,9 @@ int WINAPI WinStdIO_vfwprintf(FILE*strm, const wchar_t*Fmt, va_list val)
|
||||||
extern WINSIO_OSDATA g_osdata_stdout;
|
extern WINSIO_OSDATA g_osdata_stdout;
|
||||||
ExpandoString<wchar_t, NSIS_MAX_STRLEN> buf;
|
ExpandoString<wchar_t, NSIS_MAX_STRLEN> buf;
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
UINT cch = buf.StrFmt(Fmt, val, false);
|
const size_t cchfmt = buf.StrFmt(Fmt, val, false);
|
||||||
|
UINT cch = (UINT) cchfmt;
|
||||||
|
assert(sizeof(size_t) <= 4 || cchfmt == cch);
|
||||||
if (cch && !WinStdIO_OStreamWrite(g_osdata_stdout, buf, cch))
|
if (cch && !WinStdIO_OStreamWrite(g_osdata_stdout, buf, cch))
|
||||||
{
|
{
|
||||||
cch = 0, errno = EIO;
|
cch = 0, errno = EIO;
|
||||||
|
@ -1139,7 +1141,7 @@ static bool GetDLLVersionUsingRE(const tstring& filepath, DWORD& high, DWORD & l
|
||||||
{
|
{
|
||||||
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
||||||
LPBYTE ver = dllre->GetResource(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
LPBYTE ver = dllre->GetResource(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
||||||
int versize = dllre->GetResourceSize(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
size_t versize = (size_t) dllre->GetResourceSize(VS_FILE_INFO, VS_VERSION_INFO, 0);
|
||||||
|
|
||||||
if (ver)
|
if (ver)
|
||||||
{
|
{
|
||||||
|
@ -1147,7 +1149,7 @@ static bool GetDLLVersionUsingRE(const tstring& filepath, DWORD& high, DWORD & l
|
||||||
{
|
{
|
||||||
// get VS_FIXEDFILEINFO from VS_VERSIONINFO
|
// get VS_FIXEDFILEINFO from VS_VERSIONINFO
|
||||||
WINWCHAR *szKey = (WINWCHAR *)(ver + sizeof(WORD) * 3);
|
WINWCHAR *szKey = (WINWCHAR *)(ver + sizeof(WORD) * 3);
|
||||||
int len = (WinWStrLen(szKey) + 1) * sizeof(WINWCHAR) + sizeof(WORD) * 3;
|
size_t len = (WinWStrLen(szKey) + 1) * sizeof(WINWCHAR) + sizeof(WORD) * 3;
|
||||||
len = (len + 3) & ~3; // align on DWORD boundry
|
len = (len + 3) & ~3; // align on DWORD boundry
|
||||||
VS_FIXEDFILEINFO *verinfo = (VS_FIXEDFILEINFO *)(ver + len);
|
VS_FIXEDFILEINFO *verinfo = (VS_FIXEDFILEINFO *)(ver + len);
|
||||||
if (versize > len && verinfo->dwSignature == VS_FFI_SIGNATURE)
|
if (versize > len && verinfo->dwSignature == VS_FFI_SIGNATURE)
|
||||||
|
|
|
@ -45,7 +45,7 @@ int WinWStrNICmpASCII(const WINWCHAR *a, const char *b, size_t n)
|
||||||
|
|
||||||
WINWCHAR* WinWStrDupFromChar(const char *s, unsigned int cp)
|
WINWCHAR* WinWStrDupFromChar(const char *s, unsigned int cp)
|
||||||
{
|
{
|
||||||
size_t cch = MultiByteToWideChar(cp, 0, s, -1, 0, 0);
|
int cch = MultiByteToWideChar(cp, 0, s, -1, 0, 0);
|
||||||
wchar_t *p = (wchar_t*) malloc(cch);
|
wchar_t *p = (wchar_t*) malloc(cch);
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,11 @@ void writer_sink::write_int(const int i)
|
||||||
int fi = FIX_ENDIAN_INT32(i);
|
int fi = FIX_ENDIAN_INT32(i);
|
||||||
write_data(&fi, sizeof(int));
|
write_data(&fi, sizeof(int));
|
||||||
}
|
}
|
||||||
|
void writer_sink::write_int64(const INT64 i)
|
||||||
|
{
|
||||||
|
INT64 fi = FIX_ENDIAN_INT64(i);
|
||||||
|
write_data(&fi, sizeof(INT64));
|
||||||
|
}
|
||||||
|
|
||||||
void writer_sink::write_int_array(const int i[], const size_t len)
|
void writer_sink::write_int_array(const int i[], const size_t len)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +78,7 @@ void writer_sink::write_string(const TCHAR *s, size_t size)
|
||||||
{
|
{
|
||||||
char *wb = new char[size];
|
char *wb = new char[size];
|
||||||
memset(wb, 0, size);
|
memset(wb, 0, size);
|
||||||
WideCharToMultiByte(CP_ACP, 0, s, -1, wb, size, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, s, -1, wb, (int)size, NULL, NULL);
|
||||||
write_data(wb, size);
|
write_data(wb, size);
|
||||||
delete [] wb;
|
delete [] wb;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +98,7 @@ void writer_sink::write_growbuf(const IGrowBuf *b)
|
||||||
|
|
||||||
void growbuf_writer_sink::write_data(const void *data, const size_t size)
|
void growbuf_writer_sink::write_data(const void *data, const size_t size)
|
||||||
{
|
{
|
||||||
m_buf->add(data, size);
|
m_buf->add(data, BUGBUG64TRUNCATE(int, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_writer_sink::write_data(const void *data, const size_t size)
|
void file_writer_sink::write_data(const void *data, const size_t size)
|
||||||
|
@ -109,6 +114,6 @@ void file_writer_sink::write_data(const void *data, const size_t size)
|
||||||
|
|
||||||
void crc_writer_sink::write_data(const void *data, const size_t size)
|
void crc_writer_sink::write_data(const void *data, const size_t size)
|
||||||
{
|
{
|
||||||
*m_crc = CRC32(*m_crc, (const unsigned char *) data, size);
|
*m_crc = CRC32(*m_crc, (const unsigned char *) data, BUGBUG64TRUNCATE(unsigned int, size));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
virtual void write_byte(const unsigned char b);
|
virtual void write_byte(const unsigned char b);
|
||||||
virtual void write_short(const short s);
|
virtual void write_short(const short s);
|
||||||
virtual void write_int(const int i);
|
virtual void write_int(const int i);
|
||||||
|
virtual void write_int64(const INT64 i);
|
||||||
virtual void write_int_array(const int i[], const size_t len);
|
virtual void write_int_array(const int i[], const size_t len);
|
||||||
virtual void write_string(const TCHAR *s, size_t size);
|
virtual void write_string(const TCHAR *s, size_t size);
|
||||||
virtual void write_growbuf(const IGrowBuf *b);
|
virtual void write_growbuf(const IGrowBuf *b);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue