From fb6945ec36bf69bc0f5622b643b27b1d52370f90 Mon Sep 17 00:00:00 2001 From: anders_k Date: Thu, 6 Jun 2019 00:42:08 +0000 Subject: [PATCH] Added ManifestMaxVersionTested git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7096 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/attributes.but | 4 ++++ Docs/src/history.but | 6 ++++++ Source/build.cpp | 6 +++--- Source/build.h | 1 + Source/manifest.cpp | 22 +++++++++++++++++----- Source/manifest.h | 13 +++++++++++-- Source/script.cpp | 7 ++++++- Source/tokens.cpp | 1 + Source/tokens.h | 1 + 9 files changed, 50 insertions(+), 11 deletions(-) diff --git a/Docs/src/attributes.but b/Docs/src/attributes.but index a0c28ac0..5b481443 100644 --- a/Docs/src/attributes.but +++ b/Docs/src/attributes.but @@ -301,6 +301,10 @@ Declare that the installer is compatible with the specified Windows version(s). Windows 8.1 and later will fake its version number if you don't declare support for that particular version. You can read more about the other changes in behavior on \W{http://msdn.microsoft.com/en-us/library/windows/desktop/hh848036}{MSDN}. +\# \S2{amanifestmaxversiontested} ManifestMaxVersionTested +\# +\# \c maj.min.bld.rev + \S2{amiscbuttontext} MiscButtonText \c [back_button_text [next_button_text] [cancel_button_text] [close_button_text]] diff --git a/Docs/src/history.but b/Docs/src/history.but index ca1f451e..59267ffa 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -16,6 +16,8 @@ ANSI targets are deprecated, consider moving to Unicode. \b Added \R{loadandsetimage}{LoadAndSetImage} +\# Undocumented: \b Added ManifestMaxVersionTested + \b Allow quoted library path in System::Call (\W{http://sf.net/p/nsis/bugs/546}{bug #546}) \b %1 in !finalize command can be specified multiple times @@ -55,6 +57,8 @@ Released on December 15th, 2018 \b AddBrandingImage now supports dialog units +\# Undocumented: \b Added ManifestDisableWindowFiltering and ManifestGdiScaling + \b Fixed !macroundef of last defined macro bug \b Fixed MultiUser caption string bug (\W{http://sf.net/p/nsis/bugs/1012}{bug #1012}) @@ -103,6 +107,8 @@ Released on January 29th, 2018 \b Added more !define /math operators +\# Undocumented: \b Added ManifestDPIAwareness + \b Added WinVer.nsh IsDomainController (\W{http://sf.net/p/nsis/patches/286}{patch #286}) \b Plug-ins now set the ASLR, DEP, LAA, NOSEH and TS PE flags (\W{http://sf.net/p/nsis/bugs/1188}{bug #1188}) diff --git a/Source/build.cpp b/Source/build.cpp index 67cd7249..d7707722 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -2383,8 +2383,8 @@ int CEXEBuild::SetManifest() { try { init_res_editor(); - // This should stay ANSI - string manifest = manifest::generate((manifest::flags)manifest_flags, manifest_comctl, manifest_exec_level, manifest_dpiaware, manifest_dpiawareness.c_str(), manifest_sosl); + manifest::SPECIFICATION spec = { (manifest::flags) manifest_flags, manifest_dpiaware, manifest_dpiawareness.c_str(), manifest_sosl, manifest_maxversiontested.c_str() }; + string manifest = manifest::generate(manifest_comctl, manifest_exec_level, spec); if (manifest == "") return PS_OK; @@ -2394,7 +2394,7 @@ int CEXEBuild::SetManifest() // return PS_OK; // Allow user to completely override the manifest with PEAddResource // Saved directly as binary into the exe. - res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), (DWORD)manifest.length()); + res_editor->UpdateResource(MAKEINTRESOURCE(24), 1, NSIS_DEFAULT_LANG, (LPBYTE) const_cast(manifest.c_str()), (DWORD) manifest.length()); } catch (exception& err) { ERROR_MSG(_T("Error setting manifest: %") NPRIs _T("\n"), CtoTStrParam(err.what())); diff --git a/Source/build.h b/Source/build.h index e4b8b926..ef289ca0 100644 --- a/Source/build.h +++ b/Source/build.h @@ -684,6 +684,7 @@ class CEXEBuild { manifest::dpiaware manifest_dpiaware; tstring manifest_dpiawareness; manifest::SupportedOSList manifest_sosl; + tstring manifest_maxversiontested; CResourceEditor *res_editor; void init_res_editor(); diff --git a/Source/manifest.cpp b/Source/manifest.cpp index 3a2dfde8..344b2d7b 100644 --- a/Source/manifest.cpp +++ b/Source/manifest.cpp @@ -91,8 +91,14 @@ bool SupportedOSList::append(const TCHAR* osid) } -string generate(flags featureflags, comctl comctl_selection, exec_level exec_level_selection, dpiaware dpia, const TCHAR*dpia2, SupportedOSList& sosl) +string generate(comctl comctl_selection, exec_level exec_level_selection, const SPECIFICATION&spec) { + flags featureflags = spec.Flags; + dpiaware dpia = spec.DPIA; + const TCHAR *dpia2 = spec.DPIA2; + SupportedOSList& sosl = spec.SOSL; + const TCHAR *mvt = spec.MaxVersionTested; + bool default_or_empty_sosl = sosl.isdefaultlist() || !sosl.getcount(); if (comctl_selection == comctl_old && exec_level_selection == exec_level_none && default_or_empty_sosl && dpiaware_notset == dpia) return ""; @@ -136,15 +142,21 @@ string generate(flags featureflags, comctl comctl_selection, exec_level exec_lev } int soslcount = sosl.getcount(); - if (soslcount) + if (soslcount || *mvt) { char buf[38+1]; xml += ""; while(soslcount--) { xml += ""; + xml += (RawTStrToASCII(sosl.get(soslcount), buf, COUNTOF(buf)), buf); + xml += "\"/>"; + } + if (*mvt) + { + xml += ""; } xml += ""; } @@ -165,7 +177,7 @@ string generate(flags featureflags, comctl comctl_selection, exec_level exec_lev if (dpiaware_notset != dpia) { xml_aws += ""; - xml_aws += dpia >= dpiaware_permonitor ? "True/PM" : dpiaware_false != dpia ? "true" : "false"; + xml_aws += dpia == dpiaware_explorer ? "Explorer" : dpia >= dpiaware_permonitor ? "True/PM" : dpiaware_false != dpia ? "true" : "false"; xml_aws += ""; } if (*dpia2) diff --git a/Source/manifest.h b/Source/manifest.h index 5487ecf1..8f98dd18 100644 --- a/Source/manifest.h +++ b/Source/manifest.h @@ -50,7 +50,8 @@ namespace manifest dpiaware_notset, dpiaware_false, dpiaware_true, // System DPI on Vista+ - dpiaware_permonitor // System DPI on Vista/7/8, PerMonitor on 8.1+ + dpiaware_permonitor, // System DPI on Vista/7/8, PerMonitor on 8.1+ + dpiaware_explorer // Win8.1+? Undocumented? }; class SupportedOSList // Win7+ @@ -86,7 +87,15 @@ namespace manifest } }; - std::string generate(flags, comctl, exec_level, dpiaware, const TCHAR*, SupportedOSList&); + typedef struct { + flags Flags; + dpiaware DPIA; + const TCHAR *DPIA2; // Win10FU1607+ + SupportedOSList& SOSL; + const TCHAR *MaxVersionTested; // Win10FU1903+ github.com/microsoft/AppConsult-WinAppsModernizationWorkshop/tree/master/Exercise2 + } SPECIFICATION; + + std::string generate(comctl, exec_level, const SPECIFICATION&); }; diff --git a/Source/script.cpp b/Source/script.cpp index a4c5a8f8..0afb0578 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2331,7 +2331,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) return PS_OK; case TOK_MANIFEST_DPIAWARE: - switch(line.gettoken_enum(1,_T("none\0notset\0false\0true\0system\0permonitor\0"))) + switch(line.gettoken_enum(1,_T("none\0notset\0false\0true\0system\0permonitor\0explorer\0"))) { case 0: // A lot of attributes use "none" so we support that along with the documented value case 1: manifest_dpiaware = manifest::dpiaware_notset; break; @@ -2339,6 +2339,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) case 3: // "True" == "System DPI" case 4: manifest_dpiaware = manifest::dpiaware_true; break; case 5: manifest_dpiaware = manifest::dpiaware_permonitor; break; + case 6: manifest_dpiaware = manifest::dpiaware_explorer; break; default: PRINTHELP(); } return PS_OK; @@ -2360,6 +2361,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) PRINTHELP(); } return PS_OK; + case TOK_MANIFEST_MAXVERSIONTESTED: + manifest_maxversiontested = line.gettoken_enum(1, _T("none\0notset\0")) == -1 ? line.gettoken_str(1) : _T(""); + return PS_OK; + case TOK_MANIFEST_DISABLEWINDOWFILTERING: switch(line.gettoken_enum(1,_T("notset\0false\0true"))) { diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 12f18584..8112b714 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -259,6 +259,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_MANIFEST_DPIAWARE,_T("ManifestDPIAware"),1,0,_T("notset|true|false"),TP_GLOBAL}, {TOK_MANIFEST_DPIAWARENESS,_T("ManifestDPIAwareness"),1,0,_T("comma_separated_string"),TP_GLOBAL}, {TOK_MANIFEST_SUPPORTEDOS,_T("ManifestSupportedOS"),1,-1,_T("none|all|WinVista|Win7|Win8|Win8.1|Win10|{GUID} [...]"),TP_GLOBAL}, +{TOK_MANIFEST_MAXVERSIONTESTED,_T("ManifestMaxVersionTested"),1,0,_T("maj.min.bld.rev"),TP_GLOBAL}, {TOK_MANIFEST_DISABLEWINDOWFILTERING,_T("ManifestDisableWindowFiltering"),1,0,_T("notset|true"),TP_GLOBAL}, {TOK_MANIFEST_GDISCALING,_T("ManifestGdiScaling"),1,0,_T("notset|true"),TP_GLOBAL}, {TOK_P_PACKEXEHEADER,_T("!packhdr"),2,0,_T("temp_file_name command_line_to_compress_that_temp_file"),TP_ALL}, diff --git a/Source/tokens.h b/Source/tokens.h index 81c54d8d..cdc0fefa 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -68,6 +68,7 @@ enum TOK_MANIFEST_DPIAWARE, TOK_MANIFEST_DPIAWARENESS, TOK_MANIFEST_SUPPORTEDOS, + TOK_MANIFEST_MAXVERSIONTESTED, TOK_MANIFEST_DISABLEWINDOWFILTERING, TOK_MANIFEST_GDISCALING, TOK_CHANGEUI,