mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
[Setup] add support for embedded MSIX packages (#13263)
This commit is contained in:
5
.github/actions/spell-check/expect.txt
vendored
5
.github/actions/spell-check/expect.txt
vendored
@@ -12,10 +12,10 @@ Acceleratorkeys
|
|||||||
ACCEPTFILES
|
ACCEPTFILES
|
||||||
accessibile
|
accessibile
|
||||||
accessibilityinsights
|
accessibilityinsights
|
||||||
|
Accessible
|
||||||
Acl
|
Acl
|
||||||
aclapi
|
aclapi
|
||||||
AColumn
|
AColumn
|
||||||
Accessible
|
|
||||||
acos
|
acos
|
||||||
acrt
|
acrt
|
||||||
Actioncenter
|
Actioncenter
|
||||||
@@ -126,8 +126,8 @@ AUTOMATIONPROPERTIES
|
|||||||
Autorun
|
Autorun
|
||||||
AUTOSIZECOLUMNS
|
AUTOSIZECOLUMNS
|
||||||
AUTOUPDATE
|
AUTOUPDATE
|
||||||
AValid
|
|
||||||
available
|
available
|
||||||
|
AValid
|
||||||
awakeversion
|
awakeversion
|
||||||
AWAYMODE
|
AWAYMODE
|
||||||
AYUV
|
AYUV
|
||||||
@@ -1321,6 +1321,7 @@ msiquery
|
|||||||
MSIRESTARTMANAGERCONTROL
|
MSIRESTARTMANAGERCONTROL
|
||||||
msix
|
msix
|
||||||
msixbundle
|
msixbundle
|
||||||
|
MSIXCA
|
||||||
MSIXVERSION
|
MSIXVERSION
|
||||||
MSLLHOOKSTRUCT
|
MSLLHOOKSTRUCT
|
||||||
Mso
|
Mso
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
#include "pch.h"
|
|
||||||
#include "RcResource.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
std::optional<RcResource> RcResource::create(int resource_id, const std::wstring_view resource_class)
|
|
||||||
{
|
|
||||||
const HRSRC resHandle = FindResourceW(nullptr, MAKEINTRESOURCEW(resource_id), resource_class.data());
|
|
||||||
if (!resHandle)
|
|
||||||
{
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const HGLOBAL memHandle = LoadResource(nullptr, resHandle);
|
|
||||||
if (!memHandle)
|
|
||||||
{
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t resSize = SizeofResource(nullptr, resHandle);
|
|
||||||
if (!resSize)
|
|
||||||
{
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto res = static_cast<const std::byte*>(LockResource(memHandle));
|
|
||||||
if (!res)
|
|
||||||
{
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RcResource{ res, resSize };
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RcResource::saveAsFile(const std::filesystem::path destination)
|
|
||||||
{
|
|
||||||
std::fstream installerFile{ destination, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc };
|
|
||||||
if (!installerFile.is_open())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
installerFile.write(reinterpret_cast<const char*>(_memory), _size);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,9 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
class RcResource
|
class RcResource
|
||||||
{
|
{
|
||||||
@@ -10,8 +13,46 @@ public:
|
|||||||
const std::byte* _memory = nullptr;
|
const std::byte* _memory = nullptr;
|
||||||
size_t _size = 0;
|
size_t _size = 0;
|
||||||
|
|
||||||
static std::optional<RcResource> create(int resource_id, const std::wstring_view resource_class);
|
static inline std::optional<RcResource> create(int resource_id, const std::wstring_view resource_class, const HINSTANCE handle = nullptr)
|
||||||
bool saveAsFile(const std::filesystem::path destination);
|
{
|
||||||
|
const HRSRC resHandle = FindResourceW(handle, MAKEINTRESOURCEW(resource_id), resource_class.data());
|
||||||
|
if (!resHandle)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HGLOBAL memHandle = LoadResource(handle, resHandle);
|
||||||
|
if (!memHandle)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t resSize = SizeofResource(handle, resHandle);
|
||||||
|
if (!resSize)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto res = static_cast<const std::byte*>(LockResource(memHandle));
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RcResource{ res, resSize };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool saveAsFile(const std::filesystem::path destination)
|
||||||
|
{
|
||||||
|
std::fstream installerFile{ destination, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc };
|
||||||
|
if (!installerFile.is_open())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
installerFile.write(reinterpret_cast<const char*>(_memory), _size);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RcResource() = delete;
|
RcResource() = delete;
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ int Bootstrapper(HINSTANCE hInstance)
|
|||||||
|
|
||||||
if (!package_path.empty() && !uninstall_msi_version(package_path))
|
if (!package_path.empty() && !uninstall_msi_version(package_path))
|
||||||
{
|
{
|
||||||
spdlog::error("Couldn't install the existing MSI package ({})", GetLastError());
|
spdlog::error("Couldn't uninstall the existing MSI package ({})", GetLastError());
|
||||||
ShowMessageBoxError(IDS_UNINSTALL_PREVIOUS_VERSION_ERROR);
|
ShowMessageBoxError(IDS_UNINSTALL_PREVIOUS_VERSION_ERROR);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,6 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="progressbar_window.cpp" />
|
<ClCompile Include="progressbar_window.cpp" />
|
||||||
<ClCompile Include="RcResource.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="DotnetInstallation.h" />
|
<ClInclude Include="DotnetInstallation.h" />
|
||||||
|
|||||||
@@ -94,13 +94,20 @@
|
|||||||
</Custom>
|
</Custom>
|
||||||
<Custom Action="WixCloseApplications" Before="RemoveFiles" />
|
<Custom Action="WixCloseApplications" Before="RemoveFiles" />
|
||||||
<Custom Action="RemovePowerToysSchTasks" After="RemoveFiles" />
|
<Custom Action="RemovePowerToysSchTasks" After="RemoveFiles" />
|
||||||
|
<!-- TODO: Use to activate embedded MSIX -->
|
||||||
|
<!--<Custom Action="InstallEmbeddedMSIXTask" After="InstallFinalize">
|
||||||
|
NOT Installed
|
||||||
|
</Custom>-->
|
||||||
<Custom Action="TelemetryLogInstallSuccess" After="InstallFinalize">
|
<Custom Action="TelemetryLogInstallSuccess" After="InstallFinalize">
|
||||||
NOT Installed
|
NOT Installed
|
||||||
</Custom>
|
</Custom>
|
||||||
<Custom Action="TelemetryLogUninstallSuccess" After="InstallFinalize">
|
<Custom Action="TelemetryLogUninstallSuccess" After="InstallFinalize">
|
||||||
Installed and (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
Installed and (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
||||||
</Custom>
|
</Custom>
|
||||||
|
<!-- TODO: Use to activate embedded MSIX -->
|
||||||
|
<!--<Custom Action="UninstallEmbeddedMSIXTask" After="InstallFinalize">
|
||||||
|
Installed AND (REMOVE="ALL")
|
||||||
|
</Custom>-->
|
||||||
<Custom Action="TerminateProcesses" Before="InstallValidate" />
|
<Custom Action="TerminateProcesses" Before="InstallValidate" />
|
||||||
|
|
||||||
</InstallExecuteSequence>
|
</InstallExecuteSequence>
|
||||||
@@ -133,7 +140,21 @@
|
|||||||
DllEntry="RemoveScheduledTasksCA"
|
DllEntry="RemoveScheduledTasksCA"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CustomAction Id="TelemetryLogInstallSuccess"
|
<CustomAction Id="InstallEmbeddedMSIXTask"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="yes"
|
||||||
|
BinaryKey="PTCustomActions"
|
||||||
|
DllEntry="InstallEmbeddedMSIXCA"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="UninstallEmbeddedMSIXTask"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="yes"
|
||||||
|
BinaryKey="PTCustomActions"
|
||||||
|
DllEntry="UninstallEmbeddedMSIXCA"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="TelemetryLogInstallSuccess"
|
||||||
Return="ignore"
|
Return="ignore"
|
||||||
Impersonate="yes"
|
Impersonate="yes"
|
||||||
BinaryKey="PTCustomActions"
|
BinaryKey="PTCustomActions"
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "resource.h"
|
||||||
#include <ProjectTelemetry.h>
|
#include <ProjectTelemetry.h>
|
||||||
|
|
||||||
#include "../../src/common/utils/MsiUtils.h"
|
#include "../../src/common/utils/MsiUtils.h"
|
||||||
#include "../../src/common/updating/installer.h"
|
#include "../../src/common/updating/installer.h"
|
||||||
#include "../../src/common/version/version.h"
|
#include "../../src/common/version/version.h"
|
||||||
|
|
||||||
|
#include "../../installer/PowerToysBootstrapper/bootstrapper/RcResource.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
HINSTANCE DLL_HANDLE = nullptr;
|
||||||
|
|
||||||
TRACELOGGING_DEFINE_PROVIDER(
|
TRACELOGGING_DEFINE_PROVIDER(
|
||||||
g_hProvider,
|
g_hProvider,
|
||||||
"Microsoft.PowerToysInstaller",
|
"Microsoft.PowerToysInstaller",
|
||||||
@@ -21,6 +25,78 @@ const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0'
|
|||||||
static const wchar_t* POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}";
|
static const wchar_t* POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}";
|
||||||
static const wchar_t* POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}";
|
static const wchar_t* POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}";
|
||||||
|
|
||||||
|
UINT __stdcall InstallEmbeddedMSIXCA(MSIHANDLE hInstall)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
UINT er = ERROR_SUCCESS;
|
||||||
|
hr = WcaInitialize(hInstall, "InstallEmbeddedMSIXCA");
|
||||||
|
ExitOnFailure(hr, "Failed to initialize");
|
||||||
|
|
||||||
|
if (auto msix = RcResource::create(IDR_BIN_MSIX_HELLO_PACKAGE, L"BIN", DLL_HANDLE))
|
||||||
|
{
|
||||||
|
WcaLog(LOGMSG_STANDARD, "Extracted MSIX");
|
||||||
|
// TODO: Use to activate embedded MSIX
|
||||||
|
const auto msix_path = std::filesystem::temp_directory_path() / "hello_package.msix";
|
||||||
|
if (!msix->saveAsFile(msix_path))
|
||||||
|
{
|
||||||
|
ExitOnFailure(hr, "Failed to save msix");
|
||||||
|
}
|
||||||
|
WcaLog(LOGMSG_STANDARD, "Saved MSIX");
|
||||||
|
using namespace winrt::Windows::Management::Deployment;
|
||||||
|
using namespace winrt::Windows::Foundation;
|
||||||
|
|
||||||
|
Uri msix_uri{ msix_path.wstring() };
|
||||||
|
PackageManager pm;
|
||||||
|
auto result = pm.AddPackageAsync(msix_uri, nullptr, DeploymentOptions::None).get();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
ExitOnFailure(hr, "Failed to AddPackage");
|
||||||
|
}
|
||||||
|
|
||||||
|
WcaLog(LOGMSG_STANDARD, "MSIX[s] were installed!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExitOnFailure(hr, "Failed to extract msix");
|
||||||
|
}
|
||||||
|
|
||||||
|
LExit:
|
||||||
|
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
||||||
|
return WcaFinalize(er);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT __stdcall UninstallEmbeddedMSIXCA(MSIHANDLE hInstall)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
UINT er = ERROR_SUCCESS;
|
||||||
|
using namespace winrt::Windows::Management::Deployment;
|
||||||
|
using namespace winrt::Windows::Foundation;
|
||||||
|
// TODO: This must be replaced with the actual publisher and package name
|
||||||
|
const wchar_t package_name[] = L"46b35c25-b593-48d5-aeb1-d3e9c3b796e9";
|
||||||
|
const wchar_t publisher[] = L"CN=yuyoyuppe";
|
||||||
|
PackageManager pm;
|
||||||
|
|
||||||
|
hr = WcaInitialize(hInstall, "UninstallEmbeddedMSIXCA");
|
||||||
|
ExitOnFailure(hr, "Failed to initialize");
|
||||||
|
|
||||||
|
for (const auto& p : pm.FindPackagesForUser({}, package_name, publisher))
|
||||||
|
{
|
||||||
|
auto result = pm.RemovePackageAsync(p.Id().FullName()).get();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
WcaLog(LOGMSG_STANDARD, "MSIX was uninstalled!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WcaLog(LOGMSG_STANDARD, "Couldn't uninstall MSIX!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LExit:
|
||||||
|
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
||||||
|
return WcaFinalize(er);
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a Scheduled Task to run at logon for the current user.
|
// Creates a Scheduled Task to run at logon for the current user.
|
||||||
// The path of the executable to run should be passed as the CustomActionData (Value).
|
// The path of the executable to run should be passed as the CustomActionData (Value).
|
||||||
// Based on the Task Scheduler Logon Trigger Example:
|
// Based on the Task Scheduler Logon Trigger Example:
|
||||||
@@ -42,12 +118,12 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
|
|||||||
ITaskSettings* pSettings = nullptr;
|
ITaskSettings* pSettings = nullptr;
|
||||||
ITriggerCollection* pTriggerCollection = nullptr;
|
ITriggerCollection* pTriggerCollection = nullptr;
|
||||||
IRegisteredTask* pRegisteredTask = nullptr;
|
IRegisteredTask* pRegisteredTask = nullptr;
|
||||||
IPrincipal * pPrincipal = nullptr;
|
IPrincipal* pPrincipal = nullptr;
|
||||||
ITrigger * pTrigger = nullptr;
|
ITrigger* pTrigger = nullptr;
|
||||||
ILogonTrigger * pLogonTrigger = nullptr;
|
ILogonTrigger* pLogonTrigger = nullptr;
|
||||||
IAction * pAction = nullptr;
|
IAction* pAction = nullptr;
|
||||||
IActionCollection * pActionCollection = nullptr;
|
IActionCollection* pActionCollection = nullptr;
|
||||||
IExecAction * pExecAction = nullptr;
|
IExecAction* pExecAction = nullptr;
|
||||||
|
|
||||||
LPWSTR wszExecutablePath = nullptr;
|
LPWSTR wszExecutablePath = nullptr;
|
||||||
|
|
||||||
@@ -190,7 +266,6 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
|
|||||||
pActionCollection->Release();
|
pActionCollection->Release();
|
||||||
ExitOnFailure(hr, "Cannot create the action: %x", hr);
|
ExitOnFailure(hr, "Cannot create the action: %x", hr);
|
||||||
|
|
||||||
|
|
||||||
// QI for the executable task pointer.
|
// QI for the executable task pointer.
|
||||||
hr = pAction->QueryInterface(
|
hr = pAction->QueryInterface(
|
||||||
IID_IExecAction, (void**)&pExecAction);
|
IID_IExecAction, (void**)&pExecAction);
|
||||||
@@ -302,7 +377,7 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
|
|||||||
ITaskService* pService = nullptr;
|
ITaskService* pService = nullptr;
|
||||||
ITaskFolder* pTaskFolder = nullptr;
|
ITaskFolder* pTaskFolder = nullptr;
|
||||||
IRegisteredTaskCollection* pTaskCollection = nullptr;
|
IRegisteredTaskCollection* pTaskCollection = nullptr;
|
||||||
ITaskFolder * pRootFolder = nullptr;
|
ITaskFolder* pRootFolder = nullptr;
|
||||||
LONG numTasks = 0;
|
LONG numTasks = 0;
|
||||||
|
|
||||||
hr = WcaInitialize(hInstall, "RemoveScheduledTasksCA");
|
hr = WcaInitialize(hInstall, "RemoveScheduledTasksCA");
|
||||||
@@ -589,9 +664,8 @@ UINT __stdcall DetectPrevInstallPathCA(MSIHANDLE hInstall)
|
|||||||
MsiSetPropertyW(hInstall, L"INSTALLFOLDER", install_path->data());
|
MsiSetPropertyW(hInstall, L"INSTALLFOLDER", install_path->data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
||||||
return WcaFinalize(er);
|
return WcaFinalize(er);
|
||||||
@@ -609,7 +683,7 @@ UINT __stdcall CertifyVirtualCameraDriverCA(MSIHANDLE hInstall)
|
|||||||
HCERTSTORE hCertStore = nullptr;
|
HCERTSTORE hCertStore = nullptr;
|
||||||
HANDLE hfile = nullptr;
|
HANDLE hfile = nullptr;
|
||||||
DWORD size = INVALID_FILE_SIZE;
|
DWORD size = INVALID_FILE_SIZE;
|
||||||
char * pFileContent = nullptr;
|
char* pFileContent = nullptr;
|
||||||
|
|
||||||
hr = WcaInitialize(hInstall, "CertifyVirtualCameraDriverCA");
|
hr = WcaInitialize(hInstall, "CertifyVirtualCameraDriverCA");
|
||||||
ExitOnFailure(hr, "Failed to initialize", hr);
|
ExitOnFailure(hr, "Failed to initialize", hr);
|
||||||
@@ -648,11 +722,11 @@ UINT __stdcall CertifyVirtualCameraDriverCA(MSIHANDLE hInstall)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!CertAddEncodedCertificateToStore(hCertStore,
|
if (!CertAddEncodedCertificateToStore(hCertStore,
|
||||||
X509_ASN_ENCODING,
|
X509_ASN_ENCODING,
|
||||||
(const BYTE*)pFileContent,
|
(const BYTE*)pFileContent,
|
||||||
size,
|
size,
|
||||||
CERT_STORE_ADD_ALWAYS,
|
CERT_STORE_ADD_ALWAYS,
|
||||||
nullptr))
|
nullptr))
|
||||||
{
|
{
|
||||||
hr = GetLastError();
|
hr = GetLastError();
|
||||||
ExitOnFailure(hr, "Adding certificate failed", hr);
|
ExitOnFailure(hr, "Adding certificate failed", hr);
|
||||||
@@ -678,13 +752,11 @@ LExit:
|
|||||||
MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_WARNING + MB_OK), hRecord);
|
MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_WARNING + MB_OK), hRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
||||||
return WcaFinalize(er);
|
return WcaFinalize(er);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UINT __stdcall InstallVirtualCameraDriverCA(MSIHANDLE hInstall)
|
UINT __stdcall InstallVirtualCameraDriverCA(MSIHANDLE hInstall)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
@@ -793,7 +865,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
|
|||||||
}
|
}
|
||||||
wchar_t processName[MAX_PATH] = L"<unknown>";
|
wchar_t processName[MAX_PATH] = L"<unknown>";
|
||||||
|
|
||||||
HANDLE hProcess{OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, procID)};
|
HANDLE hProcess{ OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, procID) };
|
||||||
if (!hProcess)
|
if (!hProcess)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -819,7 +891,7 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
|
|||||||
GetWindowThreadProcessId(hwnd, &windowProcID);
|
GetWindowThreadProcessId(hwnd, &windowProcID);
|
||||||
if (windowProcID == targetProcID)
|
if (windowProcID == targetProcID)
|
||||||
{
|
{
|
||||||
DWORD_PTR _ {};
|
DWORD_PTR _{};
|
||||||
SendMessageTimeoutA(hwnd, WM_CLOSE, 0, 0, SMTO_BLOCK, timeout, &_);
|
SendMessageTimeoutA(hwnd, WM_CLOSE, 0, 0, SMTO_BLOCK, timeout, &_);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -837,7 +909,6 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall)
|
|||||||
return WcaFinalize(er);
|
return WcaFinalize(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DllMain - Initialize and cleanup WiX custom action utils.
|
// DllMain - Initialize and cleanup WiX custom action utils.
|
||||||
extern "C" BOOL WINAPI DllMain(__in HINSTANCE hInst, __in ULONG ulReason, __in LPVOID)
|
extern "C" BOOL WINAPI DllMain(__in HINSTANCE hInst, __in ULONG ulReason, __in LPVOID)
|
||||||
{
|
{
|
||||||
@@ -846,6 +917,7 @@ extern "C" BOOL WINAPI DllMain(__in HINSTANCE hInst, __in ULONG ulReason, __in L
|
|||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
WcaGlobalInitialize(hInst);
|
WcaGlobalInitialize(hInst);
|
||||||
TraceLoggingRegister(g_hProvider);
|
TraceLoggingRegister(g_hProvider);
|
||||||
|
DLL_HANDLE = hInst;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ EXPORTS
|
|||||||
TerminateProcessesCA
|
TerminateProcessesCA
|
||||||
CertifyVirtualCameraDriverCA
|
CertifyVirtualCameraDriverCA
|
||||||
InstallVirtualCameraDriverCA
|
InstallVirtualCameraDriverCA
|
||||||
|
InstallEmbeddedMSIXCA
|
||||||
UninstallVirtualCameraDriverCA
|
UninstallVirtualCameraDriverCA
|
||||||
|
UninstallEmbeddedMSIXCA
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<ProjectGuid>{32f3882b-f2d6-4586-b5ed-11e39e522bd3}</ProjectGuid>
|
<ProjectGuid>{32f3882b-f2d6-4586-b5ed-11e39e522bd3}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>PowerToysSetupCustomActions</RootNamespace>
|
<RootNamespace>PowerToysSetupCustomActions</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
@@ -53,10 +53,11 @@
|
|||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>inc;..\..\src\;telemetry;$(WIX)sdk\$(WixPlatformToolset)\inc;$(SolutionDir)\packages\WiX.3.11.2\tools\sdk\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>inc;..\..\src\;telemetry;$(WIX)sdk\$(WixPlatformToolset)\inc;$(SolutionDir)\packages\WiX.3.11.2\tools\sdk\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/await /Zc:twoPhase- /Wv:18 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalLibraryDirectories>$(WIX)sdk\$(WixPlatformToolset)\lib\x64;$(SolutionDir)\packages\WiX.3.11.2\tools\sdk\vs2017\lib\x64;..\..\$(PlatformShortName)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(WIX)sdk\$(WixPlatformToolset)\lib\x64;$(SolutionDir)\packages\WiX.3.11.2\tools\sdk\vs2017\lib\x64;..\..\$(PlatformShortName)\$(Configuration)\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>Newdev.lib;Crypt32.lib;msi.lib;wcautil.lib;Psapi.lib;Pathcch.lib;comsupp.lib;taskschd.lib;Secur32.lib;msi.lib;dutil.lib;wcautil.lib;Version.lib;ApplicationUpdate.lib;Notifications.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>WindowsApp.lib;Newdev.lib;Crypt32.lib;msi.lib;wcautil.lib;Psapi.lib;Pathcch.lib;comsupp.lib;taskschd.lib;Secur32.lib;msi.lib;dutil.lib;wcautil.lib;Version.lib;ApplicationUpdate.lib;Notifications.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
@@ -112,10 +113,15 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\PowerToysBootstrapper\bootstrapper\RcResource.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
<ClInclude Include="Telemetry\ProjectTelemetry.h" />
|
<ClInclude Include="Telemetry\ProjectTelemetry.h" />
|
||||||
<ClInclude Include="Telemetry\TraceLoggingDefines.h" />
|
<ClInclude Include="Telemetry\TraceLoggingDefines.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="Resource.rc" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets" />
|
<ImportGroup Label="ExtensionTargets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
@@ -124,4 +130,4 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\packages\WiX.3.11.2\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WiX.3.11.2\build\wix.props'))" />
|
<Error Condition="!Exists('..\packages\WiX.3.11.2\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WiX.3.11.2\build\wix.props'))" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
<ClInclude Include="Telemetry\TraceLoggingDefines.h">
|
<ClInclude Include="Telemetry\TraceLoggingDefines.h">
|
||||||
<Filter>Telemetry</Filter>
|
<Filter>Telemetry</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="..\PowerToysBootstrapper\bootstrapper\RcResource.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="CustomAction.def" />
|
<None Include="CustomAction.def" />
|
||||||
@@ -22,4 +24,7 @@
|
|||||||
<UniqueIdentifier>{6e73ce5d-e715-4e7e-b796-c5d180b07ff2}</UniqueIdentifier>
|
<UniqueIdentifier>{6e73ce5d-e715-4e7e-b796-c5d180b07ff2}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="Resource.rc" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
61
installer/PowerToysSetupCustomActions/Resource.rc
Normal file
61
installer/PowerToysSetupCustomActions/Resource.rc
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (United States) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
|
||||||
|
LANGUAGE 25, 1
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // English (United States) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// TODO: Use to activate embedded MSIX
|
||||||
|
//IDR_BIN_MSIX_HELLO_PACKAGE BIN "..\\..\..\\src\\modules\\HelloModule\\AppPackages\\HelloModule_1.0.0.0_x64_Test\\HelloModule_1.0.0.0_x64.msix"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
16
installer/PowerToysSetupCustomActions/resource.h
Normal file
16
installer/PowerToysSetupCustomActions/resource.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by Resource.rc
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 102
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IDR_BIN_MSIX_HELLO_PACKAGE 101
|
||||||
@@ -27,3 +27,9 @@
|
|||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
#include <winrt/Windows.Foundation.Collections.h>
|
||||||
|
#include <winrt/Windows.ApplicationModel.h>
|
||||||
|
#include <winrt/Windows.Management.Deployment.h>
|
||||||
|
#include <winrt/Windows.System.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user