From fa85ddb7750ad62b3e048c183e98f9506323c388 Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 27 Nov 2018 22:36:58 +0000 Subject: [PATCH] Use a undocumented variable as the nsDialogs::OnNotify return value so we don't have to worry about restoring it git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7055 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/defs.h | 1 + Contrib/nsDialogs/example.nsi | 1 + Contrib/nsDialogs/nsDialogs.c | 6 +++--- Contrib/nsDialogs/nsDialogs.nsh | 4 +--- Source/build.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Contrib/nsDialogs/defs.h b/Contrib/nsDialogs/defs.h index 14aa58b9..2eec3a71 100644 --- a/Contrib/nsDialogs/defs.h +++ b/Contrib/nsDialogs/defs.h @@ -7,6 +7,7 @@ #define NSDFUNC WINAPI +#define GetVar(vars, varlen, varid) ( (vars) + ((varid) * (varlen)) ) #define DlgRet(hDlg, val) ( SetWindowLongPtr((hDlg), DWLP_MSGRESULT, (val)) | TRUE ) #define StrToIntPtr nsishelper_str_to_ptr diff --git a/Contrib/nsDialogs/example.nsi b/Contrib/nsDialogs/example.nsi index 55bca4f8..b304f501 100644 --- a/Contrib/nsDialogs/example.nsi +++ b/Contrib/nsDialogs/example.nsi @@ -1,3 +1,4 @@ + !include nsDialogs.nsh !include LogicLib.nsh !include WinCore.nsh ; MAKELONG diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index 7688837d..3ce3fa3f 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -19,7 +19,7 @@ HINSTANCE g_hInstance; struct nsDialog g_dialog; extra_parameters* g_pluginParms; -LPTSTR g_var0; +LPTSTR g_callbackRetVar; static COLORREF GetLinkColor() { @@ -165,7 +165,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0); ret = *pFlag, *pFlag = orgFlag; if (ret) - return DlgRet(hwndDlg, StrToIntPtr(g_var0)); + return DlgRet(hwndDlg, StrToIntPtr(g_callbackRetVar)); } break; @@ -273,7 +273,7 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, TCHAR *varia g_dialog.hwParent = hwndParent; g_pluginParms = extra; - g_var0 = variables; + g_callbackRetVar = GetVar(variables, string_size, 31); // The undocumented $_OUTDIR variable hwPlacementRect = GetDlgItem(hwndParent, popint()); GetWindowRect(hwPlacementRect, &rcPlacement); diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index 1c882862..671f8e6f 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -415,9 +415,7 @@ Header file for creating custom installer pages with nsDialogs !define NSD_Return "!insertmacro NSD_Return " !macro NSD_Return val -!if "${val}" != "$0" - StrCpy $0 ${val} -!endif +StrCpy $_OUTDIR ${val} SetSilent silent Return !macroend diff --git a/Source/build.cpp b/Source/build.cpp index d2dbddb3..a549f4e1 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -344,7 +344,7 @@ CEXEBuild::CEXEBuild(signed char pponly, bool warnaserror) : m_UserVarNames.add(_T("EXEFILE"),-1); // 28 m_UserVarNames.add(_T("HWNDPARENT"),-1); // 29 m_UserVarNames.add(_T("_CLICK"),-1); // 30 - m_UserVarNames.add(_T("_OUTDIR"),1); // 31 + m_UserVarNames.add(_T("_OUTDIR"),1); // 31 Note: nsDialogs also uses this m_iBaseVarsNum = m_UserVarNames.getnum();