moved manifest generation to a seprate file and added made it support vista's access level extensions
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4751 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
f4bfa52981
commit
2f15840257
6 changed files with 108 additions and 8 deletions
|
@ -13,6 +13,7 @@ makensis_files = Split("""
|
||||||
lang.cpp
|
lang.cpp
|
||||||
lineparse.cpp
|
lineparse.cpp
|
||||||
makenssi.cpp
|
makenssi.cpp
|
||||||
|
manifest.cpp
|
||||||
mmap.cpp
|
mmap.cpp
|
||||||
Plugins.cpp
|
Plugins.cpp
|
||||||
ResourceEditor.cpp
|
ResourceEditor.cpp
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "fileform.h"
|
#include "fileform.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
|
#include "manifest.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
@ -226,6 +227,9 @@ CEXEBuild::CEXEBuild() :
|
||||||
|
|
||||||
res_editor=0;
|
res_editor=0;
|
||||||
|
|
||||||
|
manifest_comctl = manifest::comctl_old;
|
||||||
|
manifest_exec_level = manifest::exec_level_none;
|
||||||
|
|
||||||
enable_last_page_cancel=0;
|
enable_last_page_cancel=0;
|
||||||
uenable_last_page_cancel=0;
|
uenable_last_page_cancel=0;
|
||||||
|
|
||||||
|
@ -2113,6 +2117,26 @@ int CEXEBuild::SetVarsSection()
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEXEBuild::SetManifest()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
init_res_editor();
|
||||||
|
|
||||||
|
string manifest = manifest::generate(manifest_comctl, manifest_exec_level);
|
||||||
|
|
||||||
|
if (manifest == "")
|
||||||
|
return PS_OK;
|
||||||
|
|
||||||
|
res_editor->UpdateResource(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
||||||
|
}
|
||||||
|
catch (exception& err) {
|
||||||
|
ERROR_MSG("Error while setting manifest: %s\n", err.what());
|
||||||
|
return PS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int CEXEBuild::check_write_output_errors() const
|
int CEXEBuild::check_write_output_errors() const
|
||||||
{
|
{
|
||||||
if (has_called_write_output)
|
if (has_called_write_output)
|
||||||
|
@ -2273,6 +2297,9 @@ int CEXEBuild::write_output(void)
|
||||||
// Setup user variables PE section
|
// Setup user variables PE section
|
||||||
RET_UNLESS_OK( SetVarsSection() );
|
RET_UNLESS_OK( SetVarsSection() );
|
||||||
|
|
||||||
|
// Set XML manifest
|
||||||
|
RET_UNLESS_OK( SetManifest() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Save all changes to the exe header
|
// Save all changes to the exe header
|
||||||
close_res_editor();
|
close_res_editor();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "uservars.h"
|
#include "uservars.h"
|
||||||
#include "ShConstants.h"
|
#include "ShConstants.h"
|
||||||
#include "mmap.h"
|
#include "mmap.h"
|
||||||
|
#include "manifest.h"
|
||||||
|
|
||||||
#include "exehead/fileform.h"
|
#include "exehead/fileform.h"
|
||||||
#include "exehead/config.h"
|
#include "exehead/config.h"
|
||||||
|
@ -217,6 +218,7 @@ class CEXEBuild {
|
||||||
void PrepareInstTypes();
|
void PrepareInstTypes();
|
||||||
void PrepareHeaders(IGrowBuf *hdrbuf);
|
void PrepareHeaders(IGrowBuf *hdrbuf);
|
||||||
int SetVarsSection();
|
int SetVarsSection();
|
||||||
|
int SetManifest();
|
||||||
|
|
||||||
int resolve_jump_int(const char *fn, int *a, int offs, int start, int end);
|
int resolve_jump_int(const char *fn, int *a, int offs, int start, int end);
|
||||||
int resolve_call_int(const char *fn, const char *str, int fptr, int *ofs);
|
int resolve_call_int(const char *fn, const char *str, int fptr, int *ofs);
|
||||||
|
@ -375,6 +377,9 @@ class CEXEBuild {
|
||||||
int deflateToFile(FILE *fp, char *buf, int len); // len==0 to flush
|
int deflateToFile(FILE *fp, char *buf, int len); // len==0 to flush
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
manifest::comctl manifest_comctl;
|
||||||
|
manifest::exec_level manifest_exec_level;
|
||||||
|
|
||||||
CResourceEditor *res_editor;
|
CResourceEditor *res_editor;
|
||||||
void init_res_editor();
|
void init_res_editor();
|
||||||
void close_res_editor();
|
void close_res_editor();
|
||||||
|
|
46
Source/manifest.cpp
Normal file
46
Source/manifest.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#include "Platform.h"
|
||||||
|
#include "manifest.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
namespace manifest
|
||||||
|
{
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string generate(comctl comctl_selection, exec_level exec_level_selection)
|
||||||
|
{
|
||||||
|
if (comctl_selection == comctl_old && exec_level_selection == exec_level_none)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System " NSIS_VERSION "</description>";
|
||||||
|
|
||||||
|
if (comctl_selection == comctl_xp)
|
||||||
|
{
|
||||||
|
xml += "<dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"X86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" /></dependentAssembly></dependency>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exec_level_selection != exec_level_none)
|
||||||
|
{
|
||||||
|
string level = "";
|
||||||
|
|
||||||
|
switch (exec_level_selection)
|
||||||
|
{
|
||||||
|
case exec_level_user:
|
||||||
|
level = "asInvoker";
|
||||||
|
break;
|
||||||
|
case exec_level_admin:
|
||||||
|
level = "requireAdministrator";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xml += "<trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v3\"><security><requestedPrivileges><requestedExecutionLevel level=\"";
|
||||||
|
xml += level;
|
||||||
|
xml += "\" uiAccess=\"false\"/></requestedPrivileges></security></trustInfo>";
|
||||||
|
}
|
||||||
|
|
||||||
|
xml += "</assembly>";
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
24
Source/manifest.h
Normal file
24
Source/manifest.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef ___MANIFEST_H___
|
||||||
|
#define ___MANIFEST_H___
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace manifest
|
||||||
|
{
|
||||||
|
enum comctl
|
||||||
|
{
|
||||||
|
comctl_old,
|
||||||
|
comctl_xp
|
||||||
|
};
|
||||||
|
|
||||||
|
enum exec_level
|
||||||
|
{
|
||||||
|
exec_level_none,
|
||||||
|
exec_level_user,
|
||||||
|
exec_level_admin
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string generate(comctl, exec_level);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif//!___MANIFEST_H___
|
|
@ -2332,17 +2332,14 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
case TOK_XPSTYLE:
|
case TOK_XPSTYLE:
|
||||||
try {
|
{
|
||||||
int k=line.gettoken_enum(1,"on\0off\0");
|
int k=line.gettoken_enum(1,"on\0off\0");
|
||||||
if (k == -1) PRINTHELP()
|
if (k == -1) PRINTHELP()
|
||||||
SCRIPT_MSG("XPStyle: %s\n", line.gettoken_str(1));
|
SCRIPT_MSG("XPStyle: %s\n", line.gettoken_str(1));
|
||||||
init_res_editor();
|
if (!k)
|
||||||
const char *szXPManifest = k ? 0 : "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System " NSIS_VERSION "</description><dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"X86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" /></dependentAssembly></dependency></assembly>";
|
manifest_comctl = manifest::comctl_xp;
|
||||||
res_editor->UpdateResource(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (unsigned char*)szXPManifest, k ? 0 : strlen(szXPManifest));
|
else
|
||||||
}
|
manifest_comctl = manifest::comctl_old;
|
||||||
catch (exception& err) {
|
|
||||||
ERROR_MSG("Error while adding XP style: %s\n", err.what());
|
|
||||||
return PS_ERROR;
|
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
case TOK_CHANGEUI:
|
case TOK_CHANGEUI:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue