64bit fixes and optimizations
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6486 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
0bcb8f40ed
commit
36deb84820
14 changed files with 74 additions and 51 deletions
|
@ -8,6 +8,8 @@
|
|||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
#define isvalidnsisvarindex(varnum) ( ((unsigned int)(varnum)) < (__INST_LAST) )
|
||||
|
||||
unsigned int g_stringsize;
|
||||
stack_t **g_stacktop;
|
||||
TCHAR *g_variables;
|
||||
|
@ -48,13 +50,13 @@ void NSISCALL pushstring(const TCHAR *str)
|
|||
|
||||
TCHAR* NSISCALL getuservariable(const int varnum)
|
||||
{
|
||||
if (varnum < 0 || varnum >= __INST_LAST) return NULL;
|
||||
if (!isvalidnsisvarindex(varnum)) return NULL;
|
||||
return g_variables+varnum*g_stringsize;
|
||||
}
|
||||
|
||||
void NSISCALL setuservariable(const int varnum, const TCHAR *var)
|
||||
{
|
||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
if (var && isvalidnsisvarindex(varnum))
|
||||
lstrcpy(g_variables + varnum*g_stringsize, var);
|
||||
}
|
||||
|
||||
|
@ -100,7 +102,7 @@ void NSISCALL GetUserVariableA(const int varnum, char* ansiStr)
|
|||
|
||||
void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr)
|
||||
{
|
||||
if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
if (ansiStr && isvalidnsisvarindex(varnum))
|
||||
{
|
||||
wchar_t* wideStr = g_variables + varnum * g_stringsize;
|
||||
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
|
||||
|
@ -149,7 +151,7 @@ void NSISCALL GetUserVariableA(const int varnum, char* ansiStr)
|
|||
|
||||
void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr)
|
||||
{
|
||||
if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
if (wideStr && isvalidnsisvarindex(varnum))
|
||||
{
|
||||
char* ansiStr = g_variables + varnum * g_stringsize;
|
||||
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
|
||||
|
|
|
@ -265,6 +265,7 @@ HANDLE myOpenFile(const TCHAR *fn, DWORD da, DWORD cd)
|
|||
);
|
||||
}
|
||||
|
||||
#ifndef _WIN64
|
||||
/** Modifies the wininit.ini file to rename / delete a file.
|
||||
*
|
||||
* @param prevName The previous / current name of the file.
|
||||
|
@ -364,6 +365,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
|||
CloseHandle(hfile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DeleteFileOnReboot(TCHAR *pszFile)
|
||||
{
|
||||
|
@ -379,9 +381,10 @@ void DeleteFileOnReboot(TCHAR *pszFile)
|
|||
fOk=mfea(pszFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN64
|
||||
if (!fOk)
|
||||
{
|
||||
RenameViaWininit(pszFile, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
LogMessage(g_sdata.hwnd, g_sdata.compressor_stats);
|
||||
}
|
||||
DeleteFile(temp_file_name);
|
||||
lstrcpy(g_sdata.compressor_stats,_T(""));
|
||||
g_sdata.compressor_stats[0] = _T('\0');
|
||||
}
|
||||
else {
|
||||
g_sdata.compressor_name = compressor_names[this_compressor+1];
|
||||
|
@ -545,7 +545,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
l.lpstrFileTitle = NULL;
|
||||
l.lpstrInitialDir = NULL;
|
||||
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
|
||||
lstrcpy(buf,_T(""));
|
||||
buf[0] = _T('\0');
|
||||
if (GetOpenFileName(&l)) {
|
||||
SetScript(buf);
|
||||
PushMRUFile(g_sdata.script);
|
||||
|
@ -1176,7 +1176,7 @@ INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
|
||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
|
||||
SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)SYMBOL_SET_NAME_MAXLEN+1, (LPARAM)name);
|
||||
if(!lstrlen(name)) {
|
||||
if(!*name) {
|
||||
if(g_symbol_set_mode == 1) { //Load
|
||||
MessageBox(hwndDlg,LOAD_SYMBOL_SET_MESSAGE,LOAD_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
|
|
@ -268,12 +268,9 @@ void CompileNSISScript() {
|
|||
TCHAR *symbols = BuildSymbols();
|
||||
TCHAR compressor[40];
|
||||
|
||||
if(lstrlen(g_sdata.compressor_name)) {
|
||||
compressor[0] = _T('\0');
|
||||
if(*g_sdata.compressor_name)
|
||||
wsprintf(compressor,_T("/X\"SetCompressor /FINAL %s\""),g_sdata.compressor_name);
|
||||
}
|
||||
else {
|
||||
lstrcpy(compressor,_T(""));
|
||||
}
|
||||
|
||||
TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args);
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
HWND g_hwndParent;
|
||||
|
||||
#define isvalidnsisvarindex(varnum) ( ((unsigned int)(varnum)) < (__INST_LAST) )
|
||||
|
||||
TCHAR *AllocString()
|
||||
{
|
||||
return (TCHAR*) GlobalAlloc(GPTR,g_stringsize*sizeof(TCHAR));
|
||||
|
@ -46,14 +48,14 @@ TCHAR *system_pushstring(TCHAR *str)
|
|||
|
||||
TCHAR *system_getuservariable(int varnum)
|
||||
{
|
||||
if (varnum < 0 || varnum >= __INST_LAST) return AllocString();
|
||||
if (!isvalidnsisvarindex(varnum)) return AllocString();
|
||||
return AllocStr(g_variables+varnum*g_stringsize);
|
||||
}
|
||||
|
||||
TCHAR *system_setuservariable(int varnum, TCHAR *var)
|
||||
{
|
||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) {
|
||||
lstrcpy (g_variables + varnum*g_stringsize, var);
|
||||
if (var && isvalidnsisvarindex(varnum)) {
|
||||
lstrcpy(g_variables + varnum*g_stringsize, var);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
|
|
@ -379,18 +379,25 @@ PLUGINFUNCTION(Call)
|
|||
PLUGINFUNCTIONSHORT(Int64Op)
|
||||
{
|
||||
__int64 i1, i2 = 0, i3, i4;
|
||||
TCHAR *op, *o1, *o2;
|
||||
TCHAR buf[128];
|
||||
TCHAR *op;
|
||||
#ifndef _WIN64
|
||||
TCHAR buf[25], *o1, *o2;
|
||||
#endif
|
||||
|
||||
// Get strings
|
||||
o1 = system_popstring(); op = system_popstring();
|
||||
i1 = myatoi64(o1); // convert first arg to int64
|
||||
// Get parameters: <num1> <op> [num2]
|
||||
#ifdef _WIN64
|
||||
i1 = system_popintptr();
|
||||
#else
|
||||
o1 = system_popstring(), i1 = myatoi64(o1);
|
||||
#endif
|
||||
op = system_popstring();
|
||||
if ((*op != _T('~')) && (*op != _T('!')))
|
||||
{
|
||||
// get second arg, convert it, free it
|
||||
o2 = system_popstring();
|
||||
i2 = myatoi64(o2);
|
||||
GlobalFree(o2);
|
||||
#ifdef _WIN64
|
||||
i2 = system_popintptr();
|
||||
#else
|
||||
o2 = system_popstring(), i2 = myatoi64(o2), GlobalFree(o2);
|
||||
#endif
|
||||
}
|
||||
|
||||
// operation
|
||||
|
@ -418,9 +425,12 @@ PLUGINFUNCTIONSHORT(Int64Op)
|
|||
}
|
||||
|
||||
// Output and freedom
|
||||
myitoa64(i1, buf);
|
||||
system_pushstring(buf);
|
||||
GlobalFree(o1); GlobalFree(op);
|
||||
#ifdef _WIN64
|
||||
system_pushintptr(i1);
|
||||
#else
|
||||
myitoa64(i1, buf), system_pushstring(buf), GlobalFree(o1);
|
||||
#endif
|
||||
GlobalFree(op);
|
||||
} PLUGINFUNCTIONEND
|
||||
|
||||
__int64 GetIntFromString(TCHAR **p)
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef HANDLE HMODULE;
|
|||
typedef unsigned long HKEY;
|
||||
// some gdi
|
||||
typedef DWORD COLORREF;
|
||||
typedef UINT32 HBRUSH;
|
||||
typedef HANDLE HBRUSH;
|
||||
// bool
|
||||
# define FALSE 0
|
||||
# define TRUE 1
|
||||
|
|
|
@ -2316,7 +2316,7 @@ void CEXEBuild::AddStandardStrings()
|
|||
}
|
||||
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||
cur_header->str_wininit = add_asciistring(_T("$WINDIR\\wininit.ini"));
|
||||
cur_header->str_wininit = is_target_64bit() ? 0 : add_asciistring(_T("$WINDIR\\wininit.ini"));
|
||||
#endif//NSIS_SUPPORT_MOVEONREBOOT
|
||||
}
|
||||
|
||||
|
@ -2816,7 +2816,7 @@ int CEXEBuild::write_output(void)
|
|||
|
||||
if (db_opt_save)
|
||||
{
|
||||
UINT32 total_out_size_estimate=
|
||||
size_t total_out_size_estimate=
|
||||
m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(crc32_t):0);
|
||||
int pc=(int)((db_opt_save*1000)/(db_opt_save+total_out_size_estimate));
|
||||
FriendlySize fs(db_opt_save);
|
||||
|
|
|
@ -320,14 +320,14 @@ 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
|
||||
#ifdef _WIN64
|
||||
OPT=OpenProcessToken, LPV=LookupPrivilegeValue, ATP=AdjustTokenPrivileges;
|
||||
#else
|
||||
OPT=myGetProcAddress(MGA_OpenProcessToken);
|
||||
LPV=myGetProcAddress(MGA_LookupPrivilegeValue);
|
||||
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
|
||||
#else
|
||||
OPT=OpenProcessToken, LPV=LookupPrivilegeValue, ATP=AdjustTokenPrivileges;
|
||||
#endif
|
||||
if (OPT && LPV && ATP)
|
||||
#endif
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
|
|
|
@ -236,16 +236,17 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
|||
|
||||
LANGID (WINAPI *GUDUIL)();
|
||||
|
||||
#ifndef _WIN64
|
||||
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
GUDUIL = GetUserDefaultUILanguage;
|
||||
#endif
|
||||
#else
|
||||
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
||||
if (GUDUIL)
|
||||
#endif
|
||||
{
|
||||
// Windows ME/2000+
|
||||
myitoa(state_language, GUDUIL());
|
||||
}
|
||||
#ifndef _WIN64
|
||||
else
|
||||
{
|
||||
static const TCHAR reg_9x_locale[] = _T("Control Panel\\Desktop\\ResourceLocale");
|
||||
|
@ -270,6 +271,7 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
|||
|
||||
mystrcat(state_language, g_tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
// set default language
|
||||
set_language();
|
||||
|
|
|
@ -457,6 +457,7 @@ BOOL NSISCALL myReadFile(HANDLE h, LPVOID buf, DWORD cb)
|
|||
}
|
||||
|
||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||
#ifndef _WIN64
|
||||
/** Modifies the wininit.ini file to rename / delete a file.
|
||||
*
|
||||
* @param prevName The previous / current name of the file.
|
||||
|
@ -555,6 +556,7 @@ void RenameViaWininit(const TCHAR* prevName, const TCHAR* newName)
|
|||
CloseHandle(hfile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MoveFileOnReboot tries to move a file by the name of pszExisting to the
|
||||
|
@ -577,11 +579,12 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
|||
{
|
||||
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
if (!fOk && sizeof(void*) <= 4)
|
||||
#ifndef _WIN64
|
||||
if (!fOk)
|
||||
{
|
||||
RenameViaWininit(pszExisting, pszNew);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NSIS_SUPPORT_REBOOT
|
||||
g_exec_flags.exec_reboot++;
|
||||
|
@ -610,7 +613,7 @@ void NSISCALL myRegGetStr(HKEY root, const TCHAR *sub, const TCHAR *name, TCHAR
|
|||
void NSISCALL iptrtostr(TCHAR *s, INT_PTR d)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
static const TCHAR c[] = _T("%I64d");
|
||||
static const TCHAR c[] = _T("%Id");
|
||||
#else
|
||||
static const TCHAR c[] = _T("%d");
|
||||
#endif
|
||||
|
|
|
@ -723,8 +723,11 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
|
|||
if (t)
|
||||
{
|
||||
UINT32 codpts[]={utf32,UNICODE_REPLACEMENT_CHARACTER,'?'};
|
||||
for(UINT i=0; i < COUNTOF(codpts); ++i)
|
||||
if (WCFromCodePoint(dyndefbuf,COUNTOF(dyndefbuf),codpts[i])) break;
|
||||
for(size_t i=0, cch; i < COUNTOF(codpts); ++i)
|
||||
{
|
||||
cch = WCFromCodePoint(dyndefbuf,COUNTOF(dyndefbuf),codpts[i]);
|
||||
if (cch) { dyndefbuf[cch] = _T('\0'); break; }
|
||||
}
|
||||
t=dyndefbuf;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ unsigned int ExeHeadStringList::find(const void *ptr, unsigned int cchF, WORD co
|
|||
else
|
||||
delete[] bufMB;
|
||||
}
|
||||
return retval;
|
||||
return BUGBUG64TRUNCATE(unsigned int, retval);
|
||||
}
|
||||
|
||||
int ExeHeadStringList::add(const TCHAR *str, WORD codepage, bool processed)
|
||||
|
|
|
@ -58,7 +58,7 @@ typedef wchar_t TCHAR, _TUCHAR;
|
|||
#define _tprintf wprintf
|
||||
#define _vftprintf vfwprintf
|
||||
#define _vsntprintf _vsnwprintf
|
||||
#if defined(_MSC_VER) && (_MSC_VER<=1310)
|
||||
#if defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)
|
||||
# define _vstprintf vswprintf
|
||||
#else
|
||||
# define _vstprintf _vswprintf
|
||||
|
@ -242,10 +242,11 @@ typedef unsigned char _TUCHAR;
|
|||
|
||||
#endif
|
||||
|
||||
// is functions (the same in Unicode / ANSI)
|
||||
#ifndef _istgraph
|
||||
#define _istgraph isgraph
|
||||
#endif
|
||||
// is functions (the same in Unicode / ANSI on MinGW? MSVC does not agree!)
|
||||
#ifndef _istascii
|
||||
#define _istascii __isascii
|
||||
#if defined(_MSC_VER) && defined(_UNICODE)
|
||||
#define _istascii iswascii
|
||||
#else
|
||||
#define _istascii __isascii
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue