size optimization
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5109 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ec2d800d42
commit
acbd53f905
6 changed files with 65 additions and 36 deletions
|
@ -2116,8 +2116,8 @@ void CEXEBuild::AddStandardStrings()
|
||||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
if (uninstall_mode)
|
if (uninstall_mode)
|
||||||
{
|
{
|
||||||
cur_header->str_uninstchild = add_string("$TEMP\\$1");
|
cur_header->str_uninstchild = add_string("$TEMP\\$1u_.exe");
|
||||||
cur_header->str_uninstcmd = add_string("\"$TEMP\\$1\" $0 _?=$INSTDIR\\");
|
cur_header->str_uninstcmd = add_string("\"$TEMP\\$1u_.exe\" $0 _?=$INSTDIR\\");
|
||||||
}
|
}
|
||||||
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||||
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
#ifdef NSIS_SUPPORT_MOVEONREBOOT
|
||||||
|
|
|
@ -197,7 +197,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
char s[] = "Au_.exe";
|
|
||||||
|
|
||||||
mystrcat(state_temp_dir,"~nsu.tmp");
|
mystrcat(state_temp_dir,"~nsu.tmp");
|
||||||
|
|
||||||
|
@ -213,13 +212,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
mystrcpy(state_install_directory,state_exe_directory);
|
mystrcpy(state_install_directory,state_exe_directory);
|
||||||
|
|
||||||
mystrcpy(g_usrvars[0], realcmds);
|
mystrcpy(g_usrvars[0], realcmds);
|
||||||
mystrcpy(g_usrvars[1], s);
|
*(LPWORD)g_usrvars[1] = CHAR2_TO_WORD('A',0);
|
||||||
|
|
||||||
for (x = 0; x < 26; x ++)
|
for (x = 0; x < 26; x ++)
|
||||||
{
|
{
|
||||||
static char buf2[NSIS_MAX_STRLEN];
|
static char buf2[NSIS_MAX_STRLEN];
|
||||||
|
|
||||||
GetNSISString(buf2,g_header->str_uninstchild); // $TEMP\$1
|
GetNSISString(buf2,g_header->str_uninstchild); // $TEMP\$1u_.exe
|
||||||
|
|
||||||
DeleteFile(buf2); // clean up after all the other ones if they are there
|
DeleteFile(buf2); // clean up after all the other ones if they are there
|
||||||
|
|
||||||
|
@ -233,7 +232,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
||||||
MoveFileOnReboot(buf2,NULL);
|
MoveFileOnReboot(buf2,NULL);
|
||||||
MoveFileOnReboot(state_temp_dir,NULL);
|
MoveFileOnReboot(state_temp_dir,NULL);
|
||||||
#endif
|
#endif
|
||||||
GetNSISString(buf2,g_header->str_uninstcmd); // '"$TEMP\$1" $0 _?=$INSTDIR\'
|
GetNSISString(buf2,g_header->str_uninstcmd); // '"$TEMP\$1u_.exe" $0 _?=$INSTDIR\'
|
||||||
hProc=myCreateProcess(buf2);
|
hProc=myCreateProcess(buf2);
|
||||||
if (hProc)
|
if (hProc)
|
||||||
{
|
{
|
||||||
|
@ -279,9 +278,9 @@ end:
|
||||||
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
||||||
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
||||||
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
||||||
OPT=myGetProcAddress("ADVAPI32","OpenProcessToken");
|
OPT=myGetProcAddress(MGA_OpenProcessToken);
|
||||||
LPV=myGetProcAddress("ADVAPI32","LookupPrivilegeValueA");
|
LPV=myGetProcAddress(MGA_LookupPrivilegeValueA);
|
||||||
ATP=myGetProcAddress("ADVAPI32","AdjustTokenPrivileges");
|
ATP=myGetProcAddress(MGA_AdjustTokenPrivileges);
|
||||||
if (OPT && LPV && ATP)
|
if (OPT && LPV && ATP)
|
||||||
{
|
{
|
||||||
HANDLE hToken;
|
HANDLE hToken;
|
||||||
|
|
|
@ -232,9 +232,8 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
||||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0xrn.asp
|
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0xrn.asp
|
||||||
|
|
||||||
LANGID (WINAPI *GUDUIL)();
|
LANGID (WINAPI *GUDUIL)();
|
||||||
static const char guduil[] = "GetUserDefaultUILanguage";
|
|
||||||
|
|
||||||
GUDUIL = myGetProcAddress("KERNEL32", guduil);
|
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
|
||||||
if (GUDUIL)
|
if (GUDUIL)
|
||||||
{
|
{
|
||||||
// Windows ME/2000+
|
// Windows ME/2000+
|
||||||
|
@ -374,21 +373,20 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
|
||||||
|
|
||||||
#ifdef NSIS_CONFIG_LICENSEPAGE
|
#ifdef NSIS_CONFIG_LICENSEPAGE
|
||||||
{ // load richedit DLL
|
{ // load richedit DLL
|
||||||
static char str1[]="RichEd20";
|
static const char riched20[]="RichEd20";
|
||||||
static char str2[]="RichEdit20A";
|
static const char riched32[]="RichEd32";
|
||||||
if (!LoadLibrary(str1))
|
static const char richedit20a[]="RichEdit20A";
|
||||||
|
static const char richedit[]="RichEdit";
|
||||||
|
if (!LoadLibrary(riched20))
|
||||||
{
|
{
|
||||||
*(WORD*)(str1+6) = CHAR2_TO_WORD('3','2');
|
LoadLibrary(riched32);
|
||||||
LoadLibrary(str1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make richedit20a point to RICHEDIT
|
// make richedit20a point to RICHEDIT
|
||||||
if (!GetClassInfo(NULL,str2,&wc))
|
if (!GetClassInfo(NULL,richedit20a,&wc))
|
||||||
{
|
{
|
||||||
str2[8]=0;
|
GetClassInfo(NULL,richedit,&wc);
|
||||||
GetClassInfo(NULL,str2,&wc);
|
wc.lpszClassName = richedit20a;
|
||||||
wc.lpszClassName = str2;
|
|
||||||
str2[8]='2';
|
|
||||||
RegisterClass(&wc);
|
RegisterClass(&wc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -920,9 +918,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
{
|
{
|
||||||
typedef HRESULT (WINAPI *SHAutoCompletePtr)(HWND, DWORD);
|
typedef HRESULT (WINAPI *SHAutoCompletePtr)(HWND, DWORD);
|
||||||
SHAutoCompletePtr fSHAutoComplete;
|
SHAutoCompletePtr fSHAutoComplete;
|
||||||
static const char shlwapi[] = "shlwapi";
|
fSHAutoComplete = (SHAutoCompletePtr) myGetProcAddress(MGA_SHAutoComplete);
|
||||||
static const char shac[] = "SHAutoComplete";
|
|
||||||
fSHAutoComplete = (SHAutoCompletePtr) myGetProcAddress(shlwapi, shac);
|
|
||||||
if (fSHAutoComplete)
|
if (fSHAutoComplete)
|
||||||
{
|
{
|
||||||
fSHAutoComplete(hDir, SHACF_FILESYSTEM);
|
fSHAutoComplete(hDir, SHACF_FILESYSTEM);
|
||||||
|
@ -996,7 +992,7 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
// Test for and use the GetDiskFreeSpaceEx API
|
// Test for and use the GetDiskFreeSpaceEx API
|
||||||
{
|
{
|
||||||
BOOL (WINAPI *GDFSE)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
|
BOOL (WINAPI *GDFSE)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) =
|
||||||
myGetProcAddress("KERNEL32", "GetDiskFreeSpaceExA");
|
myGetProcAddress(MGA_GetDiskFreeSpaceExA);
|
||||||
if (GDFSE)
|
if (GDFSE)
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER available64;
|
ULARGE_INTEGER available64;
|
||||||
|
|
|
@ -158,7 +158,7 @@ static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyif
|
||||||
{
|
{
|
||||||
typedef LONG (WINAPI * RegDeleteKeyExAPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
|
typedef LONG (WINAPI * RegDeleteKeyExAPtr)(HKEY, LPCTSTR, REGSAM, DWORD);
|
||||||
RegDeleteKeyExAPtr RDKE = (RegDeleteKeyExAPtr)
|
RegDeleteKeyExAPtr RDKE = (RegDeleteKeyExAPtr)
|
||||||
myGetProcAddress("ADVAPI32","RegDeleteKeyExA");
|
myGetProcAddress(MGA_RegDeleteKeyExA);
|
||||||
|
|
||||||
if (RDKE)
|
if (RDKE)
|
||||||
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
|
retval=RDKE(thiskey,lpSubKey,AlterRegistrySAM(0),0);
|
||||||
|
|
|
@ -348,7 +348,7 @@ int NSISCALL is_valid_instpath(char *s)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * NSISCALL mystrstri(char *a, char *b)
|
char * NSISCALL mystrstri(char *a, const char *b)
|
||||||
{
|
{
|
||||||
int l = mystrlen(b);
|
int l = mystrlen(b);
|
||||||
while (mystrlen(a) >= l)
|
while (mystrlen(a) >= l)
|
||||||
|
@ -418,7 +418,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
||||||
BOOL fOk = 0;
|
BOOL fOk = 0;
|
||||||
typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags);
|
typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags);
|
||||||
mfea_t mfea;
|
mfea_t mfea;
|
||||||
mfea=(mfea_t) myGetProcAddress("KERNEL32","MoveFileExA");
|
mfea=(mfea_t) myGetProcAddress(MGA_MoveFileExA);
|
||||||
if (mfea)
|
if (mfea)
|
||||||
{
|
{
|
||||||
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
fOk=mfea(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
|
||||||
|
@ -430,7 +430,7 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
|
||||||
static char wininit[1024];
|
static char wininit[1024];
|
||||||
static char tmpbuf[1024];
|
static char tmpbuf[1024];
|
||||||
int cchRenameLine;
|
int cchRenameLine;
|
||||||
char *szRenameSec = "[Rename]\r\n";
|
static const char szRenameSec[] = "[Rename]\r\n";
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
DWORD dwFileSize;
|
DWORD dwFileSize;
|
||||||
DWORD dwBytes;
|
DWORD dwBytes;
|
||||||
|
@ -591,7 +591,8 @@ char * NSISCALL mystrcat(char *out, const char *concat)
|
||||||
|
|
||||||
char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
||||||
|
|
||||||
#define SYSREGKEY "Software\\Microsoft\\Windows\\CurrentVersion"
|
const char SYSREGKEY[] = "Software\\Microsoft\\Windows\\CurrentVersion";
|
||||||
|
const char QUICKLAUNCH[] = "\\Microsoft\\Internet Explorer\\Quick Launch";
|
||||||
|
|
||||||
// Based on Dave Laundon's simplified process_string
|
// Based on Dave Laundon's simplified process_string
|
||||||
char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
||||||
|
@ -666,7 +667,7 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
||||||
// for normal $APPDATA, it'd be CSIDL_APPDATA_COMMON
|
// for normal $APPDATA, it'd be CSIDL_APPDATA_COMMON
|
||||||
if (fldrs[2] == CSIDL_APPDATA)
|
if (fldrs[2] == CSIDL_APPDATA)
|
||||||
{
|
{
|
||||||
mystrcat(out, "\\Microsoft\\Internet Explorer\\Quick Launch");
|
mystrcat(out, QUICKLAUNCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,15 +883,32 @@ WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * NSISCALL myGetProcAddress(const char *dll, const char *func)
|
struct MGA_FUNC
|
||||||
{
|
{
|
||||||
HMODULE hModule = GetModuleHandle(dll);
|
const char *dll;
|
||||||
|
const char *func;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MGA_FUNC MGA_FUNCS[] = {
|
||||||
|
{"KERNEL32", "GetDiskFreeSpaceExA"},
|
||||||
|
{"KERNEL32", "MoveFileExA"},
|
||||||
|
{"ADVAPI32", "RegDeleteKeyExA"},
|
||||||
|
{"ADVAPI32", "OpenProcessToken"},
|
||||||
|
{"ADVAPI32", "LookupPrivilegeValueA"},
|
||||||
|
{"ADVAPI32", "AdjustTokenPrivileges"},
|
||||||
|
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||||
|
{"SHLWAPI", "SHAutoComplete"}
|
||||||
|
};
|
||||||
|
|
||||||
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func)
|
||||||
|
{
|
||||||
|
HMODULE hModule = GetModuleHandle(MGA_FUNCS[func].dll);
|
||||||
if (!hModule)
|
if (!hModule)
|
||||||
hModule = LoadLibrary(dll);
|
hModule = LoadLibrary(MGA_FUNCS[func].dll);
|
||||||
if (!hModule)
|
if (!hModule)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GetProcAddress(hModule, func);
|
return GetProcAddress(hModule, MGA_FUNCS[func].func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSISCALL MessageLoop(UINT uCheckedMsg)
|
void NSISCALL MessageLoop(UINT uCheckedMsg)
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
* warranty.
|
* warranty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef ___NSIS_UTIL_H___
|
||||||
|
#define ___NSIS_UTIL_H___
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Platform.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
@ -91,7 +94,18 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
||||||
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
||||||
void NSISCALL remove_ro_attr(char *file);
|
void NSISCALL remove_ro_attr(char *file);
|
||||||
|
|
||||||
void * NSISCALL myGetProcAddress(const char *dll, const char *func);
|
enum myGetProcAddressFunctions {
|
||||||
|
MGA_GetDiskFreeSpaceExA,
|
||||||
|
MGA_MoveFileExA,
|
||||||
|
MGA_RegDeleteKeyExA,
|
||||||
|
MGA_OpenProcessToken,
|
||||||
|
MGA_LookupPrivilegeValueA,
|
||||||
|
MGA_AdjustTokenPrivileges,
|
||||||
|
MGA_GetUserDefaultUILanguage,
|
||||||
|
MGA_SHAutoComplete
|
||||||
|
};
|
||||||
|
|
||||||
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
||||||
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
||||||
|
|
||||||
// Turn a pair of chars into a word
|
// Turn a pair of chars into a word
|
||||||
|
@ -103,3 +117,5 @@ void NSISCALL MessageLoop(UINT uCheckedMsg);
|
||||||
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
||||||
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif//!___NSIS_UTIL_H___
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue