Added MakeNSISW donate link to permalink redirected donate page

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7049 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-11-11 22:05:32 +00:00
parent b2daa7d5fe
commit 4f695dbd30
8 changed files with 80 additions and 27 deletions

View file

@ -7,3 +7,7 @@
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
#ifndef LWS_IGNORERETURN
#define LWS_IGNORERETURN 0x0002
#endif

View file

@ -49,11 +49,27 @@ void* g_ModalDlgData;
NSIS_ENTRYPOINT_SIMPLEGUI
int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int ShowCmd) {
HMODULE hK32 = LoadLibraryA("KERNEL32");
// We can be associated with .nsi files and when launched from the shell we inherit the current directory so
// we need to prevent LoadLibrary from searching the current directory because it can contain untrusted DLLs!
FARPROC SDDA = GetProcAddress(hK32, "SetDllDirectoryA"); // WinXP.SP1+
FARPROC SDDA = GetSysProcAddr("KERNEL32", "SetDllDirectoryA"); // WinXP.SP1+
if (SDDA) ((BOOL(WINAPI*)(LPCSTR))SDDA)(""); // Remove the current directory from the default DLL search order
// Try to register the SysLink class
DWORD iccestruct[2] = { 8, 0x8000 }; // ICC_LINK_CLASS (ComCtl32v6)
FARPROC icce = SupportsW95() ? GetSysProcAddr("COMCTL32", "InitCommonControlsEx") : (FARPROC) InitCommonControlsEx;
BOOL succ = ((BOOL(WINAPI*)(const void*))icce)(iccestruct);
if (!succ && (sizeof(void*) > 4 || LOBYTE(GetVersion()) >= 5))
{
FARPROC lwrc = GetSysProcAddr("SHELL32", (LPCSTR) 258); // LinkWindow_RegisterClass
if (lwrc) ((BOOL(WINAPI*)())lwrc)();
WNDCLASS wc;
if (GetClassInfo(NULL, _T("Link Window"), &wc))
{
wc.lpszClassName = _T("SysLink");
RegisterClass(&wc); // Superclass the old link window class if SysLink is not available
}
}
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
memset(&g_resize,0,sizeof(NRESIZEDATA));
memset(&g_find,0,sizeof(NFINDREPLACE));
@ -63,8 +79,7 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
g_sdata.verbosity = (unsigned char) ReadRegSettingDW(REGVERBOSITY, 4);
if (g_sdata.verbosity > 4) g_sdata.verbosity = 4;
RestoreSymbols();
HMODULE hRichEditDLL = LoadLibraryA("RichEd20.dll");
LoadSysLibrary("RichEd20");
if (!InitBranding()) {
MessageBox(0,NSISERROR,ERRBOXTITLE,MB_ICONEXCLAMATION|MB_OK|MB_TASKMODAL);
@ -94,7 +109,6 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
if (g_sdata.script_cmd_args) GlobalFree(g_sdata.script_cmd_args);
if (g_sdata.sigint_event) CloseHandle(g_sdata.sigint_event);
if (g_sdata.sigint_event_legacy) CloseHandle(g_sdata.sigint_event_legacy);
FreeLibrary(hRichEditDLL);
return (int) msg.wParam;
}
@ -895,17 +909,32 @@ static INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
dd.hFont = fontnorm, dd.hBoldFont = fontbold;
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)fontbold, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTPORTIONS, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_NSISVER, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_OTHERCONTRIB, WM_SETFONT, (WPARAM)fontnorm, FALSE);
static const BYTE fontnormctlids[] = { IDC_ABOUTCOPY, IDC_ABOUTPORTIONS, IDC_ABOUTDONATE, IDC_OTHERCONTRIB, IDC_NSISVER };
for (UINT i = 0; i < COUNTOF(fontnormctlids); ++i) SendDlgItemMessage(hwndDlg, fontnormctlids[i], WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendMessage(hwndDlg, WM_APP, 0, 0); // Set IDC_ABOUTVERSION
SetDlgItemText(hwndDlg, IDC_ABOUTCOPY, COPYRIGHT);
SetDlgItemText(hwndDlg, IDC_OTHERCONTRIB, CONTRIB);
SetDlgItemText(hwndDlg, IDC_ABOUTDONATE, DONATE);
SetDlgItemText(hwndDlg, IDC_NSISVER, g_sdata.branding);
SetTimer(hwndDlg, ABOUTDLGDATA::TID_HEADER, 50, NULL);
break;
}
case WM_NOTIFY:
switch (((NMHDR*)lParam)->code)
{
case NM_CLICK:
// fall through
case NM_RETURN:
if (((NMHDR*)lParam)->idFrom == IDC_ABOUTDONATE)
{
static const BYTE x = 128, encurl[] = DONATEURL;
char url[COUNTOF(encurl)];
for (UINT i = 0;; ++i) if (!(url[i] = (char) (encurl[i] & ~x))) break; // "Decrypt" URL
OpenUrlInDefaultBrowser(hwndDlg, url);
}
break;
}
break;
case WM_COMMAND:
if (wParam == MAKELONG(IDC_ABOUTVERSION, STN_DBLCLK)) goto showversion;
if (IDOK != LOWORD(wParam)) break;

View file

@ -32,12 +32,13 @@
#include <richedit.h>
#undef _RICHEDIT_VER
// Defines
#define DpiAwarePerMonitor2() ( FALSE ) // Not yet
#define DpiAwarePerMonitor() ( FALSE )
#define SupportsWNT4() ( sizeof(void*) == 4 && !DpiAwarePerMonitor() ) // NT4 does not support the MultiMon API
#define SupportsW9X() ( sizeof(TCHAR) == 1 )
#define SupportsW95() ( FALSE && SupportsW9X() && !DpiAwarePerMonitor() )
// Defines
#define NSIS_URL "http://nsis.sourceforge.net/"
#define NSIS_FORUM_URL "http://forums.winamp.com/forumdisplay.php?forumid=65"
#define NSIS_UC_URL "http://nsis.sourceforge.net/update.php?version="
@ -45,6 +46,8 @@
#define USAGE _T("Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSIS Script\"")
#define COPYRIGHT _T("Copyright (C) 2002 Robert Rainwater")
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg, Anders Kjersem")
#define DONATE _T("<A ID=\"D\">Donate</A> to support NSIS development.")
#define DONATEURL { 'h'|x,'t','t'|x,'p',':'|x,'/'|x,'/'|x,'n'|x,'s'|x,'i'|x,'s'|x,'.'|x,'s'|x,'f'|x,'.','n'|x,'e'|x,'t'|x,'/'|x,'r','/'|x,'D'|x,'o'|x,'n'|x,'a'|x,'t'|x,'e'|x,'\0' } // "Encrypted"
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
#define LOCALDOCS _T("\\NSIS.chm")
#define ERRBOXTITLE 0 //_T("Error")

View file

@ -61,6 +61,7 @@
#define IDC_NSISVER 224
#define IDC_OTHERCONTRIB 225
#define IDC_ABOUTHEADER 226
#define IDC_ABOUTDONATE 227
#define IDC_RIGHT 230
#define IDC_LEFT 231
#define IDC_CLEAR 232

View file

@ -174,20 +174,21 @@ BEGIN
PUSHBUTTON "&Close",IDCANCEL,296,226,49,15,WS_TABSTOP
END
DLG_ABOUT DIALOGEX 0, 0, 233, 126
DLG_ABOUT DIALOGEX 0, 0, 233, 142
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP |
WS_CAPTION | WS_SYSMENU
WS_CAPTION | WS_SYSMENU | DS_NOFAILCREATE
CAPTION "About MakeNSISW"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,171,104,50,15
DEFPUSHBUTTON "OK",IDOK,171,120,50,15
CONTROL "",IDC_ABOUTHEADER,"Static",SS_OWNERDRAW,0,0,233,25
LTEXT "",IDC_ABOUTVERSION,14,31,219,8,SS_NOTIFY
LTEXT "Copyright",IDC_ABOUTCOPY,14,43,220,8
LTEXT "Other Contributors:",IDC_ABOUTPORTIONS,14,56,220,10
LTEXT "",IDC_ABOUTVERSION,14,31,218,8,SS_NOTIFY
LTEXT "Copyright",IDC_ABOUTCOPY,14,43,218,8
LTEXT "Other Contributors:",IDC_ABOUTPORTIONS,14,56,218,10
LTEXT "",IDC_OTHERCONTRIB,27,68,206,22
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,13,97,209,1
LTEXT "NSIS",IDC_NSISVER,14,107,135,8,WS_DISABLED
CONTROL "",IDC_ABOUTDONATE,"SysLink",WS_TABSTOP|LWS_IGNORERETURN,14,98,218,8
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,13,113,209,1
LTEXT "NSIS",IDC_NSISVER,14,123,135,8,WS_DISABLED
END
DLG_SETTINGS DIALOGEX 0, 0, 292, 215

View file

@ -50,6 +50,21 @@ extern const TCHAR *compressor_names[];
void MemSafeFree(void*mem) { if (mem) GlobalFree(mem); }
void*MemAllocZI(SIZE_T cb) { return GlobalAlloc(GPTR, cb); }
HMODULE LoadSysLibrary(LPCSTR Mod)
{
TCHAR buf[MAX_PATH+20], *path;
UINT dirmax = MAX_PATH, cch;
if ((cch = GetSystemDirectory(buf, dirmax)) >= dirmax) cch = 0;
wsprintf(buf + cch, _T("\\%hs.dll"), Mod); // Note: We always append ".dll"
path = buf + !cch; // Full path or just the filename
return LoadLibrary(path);
}
FARPROC GetSysProcAddr(LPCSTR Mod, LPCSTR FuncName)
{
return GetProcAddress(LoadSysLibrary(Mod), FuncName);
}
static bool WriteFile(HANDLE hFile, const void*pData, DWORD cb)
{
DWORD cbio;
@ -1010,7 +1025,6 @@ HMENU FindSubMenu(HMENU hMenu, UINT uId)
return GetMenuItemInfo(hMenu, uId, FALSE, &mii) ? mii.hSubMenu : 0;
}
static FARPROC GetProcAddr(LPCSTR Mod, LPCSTR FuncName) { return GetProcAddress(LoadLibraryA(Mod), FuncName); }
static UINT DpiGetClassicSystemDpiY() { HDC hDC = GetDC(NULL); UINT dpi = GetDeviceCaps(hDC, LOGPIXELSY); ReleaseDC(NULL, hDC); return dpi; }
static HRESULT WINAPI DpiFallbackGetDpiForMonitor(HMONITOR hMon, int MDT, UINT*pX, UINT*pY) { return (*pX = *pY = DpiGetClassicSystemDpiY(), S_OK); }
static UINT WINAPI DpiFallbackGetDpiForWindow(HWND hWnd) { return 0; }
@ -1018,7 +1032,7 @@ static UINT WINAPI DpiFallbackGetDpiForWindow(HWND hWnd) { return 0; }
static UINT DpiNativeGetForMonitor(HMONITOR hMon)
{
static HRESULT(WINAPI*f)(HMONITOR, int, UINT*, UINT*);
if (!f && !((FARPROC&)f = GetProcAddr("SHCORE", "GetDpiForMonitor"))) f = DpiFallbackGetDpiForMonitor;
if (!f && !((FARPROC&)f = GetSysProcAddr("SHCORE", "GetDpiForMonitor"))) f = DpiFallbackGetDpiForMonitor;
UINT x, y, mdt_effective_dpi = 0;
return SUCCEEDED(f(hMon, mdt_effective_dpi, &x, &y)) ? y : 0;
}
@ -1034,7 +1048,7 @@ UINT DpiGetForWindow(HWND hWnd)
if (DpiAwarePerMonitor() || DpiAwarePerMonitor2())
{
static UINT(WINAPI*f)(HWND);
if (!f && !((FARPROC&)f = GetProcAddr("USER32", "GetDpiForWindow"))) f = DpiFallbackGetDpiForWindow;
if (!f && !((FARPROC&)f = GetSysProcAddr("USER32", "GetDpiForWindow"))) f = DpiFallbackGetDpiForWindow;
if ((dpi = f(hWnd))) return dpi;
}
if (DpiAwarePerMonitor() && (dpi = DpiGetForMonitor(hWnd))) return dpi;
@ -1064,7 +1078,7 @@ static BOOL DrawHorzGradient(HDC hDC, const RECT&rect, COLOR16 r1, COLOR16 g1, C
BOOL(WINAPI*gf)(HDC,TRIVERTEX*,ULONG,VOID*,ULONG,ULONG);
if (SupportsWNT4() || SupportsW95())
{
if (!((FARPROC&)gf = GetProcAddr("MSIMG32", "GradientFill")))
if (!((FARPROC&)gf = GetSysProcAddr("MSIMG32", "GradientFill")))
{
COLORREF orgclr = SetBkColor(hDC, RGB((((UINT)r1+r2)/2)>>8, (((UINT)g1+g2)/2)>>8, (((UINT)b1+b2)/2)>>8));
ExtTextOut(hDC, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""), 0, NULL); // TODO: Actually try to draw a gradient
@ -1099,7 +1113,7 @@ struct VisualStyles {
void InitUXTheme()
{
if (m_OpenThemeData) return ;
HMODULE hUXT = LoadLibraryA("UXTHEME");
HMODULE hUXT = LoadSysLibrary("UXTHEME");
if (!((FARPROC&) m_OpenThemeData = GetProcAddress(hUXT, "OpenThemeData"))) m_OpenThemeData = Compat_OpenThemeData;
(FARPROC&) CloseThemeData = GetProcAddress(hUXT, "CloseThemeData");
(FARPROC&) DrawThemeBackground = GetProcAddress(hUXT, "DrawThemeBackground");

View file

@ -42,6 +42,8 @@ void* MemAllocZI(SIZE_T cb);
void MemSafeFree(void*mem);
#define MemAlloc MemAllocZI
#define MemFree MemSafeFree
HMODULE LoadSysLibrary(LPCSTR Mod);
FARPROC GetSysProcAddr(LPCSTR Mod, LPCSTR FuncName);
bool WriteUTF16LEBOM(HANDLE hFile);
void FreeSpawn(PROCESS_INFORMATION *pPI, HANDLE hRd, HANDLE hWr);

View file

@ -16,9 +16,8 @@
#include "utils.h"
#include "resource.h"
static FARPROC GetModProc(LPCSTR Mod, LPCSTR Func) { return GetProcAddress(LoadLibraryA(Mod), Func); }
#define InitializeApiFuncWithFallback(mn, fn) { FARPROC f = GetModProc((mn), (#fn)); g_##fn = Compat_##fn; if (f) (FARPROC&) g_##fn = f; }
#define InitializeApiFunc(mn, fn) ( (FARPROC&)(g_##fn) = GetModProc((mn), (#fn)) )
#define InitializeApiFuncWithFallback(mn, fn) { FARPROC f = GetSysProcAddr((mn), (#fn)); g_##fn = Compat_##fn; if (f) (FARPROC&) g_##fn = f; }
#define InitializeApiFunc(mn, fn) ( (FARPROC&)(g_##fn) = GetSysProcAddr((mn), (#fn)) )
#define CallApiFunc(fn) ( g_##fn )
#define HasApiFunc(fn) ( !!(g_##fn) )
@ -122,7 +121,7 @@ static BOOL IsHung(HWND hWnd)
else
#endif
{
static FARPROC g_func = GetProcAddress(LoadLibraryA("USER32"), "IsHungAppWindow");
static FARPROC g_func = GetSysProcAddr("USER32", "IsHungAppWindow");
if (g_func) return ((BOOL(WINAPI*)(HWND))g_func)(hWnd);
DWORD_PTR mr;
LRESULT rv = SendMessageTimeout(hWnd, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 500, &mr);