EvaluateScheduledTasks() => EvaluateSequence()

InstallScheduledTasks() => ExecuteSequence()

Dodal sem še projekt za MSICACert.dll, ki je trenutno še čista kopija MSICATS.dll.
This commit is contained in:
Simon Rozman 2014-03-13 10:57:11 +00:00
parent fcbb7bb3c9
commit 1ea0d5944d
19 changed files with 937 additions and 160 deletions

10
.gitattributes vendored
View File

@ -1,5 +1,15 @@
* text=auto !eol
/MSICA.sln svneol=CRLF#text/plain eol=crlf
MSICACert/L10N/sl_SI.po -text
MSICACert/MSICACert.cpp -text
MSICACert/MSICACert.h -text
MSICACert/MSICACert.rc -text svneol=unset#unset
MSICACert/MSICACert.rcx -text svneol=unset#unset
MSICACert/MSICACert.vcxproj -text svneol=unset#text/xml
MSICACert/MSICACert.vcxproj.filters -text svneol=unset#text/xml
MSICACert/msm/Makefile -text svneol=unset#text/plain%3B+charset%3DWindows-1250
MSICACert/stdafx.cpp -text
MSICACert/stdafx.h -text
MSICALib/L10N/sl_SI.po -text
MSICALib/MSICALib.cpp -text
MSICALib/MSICALib.h -text

12
.gitignore vendored
View File

@ -1,6 +1,18 @@
/*.opensdf
/*.sdf
/*.suo
MSICACert/*.user
MSICACert/L10N/*.mo
MSICACert/msm/*-1.idt
MSICACert/msm/*-2.idt
MSICACert/msm/*-2.idtx
MSICACert/msm/*.Binary-1
MSICACert/msm/*.Binary-2
MSICACert/msm/*.Icon-1
MSICACert/msm/*.Icon-2
MSICACert/msm/*.lst
MSICACert/msm/*.msm
MSICACert/temp
MSICALib/*.user
MSICALib/L10N/*.mo
MSICALib/msm/*-1.idt

View File

@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
include\version.h = include\version.h
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MSICACert", "MSICACert\MSICACert.vcxproj", "{0379563D-9835-44AC-928E-24D4E316CE5D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -34,6 +36,14 @@ Global
{A7D9EBC1-1E64-4399-9C88-6692F8742153}.Release|Win32.Build.0 = Release|Win32
{A7D9EBC1-1E64-4399-9C88-6692F8742153}.Release|x64.ActiveCfg = Release|x64
{A7D9EBC1-1E64-4399-9C88-6692F8742153}.Release|x64.Build.0 = Release|x64
{0379563D-9835-44AC-928E-24D4E316CE5D}.Debug|Win32.ActiveCfg = Debug|Win32
{0379563D-9835-44AC-928E-24D4E316CE5D}.Debug|Win32.Build.0 = Debug|Win32
{0379563D-9835-44AC-928E-24D4E316CE5D}.Debug|x64.ActiveCfg = Debug|x64
{0379563D-9835-44AC-928E-24D4E316CE5D}.Debug|x64.Build.0 = Debug|x64
{0379563D-9835-44AC-928E-24D4E316CE5D}.Release|Win32.ActiveCfg = Release|Win32
{0379563D-9835-44AC-928E-24D4E316CE5D}.Release|Win32.Build.0 = Release|Win32
{0379563D-9835-44AC-928E-24D4E316CE5D}.Release|x64.ActiveCfg = Release|x64
{0379563D-9835-44AC-928E-24D4E316CE5D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

73
MSICACert/L10N/sl_SI.po Normal file
View File

@ -0,0 +1,73 @@
msgid ""
msgstr ""
"Project-Id-Version: MSICACert\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-13 11:34+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <simon.rozman@amebis.si>\n"
"Language: sl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __\n"
"X-Poedit-Basepath: ..\n"
"X-Generator: Poedit 1.5.7\n"
"X-Poedit-SearchPath-0: .\n"
# Language Code and Windows Charset (hexadecimal)
# If we do not intend to provide different localization of same base language (like merging Portugal Portugeese and Brasil Portugese into the same Portugeese), use the code of Microsoft defined default sublanguage.
# For example: Use LANG_PORTUGUESE + SUBLANG_DEFAULT = 0x416, although 0x416 represents Brasil Portugese (too).
#: MSICACert.rcx:42
msgid "040904e4"
msgstr "042404e2"
# Language Code (hexadecimal)
# If we do not intend to provide different localization of same base language (like merging Portugal Portugeese and Brasil Portugese into the same Portugeese), use the code of Microsoft defined default sublanguage.
# For example: Use LANG_PORTUGUESE + SUBLANG_DEFAULT = 0x416, although 0x416 represents Brasil Portugese (too).
#: MSICACert.rcx:60
msgid "0x409"
msgstr "0x424"
# Windows charset for this language (decimal)
#: MSICACert.rcx:60
msgid "1252"
msgstr "1250"
# The name of the constant in RC to include the resources in this language.
#: MSICACert.rcx:41 MSICACert.rcx:59 MSICACert.rcx:75
msgid "AFX_TARG_ENU"
msgstr "AFX_TARG_SLV"
#: MSICACert.rcx:44
msgid "Amebis, d. o. o., Kamnik"
msgstr "Amebis, d. o. o., Kamnik"
#: MSICACert.rcx:45
msgid "Certificate Installation Support Library"
msgstr "Podporna knjižnica za nameščanje certifikatov"
#: MSICACert.rcx:48
msgid "Copyright © Amebis, d. o. o., Kamnik, 2012"
msgstr "Vse pravice pridržane © Amebis, d. o. o., Kamnik, 2012"
# Language Identifier (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx)
#: MSICACert.rcx:77
msgid "LANG_ENGLISH"
msgstr "LANG_SLOVENIAN"
#: MSICACert.rcx:47 MSICACert.rcx:49
msgid "MSICACert"
msgstr "MSICACert"
# Sublanguage Identifier (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx)
#: MSICACert.rcx:77
msgid "SUBLANG_DEFAULT"
msgstr "SUBLANG_DEFAULT"
#~ msgid "Scheduled task: [1]"
#~ msgstr "Razporejeno opravilo: [1]"
#~ msgid "Registering scheduled tasks"
#~ msgstr "Registracija razporejenih opravil"

216
MSICACert/MSICACert.cpp Normal file
View File

@ -0,0 +1,216 @@
#include "stdafx.h"
////////////////////////////////////////////////////////////////////////////
// Local constants
////////////////////////////////////////////////////////////////////////////
#define MSICACERT_TASK_TICK_SIZE (16*1024)
////////////////////////////////////////////////////////////////////////////
// Global functions
////////////////////////////////////////////////////////////////////////////
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(lpReserved);
return TRUE;
}
////////////////////////////////////////////////////////////////////
// Exported functions
////////////////////////////////////////////////////////////////////
UINT MSICACERT_API EvaluateSequence(MSIHANDLE hInstall)
{
UINT uiResult;
HRESULT hr;
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
MSICA::COpList olExecute;
BOOL bRollbackEnabled;
PMSIHANDLE
hDatabase,
hRecordProg = ::MsiCreateRecord(3);
ATL::CAtlString sValue;
// Check and add the rollback enabled state.
uiResult = ::MsiGetProperty(hInstall, _T("RollbackDisabled"), sValue);
bRollbackEnabled = uiResult == ERROR_SUCCESS ?
_ttoi(sValue) || !sValue.IsEmpty() && _totlower(sValue.GetAt(0)) == _T('y') ? FALSE : TRUE :
TRUE;
olExecute.AddTail(new MSICA::COpRollbackEnable(bRollbackEnabled));
// Open MSI database.
hDatabase = ::MsiGetActiveDatabase(hInstall);
if (hDatabase) {
// Check if ScheduledTask table exists. If it doesn't exist, there's nothing to do.
MSICONDITION condition = ::MsiDatabaseIsTablePersistent(hDatabase, _T("ScheduledTask"));
if (condition == MSICONDITION_FALSE || condition == MSICONDITION_TRUE) {
PMSIHANDLE hViewST;
// Prepare a query to get a list/view of tasks.
uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Task,DisplayName,Application,Parameters,Directory_,Flags,Priority,User,Password,Author,Description,IdleMin,IdleDeadline,MaxRuntime,Condition,Component_ FROM ScheduledTask"), &hViewST);
if (uiResult == ERROR_SUCCESS) {
// Execute query!
uiResult = ::MsiViewExecute(hViewST, NULL);
if (uiResult == ERROR_SUCCESS) {
//ATL::CAtlString sComponent;
ATL::CAtlStringW sDisplayName;
for (;;) {
PMSIHANDLE hRecord;
INSTALLSTATE iInstalled, iAction;
// Fetch one record from the view.
uiResult = ::MsiViewFetch(hViewST, &hRecord);
if (uiResult == ERROR_NO_MORE_ITEMS) {
uiResult = ERROR_SUCCESS;
break;
} else if (uiResult != ERROR_SUCCESS)
break;
// Read and evaluate task's condition.
uiResult = ::MsiRecordGetString(hRecord, 15, sValue);
if (uiResult != ERROR_SUCCESS) break;
condition = ::MsiEvaluateCondition(hInstall, sValue);
if (condition == MSICONDITION_FALSE)
continue;
else if (condition == MSICONDITION_ERROR) {
uiResult = ERROR_INVALID_FIELD;
break;
}
// Read task's Component ID.
uiResult = ::MsiRecordGetString(hRecord, 16, sValue);
if (uiResult != ERROR_SUCCESS) break;
// Get the component state.
uiResult = ::MsiGetComponentState(hInstall, sValue, &iInstalled, &iAction);
if (uiResult != ERROR_SUCCESS) break;
// Get task's DisplayName.
uiResult = ::MsiRecordFormatStringW(hInstall, hRecord, 2, sDisplayName);
if (iAction >= INSTALLSTATE_LOCAL) {
// Component is or should be installed. Create the task.
PMSIHANDLE hViewTT;
MSICA::COpTaskCreate *opCreateTask = new MSICA::COpTaskCreate(sDisplayName, MSICACERT_TASK_TICK_SIZE);
// Populate the operation with task's data.
uiResult = opCreateTask->SetFromRecord(hInstall, hRecord);
if (uiResult != ERROR_SUCCESS) break;
// Perform another query to get task's triggers.
uiResult = ::MsiDatabaseOpenView(hDatabase, _T("SELECT Trigger,BeginDate,EndDate,StartTime,StartTimeRand,MinutesDuration,MinutesInterval,Flags,Type,DaysInterval,WeeksInterval,DaysOfTheWeek,DaysOfMonth,WeekOfMonth,MonthsOfYear FROM TaskTrigger WHERE Task_=?"), &hViewTT);
if (uiResult != ERROR_SUCCESS) break;
// Execute query!
uiResult = ::MsiViewExecute(hViewTT, hRecord);
if (uiResult == ERROR_SUCCESS) {
// Populate trigger list.
uiResult = opCreateTask->SetTriggersFromView(hViewTT);
::MsiViewClose(hViewTT);
if (uiResult != ERROR_SUCCESS) break;
} else
break;
olExecute.AddTail(opCreateTask);
} else if (iAction >= INSTALLSTATE_REMOVED) {
// Component is installed, but should be degraded to advertised/removed. Delete the task.
olExecute.AddTail(new MSICA::COpTaskDelete(sDisplayName, MSICACERT_TASK_TICK_SIZE));
}
// The amount of tick space to add for each task to progress indicator.
::MsiRecordSetInteger(hRecordProg, 1, 3 );
::MsiRecordSetInteger(hRecordProg, 2, MSICACERT_TASK_TICK_SIZE);
if (::MsiProcessMessage(hInstall, INSTALLMESSAGE_PROGRESS, hRecordProg) == IDCANCEL) { uiResult = ERROR_INSTALL_USEREXIT; break; }
}
::MsiViewClose(hViewST);
if (SUCCEEDED(uiResult)) {
ATL::CAtlString sSequenceFilename;
ATL::CAtlFile fSequence;
// Prepare our own sequence script file.
// The InstallCertificates is a deferred custom action, thus all this information will be unavailable to it.
// Therefore save all required info to file now.
{
LPTSTR szBuffer = sSequenceFilename.GetBuffer(MAX_PATH);
::GetTempPath(MAX_PATH, szBuffer);
::GetTempFileName(szBuffer, _T("TS"), 0, szBuffer);
sSequenceFilename.ReleaseBuffer();
}
// Save execute sequence to file.
hr = olExecute.SaveToFile(sSequenceFilename);
if (SUCCEEDED(hr)) {
// Store sequence script file names to properties for deferred custiom actions.
uiResult = ::MsiSetProperty(hInstall, _T("InstallCertificates"), sSequenceFilename);
if (uiResult == ERROR_SUCCESS) {
LPCTSTR pszExtension = ::PathFindExtension(sSequenceFilename);
ATL::CAtlString sSequenceFilename2;
sSequenceFilename2.Format(_T("%.*ls-rb%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
uiResult = ::MsiSetProperty(hInstall, _T("RollbackCertificates"), sSequenceFilename2);
if (uiResult == ERROR_SUCCESS) {
sSequenceFilename2.Format(_T("%.*ls-cm%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
uiResult = ::MsiSetProperty(hInstall, _T("CommitCertificates"), sSequenceFilename2);
if (uiResult != ERROR_SUCCESS) {
::MsiRecordSetInteger(hRecordProg, 1, ERROR_INSTALL_PROPERTY_SET);
::MsiRecordSetString (hRecordProg, 2, _T("CommitCertificates"));
::MsiRecordSetInteger(hRecordProg, 3, uiResult );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
::MsiRecordSetInteger(hRecordProg, 1, ERROR_INSTALL_PROPERTY_SET );
::MsiRecordSetString (hRecordProg, 2, _T("RollbackCertificates"));
::MsiRecordSetInteger(hRecordProg, 3, uiResult );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
::MsiRecordSetInteger(hRecordProg, 1, ERROR_INSTALL_PROPERTY_SET );
::MsiRecordSetString (hRecordProg, 2, _T("InstallCertificates"));
::MsiRecordSetInteger(hRecordProg, 3, uiResult );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
if (uiResult != ERROR_SUCCESS) ::DeleteFile(sSequenceFilename);
} else {
uiResult = ERROR_INSTALL_SCRIPT_WRITE;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilename);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else if (uiResult != ERROR_INSTALL_USEREXIT) {
::MsiRecordSetInteger(hRecordProg, 1, ERROR_INSTALL_OPLIST_CREATE);
::MsiRecordSetInteger(hRecordProg, 2, uiResult );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
::MsiRecordSetInteger(hRecordProg, 1, uiResult);
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
::MsiRecordSetInteger(hRecordProg, 1, uiResult);
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
}
} else {
uiResult = ERROR_INSTALL_DATABASE_OPEN;
::MsiRecordSetInteger(hRecordProg, 1, uiResult);
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
olExecute.Free();
if (bIsCoInitialized) ::CoUninitialize();
return uiResult;
}
UINT MSICACERT_API ExecuteSequence(MSIHANDLE hInstall)
{
return MSICA::ExecuteSequence(hInstall);
}

34
MSICACert/MSICACert.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef __MSICACERT_H__
#define __MSICACERT_H__
#include <msi.h>
////////////////////////////////////////////////////////////////////
// Calling declaration
////////////////////////////////////////////////////////////////////
#if defined(MSICACERT_DLL)
#define MSICACERT_API __declspec(dllexport)
#elif defined(MSICACERT_DLLIMP)
#define MSICACERT_API __declspec(dllimport)
#else
#define MSICACERT_API
#endif
////////////////////////////////////////////////////////////////////
// Exported functions
////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
UINT MSICACERT_API EvaluateSequence(MSIHANDLE hInstall);
UINT MSICACERT_API ExecuteSequence(MSIHANDLE hInstall);
#ifdef __cplusplus
}
#endif
#endif // __MSICACERT_H__

BIN
MSICACert/MSICACert.rc Normal file

Binary file not shown.

BIN
MSICACert/MSICACert.rcx Normal file

Binary file not shown.

171
MSICACert/MSICACert.vcxproj Normal file
View File

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0379563D-9835-44AC-928E-24D4E316CE5D}</ProjectGuid>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfAtl>Static</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\rcxgettext.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\common.props" />
<Import Project="..\include\Win32.props" />
<Import Project="..\include\Release.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\common.props" />
<Import Project="..\include\Win32.props" />
<Import Project="..\include\Debug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\common.props" />
<Import Project="..\include\x64.props" />
<Import Project="..\include\Release.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\common.props" />
<Import Project="..\include\x64.props" />
<Import Project="..\include\Debug.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\output\$(Configuration).$(Platform)\</OutDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</IgnoreImportLibrary>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\output\$(Configuration).$(Platform)\</OutDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</IgnoreImportLibrary>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\output\$(Configuration).$(Platform)\</OutDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</IgnoreImportLibrary>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\output\$(Configuration).$(Platform)\</OutDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</IgnoreImportLibrary>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<HeaderFileName>%(Filename)_h.h</HeaderFileName>
</Midl>
<ClCompile />
<ResourceLocalizator>
<LanguageCatalogs>L10N\sl_SI.po</LanguageCatalogs>
</ResourceLocalizator>
<ClCompile />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<HeaderFileName>%(Filename)_h.h</HeaderFileName>
</Midl>
<ClCompile />
<ResourceLocalizator>
<LanguageCatalogs>L10N\sl_SI.po</LanguageCatalogs>
</ResourceLocalizator>
<ClCompile />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<HeaderFileName>%(Filename)_h.h</HeaderFileName>
</Midl>
<ClCompile />
<ResourceLocalizator>
<LanguageCatalogs>L10N\sl_SI.po</LanguageCatalogs>
</ResourceLocalizator>
<ClCompile />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Midl>
<HeaderFileName>%(Filename)_h.h</HeaderFileName>
</Midl>
<ClCompile />
<ResourceLocalizator>
<LanguageCatalogs>L10N\sl_SI.po</LanguageCatalogs>
</ResourceLocalizator>
<ClCompile />
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MSICACert.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MSICACert.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MSICACert.rc" />
</ItemGroup>
<ItemGroup>
<ResourceLocalizator Include="MSICACert.rcx" />
</ItemGroup>
<ItemGroup>
<None Include="L10N\sl_SI.po" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MSICALib\MSICALib.vcxproj">
<Project>{8552ee55-177e-4f51-b51b-baf7d6462cde}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\rcxgettext.targets" />
</ImportGroup>
</Project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;rcx;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;po</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MSICACert.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MSICACert.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MSICACert.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ResourceLocalizator Include="MSICACert.rcx">
<Filter>Resource Files</Filter>
</ResourceLocalizator>
</ItemGroup>
<ItemGroup>
<None Include="L10N\sl_SI.po">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

167
MSICACert/msm/Makefile Normal file
View File

@ -0,0 +1,167 @@
!INCLUDE "..\..\include\MSIBuildCfg.mak"
MSIBUILD_IS_LOCALIZEABLE=1
######################################################################
# _Validation
All :: "$(LANG).$(PLAT).$(CFG)._Validation-1.idt"
"$(LANG).$(PLAT).$(CFG)._Validation-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Table Column Nullable MinValue MaxValue KeyTable KeyColumn Category Set Description
s32 s32 s4 I4 I4 S255 I2 S32 S255 S255
_Validation Table Column
ScheduledTask Task N Identifier Primary key, non-localized token.
ScheduledTask DisplayName N Formatted Task name.
ScheduledTask Application N Formatted Task application name.
ScheduledTask Parameters Y Formatted Task command line parameters.
ScheduledTask Directory_ N Directory 1 Identifier Task working directory.
ScheduledTask Flags N DoubleInteger Task's flags to pass in IScheduledWorkItem::SetFlags() call.
ScheduledTask Priority N DoubleInteger 32;64;128;256;16384,32768 Task's priority to pass in ITask::SetPriority() call.
ScheduledTask User Y Formatted Account name to run task as. Use empty string for system account.
ScheduledTask Password Y Formatted Account password to run task as. Use NULL for system account.
ScheduledTask Author Y Formatted Task author.
ScheduledTask Description Y Formatted Task description.
ScheduledTask IdleMin Y Integer A value that specifies how long, in minutes, the system must remain idle before the work item can run.
ScheduledTask IdleDeadline Y Integer A value that specifies the maximum number of minutes that the Task Scheduler will wait for the idle-time period.
ScheduledTask MaxRuntime N DoubleInteger Specifies the maximum run time (in milliseconds), for the task. This parameter may be set to -1 to specify an unlimited time.
ScheduledTask Condition Y Condition Optional expression which skips the task if evaluates to expFalse. If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.
ScheduledTask Component_ N Component 1 Identifier Component the task is part of.
TaskTrigger Trigger N Identifier Primary key, non-localized token.
TaskTrigger BeginDate N DoubleInteger Date that the task trigger activates (counted in days from January 1st, 1980). The beginning date must be specified when setting a task.
TaskTrigger EndDate Y DoubleInteger Date that the task trigger deactivates (counted in days from January 1st, 1980).
TaskTrigger StartTime N DoubleInteger Time of the day the task runs (counted in minutes since midnight).
TaskTrigger StartTimeRand Y Integer Maximum random number of minutes to add to start time.
TaskTrigger MinutesDuration Y DoubleInteger Number of minutes after the task starts that the trigger will remain active. The number of minutes specified here must be greater than or equal to the MinutesInterval column.
TaskTrigger MinutesInterval Y DoubleInteger Number of minutes between consecutive task executions. This number is counted from the start of the previous scheduled task. The number of minutes specified here must be less than the MinutesDuration column.
TaskTrigger Flags N DoubleInteger Value that describes the behavior of the trigger. This value is a combination of the flags in TASK_TRIGGER::rgFlags.
TaskTrigger Type N 0 7 Integer A TASK_TRIGGER_TYPE enumerated value that specifies the type of trigger. This member is used with Type. The type of trigger specified here determines which fields of the TRIGGER_TYPE_UNION specified in Type member will be used. Trigger type is based on when the trigger will run the task.
TaskTrigger DaysInterval Y Integer Specifies the number of days between task runs.
TaskTrigger WeeksInterval Y Integer Number of weeks between invocations of a task.
TaskTrigger DaysOfTheWeek Y 0 127 Integer Value that describes the days of the week the task runs. This value is a bitfield and is a combination of the following values: 1=Sun, 2=Mon, 4=Tue, 8=Wed, 16=Thu, 32=Fri, 64=Sat.
TaskTrigger DaysOfMonth Y DoubleInteger Specifies the day of the month a task runs. This value is a bitfield that specifies the day(s) the task will run. Bit 0 corresponds to the first of the month, bit 1 to the second, and so forth.
TaskTrigger WeekOfMonth Y Integer 1;2;3;4;5 Specifies the week of the month when the task runs. This value is exclusive and is one of the following: 1=The task will run between the first and seventh day of the month, 2=The task will run between the eighth and 14th day of the month, 3=The task will run between the 15th and 21st day of the month, 4=The task will run between the 22nd and 28th of the month, 5=The task will run between the last seven days of the month.
TaskTrigger MonthsOfYear Y 0 4095 Integer Specifies the month(s) when the task runs. This value is a combination of the following values: 1=Jan, 2=Feb, 4=Mar, 8=Apr, 16=May, 32=Jun, 64=Jul, 128=Aug, 256=Sep, 512=Oct, 1024=Nov, 2048=Dec.
TaskTrigger Task_ N ScheduledTask 1 Identifier Key of the Trigger's task.
<<NOKEEP
######################################################################
# ActionText
All :: "$(LANG).$(PLAT).$(CFG).ActionText-2.idt"
"En.$(PLAT).$(CFG).ActionText-2.idtx" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Action Description Template
s$(MSIBUILD_LENGTH_ID) L0 L0
1250 ActionText Action
InstallCertificates Installing certificates Certificate: [1]
<<NOKEEP
"De.$(CFG).$(PLAT).ActionText-2.idt" : "En.$(PLAT).$(CFG).ActionText-2.idtx" "..\L10N\de_DE.po"
rcxgettext.exe idtp $@ $**
"En.$(PLAT).$(CFG).ActionText-2.idt" : "En.$(PLAT).$(CFG).ActionText-2.idtx"
copy /y $** $@ > NUL
"It.$(CFG).$(PLAT).ActionText-2.idt" : "En.$(PLAT).$(CFG).ActionText-2.idtx" "..\L10N\it_IT.po"
rcxgettext.exe idtp $@ $**
"Sl.$(CFG).$(PLAT).ActionText-2.idt" : "En.$(PLAT).$(CFG).ActionText-2.idtx" "..\L10N\sl_SI.po"
rcxgettext.exe idtp $@ $**
######################################################################
# Binary
All :: \
"$(LANG).$(PLAT).$(CFG).Binary-1.idt" \
"$(LANG).$(PLAT).$(CFG).Binary-1\MSICACert.dll"
"$(LANG).$(PLAT).$(CFG).Binary-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak"" "$(LANG).$(PLAT).$(CFG).Binary-1"
-if exist $@ del /f /q $@
move /y << $@ > NUL
Name Data
s$(MSIBUILD_LENGTH_ID) v0
Binary Name
binMSICACert.dll MSICACert.dll
<<NOKEEP
"$(LANG).$(PLAT).$(CFG).Binary-1\MSICACert.dll" : "..\..\Test\$(CFG).$(PLAT)\MSICACert.dll"
copy /y $** $@ > NUL
######################################################################
# CustomAction
All :: "$(LANG).$(PLAT).$(CFG).CustomAction-1.idt"
"$(LANG).$(PLAT).$(CFG).CustomAction-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Action Type Source Target
s$(MSIBUILD_LENGTH_ID) i2 S$(MSIBUILD_LENGTH_ID) S255
CustomAction Action
EvaluateCertificates 1 binMSICACert.dll EvaluateSequence
InstallCertificates 3073 binMSICACert.dll ExecuteSequence
RollbackCertificates 3329 binMSICACert.dll ExecuteSequence
CommitCertificates 3585 binMSICACert.dll ExecuteSequence
<<NOKEEP
######################################################################
# InstallExecuteSequence
All :: "$(LANG).$(PLAT).$(CFG).InstallExecuteSequence-1.idt"
"$(LANG).$(PLAT).$(CFG).InstallExecuteSequence-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Action Condition Sequence
s$(MSIBUILD_LENGTH_ID) S255 I2
InstallExecuteSequence Action
EvaluateCertificates 6577
RollbackCertificates 6576
InstallCertificates 6578
CommitCertificates 6579
<<NOKEEP
######################################################################
# ScheduledTask
All :: "$(LANG).$(PLAT).$(CFG).ScheduledTask-1.idt"
"$(LANG).$(PLAT).$(CFG).ScheduledTask-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Task DisplayName Application Parameters Directory_ Flags Priority User Password Author Description IdleMin IdleDeadline MaxRuntime Condition Component_
s$(MSIBUILD_LENGTH_ID) l255 s255 S255 s$(MSIBUILD_LENGTH_ID) i4 i4 S255 S255 L255 L0 I2 I2 i4 S255 s$(MSIBUILD_LENGTH_ID)
ScheduledTask Task
<<NOKEEP
######################################################################
# TaskTrigger
All :: "$(LANG).$(PLAT).$(CFG).TaskTrigger-1.idt"
"$(LANG).$(PLAT).$(CFG).TaskTrigger-1.idt" : "Makefile" ""..\..\include\MSIBuildCfg.mak""
-if exist $@ del /f /q $@
move /y << $@ > NUL
Trigger BeginDate EndDate StartTime StartTimeRand MinutesDuration MinutesInterval Flags Type DaysInterval WeeksInterval DaysOfTheWeek DaysOfMonth WeekOfMonth MonthsOfYear Task_
s$(MSIBUILD_LENGTH_ID) i2 I2 i2 I2 I4 I4 i4 i2 I2 I2 I2 I4 I2 I2 s$(MSIBUILD_LENGTH_ID)
TaskTrigger Trigger
<<NOKEEP
######################################################################
# Build MSM module!
######################################################################
!INCLUDE "..\..\MSIBuild\MSM.mak"

1
MSICACert/stdafx.cpp Normal file
View File

@ -0,0 +1 @@
#include "stdafx.h"

37
MSICACert/stdafx.h Normal file
View File

@ -0,0 +1,37 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#if defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#if defined(_WIN32) && !defined(WIN32)
#define WIN32
#endif
#ifndef STRICT
#define STRICT
#endif
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define _WIN32_WINNT 0x0501 // Include Windows XP symbols
#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
#ifdef _WINDLL
#define MSICACERT_DLL // This is a DLL
#endif
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
#include <atlfile.h>
#include <atlstr.h>
#include <corerror.h>
#include <stdlib.h>
#include <time.h>
#include "..\MSICALib\MSICALib.h"
#include "MSICACert.h"

View File

@ -181,4 +181,127 @@ CSession::~CSession()
m_olCommit.Free();
}
////////////////////////////////////////////////////////////////////////////
// Helper functions
////////////////////////////////////////////////////////////////////////////
UINT ExecuteSequence(MSIHANDLE hInstall)
{
UINT uiResult;
HRESULT hr;
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
ATL::CAtlString sSequenceFilename;
uiResult = ::MsiGetProperty(hInstall, _T("CustomActionData"), sSequenceFilename);
if (uiResult == ERROR_SUCCESS) {
MSICA::COpList lstOperations;
BOOL bIsCleanup = ::MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
// Load operation sequence.
hr = lstOperations.LoadFromFile(sSequenceFilename);
if (SUCCEEDED(hr)) {
MSICA::CSession session;
session.m_hInstall = hInstall;
// In case of commit/rollback, continue sequence on error, to do as much cleanup as possible.
session.m_bContinueOnError = bIsCleanup;
// Execute the operations.
hr = lstOperations.Execute(&session);
if (!bIsCleanup) {
// Save cleanup scripts of delayed action regardless of action's execution status.
// Rollback action MUST be scheduled in InstallExecuteSequence before this action! Otherwise cleanup won't be performed in case this action execution failed.
LPCTSTR pszExtension = ::PathFindExtension(sSequenceFilename);
ATL::CAtlString sSequenceFilenameCM, sSequenceFilenameRB;
HRESULT hr;
sSequenceFilenameRB.Format(_T("%.*ls-rb%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
sSequenceFilenameCM.Format(_T("%.*ls-cm%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
// After commit, delete rollback file. After rollback, delete commit file.
session.m_olCommit.AddTail(new MSICA::COpFileDelete(
#ifdef _UNICODE
sSequenceFilenameRB
#else
ATL::CAtlStringW(sSequenceFilenameRB)
#endif
));
session.m_olRollback.AddTail(new MSICA::COpFileDelete(
#ifdef _UNICODE
sSequenceFilenameCM
#else
ATL::CAtlStringW(sSequenceFilenameCM)
#endif
));
// Save commit file first.
hr = session.m_olCommit.SaveToFile(sSequenceFilenameCM);
if (SUCCEEDED(hr)) {
// Save rollback file next.
hr = session.m_olRollback.SaveToFile(sSequenceFilenameRB);
if (SUCCEEDED(hr)) {
uiResult = ERROR_SUCCESS;
} else {
// Saving rollback file failed.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_WRITE;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilenameRB);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
// Saving commit file failed.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_WRITE;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilenameCM);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
if (uiResult != ERROR_SUCCESS) {
// The commit and/or rollback scripts were not written to file successfully. Perform the cleanup immediately.
session.m_bContinueOnError = TRUE;
session.m_bRollbackEnabled = FALSE;
session.m_olRollback.Execute(&session);
::DeleteFile(sSequenceFilenameRB);
}
} else {
// No cleanup after cleanup support.
uiResult = ERROR_SUCCESS;
}
if (FAILED(hr)) {
// Execution of the action failed.
uiResult = HRESULT_CODE(hr);
}
::DeleteFile(sSequenceFilename);
} else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) && bIsCleanup) {
// Sequence file not found and this is rollback/commit action. Either of the following scenarios are possible:
// - The delayed action failed to save the rollback/commit file. The delayed action performed cleanup itself. No further action is required.
// - Somebody removed the rollback/commit file between delayed action and rollback/commit action. No further action is possible.
uiResult = ERROR_SUCCESS;
} else {
// Sequence loading failed. Probably, LOCAL SYSTEM doesn't have read access to user's temp directory.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_READ;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilename);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
lstOperations.Free();
} else {
// Couldn't get CustomActionData property. uiResult has the error code.
}
if (bIsCoInitialized) ::CoUninitialize();
return uiResult;
}
} // namespace MSICA

View File

@ -516,6 +516,13 @@ public:
COpList m_olCommit; // Commit operation list
};
////////////////////////////////////////////////////////////////////////////
// Helper functions
////////////////////////////////////////////////////////////////////////////
UINT ExecuteSequence(MSIHANDLE hInstall);
} // namespace MSICA

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: MSICATS\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-06-07 20:27+0100\n"
"POT-Creation-Date: 2014-03-13 11:35+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <simon.rozman@amebis.si>\n"
@ -14,64 +14,60 @@ msgstr ""
"X-Poedit-KeywordsList: __\n"
"X-Poedit-Basepath: ..\n"
"X-Generator: Poedit 1.5.7\n"
"X-Poedit-SearchPath-0: res\n"
"X-Poedit-SearchPath-1: msm\n"
"X-Poedit-SearchPath-0: .\n"
# Language Code and Windows Charset (hexadecimal)
# If we do not intend to provide different localization of same base language (like merging Portugal Portugeese and Brasil Portugese into the same Portugeese), use the code of Microsoft defined default sublanguage.
# For example: Use LANG_PORTUGUESE + SUBLANG_DEFAULT = 0x416, although 0x416 represents Brasil Portugese (too).
#: MSICATS.rcx:43
#: MSICATS.rcx:42
msgid "040904e4"
msgstr "042404e2"
# Language Code (hexadecimal)
# If we do not intend to provide different localization of same base language (like merging Portugal Portugeese and Brasil Portugese into the same Portugeese), use the code of Microsoft defined default sublanguage.
# For example: Use LANG_PORTUGUESE + SUBLANG_DEFAULT = 0x416, although 0x416 represents Brasil Portugese (too).
#: MSICATS.rcx:61
#: MSICATS.rcx:60
msgid "0x409"
msgstr "0x424"
# Windows charset for this language (decimal)
#: MSICATS.rcx:61 ..\msm/Sl.DebugU.Win32.ActionText-2.idtx:3
#: ..\msm/Sl.DebugU.Win32.Error-2.idtx:3
#: MSICATS.rcx:60
msgid "1252"
msgstr "1250"
# The name of the constant in RC to include the resources in this language.
#: MSICATS.rcx:42 MSICATS.rcx:60 MSICATS.rcx:76
#: MSICATS.rcx:41 MSICATS.rcx:59 MSICATS.rcx:75
msgid "AFX_TARG_ENU"
msgstr "AFX_TARG_SLV"
#: MSICATS.rcx:45
#: MSICATS.rcx:44
msgid "Amebis, d. o. o., Kamnik"
msgstr "Amebis, d. o. o., Kamnik"
#: MSICATS.rcx:48
msgid "Copyright © Amebis, d. o. o., Kamnik, 2012"
msgstr "Vse pravice pridržane © Amebis, d. o. o., Kamnik, 2012"
# Language Identifier (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx)
#: MSICATS.rcx:78
#: MSICATS.rcx:77
msgid "LANG_ENGLISH"
msgstr "LANG_SLOVENIAN"
#: MSICATS.rcx:48 MSICATS.rcx:50
#: MSICATS.rcx:47 MSICATS.rcx:49
msgid "MSICATS"
msgstr "MSICATS"
#: MSICATS.rcx:46
#: MSICATS.rcx:45
msgid "Scheduled Task Installation Support Library"
msgstr "Podporna knjižnica za nameščanje načrtovanih opravil"
# Sublanguage Identifier (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx)
#: MSICATS.rcx:78
#: MSICATS.rcx:77
msgid "SUBLANG_DEFAULT"
msgstr "SUBLANG_DEFAULT"
#: MSICATS.rcx:49
msgid "Copyright © Amebis, d. o. o., Kamnik, 2012"
msgstr "Vse pravice pridržane © Amebis, d. o. o., Kamnik, 2012"
#~ msgid "Scheduled task: [1]"
#~ msgstr "Razporejeno opravilo: [1]"
#: ..\msm/Sl.DebugU.Win32.ActionText-2.idtx:4
msgid "Scheduled task: [1]"
msgstr "Razporejeno opravilo: [1]"
#: ..\msm/Sl.DebugU.Win32.ActionText-2.idtx:4
msgid "Registering scheduled tasks"
msgstr "Registracija razporejenih opravil"
#~ msgid "Registering scheduled tasks"
#~ msgstr "Registracija razporejenih opravil"

View File

@ -17,19 +17,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRes
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(lpReserved);
switch (dwReason) {
case DLL_PROCESS_ATTACH:
//assert(0); // Attach debugger here, or press "Ignore"!
// Randomize!
srand((unsigned)time(NULL));
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
@ -38,7 +25,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRes
// Exported functions
////////////////////////////////////////////////////////////////////
UINT MSICATS_API EvaluateScheduledTasks(MSIHANDLE hInstall)
UINT MSICATS_API EvaluateSequence(MSIHANDLE hInstall)
{
UINT uiResult;
HRESULT hr;
@ -223,122 +210,7 @@ UINT MSICATS_API EvaluateScheduledTasks(MSIHANDLE hInstall)
}
UINT MSICATS_API InstallScheduledTasks(MSIHANDLE hInstall)
UINT MSICATS_API ExecuteSequence(MSIHANDLE hInstall)
{
UINT uiResult;
HRESULT hr;
BOOL bIsCoInitialized = SUCCEEDED(::CoInitialize(NULL));
ATL::CAtlString sSequenceFilename;
uiResult = ::MsiGetProperty(hInstall, _T("CustomActionData"), sSequenceFilename);
if (uiResult == ERROR_SUCCESS) {
MSICA::COpList lstOperations;
BOOL bIsCleanup = ::MsiGetMode(hInstall, MSIRUNMODE_COMMIT) || ::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK);
//assert(0); // Attach debugger here, or press "Ignore"!
// Load operation sequence.
hr = lstOperations.LoadFromFile(sSequenceFilename);
if (SUCCEEDED(hr)) {
MSICA::CSession session;
session.m_hInstall = hInstall;
// In case of commit/rollback, continue sequence on error, to do as much cleanup as possible.
session.m_bContinueOnError = bIsCleanup;
// Execute the operations.
hr = lstOperations.Execute(&session);
if (!bIsCleanup) {
// Save cleanup scripts of delayed action regardless of action's execution status.
// Rollback action MUST be scheduled in InstallExecuteSequence before this action! Otherwise cleanup won't be performed in case this action execution failed.
LPCTSTR pszExtension = ::PathFindExtension(sSequenceFilename);
ATL::CAtlString sSequenceFilenameCM, sSequenceFilenameRB;
HRESULT hr;
sSequenceFilenameRB.Format(_T("%.*ls-rb%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
sSequenceFilenameCM.Format(_T("%.*ls-cm%ls"), pszExtension - (LPCTSTR)sSequenceFilename, (LPCTSTR)sSequenceFilename, pszExtension);
// After commit, delete rollback file. After rollback, delete commit file.
session.m_olCommit.AddTail(new MSICA::COpFileDelete(
#ifdef _UNICODE
sSequenceFilenameRB
#else
ATL::CAtlStringW(sSequenceFilenameRB)
#endif
));
session.m_olRollback.AddTail(new MSICA::COpFileDelete(
#ifdef _UNICODE
sSequenceFilenameCM
#else
ATL::CAtlStringW(sSequenceFilenameCM)
#endif
));
// Save commit file first.
hr = session.m_olCommit.SaveToFile(sSequenceFilenameCM);
if (SUCCEEDED(hr)) {
// Save rollback file next.
hr = session.m_olRollback.SaveToFile(sSequenceFilenameRB);
if (SUCCEEDED(hr)) {
uiResult = ERROR_SUCCESS;
} else {
// Saving rollback file failed.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_WRITE;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilenameRB);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
} else {
// Saving commit file failed.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_WRITE;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilenameCM);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
if (uiResult != ERROR_SUCCESS) {
// The commit and/or rollback scripts were not written to file successfully. Perform the cleanup immediately.
session.m_bContinueOnError = TRUE;
session.m_bRollbackEnabled = FALSE;
session.m_olRollback.Execute(&session);
::DeleteFile(sSequenceFilenameRB);
}
} else {
// No cleanup after cleanup support.
uiResult = ERROR_SUCCESS;
}
if (FAILED(hr)) {
// Execution of the action failed.
uiResult = HRESULT_CODE(hr);
}
::DeleteFile(sSequenceFilename);
} else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) && bIsCleanup) {
// Sequence file not found and this is rollback/commit action. Either of the following scenarios are possible:
// - The delayed action failed to save the rollback/commit file. The delayed action performed cleanup itself. No further action is required.
// - Somebody removed the rollback/commit file between delayed action and rollback/commit action. No further action is possible.
uiResult = ERROR_SUCCESS;
} else {
// Sequence loading failed. Probably, LOCAL SYSTEM doesn't have read access to user's temp directory.
PMSIHANDLE hRecordProg = ::MsiCreateRecord(3);
uiResult = ERROR_INSTALL_SCRIPT_READ;
::MsiRecordSetInteger(hRecordProg, 1, uiResult );
::MsiRecordSetString (hRecordProg, 2, sSequenceFilename);
::MsiRecordSetInteger(hRecordProg, 3, hr );
::MsiProcessMessage(hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
}
lstOperations.Free();
} else {
// Couldn't get CustomActionData property. uiResult has the error code.
}
if (bIsCoInitialized) ::CoUninitialize();
return uiResult;
return MSICA::ExecuteSequence(hInstall);
}

View File

@ -24,8 +24,8 @@
extern "C" {
#endif
UINT MSICATS_API EvaluateScheduledTasks(MSIHANDLE hInstall);
UINT MSICATS_API InstallScheduledTasks(MSIHANDLE hInstall);
UINT MSICATS_API EvaluateSequence(MSIHANDLE hInstall);
UINT MSICATS_API ExecuteSequence(MSIHANDLE hInstall);
#ifdef __cplusplus
}

View File

@ -107,10 +107,10 @@ All :: "$(LANG).$(PLAT).$(CFG).CustomAction-1.idt"
Action Type Source Target
s$(MSIBUILD_LENGTH_ID) i2 S$(MSIBUILD_LENGTH_ID) S255
CustomAction Action
EvaluateScheduledTasks 1 binMSICATS.dll EvaluateScheduledTasks
InstallScheduledTasks 3073 binMSICATS.dll InstallScheduledTasks
RollbackScheduledTasks 3329 binMSICATS.dll InstallScheduledTasks
CommitScheduledTasks 3585 binMSICATS.dll InstallScheduledTasks
EvaluateScheduledTasks 1 binMSICATS.dll EvaluateSequence
InstallScheduledTasks 3073 binMSICATS.dll ExecuteSequence
RollbackScheduledTasks 3329 binMSICATS.dll ExecuteSequence
CommitScheduledTasks 3585 binMSICATS.dll ExecuteSequence
<<NOKEEP