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;
|
||||
}
|
||||
|
||||
void CALLBACK TimeProc(UINT uID,
|
||||
UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
|
||||
void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||
{
|
||||
int call = -1;
|
||||
switch (state) {
|
||||
|
@ -251,11 +250,15 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
|||
|
||||
// Set transparency / key color
|
||||
if (nt50) {
|
||||
#ifndef _WIN64
|
||||
// Get blending proc address
|
||||
HANDLE user32 = GetModuleHandle(_T("user32"));
|
||||
SetLayeredWindowAttributesProc =
|
||||
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
|
||||
"SetLayeredWindowAttributes");
|
||||
#else
|
||||
#define SetLayeredWindowAttributesProc SetLayeredWindowAttributes
|
||||
#endif
|
||||
// Use win2k method
|
||||
SetLayeredWindowAttributesProc(myWnd, keycolor,
|
||||
(BYTE) ((fadein_val > 0) ? (0) : (255)),
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef wchar_t TCHAR;
|
|||
// printfs
|
||||
#define _ftprintf fwprintf
|
||||
#define _sntprintf _snwprintf
|
||||
#if (defined(_MSC_VER) && (_MSC_VER<=1310)) || defined(__MINGW32__)
|
||||
#if (defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)) || defined(__MINGW32__)
|
||||
# define _stprintf swprintf
|
||||
#else
|
||||
# define _stprintf _swprintf
|
||||
|
|
|
@ -221,7 +221,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
|
|||
|
||||
bool INLINE ValidateFields() {
|
||||
int nIdx;
|
||||
int nLength;
|
||||
INT_PTR nLength;
|
||||
|
||||
// In the unlikely event we can't allocate memory, go ahead and return true so we can get out of here.
|
||||
// May cause problems for the install script, but no memory is problems for us.
|
||||
|
@ -290,7 +290,7 @@ bool WINAPI SaveSettings(void) {
|
|||
if (!pszItem) return false;
|
||||
|
||||
*pszBuffer = _T('\0');
|
||||
int nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
|
||||
INT_PTR nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
|
||||
for (int nIdx2 = 0; nIdx2 < nNumItems; nIdx2++) {
|
||||
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
|
||||
if (*pszBuffer) lstrcat(pszBuffer, _T("|"));
|
||||
|
@ -308,7 +308,7 @@ bool WINAPI SaveSettings(void) {
|
|||
case FIELD_DIRREQUEST:
|
||||
case FIELD_COMBOBOX:
|
||||
{
|
||||
int nLength = mySendMessage(pField->hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
int nLength = (int) mySendMessage(pField->hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
if (nLength > nBufLen) {
|
||||
FREE(pszBuffer);
|
||||
// add a bit extra so we do this less often
|
||||
|
@ -346,7 +346,7 @@ bool WINAPI SaveSettings(void) {
|
|||
// CharNext()'s behavior at terminating null char. But still
|
||||
// definitely, unsafe.
|
||||
default:
|
||||
lstrcpyn(p2, p1, CharNext(p1) - p1 + 1);
|
||||
lstrcpyn(p2, p1, (int)(CharNext(p1) - p1) + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ INT_PTR CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
#endif
|
||||
|
||||
// pFields[nIdx].nParentIdx is used to store original windowproc
|
||||
int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CALLBACK StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int StaticField = FindControlIdx(GetDlgCtrlID(hWin));
|
||||
if (StaticField < 0)
|
||||
|
@ -869,7 +869,7 @@ int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
}
|
||||
#endif
|
||||
|
||||
int WINAPI NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CALLBACK NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int nIdx = FindControlIdx(GetDlgCtrlID(hWin));
|
||||
if (nIdx < 0)
|
||||
|
@ -1275,7 +1275,7 @@ int WINAPI createCfgDlg()
|
|||
*pszEnd = _T('\0');
|
||||
if (*pszStart)
|
||||
{
|
||||
int nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
|
||||
INT_PTR nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
|
||||
if (nItem != LB_ERR)
|
||||
mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
|
||||
}
|
||||
|
@ -1288,7 +1288,7 @@ int WINAPI createCfgDlg()
|
|||
}
|
||||
}
|
||||
else {
|
||||
int nItem = mySendMessage(hwCtrl, nFindMsg, (WPARAM)-1, (LPARAM)pField->pszState);
|
||||
INT_PTR nItem = mySendMessage(hwCtrl, nFindMsg, (WPARAM)-1, (LPARAM)pField->pszState);
|
||||
if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
|
||||
mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
|
||||
}
|
||||
|
@ -1300,7 +1300,7 @@ int WINAPI createCfgDlg()
|
|||
case FIELD_ICON:
|
||||
case FIELD_BITMAP:
|
||||
{
|
||||
WPARAM nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
|
||||
UINT nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
|
||||
LPARAM nImage = 0;
|
||||
|
||||
if (pField->pszText) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
|
||||
#include <nsis/pluginapi.h> // nsis plugin
|
||||
#define NSIS_DECLSPEC_DLLEXPORT __declspec(dllexport) // BUGBUG: Compiler specific
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
HWND g_hwndParent;
|
||||
|
@ -34,14 +35,15 @@ struct lang {
|
|||
|
||||
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int i, size;
|
||||
INT_PTR i;
|
||||
int size;
|
||||
TCHAR *selected_language = NULL;
|
||||
static HFONT font;
|
||||
switch (uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG:
|
||||
// add languages
|
||||
for (i = visible_langs_num - 1; i >= 0; i--) {
|
||||
int cbi;
|
||||
INT_PTR cbi;
|
||||
|
||||
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
|
||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
|
||||
|
@ -82,7 +84,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
case IDOK:
|
||||
// push result on the stack
|
||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
|
||||
|
@ -113,7 +115,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
return TRUE; // message processed
|
||||
}
|
||||
|
||||
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||
void NSIS_DECLSPEC_DLLEXPORT LangDialog(HWND hwndParent, int string_size,
|
||||
TCHAR *variables, stack_t **stacktop)
|
||||
{
|
||||
g_hwndParent=hwndParent;
|
||||
|
@ -240,5 +242,5 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
|||
BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
g_hInstance=hInst;
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
|||
*pEnd-- = *p--;
|
||||
}
|
||||
|
||||
dwRenameLinePos = pszNextSec - pszWinInit + 1; // +1 for the \n
|
||||
dwRenameLinePos = BUGBUG64TRUNCATE(DWORD, pszNextSec - pszWinInit) + 1; // +1 for the \n
|
||||
}
|
||||
// rename section is last, stick item at end of file
|
||||
else dwRenameLinePos = dwFileSize;
|
||||
|
|
|
@ -157,7 +157,7 @@ void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent
|
|||
FD_SET(m_socket,&f[2]);
|
||||
struct timeval tv;
|
||||
memset(&tv,0,sizeof(tv));
|
||||
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
|
||||
if (select((int)(m_socket+1),&f[0],&f[1],&f[2],&tv)==-1)
|
||||
{
|
||||
m_errorstr="connecting to host (calling select())";
|
||||
m_state=STATE_ERROR;
|
||||
|
|
|
@ -605,11 +605,13 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
case IDM_EDITSCRIPT:
|
||||
{
|
||||
if (g_sdata.input_script) {
|
||||
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
|
||||
LPCTSTR verb = _T("open"); // BUGBUG: Should not force the open verb?
|
||||
HINSTANCE hi = ShellExecute(g_sdata.hwnd,verb,g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL);
|
||||
if ((UINT_PTR)hi <= 32) {
|
||||
TCHAR path[MAX_PATH];
|
||||
if (GetWindowsDirectory(path,sizeof(path))) {
|
||||
lstrcat(path,_T("\\notepad.exe"));
|
||||
ShellExecute(g_sdata.hwnd,_T("open"),path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
|
||||
ShellExecute(g_sdata.hwnd,verb,path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,15 @@ void CreateToolBar()
|
|||
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LPARAM) &tbbs);
|
||||
|
||||
// For Comctl32.dll version detection
|
||||
#ifndef _WIN64
|
||||
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
|
||||
const FARPROC hasCC4_70 = GetProcAddress(hMod, "InitCommonControlsEx");
|
||||
const FARPROC hasCC4_71 = GetProcAddress(hMod, "DllGetVersion");
|
||||
#else
|
||||
const bool hasCC4_70 = true, hasCC4_71 = true;
|
||||
#endif
|
||||
|
||||
if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
|
||||
if (hasCC4_70) { // Version 4.70
|
||||
// Modern toolbar, 24-bit bitmaps
|
||||
|
||||
g_toolbar.imagelist = ImageList_LoadImage(g_sdata.hInstance, MAKEINTRESOURCE(IDB_TOOLBAR24), 16, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
|
||||
|
@ -88,8 +94,7 @@ void CreateToolBar()
|
|||
SendMessage(g_toolbar.hwnd, TB_SETDISABLEDIMAGELIST, 0, (LPARAM) g_toolbar.imagelistd);
|
||||
SendMessage(g_toolbar.hwnd, TB_SETHOTIMAGELIST, 0, (LPARAM) g_toolbar.imagelisth);
|
||||
|
||||
// Version 4.71
|
||||
if (GetProcAddress(hMod, "DllGetVersion")) {
|
||||
if (hasCC4_71) { // Version 4.71
|
||||
SendMessage(g_toolbar.hwnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent
|
|||
FD_SET(m_socket,&f[2]);
|
||||
struct timeval tv;
|
||||
memset(&tv,0,sizeof(tv));
|
||||
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
|
||||
if (select((int)(m_socket+1),&f[0],&f[1],&f[2],&tv)==-1)
|
||||
{
|
||||
m_errorstr="connecting to host (calling select())";
|
||||
m_state=STATE_ERROR;
|
||||
|
|
|
@ -118,9 +118,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
|||
NULL
|
||||
);
|
||||
|
||||
long c;
|
||||
|
||||
c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
|
||||
LRESULT c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0);
|
||||
SendMessage(hwndP, PBM_SETBARCOLOR, 0, c);
|
||||
SendMessage(pb, PBM_SETBARCOLOR, 0, c);
|
||||
|
||||
|
@ -129,7 +127,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
|||
SendMessage(pb, PBM_SETBKCOLOR, 0, c);
|
||||
|
||||
// set font
|
||||
long hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0);
|
||||
LRESULT hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0);
|
||||
SendMessage(pb, WM_SETFONT, hFont, 0);
|
||||
SendMessage(s, WM_SETFONT, hFont, 0);
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ static INT_PTR CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
|||
|
||||
void AddRTLStyle(HWND hWnd, long dwStyle)
|
||||
{
|
||||
long s;
|
||||
LONG_PTR s;
|
||||
|
||||
s = GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||
SetWindowLongPtr(hWnd, GWL_STYLE, s | dwStyle);
|
||||
|
|
|
@ -33,10 +33,10 @@ if env['TARGET_ARCH'] != 'amd64':
|
|||
elif conf.TryCompile('.end', '.sx'):
|
||||
files += ['Source/Call.sx']
|
||||
else:
|
||||
print 'WARNING: unable to find assembler for Call.S'
|
||||
print 'WARNING: System.dll: unable to find assembler for Call.S'
|
||||
conf.Finish()
|
||||
else:
|
||||
print 'WARNING: missing Win64 code, dynamic function calls not supported'
|
||||
print 'WARNING: System.dll: missing Win64 code, dynamic function calls not supported'
|
||||
|
||||
BuildPlugin(
|
||||
target,
|
||||
|
|
|
@ -38,7 +38,7 @@ PLUGINFUNCTIONEND
|
|||
|
||||
PLUGINFUNCTIONSHORT(Copy)
|
||||
{
|
||||
int size = 0;
|
||||
SIZE_T size = 0;
|
||||
HANDLE source, dest;
|
||||
TCHAR *str;
|
||||
// Get the string
|
||||
|
@ -47,10 +47,10 @@ PLUGINFUNCTIONSHORT(Copy)
|
|||
// Check for size option
|
||||
if (str[0] == _T('/'))
|
||||
{
|
||||
size = (SIZE_T) myatoi(str+1);
|
||||
size = (SIZE_T) StrToIntPtr(str+1);
|
||||
dest = (HANDLE) popintptr();
|
||||
}
|
||||
else dest = (HANDLE) myatoi(str);
|
||||
else dest = (HANDLE) StrToIntPtr(str);
|
||||
source = (HANDLE) popintptr();
|
||||
|
||||
// Ok, check the size
|
||||
|
|
|
@ -273,9 +273,9 @@ PLUGINFUNCTION(Get)
|
|||
/*
|
||||
TODO: CallProc/Back not implemeted.
|
||||
Fake the behavior of the System plugin for the LoadImage API function so MUI works.
|
||||
BUGBUG: Leaking DeleteObject and failing GetClientRect
|
||||
BUGBUG: MUI is leaking DeleteObject and failing GetClientRect
|
||||
*/
|
||||
static SystemProc* CallProc(SystemProc *proc)
|
||||
SystemProc* CallProc(SystemProc *proc)
|
||||
{
|
||||
INT_PTR ret, *place;
|
||||
LastError = lstrcmp(proc->ProcName, sizeof(TCHAR) > 1 ? _T("LoadImageW") : _T("LoadImageA"));
|
||||
|
@ -294,7 +294,7 @@ static SystemProc* CallProc(SystemProc *proc)
|
|||
if (place) *place = ret;
|
||||
return proc;
|
||||
}
|
||||
static SystemProc* CallBack(SystemProc *proc)
|
||||
SystemProc* CallBack(SystemProc *proc)
|
||||
{
|
||||
proc->ProcResult = PR_ERROR;
|
||||
return proc;
|
||||
|
@ -741,10 +741,10 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
|||
// it may contain previous inline input
|
||||
if (!((proc->Params[ParamIndex].Input > -1) && (proc->Params[ParamIndex].Input <= __INST_LAST)))
|
||||
GlobalFree((HANDLE) proc->Params[ParamIndex].Input);
|
||||
proc->Params[ParamIndex].Input = temp4;
|
||||
proc->Params[ParamIndex].Input = BUGBUG64(int) temp4;
|
||||
}
|
||||
if (temp3 == 1)
|
||||
proc->Params[ParamIndex].Output = temp4;
|
||||
proc->Params[ParamIndex].Output = BUGBUG64(int) temp4;
|
||||
// Next parameter is output or something else
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
|
@ -985,7 +985,7 @@ void ParamsIn(SystemProc *proc)
|
|||
case PAT_CALLBACK:
|
||||
// Generate new or use old callback
|
||||
if (lstrlen(realbuf) > 0)
|
||||
par->Value = BUGBUG64(int) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
|
||||
par->Value = (INT_PTR) CreateCallback((SystemProc*) StrToIntPtr(realbuf));
|
||||
break;
|
||||
}
|
||||
GlobalFree(realbuf);
|
||||
|
@ -1254,7 +1254,7 @@ void CallStruct(SystemProc *proc)
|
|||
SYSTEM_LOG_POST;
|
||||
|
||||
// Proc virtual return - pointer to memory struct
|
||||
proc->Params[0].Value = BUGBUG64(int) proc->Proc;
|
||||
proc->Params[0].Value = (INT_PTR) proc->Proc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// This should probably be moved to platform.h at some point
|
||||
|
||||
#if defined(_M_X64) || defined(__amd64__)
|
||||
#if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__)
|
||||
# define SYSTEM_X64
|
||||
#elif defined(_M_IX86) || defined(__i386__) || defined(_X86_)
|
||||
# define SYSTEM_X86
|
||||
|
|
|
@ -86,6 +86,6 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
|
|||
InitCommonControls();
|
||||
g_hInstance = hInst;
|
||||
LoadLibrary(_T("RichEd32.dll"));
|
||||
return DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
|
||||
return (int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST),0,DialogProc);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,8 +67,12 @@ TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
|||
if (CheckTokenForGroupDeny)
|
||||
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
|
||||
_CheckTokenMembership=
|
||||
#ifndef _WIN64
|
||||
(CHECKTOKENMEMBERSHIP) GetProcAddress(
|
||||
GetModuleHandle(_T("ADVAPI32")), "CheckTokenMembership");
|
||||
#else
|
||||
_CheckTokenMembership = CheckTokenMembership;
|
||||
#endif
|
||||
|
||||
// Use "old school" membership check?
|
||||
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)
|
||||
|
|
|
@ -466,7 +466,7 @@ void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, TCHAR *
|
|||
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
||||
{
|
||||
// we use a timer proc instead of WM_TIMER to make sure no one messes with the ids but us
|
||||
g_pluginParms->ExecuteCodeSegment(idEvent - 1, 0);
|
||||
g_pluginParms->ExecuteCodeSegment((int)(idEvent - 1), 0);
|
||||
}
|
||||
|
||||
void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||
|
|
|
@ -176,7 +176,7 @@ void ExecScript(int log) {
|
|||
// WinMain will have the address of the WinMain function in memory.
|
||||
// Getting the difference gets you the relative location of the
|
||||
// WinMain function.
|
||||
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD_PTR)AsExeWinMain - (DWORD_PTR)g_hInst;
|
||||
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD) ((DWORD_PTR)AsExeWinMain - (DWORD_PTR)g_hInst);
|
||||
UnmapViewOfFile(pMapView);
|
||||
}
|
||||
CloseHandle(hMapping);
|
||||
|
@ -414,7 +414,7 @@ void LogMessage(const TCHAR *pStr, BOOL bOEM) {
|
|||
#ifndef _UNICODE
|
||||
if (bOEM == TRUE) OemToCharBuff(pStr, (char*)pStr, lstrlen(pStr));
|
||||
#endif
|
||||
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||
nItemCount=(int) SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||
item.mask=LVIF_TEXT;
|
||||
item.pszText=(TCHAR *)pStr;
|
||||
item.cchTextMax=0;
|
||||
|
|
|
@ -203,7 +203,7 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn)
|
|||
// was zip created on MS-DOS/Windows?
|
||||
if ((info.version & 0xFF00) == 0)
|
||||
{
|
||||
OemToCharBuffA(filenameA, filenameA, strlen(filenameA));
|
||||
OemToCharBuffA(filenameA, filenameA, (DWORD)strlen(filenameA));
|
||||
}
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
;
|
||||
; 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_2 2
|
||||
|
|
|
@ -145,6 +145,9 @@ if defenv['UNICODE']:
|
|||
|
||||
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']:
|
||||
plugin_env.Append(CCFLAGS = ['/O1']) # optimize for size
|
||||
plugin_env.Append(CCFLAGS = ['/W3']) # level 3 warnings
|
||||
|
@ -201,7 +204,9 @@ def check_requirement(ctx, func, trigger):
|
|||
|
||||
return result
|
||||
|
||||
def add_file_to_emitter(env, emitter_name, file):
|
||||
def add_file_to_emitter(env, emitter_name, file, obj_name=None):
|
||||
if obj_name is None:
|
||||
obj_name = emitter_name
|
||||
try:
|
||||
original_emitter = env[emitter_name]
|
||||
if type(original_emitter) == list:
|
||||
|
@ -216,17 +221,17 @@ def add_file_to_emitter(env, emitter_name, file):
|
|||
if '$NODEFLIBS_FLAG' not in env['LINKFLAGS']:
|
||||
return target, source
|
||||
|
||||
return target, source + env.Object(emitter_name, file)
|
||||
return target, source + env.Object(obj_name, file)
|
||||
|
||||
env[emitter_name] = emitter
|
||||
|
||||
def add_file(file):
|
||||
def add_file(file, obj_name=None):
|
||||
file = File(file)
|
||||
add_file_to_emitter(stub_env, 'PROGEMITTER', file)
|
||||
add_file_to_emitter(stub_uenv, 'PROGEMITTER', file)
|
||||
add_file_to_emitter(util_env, 'PROGEMITTER', file)
|
||||
add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file)
|
||||
add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file)
|
||||
add_file_to_emitter(stub_env, 'PROGEMITTER', file, obj_name)
|
||||
add_file_to_emitter(stub_uenv, 'PROGEMITTER', file, obj_name)
|
||||
add_file_to_emitter(util_env, 'PROGEMITTER', file, obj_name)
|
||||
add_file_to_emitter(plugin_env, 'SHLIBEMITTER', file, obj_name)
|
||||
add_file_to_emitter(plugin_uenv, 'SHLIBEMITTER', file, obj_name)
|
||||
|
||||
#
|
||||
# MSVC 6 SP6 doesn't like direct shifting of 64-bit integers.
|
||||
|
@ -253,12 +258,21 @@ conf.Finish()
|
|||
|
||||
#
|
||||
# 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 })
|
||||
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";'):
|
||||
add_file('memset.c')
|
||||
memcpy_test = """
|
||||
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()
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
EnsureSConsVersion(1,2)
|
||||
|
||||
|
||||
stubs = [
|
||||
'bzip2',
|
||||
'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'):
|
||||
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']
|
||||
if defenv.has_key('VER_MINOR'):
|
||||
defenv['VERSION'] += '.' + defenv['VER_MINOR']
|
||||
|
@ -694,7 +694,9 @@ for plugin in plugin_libs + plugins:
|
|||
|
||||
srcpath = 'Contrib/' + 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']:
|
||||
pvariants += [{'e':plugin_uenv.Clone()}]
|
||||
for pvariant in pvariants:
|
||||
|
|
|
@ -92,9 +92,9 @@ public:
|
|||
_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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -85,7 +85,7 @@ void ReadVarLenArr(LPBYTE &seeker, WINWCHAR* &readInto, unsigned int uCodePage)
|
|||
seeker += sizeof(WORD);
|
||||
|
||||
// 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
|
||||
|
@ -381,7 +381,7 @@ SIZE CDialogTemplate::GetStringSize(WORD id, TCHAR *str) {
|
|||
SelectObject(memDC, font);
|
||||
|
||||
SIZE size;
|
||||
GetTextExtentPoint32(memDC, str, _tcslen(str), &size);
|
||||
GetTextExtentPoint32(memDC, str, (int) _tcslen(str), &size);
|
||||
|
||||
DestroyWindow(hDlg);
|
||||
DeleteObject(font);
|
||||
|
|
|
@ -130,7 +130,7 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
|||
|
||||
#ifdef __cplusplus
|
||||
#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_MAX std::_MAX
|
||||
#else
|
||||
|
@ -146,16 +146,27 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG;
|
|||
#endif
|
||||
|
||||
#ifndef __BIG_ENDIAN__
|
||||
# define FIX_ENDIAN_INT64(x) (x)
|
||||
# define FIX_ENDIAN_INT32_INPLACE(x) ((void)(x))
|
||||
# define FIX_ENDIAN_INT32(x) (x)
|
||||
# define FIX_ENDIAN_INT16_INPLACE(x) ((void)(x))
|
||||
# define FIX_ENDIAN_INT16(x) (x)
|
||||
#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(x) SWAP_ENDIAN_INT32(x)
|
||||
# define FIX_ENDIAN_INT16_INPLACE(x) ((x) = SWAP_ENDIAN_INT16(x))
|
||||
# define FIX_ENDIAN_INT16(x) SWAP_ENDIAN_INT16(x)
|
||||
#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) ( \
|
||||
(((x)&0xFF000000) >> 24) | \
|
||||
(((x)&0x00FF0000) >> 8) | \
|
||||
|
@ -993,6 +1004,7 @@ typedef struct tagVS_FIXEDFILEINFO {
|
|||
|
||||
|
||||
#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*!
|
||||
|
|
|
@ -129,7 +129,7 @@ void read_file(const tstring& filename, vector<unsigned char>& data)
|
|||
rewind(file);
|
||||
data.resize(filesize);
|
||||
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("'"));
|
||||
}
|
||||
|
|
|
@ -669,7 +669,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
|||
crd->m_ulWrittenAt = (ULONG_PTR)(seeker);
|
||||
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())
|
||||
qStrings.push(crd->GetEntry(i));
|
||||
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));
|
||||
|
||||
WINWCHAR* szName = cRDirE->GetName();
|
||||
WORD iLen = WinWStrLen(szName) + 1;
|
||||
WORD iLen = (WORD) WinWStrLen(szName) + 1;
|
||||
|
||||
*(WORD*)seeker = ConvertEndianness(iLen);
|
||||
CopyMemory(seeker + sizeof(WORD), szName, iLen*sizeof(WINWCHAR));
|
||||
|
@ -751,7 +751,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
|||
|
||||
// Sets the offsets in directory entries
|
||||
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);
|
||||
if (resDir->GetEntry(i)->IsDataDirectory()) {
|
||||
rde->UOffset.DirectoryOffset.DataIsDirectory = 1;
|
||||
|
@ -860,8 +860,8 @@ void CResourceDirectory::RemoveEntry(int i) {
|
|||
m_vEntries.erase(m_vEntries.begin() + i);
|
||||
}
|
||||
|
||||
int CResourceDirectory::CountEntries() {
|
||||
return m_vEntries.size();
|
||||
unsigned int CResourceDirectory::CountEntries() {
|
||||
return BUGBUG64TRUNCATE(unsigned int,m_vEntries.size());
|
||||
}
|
||||
|
||||
// Returns the index of a directory entry with the specified name
|
||||
|
@ -987,7 +987,7 @@ WINWCHAR* CResourceDirectoryEntry::GetName() {
|
|||
}
|
||||
|
||||
int CResourceDirectoryEntry::GetNameLength() {
|
||||
return WinWStrLen(m_szName);
|
||||
return (int) WinWStrLen(m_szName);
|
||||
}
|
||||
|
||||
WORD CResourceDirectoryEntry::GetId() {
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
CResourceDirectoryEntry* GetEntry(unsigned int i);
|
||||
bool AddEntry(CResourceDirectoryEntry* entry);
|
||||
void RemoveEntry(int i);
|
||||
int CountEntries();
|
||||
unsigned int CountEntries();
|
||||
int Find(const WINWCHAR* szName);
|
||||
int Find(WORD wId);
|
||||
|
||||
|
|
|
@ -131,9 +131,12 @@ CEXEBuild::CEXEBuild() :
|
|||
definedlist.add(_T("NSIS_PACKEDVERSION"), NSIS_PACKEDVERSION);
|
||||
#endif
|
||||
|
||||
build_unicode=false;
|
||||
build_lockedunicodetarget=false;
|
||||
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
|
||||
#include <nsis-defines.h>
|
||||
|
@ -379,7 +382,6 @@ CEXEBuild::CEXEBuild() :
|
|||
|
||||
set_uninstall_mode(0);
|
||||
set_code_type_predefines();
|
||||
set_target_architecture_predefines();
|
||||
}
|
||||
|
||||
void CEXEBuild::initialize(const TCHAR *makensis_path)
|
||||
|
@ -403,7 +405,7 @@ void CEXEBuild::initialize(const TCHAR *makensis_path)
|
|||
stubs_dir = nsis_dir;
|
||||
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");
|
||||
}
|
||||
|
@ -2303,7 +2305,7 @@ void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
|
|||
lang_table_writer::write_block(cur_langtables, &sink, cur_header->langtable_size);
|
||||
|
||||
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
|
||||
if (cur_header->bg_color1 != -1)
|
||||
|
@ -2357,7 +2359,7 @@ int CEXEBuild::SetManifest()
|
|||
return PS_OK;
|
||||
|
||||
// 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) {
|
||||
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)
|
||||
{
|
||||
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
|
||||
build_crcchk=0;
|
||||
#endif
|
||||
|
@ -2618,9 +2621,9 @@ int CEXEBuild::write_output(void)
|
|||
|
||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||
#ifdef NSIS_CONFIG_CRC_ANAL
|
||||
crc=CRC32(crc,m_exehead,m_exehead_size);
|
||||
crc=CRC32(crc,m_exehead,(DWORD)m_exehead_size);
|
||||
#else
|
||||
crc=CRC32(crc,m_exehead+512,m_exehead_size-512);
|
||||
crc=CRC32(crc,m_exehead+512,(DWORD)m_exehead_size-512);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -2776,8 +2779,8 @@ int CEXEBuild::write_output(void)
|
|||
|
||||
if (db_opt_save)
|
||||
{
|
||||
int total_out_size_estimate=
|
||||
m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(crc32_t):0);
|
||||
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));
|
||||
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,
|
||||
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(""));
|
||||
#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);
|
||||
|
||||
|
@ -2912,7 +2915,7 @@ int CEXEBuild::write_output(void)
|
|||
for (;;)
|
||||
{
|
||||
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;
|
||||
crc=CRC32(crc,(unsigned char *)buf,l);
|
||||
}
|
||||
|
@ -2949,7 +2952,7 @@ int CEXEBuild::write_output(void)
|
|||
TCHAR *arg = _tcsstr(cmdstr, _T("%1"));
|
||||
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) );
|
||||
if (!cmdstrbuf)
|
||||
{
|
||||
|
@ -3000,7 +3003,7 @@ int CEXEBuild::deflateToFile(FILE *fp, char *buf, int len) // len==0 to flush
|
|||
int l=compressor->GetNextOut()-obuf;
|
||||
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);
|
||||
return 1;
|
||||
|
@ -3062,7 +3065,7 @@ int CEXEBuild::uninstall_generate()
|
|||
if (ent->which == EW_WRITEUNINSTALLER)
|
||||
{
|
||||
ent->offsets[1] = uninstdata_offset;
|
||||
ent->offsets[2] = m_unicon_size;
|
||||
ent->offsets[2] = (int) m_unicon_size;
|
||||
uns--;
|
||||
if (!uns)
|
||||
break;
|
||||
|
@ -3099,9 +3102,9 @@ int CEXEBuild::uninstall_generate()
|
|||
delete [] unicon_data;
|
||||
|
||||
#ifdef NSIS_CONFIG_CRC_ANAL
|
||||
crc=CRC32(crc, uninst_header, m_exehead_size);
|
||||
crc=CRC32(crc, uninst_header, (DWORD)m_exehead_size);
|
||||
#else
|
||||
crc=CRC32(crc, uninst_header + 512, m_exehead_size - 512);
|
||||
crc=CRC32(crc, uninst_header + 512, (DWORD)m_exehead_size - 512);
|
||||
#endif
|
||||
|
||||
free(uninst_header);
|
||||
|
@ -3242,7 +3245,7 @@ int CEXEBuild::uninstall_generate()
|
|||
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+m_unicon_size;
|
||||
uninstall_size_full=fh.length_of_all_following_data+(int)m_unicon_size;
|
||||
|
||||
// compressed size
|
||||
uninstall_size=build_datablock.getlen()-uninstdata_offset;
|
||||
|
@ -3409,7 +3412,7 @@ void CEXEBuild::notify(MakensisAPI::notify_e code, const TCHAR *data) const
|
|||
#ifdef _WIN32
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
@ -3529,7 +3532,7 @@ void CEXEBuild::init_res_editor()
|
|||
{
|
||||
build_compressor_set = true;
|
||||
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()
|
||||
|
@ -3569,7 +3572,7 @@ int CEXEBuild::DeclaredUserVar(const TCHAR *szVarName)
|
|||
return PS_ERROR;
|
||||
}
|
||||
const TCHAR *pVarName = szVarName;
|
||||
int iVarLen = _tcslen(szVarName);
|
||||
size_t iVarLen = _tcslen(szVarName);
|
||||
|
||||
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_CHAR_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_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"));
|
||||
return PS_ERROR;
|
||||
}
|
||||
|
||||
m_target_type = build_unicode ? TARGET_X86UNICODE : TARGET_X86ANSI; // BUGBUG64
|
||||
set_target_architecture_predefines();
|
||||
m_target_type = tt;
|
||||
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
|
||||
if (PS_OK==ec) ec = initialize_default_plugins(true);
|
||||
if (PS_OK == ec) ec = initialize_default_plugins(true);
|
||||
#endif
|
||||
return ec;
|
||||
}
|
||||
|
@ -3677,10 +3686,9 @@ int CEXEBuild::change_target_architecture()
|
|||
int CEXEBuild::set_target_charset(bool unicode)
|
||||
{
|
||||
if (build_lockedunicodetarget) return PS_ERROR;
|
||||
build_unicode = unicode;
|
||||
build_strlist.setunicode(unicode);
|
||||
ubuild_strlist.setunicode(unicode);
|
||||
return change_target_architecture();
|
||||
TARGETTYPE tt = unicode ? m_target_type : TARGET_X86ANSI;
|
||||
if (TARGET_X86ANSI == tt && unicode) tt = TARGET_X86UNICODE;
|
||||
return change_target_architecture(tt);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ class CEXEBuild {
|
|||
TARGETTYPE get_target_type(const TCHAR*s) const;
|
||||
const TCHAR* get_target_suffix(CEXEBuild::TARGETTYPE tt) const;
|
||||
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);
|
||||
|
||||
|
@ -239,8 +240,8 @@ class CEXEBuild {
|
|||
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
|
||||
void set_target_architecture_predefines();
|
||||
int change_target_architecture();
|
||||
int set_target_architecture_data();
|
||||
int change_target_architecture(TARGETTYPE tt);
|
||||
void set_code_type_predefines(const TCHAR *value = NULL);
|
||||
int getcurdbsize();
|
||||
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_db_data(IMMap *map); // 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_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
|
||||
|
|
|
@ -260,7 +260,7 @@ void generateMTFValues ( EState* s )
|
|||
*ryy_j = rtmp2;
|
||||
};
|
||||
yy[0] = rtmp;
|
||||
j = ryy_j - &(yy[0]);
|
||||
j = BUGBUG64TRUNCATE(Int32, ryy_j - &(yy[0]));
|
||||
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
|
||||
}
|
||||
|
||||
|
|
|
@ -320,9 +320,13 @@ end:
|
|||
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
||||
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
||||
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
||||
#ifndef _WIN64
|
||||
OPT=myGetProcAddress(MGA_OpenProcessToken);
|
||||
LPV=myGetProcAddress(MGA_LookupPrivilegeValue);
|
||||
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
|
||||
#else
|
||||
OPT=OpenProcessToken, LPV=LookupPrivilegeValue, ATP=AdjustTokenPrivileges;
|
||||
#endif
|
||||
if (OPT && LPV && ATP)
|
||||
{
|
||||
HANDLE hToken;
|
||||
|
@ -368,4 +372,7 @@ void NSISCALL CleanUp()
|
|||
// Clean up after plug-ins
|
||||
myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT);
|
||||
#endif // NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
#ifdef _DEBUG
|
||||
// GlobalFree(g_header); ?
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -236,7 +236,11 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
|||
|
||||
LANGID (WINAPI *GUDUIL)();
|
||||
|
||||
#ifndef _WIN64
|
||||
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
||||
#else
|
||||
GUDUIL = GetUserDefaultUILanguage;
|
||||
#endif
|
||||
if (GUDUIL)
|
||||
{
|
||||
// Windows ME/2000+
|
||||
|
@ -407,7 +411,7 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
|||
#endif
|
||||
|
||||
{
|
||||
int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
|
||||
int ret=(int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
|
||||
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
|
||||
ExecuteCallbackFunction(CB_ONGUIEND);
|
||||
#endif
|
||||
|
@ -483,7 +487,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
#endif
|
||||
};
|
||||
|
||||
m_delta = wParam;
|
||||
m_delta = (int) wParam;
|
||||
|
||||
if (uMsg == WM_INITDIALOG)
|
||||
{
|
||||
|
@ -538,7 +542,6 @@ nextPage:
|
|||
else
|
||||
{
|
||||
HWND hwndtmp;
|
||||
|
||||
int pflags = this_page->flags;
|
||||
|
||||
GetNSISString(state_click_next, this_page->clicknext);
|
||||
|
@ -730,7 +733,7 @@ DWORD CALLBACK StreamLicenseRTF(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG
|
|||
{
|
||||
size_t len = lstrlen(((LPWSTR) dwCookie)+g_cbLicRead);
|
||||
len = min(len, cb/sizeof(WCHAR));
|
||||
*pcb=WideCharToMultiByte(CP_ACP,0,((LPWSTR) dwCookie)+g_cbLicRead,len,(char*)pbBuff,cb,NULL,NULL);
|
||||
*pcb=WideCharToMultiByte(CP_ACP,0,((LPWSTR) dwCookie)+g_cbLicRead,(int)len,(char*)pbBuff,cb,NULL,NULL);
|
||||
// RTF uses only ASCII characters, so we can assume "number of output bytes" = "number of source WChar consumed"
|
||||
g_cbLicRead+=*pcb;
|
||||
return 0;
|
||||
|
@ -779,7 +782,7 @@ static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
}
|
||||
if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !LicIgnoreWMCommand) {
|
||||
if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) {
|
||||
int is = SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED;
|
||||
int is = (int) (SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED);
|
||||
m_this_page->flags &= ~PF_LICENSE_SELECTED;
|
||||
m_this_page->flags |= is;
|
||||
EnableNext(is);
|
||||
|
@ -1052,7 +1055,11 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
// Test for and use the GetDiskFreeSpaceEx API
|
||||
{
|
||||
BOOL (WINAPI *GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
|
||||
#ifdef _WIN64
|
||||
GetDiskFreeSpaceEx;
|
||||
#else
|
||||
myGetProcAddress(MGA_GetDiskFreeSpaceEx);
|
||||
#endif
|
||||
if (GDFSE)
|
||||
{
|
||||
ULARGE_INTEGER available64;
|
||||
|
@ -1086,7 +1093,7 @@ static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
}
|
||||
}
|
||||
|
||||
if (!available_set)
|
||||
if (!available_set) // TODO: Can GetDiskFreeSpace succeed when ..Ex failed on x64?
|
||||
{
|
||||
DWORD spc, bps, fc, tc;
|
||||
TCHAR *root;
|
||||
|
@ -1252,7 +1259,7 @@ void NSISCALL ExecuteCallbackFunctionWithr0Int(int num,int r0)
|
|||
|
||||
static WNDPROC oldTreeWndProc;
|
||||
static LPARAM last_selected_tree_item;
|
||||
static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
static LRESULT CALLBACK newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (uMsg == WM_CHAR && wParam == VK_SPACE) {
|
||||
NotifyCurWnd(WM_TREEVIEW_KEYHACK);
|
||||
|
@ -1271,7 +1278,7 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
if (last_selected_tree_item != lParam)
|
||||
{
|
||||
last_selected_tree_item = lParam;
|
||||
ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,lParam);
|
||||
ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,(int)lParam);
|
||||
}
|
||||
}
|
||||
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||
|
@ -1320,7 +1327,7 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
{
|
||||
if (install_types[i])
|
||||
{
|
||||
int j;
|
||||
LRESULT j;
|
||||
if (i != NSIS_MAX_INST_TYPES) noCombo = 0;
|
||||
j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetNSISStringTT(install_types[i]));
|
||||
SendMessage(hwndCombo1,CB_SETITEMDATA,j,i);
|
||||
|
@ -1453,10 +1460,10 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
|
||||
if (uMsg == WM_COMMAND && LOWORD(wParam) == IDC_COMBO1 && HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
int t = SendMessage(hwndCombo1,CB_GETCURSEL,0,0);
|
||||
LRESULT t = SendMessage(hwndCombo1,CB_GETCURSEL,0,0);
|
||||
if (t != CB_ERR)
|
||||
{
|
||||
int whichcfg = SendMessage(hwndCombo1, CB_GETITEMDATA, t, 0);
|
||||
int whichcfg = (int) SendMessage(hwndCombo1, CB_GETITEMDATA, t, 0);
|
||||
|
||||
if (whichcfg == CB_ERR || !install_types[whichcfg])
|
||||
whichcfg = NSIS_MAX_INST_TYPES;
|
||||
|
@ -1492,7 +1499,7 @@ static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_COMPONENTPAGE)
|
||||
if (wParam != 0)
|
||||
{
|
||||
int secid = wParam;
|
||||
int secid = (int) wParam;
|
||||
if (wParamSelChangeNotifyInstTypeChanged != secid) --secid;
|
||||
ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid);
|
||||
}
|
||||
|
@ -1744,7 +1751,7 @@ static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
i = count;
|
||||
while (i--)
|
||||
// Add 2 for the CR/LF combination that must follow every line.
|
||||
total += 2+SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
|
||||
total += 2+(int)SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
|
||||
|
||||
// 2nd pass - store detail view strings on the clipboard
|
||||
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE
|
||||
|
|
|
@ -172,8 +172,11 @@ static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyif
|
|||
{
|
||||
typedef LONG (WINAPI * RegDeleteKeyExPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
|
||||
RegDeleteKeyExPtr RDKE = (RegDeleteKeyExPtr)
|
||||
#ifdef _WIN64
|
||||
RegDeleteKeyEx;
|
||||
#else
|
||||
myGetProcAddress(MGA_RegDeleteKeyEx);
|
||||
|
||||
#endif
|
||||
if (RDKE)
|
||||
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
|
||||
else
|
||||
|
@ -771,7 +774,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
HWND hwnd=GetHwndFromParm(1);
|
||||
int msg=GetIntFromParm(2);
|
||||
|
||||
if (parm5>>2) exec_error += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(LPDWORD)&v);
|
||||
if (parm5>>2) exec_error += !SendMessageTimeout(hwnd,msg,b3,b4,SMTO_NORMAL,parm5>>2,(PDWORD_PTR)&v);
|
||||
// Jim Park: This sends script messages. Some messages require
|
||||
// settings for Unicode. This means the user's script may need
|
||||
// to change for Unicode NSIS.
|
||||
|
|
|
@ -398,14 +398,14 @@ int NSISCALL _dodecomp(int offset, HANDLE hFileOut, unsigned char *outbuf, int o
|
|||
|
||||
if (err<0) return -4;
|
||||
|
||||
u=(char*)g_inflate_stream.next_out - outbuffer;
|
||||
u=BUGBUG64TRUNCATE(int, (char*)g_inflate_stream.next_out - outbuffer);
|
||||
|
||||
tc = GetTickCount();
|
||||
tc=GetTickCount();
|
||||
if (g_exec_flags.status_update & 1 && (tc - ltc > 200 || !input_len))
|
||||
{
|
||||
wsprintf(progress, _T("... %d%%"), MulDiv(input_len_total - input_len, 100, input_len_total));
|
||||
update_status_text(0, progress);
|
||||
ltc = tc;
|
||||
ltc=tc;
|
||||
}
|
||||
|
||||
// if there's no output, more input is needed
|
||||
|
|
|
@ -473,13 +473,31 @@ typedef struct {
|
|||
COLORREF text;
|
||||
COLORREF bkc;
|
||||
UINT lbStyle;
|
||||
#ifndef MAKENSIS
|
||||
HBRUSH bkb;
|
||||
#ifdef _WIN64
|
||||
#error Should we swap lbStyle and bkb to get better alignment? If we are going to do it, now is our only chance before plugins in the wild start depending on the ctlcolors layout on x64
|
||||
#else
|
||||
INT32 bkb;
|
||||
#endif
|
||||
int bkmode;
|
||||
int flags;
|
||||
} ctlcolors;
|
||||
} ctlcolors32;
|
||||
typedef struct {
|
||||
COLORREF text;
|
||||
COLORREF bkc;
|
||||
#ifndef MAKENSIS
|
||||
HBRUSH bkb; // NOTE: Placed above lbStyle for better alignment
|
||||
#else
|
||||
INT64 bkb;
|
||||
#endif
|
||||
UINT lbStyle;
|
||||
int bkmode;
|
||||
int flags;
|
||||
} ctlcolors64;
|
||||
#if defined(_WIN64) && !defined(MAKENSIS)
|
||||
# define ctlcolors ctlcolors64
|
||||
#else
|
||||
# define ctlcolors ctlcolors32
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
|
||||
// constants for myDelete (util.c)
|
||||
|
|
|
@ -404,16 +404,14 @@ char * NSISCALL mystrstriA(char *a, const char *b)
|
|||
}
|
||||
|
||||
|
||||
#ifndef _NSIS_NODEFLIB_CRTMEMCPY
|
||||
// mini_memcpy takes the number of bytes to copy.
|
||||
void NSISCALL mini_memcpy(void *out, const void *in, int len)
|
||||
void NSISCALL mini_memcpy(void *out, const void *in, UINT_PTR cb)
|
||||
{
|
||||
char *c_out=(char*)out;
|
||||
char *c_in=(char *)in;
|
||||
while (len-- > 0)
|
||||
{
|
||||
*c_out++=*c_in++;
|
||||
}
|
||||
char *dst = (char*) out, *src = (char*) in;
|
||||
while (cb-- > 0) *dst++ = *src++;
|
||||
}
|
||||
#endif
|
||||
|
||||
DWORD NSISCALL remove_ro_attr(LPCTSTR file)
|
||||
{
|
||||
|
@ -538,7 +536,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
|||
*pEnd-- = *p--;
|
||||
}
|
||||
|
||||
dwRenameLinePos = pszNextSec - pszWinInit + 1; // +1 for the \n
|
||||
dwRenameLinePos = BUGBUG64TRUNCATE(DWORD, pszNextSec - pszWinInit) + 1; // +1 for the \n
|
||||
}
|
||||
// rename section is last, stick item at end of file
|
||||
else dwRenameLinePos = dwFileSize;
|
||||
|
@ -570,13 +568,17 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
|||
BOOL fOk = 0;
|
||||
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
||||
mfea_t mfea;
|
||||
#ifdef _WIN64
|
||||
mfea=MoveFileEx;
|
||||
#else
|
||||
mfea=(mfea_t) myGetProcAddress(MGA_MoveFileEx);
|
||||
if (mfea)
|
||||
#endif
|
||||
{
|
||||
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
if (!fOk)
|
||||
if (!fOk && sizeof(void*) <= 4)
|
||||
{
|
||||
RenameViaWininit(pszExisting, pszNew);
|
||||
}
|
||||
|
@ -691,7 +693,7 @@ TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab)
|
|||
// indexes into the language
|
||||
TCHAR *in = (TCHAR*)GetNSISStringNP(GetNSISTab(strtab));
|
||||
TCHAR *out = ps_tmpbuf;
|
||||
|
||||
|
||||
// Still working within ps_tmpbuf, so set out to the
|
||||
// current position that is passed in.
|
||||
if (outbuf >= ps_tmpbuf &&
|
||||
|
@ -1035,6 +1037,7 @@ struct MGA_FUNC
|
|||
|
||||
#ifdef _UNICODE
|
||||
struct MGA_FUNC MGA_FUNCS[] = {
|
||||
#ifndef _WIN64
|
||||
{"KERNEL32", "GetDiskFreeSpaceExW"},
|
||||
{"KERNEL32", "MoveFileExW"},
|
||||
{"ADVAPI32", "RegDeleteKeyExW"},
|
||||
|
@ -1042,6 +1045,7 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
|||
{"ADVAPI32", "LookupPrivilegeValueW"},
|
||||
{"ADVAPI32", "AdjustTokenPrivileges"},
|
||||
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||
#endif
|
||||
{"SHLWAPI", "SHAutoComplete"},
|
||||
{"SHFOLDER", "SHGetFolderPathW"}
|
||||
};
|
||||
|
|
|
@ -108,11 +108,16 @@ void NSISCALL validate_filename(TCHAR *fn);
|
|||
* @param pszNew The new name of the file.
|
||||
*/
|
||||
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
||||
|
||||
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
||||
DWORD NSISCALL remove_ro_attr(LPCTSTR file);
|
||||
|
||||
#ifdef _NSIS_NODEFLIB_CRTMEMCPY
|
||||
#define mini_memcpy memcpy
|
||||
#else
|
||||
void NSISCALL mini_memcpy(void *out, const void *in, UINT_PTR cb);
|
||||
#endif
|
||||
|
||||
enum myGetProcAddressFunctions {
|
||||
#ifndef _WIN64
|
||||
MGA_GetDiskFreeSpaceEx,
|
||||
MGA_MoveFileEx,
|
||||
MGA_RegDeleteKeyEx,
|
||||
|
@ -120,8 +125,9 @@ enum myGetProcAddressFunctions {
|
|||
MGA_LookupPrivilegeValue,
|
||||
MGA_AdjustTokenPrivileges,
|
||||
MGA_GetUserDefaultUILanguage,
|
||||
MGA_SHAutoComplete,
|
||||
MGA_SHGetFolderPath,
|
||||
#endif
|
||||
MGA_SHAutoComplete, // x64 can link to shlwapi directly but as long as MGA_SHGetFolderPath is used we can stick with myGetProcAddress
|
||||
MGA_SHGetFolderPath, // TODO: This can probably call something else directly on x64
|
||||
};
|
||||
|
||||
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
||||
|
|
|
@ -146,14 +146,25 @@ void page_writer::write(const page *data)
|
|||
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);
|
||||
m_sink->write_int(data->bkc);
|
||||
m_sink->write_int(data->lbStyle);
|
||||
m_sink->write_int((INT_PTR) data->bkb);
|
||||
m_sink->write_int(data->bkmode);
|
||||
m_sink->write_int(data->flags);
|
||||
assert(sizeof(int) == 4 && sizeof(ctlcolors64) > sizeof(ctlcolors32));
|
||||
ctlcolors *p = (ctlcolors*) data;
|
||||
m_sink->write_int(p->text);
|
||||
m_sink->write_int(p->bkc);
|
||||
if (x64)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -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(block_header);
|
||||
DECLARE_WRITER(header);
|
||||
DECLARE_WRITER(section);
|
||||
DECLARE_WRITER(entry);
|
||||
DECLARE_WRITER(page);
|
||||
DECLARE_WRITER(ctlcolors);
|
||||
DECLARE_PLATFORMITEMWRITER(ctlcolors);
|
||||
DECLARE_WRITER(LOGFONT);
|
||||
|
||||
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_icons2[i].meta.dwRawSize)
|
||||
);
|
||||
pair.size_index = i;
|
||||
pair.size_index = BUGBUG64TRUNCATE(unsigned int,i);
|
||||
|
||||
result.push_back(pair);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
|||
pair.index1 = sorted_icons1[i].index;
|
||||
pair.index2 = 0xffff;
|
||||
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())
|
||||
|
@ -235,7 +235,7 @@ static IconPairs get_icon_order(IconGroup icon1, IconGroup icon2)
|
|||
pair.index2 = sorted_icons2[i].index;
|
||||
pair.index1 = 0xffff;
|
||||
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);
|
||||
|
@ -256,7 +256,7 @@ static LPBYTE generate_icon_group(IconGroup icon, IconPairs order, bool first)
|
|||
|
||||
header->wReserved = 0;
|
||||
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);
|
||||
|
||||
|
@ -285,7 +285,7 @@ void set_icon(CResourceEditor* re, WORD wIconId, IconGroup icon1, IconGroup icon
|
|||
size_t group_size = sizeof(IconGroupHeader) // header
|
||||
+ 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);
|
||||
|
||||
// delete old icons
|
||||
|
@ -343,7 +343,7 @@ unsigned char* generate_uninstall_icon_data(IconGroup icon1, IconGroup icon2, si
|
|||
LPBYTE seeker = uninst_data;
|
||||
|
||||
// fill group header
|
||||
*(LPDWORD) seeker = FIX_ENDIAN_INT32(group_size);
|
||||
*(LPDWORD) seeker = FIX_ENDIAN_INT32((UINT32)group_size);
|
||||
seeker += sizeof(DWORD);
|
||||
*(LPDWORD) seeker = 0;
|
||||
seeker += sizeof(DWORD);
|
||||
|
@ -382,7 +382,7 @@ int generate_unicons_offsets(LPBYTE exeHeader, size_t exeHeaderSize, LPBYTE unin
|
|||
DWORD offset;
|
||||
DWORD size;
|
||||
|
||||
CResourceEditor re(exeHeader, exeHeaderSize, false);
|
||||
CResourceEditor re(exeHeader, (DWORD)exeHeaderSize, false);
|
||||
|
||||
LPBYTE seeker = uninstIconData;
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ int StringsArray::set(int idx, const TCHAR *str)
|
|||
int old = ((int*) m_offsets.get())[idx];
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -1014,7 +1014,7 @@ l_readerr:
|
|||
// set ^Language
|
||||
nlf->m_szStrings[NLF_LANGUAGE] = _tcsdup(nlf->m_szName);
|
||||
|
||||
int temp;
|
||||
size_t temp;
|
||||
|
||||
// Get font
|
||||
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
|
||||
const size_t cchstr = _tcslen(str);
|
||||
const unsigned int cchstr = (unsigned int) _tcslen(str);
|
||||
m_linebuild.add(str,(cchstr+1)*sizeof(TCHAR));
|
||||
|
||||
// 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)
|
||||
{
|
||||
linedata.add((void*)in,(t-in)*sizeof(TCHAR));
|
||||
linedata.add((void*)in,BUGBUG64TRUNCATE(int,(t-in)*sizeof(TCHAR)));
|
||||
in=t;
|
||||
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);
|
||||
return PS_ERROR;
|
||||
}
|
||||
m_macros.add(macroname,(_tcslen(macroname)+1)*sizeof(TCHAR));
|
||||
m_macros.add(macroname,(int)(_tcslen(macroname)+1)*sizeof(TCHAR));
|
||||
|
||||
int pc;
|
||||
for (pc=2; pc < line.getnumtokens(); pc ++)
|
||||
|
@ -1154,7 +1154,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
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("")));
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
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(" ")));
|
||||
linecnt++;
|
||||
}
|
||||
|
@ -1220,9 +1220,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
return PS_ERROR;
|
||||
}
|
||||
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)));
|
||||
m_macros.resize(mbufcb-(mcb+sizeof(TCHAR)));
|
||||
m_macros.resize((int)(mbufcb-(mcb+sizeof(TCHAR))));
|
||||
SCRIPT_MSG(_T("!macroundef: %") NPRIs _T("\n"),mname);
|
||||
}
|
||||
return PS_OK;
|
||||
|
@ -1251,7 +1251,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
l_define_saves.add(t,v);
|
||||
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));
|
||||
|
||||
npr++;
|
||||
|
@ -3132,9 +3132,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
} else if (!_tcscmp(mathop,_T("<<")) || !_tcscmp(mathop,_T("<<<")) ) {
|
||||
_stprintf(value,_T("%d"),value1<<value2);
|
||||
} else if (!_tcscmp(mathop,_T(">>"))) {
|
||||
_stprintf(value,_T("%d"),(signed)value1>>(signed)value2);
|
||||
} else if (!_tcscmp(mathop,_T(">>>"))) {
|
||||
_stprintf(value,_T("%d"),(unsigned)value1>>(unsigned)value2);
|
||||
_stprintf(value,_T("%d"),(signed int)value1>>(signed int)value2);
|
||||
} else if (!_tcscmp(mathop,_T(">>>"))) {
|
||||
_stprintf(value,_T("%d"),(unsigned int)value1>>(unsigned int)value2);
|
||||
} else if (!_tcscmp(mathop,_T("/"))) {
|
||||
if (value2==0) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (dupemode==2)definedlist.del(define);
|
||||
if (dupemode==2) definedlist.del(define);
|
||||
if (definedlist.add(define,value))
|
||||
{
|
||||
ERROR_MSG(_T("!define: \"%") NPRIs _T("\" already defined!\n"),define);
|
||||
|
@ -3453,7 +3453,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
delete tlist;
|
||||
// parse line
|
||||
}
|
||||
if ((unsigned)-1 != fail_parm && !noErrors)
|
||||
if ((UINT)-1 != fail_parm && !noErrors)
|
||||
{
|
||||
const TCHAR *msgprefix=!fail_parm ? _T("starting ") : _T("");
|
||||
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 *search = line.gettoken_str(3+ignoreCase);
|
||||
TCHAR *replace = line.gettoken_str(4+ignoreCase);
|
||||
int searchlen=_tcslen(search);
|
||||
int replacelen=_tcslen(replace);
|
||||
int searchlen=(int)_tcslen(search), replacelen=(int)_tcslen(replace);
|
||||
if (!searchlen)
|
||||
{
|
||||
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;
|
||||
while (*np && *np != _T('|')) np++;
|
||||
if (*np) *np++=0;
|
||||
for (x = 0 ; (unsigned) x < COUNTOF(list) && _tcsicmp(list[x].str, p); x++);
|
||||
if ((unsigned) x < COUNTOF(list))
|
||||
for (x = 0 ; (size_t) x < COUNTOF(list) && _tcsicmp(list[x].str, p); x++);
|
||||
if ((size_t) x < COUNTOF(list))
|
||||
{
|
||||
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[5]=0;
|
||||
|
||||
if (INVALID_FILE_ATTRIBUTES != (unsigned)ent.offsets[1])
|
||||
if (INVALID_FILE_ATTRIBUTES != (DWORD)ent.offsets[1])
|
||||
{
|
||||
a=add_entry(&ent);
|
||||
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
|
||||
else
|
||||
{
|
||||
toklen = _tcslen(tok);
|
||||
toklen = (int) _tcslen(tok);
|
||||
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
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ unsigned int ExeHeadStringList::getnum() const
|
|||
{
|
||||
char *p = (char*) m_gr.get();
|
||||
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
|
||||
if (m_wide)
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ unsigned int ExeHeadStringList::find(const TCHAR *str, WORD codepage, bool proce
|
|||
}
|
||||
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
|
||||
|
@ -140,7 +141,7 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co
|
|||
for(;;)
|
||||
{
|
||||
if (pos+=cb >= cbList) break;
|
||||
cb = strlen(p+=cb) + 1;
|
||||
cb = (unsigned int) strlen(p+=cb) + 1;
|
||||
if (cb < cbF) continue;
|
||||
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;
|
||||
unsigned int pos = find(str,codepage,processed,m_wide ? 0 : &bufMB);
|
||||
if ((unsigned)-1 != pos)
|
||||
if ((unsigned int)-1 != pos)
|
||||
{
|
||||
delete[] bufMB;
|
||||
return pos;
|
||||
|
@ -180,7 +181,7 @@ int ExeHeadStringList::add(const TCHAR *str, WORD codepage, bool processed)
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned int cbMB = strlen(bufMB) + 1;
|
||||
unsigned int cbMB = (unsigned int) strlen(bufMB) + 1;
|
||||
pos = m_gr.add(bufMB,cbMB);
|
||||
delete[] bufMB;
|
||||
}
|
||||
|
@ -192,7 +193,7 @@ int StringList::add(const TCHAR *str, int case_sensitive)
|
|||
{
|
||||
int a=find(str,case_sensitive);
|
||||
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
|
||||
|
@ -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
|
||||
!_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)++;
|
||||
}
|
||||
|
@ -235,12 +236,12 @@ int StringList::find(const TCHAR *str, int case_sensitive, int *idx/*=NULL*/) co
|
|||
void StringList::delbypos(int pos)
|
||||
{
|
||||
TCHAR *s=(TCHAR*) m_gr.get();
|
||||
int len=_tcslen(s+pos)+1;
|
||||
int len=(int)_tcslen(s+pos)+1;
|
||||
|
||||
if (pos+len < getcount())
|
||||
{
|
||||
// Move everything after the string position to the current position.
|
||||
memcpy(s+pos,s+pos+len, (getcount()-pos+len)*sizeof(TCHAR));
|
||||
// Move everything after the string position to the current position.
|
||||
memcpy(s+pos,s+pos+len, (getcount()-pos+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 (cnt++ == idx) return offs;
|
||||
offs+=_tcslen(s+offs)+1;
|
||||
offs+=(int)_tcslen(s+offs)+1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -267,7 +268,7 @@ int StringList::getnum() const
|
|||
int idx=0;
|
||||
while (offs < ml)
|
||||
{
|
||||
offs+=_tcslen(s+offs)+1;
|
||||
offs+=(int)_tcslen(s+offs)+1;
|
||||
idx++;
|
||||
}
|
||||
return idx;
|
||||
|
|
|
@ -164,10 +164,10 @@ template <class T>
|
|||
class SortedStringList
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Jim Park: Note that SortedStringList actually <b>owns</b> T.name.
|
||||
* Yes, this violates all kinds of encapsulation ideas.
|
||||
*/
|
||||
/**
|
||||
* Jim Park: Note that SortedStringList actually <b>owns</b> T.name.
|
||||
* Yes, this violates all kinds of encapsulation ideas.
|
||||
*/
|
||||
virtual ~SortedStringList()
|
||||
{
|
||||
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
|
||||
* 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
|
||||
* can get random behavior.
|
||||
*
|
||||
* @param name The name which is the "key" to finding the instance of T.
|
||||
* @param case_sensitive 1 means case sensitive, 0 insensitive.
|
||||
/**
|
||||
* 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
|
||||
* add must be done with the same value for case_sensitive or you
|
||||
* can get random behavior.
|
||||
*
|
||||
* @param name The name which is the "key" to finding the instance of T.
|
||||
* @param case_sensitive 1 means case sensitive, 0 insensitive.
|
||||
* @return Returns -1 when name already exists and pos if added.
|
||||
*/
|
||||
*/
|
||||
int add(const TCHAR *name, int case_sensitive=0)
|
||||
{
|
||||
T newstruct={0,};
|
||||
int pos=find(name,case_sensitive,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);
|
||||
if (!newstruct.name)
|
||||
{
|
||||
|
@ -215,22 +215,22 @@ class SortedStringList
|
|||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
* 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 case_sensitive If 1, do a case sensitive search, otherwise, case insensitive.
|
||||
*
|
||||
*
|
||||
* @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
|
||||
* sorted position to insert str into the buffer.
|
||||
*
|
||||
*
|
||||
* @return Returns -1 if not found, position if found. If returnbestpos=1
|
||||
* returns -1 if found, best pos to insert if not found
|
||||
*/
|
||||
*/
|
||||
int find(const TCHAR *str, int case_sensitive=0, int returnbestpos=0)
|
||||
{
|
||||
T *data=(T *) m_gr.get();
|
||||
|
@ -254,12 +254,12 @@ class SortedStringList
|
|||
return returnbestpos ? nextpos : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function looks for str in T.name and deletes the T in the
|
||||
* buffer.
|
||||
*
|
||||
* @return Returns 0 on success, 1 on failure.
|
||||
*/
|
||||
/**
|
||||
* This function looks for str in T.name and deletes the T in the
|
||||
* buffer.
|
||||
*
|
||||
* @return Returns 0 on success, 1 on failure.
|
||||
*/
|
||||
int del(const TCHAR *str, int case_sensitive=0)
|
||||
{
|
||||
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;
|
||||
|
||||
// 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));
|
||||
T *s=(T*) m_gr.get();
|
||||
|
@ -403,7 +403,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned int pCurr_len = _tcslen(pCurr);
|
||||
unsigned int pCurr_len = (unsigned int) _tcslen(pCurr);
|
||||
if (case_sensitive)
|
||||
res = _tcsncmp(str, pCurr, STD_MIN((unsigned int) n_chars, pCurr_len));
|
||||
else
|
||||
|
@ -444,8 +444,8 @@ class SortedStringListND // no delete - can be placed in GrowBuf
|
|||
* Structure stored by DefineList.
|
||||
*/
|
||||
struct define {
|
||||
TCHAR *name; // key
|
||||
TCHAR *value; // value stored
|
||||
TCHAR *name; // key
|
||||
TCHAR *value; // value stored
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -459,11 +459,11 @@ class DefineList : public SortedStringList<struct define>
|
|||
void operator=(const DefineList&);
|
||||
|
||||
public:
|
||||
/* Empty default constructor */
|
||||
/* Empty default constructor */
|
||||
DefineList() {} // VC6 complains otherwise
|
||||
virtual ~DefineList();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Add a name-value pair, case insensitively.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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(""));
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef wchar_t TCHAR, _TUCHAR;
|
|||
// printfs
|
||||
#define _ftprintf fwprintf
|
||||
#define _sntprintf _snwprintf
|
||||
#if (defined(_MSC_VER) && (_MSC_VER<=1310)) || defined(__MINGW32__)
|
||||
#if (defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)) || defined(__MINGW32__)
|
||||
# define _stprintf swprintf
|
||||
#else
|
||||
# define _stprintf _swprintf
|
||||
|
@ -243,5 +243,9 @@ typedef unsigned char _TUCHAR;
|
|||
#endif
|
||||
|
||||
// is functions (the same in Unicode / ANSI)
|
||||
#ifndef _istgraph
|
||||
#define _istgraph isgraph
|
||||
#endif
|
||||
#ifndef _istascii
|
||||
#define _istascii __isascii
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
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)
|
||||
|
@ -204,10 +204,10 @@ void* CharEncConv::Convert(const void*Src, size_t cbSrc, size_t*cbOut)
|
|||
{
|
||||
if (NStreamEncoding::UTF16BE == m_TE) goto l_swapUTF16;
|
||||
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));
|
||||
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 (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));
|
||||
if (p) m_Result = p; else return 0;
|
||||
memcpy(p, Src, cbSrc);
|
||||
cchDest = cbSrc / sizeof(wchar_t);
|
||||
cchDest = (UINT) (cbSrc / sizeof(wchar_t));
|
||||
UTF16InplaceEndianSwap(p, cchDest);
|
||||
if (!cchDest) *((WORD*)p) = 0, ++cchDest; // For "--cchDest" during \0 termination
|
||||
}
|
||||
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));
|
||||
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 (((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(;;)
|
||||
{
|
||||
cch = ExpandoStrFmtVaList_vsnwprintf(dest, cchAvail, FmtStr, Args);
|
||||
if ((unsigned)-1 == cch)
|
||||
if ((size_t)-1 == cch)
|
||||
{
|
||||
cch = 0;
|
||||
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;
|
||||
errno = ENOMEM;
|
||||
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) );
|
||||
if (!cmd) return -1;
|
||||
_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)
|
||||
{
|
||||
if ((unsigned)-1 == cch) cch = _tcslen(Str);
|
||||
if ((UINT)-1 == cch) cch = (UINT)_tcslen(Str);
|
||||
DWORD cbio;
|
||||
if (WinStdIO_IsConsole(osd))
|
||||
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;
|
||||
ExpandoString<wchar_t, NSIS_MAX_STRLEN> buf;
|
||||
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))
|
||||
{
|
||||
cch = 0, errno = EIO;
|
||||
|
@ -1139,7 +1141,7 @@ static bool GetDLLVersionUsingRE(const tstring& filepath, DWORD& high, DWORD & l
|
|||
{
|
||||
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
||||
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)
|
||||
{
|
||||
|
@ -1147,7 +1149,7 @@ static bool GetDLLVersionUsingRE(const tstring& filepath, DWORD& high, DWORD & l
|
|||
{
|
||||
// get VS_FIXEDFILEINFO from VS_VERSIONINFO
|
||||
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
|
||||
VS_FIXEDFILEINFO *verinfo = (VS_FIXEDFILEINFO *)(ver + len);
|
||||
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)
|
||||
{
|
||||
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);
|
||||
if (p)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,11 @@ void writer_sink::write_int(const int i)
|
|||
int fi = FIX_ENDIAN_INT32(i);
|
||||
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)
|
||||
{
|
||||
|
@ -73,7 +78,7 @@ void writer_sink::write_string(const TCHAR *s, size_t size)
|
|||
{
|
||||
char *wb = new char[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);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -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)
|
||||
{
|
||||
*m_crc = CRC32(*m_crc, (const unsigned char *) data, size);
|
||||
*m_crc = CRC32(*m_crc, (const unsigned char *) data, BUGBUG64TRUNCATE(unsigned int, size));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
virtual void write_byte(const unsigned char b);
|
||||
virtual void write_short(const short s);
|
||||
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_string(const TCHAR *s, size_t size);
|
||||
virtual void write_growbuf(const IGrowBuf *b);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue