2019-09-05 00:26:26 +08:00
# include "stdafx.h"
2021-09-21 20:15:59 +08:00
# include "resource.h"
2022-01-06 02:28:09 +08:00
# include "RcResource.h"
2019-09-05 00:26:26 +08:00
# include <ProjectTelemetry.h>
2021-11-10 03:48:07 +08:00
# include <spdlog/sinks/base_sink.h>
# include "../../src/common/logger/logger.h"
2021-06-14 17:55:59 +08:00
# include "../../src/common/utils/MsiUtils.h"
2021-10-05 23:54:42 +08:00
# include "../../src/common/utils/modulesRegistry.h"
2020-11-20 16:34:34 +08:00
# include "../../src/common/updating/installer.h"
2021-03-18 23:55:01 +08:00
# include "../../src/common/version/version.h"
2020-07-28 00:53:29 +08:00
2022-07-01 04:10:14 +08:00
# include <winrt/Windows.ApplicationModel.h>
# include <winrt/Windows.Foundation.h>
# include <winrt/Windows.Management.Deployment.h>
2022-12-14 20:37:23 +08:00
# include "DepsFilesLists.h"
2019-09-05 00:26:26 +08:00
using namespace std ;
2021-09-21 20:15:59 +08:00
HINSTANCE DLL_HANDLE = nullptr ;
2019-09-05 00:26:26 +08:00
TRACELOGGING_DEFINE_PROVIDER (
2020-04-13 21:00:51 +08:00
g_hProvider ,
" Microsoft.PowerToysInstaller " ,
// {e1d8165d-5cb6-5c74-3b51-bdfbfe4f7a3b}
( 0xe1d8165d , 0x5cb6 , 0x5c74 , 0x3b , 0x51 , 0xbd , 0xfb , 0xfe , 0x4f , 0x7a , 0x3b ) ,
TraceLoggingOptionProjectTelemetry ( ) ) ;
2019-09-05 00:26:26 +08:00
const DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2 ; // Domain Name + '\' + User Name + '\0'
const DWORD USERNAME_LEN = UNLEN + 1 ; // User Name + '\0'
2021-06-29 18:06:12 +08:00
static const wchar_t * POWERTOYS_EXE_COMPONENT = L " {A2C66D91-3485-4D00-B04D-91844E6B345B} " ;
2020-04-22 01:52:28 +08:00
static const wchar_t * POWERTOYS_UPGRADE_CODE = L " {42B84BF7-5FBF-473B-9C8B-049DC16F7708} " ;
2021-11-10 03:48:07 +08:00
struct WcaSink : spdlog : : sinks : : base_sink < std : : mutex >
{
virtual void sink_it_ ( const spdlog : : details : : log_msg & msg ) override
{
WcaLog ( LOGMSG_STANDARD , msg . payload . data ( ) ) ;
}
virtual void flush_ ( ) override
{
// we don't need to flush wca log manually
}
} ;
void initSystemLogger ( )
{
static std : : once_flag initLoggerFlag ;
std : : call_once ( initLoggerFlag , [ ] ( ) { Logger : : init ( std : : vector < spdlog : : sink_ptr > { std : : make_shared < WcaSink > ( ) } ) ; } ) ;
}
2021-10-05 23:54:42 +08:00
HRESULT getInstallFolder ( MSIHANDLE hInstall , std : : wstring & installationDir )
{
DWORD len = 0 ;
wchar_t _ [ 1 ] ;
MsiGetPropertyW ( hInstall , L " CustomActionData " , _ , & len ) ;
len + = 1 ;
installationDir . resize ( len ) ;
HRESULT hr = MsiGetPropertyW ( hInstall , L " CustomActionData " , installationDir . data ( ) , & len ) ;
2021-11-10 03:48:07 +08:00
if ( installationDir . length ( ) )
2021-10-05 23:54:42 +08:00
{
installationDir . resize ( installationDir . length ( ) - 1 ) ;
}
ExitOnFailure ( hr , " Failed to get INSTALLFOLDER property. " ) ;
LExit :
return hr ;
}
UINT __stdcall ApplyModulesRegistryChangeSetsCA ( MSIHANDLE hInstall )
{
2021-11-10 03:48:07 +08:00
initSystemLogger ( ) ;
2021-10-05 23:54:42 +08:00
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
std : : wstring installationFolder ;
2021-11-10 03:48:07 +08:00
bool failedToApply = false ;
2021-10-05 23:54:42 +08:00
hr = WcaInitialize ( hInstall , " ApplyModulesRegistryChangeSets " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
2021-10-27 17:39:25 +08:00
ExitOnFailure ( hr , " Failed to get installFolder. " ) ;
2021-11-10 03:48:07 +08:00
2022-03-26 05:01:09 +08:00
for ( const auto & changeSet : getAllOnByDefaultModulesChangeSets ( installationFolder ) )
2021-10-05 23:54:42 +08:00
{
2021-10-22 08:55:46 +08:00
if ( ! changeSet . apply ( ) )
2021-10-05 23:54:42 +08:00
{
2021-10-22 08:55:46 +08:00
WcaLog ( LOGMSG_STANDARD , " Couldn't apply registry changeSet " ) ;
2021-11-10 03:48:07 +08:00
failedToApply = true ;
2021-10-05 23:54:42 +08:00
}
}
2021-11-10 03:48:07 +08:00
if ( ! failedToApply )
{
WcaLog ( LOGMSG_STANDARD , " All registry changeSets applied successfully " ) ;
}
2021-10-05 23:54:42 +08:00
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
UINT __stdcall UnApplyModulesRegistryChangeSetsCA ( MSIHANDLE hInstall )
{
2021-11-10 03:48:07 +08:00
initSystemLogger ( ) ;
2021-10-05 23:54:42 +08:00
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
std : : wstring installationFolder ;
hr = WcaInitialize ( hInstall , " UndoModulesRegistryChangeSets " ) ; // original func name is too long
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
2021-10-27 17:39:25 +08:00
ExitOnFailure ( hr , " Failed to get installFolder. " ) ;
2022-01-06 02:28:09 +08:00
for ( const auto & changeSet : getAllModulesChangeSets ( installationFolder ) )
2021-10-05 23:54:42 +08:00
{
2021-10-22 08:55:46 +08:00
changeSet . unApply ( ) ;
2021-10-05 23:54:42 +08:00
}
ExitOnFailure ( hr , " Failed to extract msix " ) ;
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2021-09-21 20:15:59 +08:00
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 ) ;
}
2019-09-05 00:26:26 +08:00
// 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).
// Based on the Task Scheduler Logon Trigger Example:
2022-09-29 00:18:55 +08:00
// https://learn.microsoft.com/windows/win32/taskschd/logon-trigger-example--c---/
2020-04-13 21:00:51 +08:00
UINT __stdcall CreateScheduledTaskCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
TCHAR username_domain [ USERNAME_DOMAIN_LEN ] ;
TCHAR username [ USERNAME_LEN ] ;
std : : wstring wstrTaskName ;
2020-11-13 20:57:01 +08:00
ITaskService * pService = nullptr ;
ITaskFolder * pTaskFolder = nullptr ;
ITaskDefinition * pTask = nullptr ;
IRegistrationInfo * pRegInfo = nullptr ;
ITaskSettings * pSettings = nullptr ;
ITriggerCollection * pTriggerCollection = nullptr ;
IRegisteredTask * pRegisteredTask = nullptr ;
2021-09-21 20:15:59 +08:00
IPrincipal * pPrincipal = nullptr ;
ITrigger * pTrigger = nullptr ;
ILogonTrigger * pLogonTrigger = nullptr ;
IAction * pAction = nullptr ;
IActionCollection * pActionCollection = nullptr ;
IExecAction * pExecAction = nullptr ;
2020-11-13 20:57:01 +08:00
LPWSTR wszExecutablePath = nullptr ;
2020-04-22 01:52:28 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " CreateScheduledTaskCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
WcaLog ( LOGMSG_STANDARD , " Initialized. " ) ;
// ------------------------------------------------------
// Get the Domain/Username for the trigger.
//
// This action needs to run as the system to get elevated privileges from the installation,
// so GetUserNameEx can't be used to get the current user details.
// The USERNAME and USERDOMAIN environment variables are used instead.
if ( ! GetEnvironmentVariable ( L " USERNAME " , username , USERNAME_LEN ) )
{
ExitWithLastError ( hr , " Getting username failed: %x " , hr ) ;
}
if ( ! GetEnvironmentVariable ( L " USERDOMAIN " , username_domain , USERNAME_DOMAIN_LEN ) )
{
ExitWithLastError ( hr , " Getting the user's domain failed: %x " , hr ) ;
}
wcscat_s ( username_domain , L " \\ " ) ;
wcscat_s ( username_domain , username ) ;
WcaLog ( LOGMSG_STANDARD , " Current user detected: %ls " , username_domain ) ;
// Task Name.
wstrTaskName = L " Autorun for " ;
wstrTaskName + = username ;
// Get the executable path passed to the custom action.
hr = WcaGetProperty ( L " CustomActionData " , & wszExecutablePath ) ;
ExitOnFailure ( hr , " Failed to get the executable path from CustomActionData. " ) ;
// COM and Security Initialization is expected to have been done by the MSI.
// It couldn't be done in the DLL, anyway.
// ------------------------------------------------------
// Create an instance of the Task Service.
hr = CoCreateInstance ( CLSID_TaskScheduler ,
2020-11-13 20:57:01 +08:00
nullptr ,
2020-04-13 21:00:51 +08:00
CLSCTX_INPROC_SERVER ,
IID_ITaskService ,
( void * * ) & pService ) ;
ExitOnFailure ( hr , " Failed to create an instance of ITaskService: %x " , hr ) ;
// Connect to the task service.
hr = pService - > Connect ( _variant_t ( ) , _variant_t ( ) , _variant_t ( ) , _variant_t ( ) ) ;
ExitOnFailure ( hr , " ITaskService::Connect failed: %x " , hr ) ;
// ------------------------------------------------------
// Get the PowerToys task folder. Creates it if it doesn't exist.
hr = pService - > GetFolder ( _bstr_t ( L " \\ PowerToys " ) , & pTaskFolder ) ;
if ( FAILED ( hr ) )
{
// Folder doesn't exist. Get the Root folder and create the PowerToys subfolder.
2020-11-13 20:57:01 +08:00
ITaskFolder * pRootFolder = nullptr ;
2020-04-13 21:00:51 +08:00
hr = pService - > GetFolder ( _bstr_t ( L " \\ " ) , & pRootFolder ) ;
ExitOnFailure ( hr , " Cannot get Root Folder pointer: %x " , hr ) ;
hr = pRootFolder - > CreateFolder ( _bstr_t ( L " \\ PowerToys " ) , _variant_t ( L " " ) , & pTaskFolder ) ;
if ( FAILED ( hr ) )
{
pRootFolder - > Release ( ) ;
ExitOnFailure ( hr , " Cannot create PowerToys task folder: %x " , hr ) ;
}
WcaLog ( LOGMSG_STANDARD , " PowerToys task folder created. " ) ;
}
// If the same task exists, remove it.
pTaskFolder - > DeleteTask ( _bstr_t ( wstrTaskName . c_str ( ) ) , 0 ) ;
// Create the task builder object to create the task.
hr = pService - > NewTask ( 0 , & pTask ) ;
ExitOnFailure ( hr , " Failed to create a task definition: %x " , hr ) ;
// ------------------------------------------------------
// Get the registration info for setting the identification.
hr = pTask - > get_RegistrationInfo ( & pRegInfo ) ;
ExitOnFailure ( hr , " Cannot get identification pointer: %x " , hr ) ;
hr = pRegInfo - > put_Author ( _bstr_t ( username_domain ) ) ;
ExitOnFailure ( hr , " Cannot put identification info: %x " , hr ) ;
// ------------------------------------------------------
// Create the settings for the task
hr = pTask - > get_Settings ( & pSettings ) ;
ExitOnFailure ( hr , " Cannot get settings pointer: %x " , hr ) ;
hr = pSettings - > put_StartWhenAvailable ( VARIANT_FALSE ) ;
ExitOnFailure ( hr , " Cannot put_StartWhenAvailable setting info: %x " , hr ) ;
hr = pSettings - > put_StopIfGoingOnBatteries ( VARIANT_FALSE ) ;
ExitOnFailure ( hr , " Cannot put_StopIfGoingOnBatteries setting info: %x " , hr ) ;
hr = pSettings - > put_ExecutionTimeLimit ( _bstr_t ( L " PT0S " ) ) ; //Unlimited
ExitOnFailure ( hr , " Cannot put_ExecutionTimeLimit setting info: %x " , hr ) ;
hr = pSettings - > put_DisallowStartIfOnBatteries ( VARIANT_FALSE ) ;
ExitOnFailure ( hr , " Cannot put_DisallowStartIfOnBatteries setting info: %x " , hr ) ;
// ------------------------------------------------------
// Get the trigger collection to insert the logon trigger.
hr = pTask - > get_Triggers ( & pTriggerCollection ) ;
ExitOnFailure ( hr , " Cannot get trigger collection: %x " , hr ) ;
// Add the logon trigger to the task.
hr = pTriggerCollection - > Create ( TASK_TRIGGER_LOGON , & pTrigger ) ;
ExitOnFailure ( hr , " Cannot create the trigger: %x " , hr ) ;
hr = pTrigger - > QueryInterface (
IID_ILogonTrigger , ( void * * ) & pLogonTrigger ) ;
pTrigger - > Release ( ) ;
ExitOnFailure ( hr , " QueryInterface call failed for ILogonTrigger: %x " , hr ) ;
hr = pLogonTrigger - > put_Id ( _bstr_t ( L " Trigger1 " ) ) ;
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot put the trigger ID: %x " , hr ) ;
}
// Timing issues may make explorer not be started when the task runs.
// Add a little delay to mitigate this.
hr = pLogonTrigger - > put_Delay ( _bstr_t ( L " PT03S " ) ) ;
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot put the trigger delay: %x " , hr ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
// Define the user. The task will execute when the user logs on.
// The specified user must be a user on this computer.
hr = pLogonTrigger - > put_UserId ( _bstr_t ( username_domain ) ) ;
pLogonTrigger - > Release ( ) ;
ExitOnFailure ( hr , " Cannot add user ID to logon trigger: %x " , hr ) ;
// ------------------------------------------------------
// Add an Action to the task. This task will execute the path passed to this custom action.
// Get the task action collection pointer.
hr = pTask - > get_Actions ( & pActionCollection ) ;
ExitOnFailure ( hr , " Cannot get Task collection pointer: %x " , hr ) ;
// Create the action, specifying that it is an executable action.
hr = pActionCollection - > Create ( TASK_ACTION_EXEC , & pAction ) ;
pActionCollection - > Release ( ) ;
ExitOnFailure ( hr , " Cannot create the action: %x " , hr ) ;
// QI for the executable task pointer.
hr = pAction - > QueryInterface (
IID_IExecAction , ( void * * ) & pExecAction ) ;
pAction - > Release ( ) ;
ExitOnFailure ( hr , " QueryInterface call failed for IExecAction: %x " , hr ) ;
// Set the path of the executable to PowerToys (passed as CustomActionData).
hr = pExecAction - > put_Path ( _bstr_t ( wszExecutablePath ) ) ;
pExecAction - > Release ( ) ;
ExitOnFailure ( hr , " Cannot set path of executable: %x " , hr ) ;
// ------------------------------------------------------
// Create the principal for the task
hr = pTask - > get_Principal ( & pPrincipal ) ;
ExitOnFailure ( hr , " Cannot get principal pointer: %x " , hr ) ;
// Set up principal information:
hr = pPrincipal - > put_Id ( _bstr_t ( L " Principal1 " ) ) ;
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot put the principal ID: %x " , hr ) ;
}
hr = pPrincipal - > put_UserId ( _bstr_t ( username_domain ) ) ;
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot put principal user Id: %x " , hr ) ;
}
hr = pPrincipal - > put_LogonType ( TASK_LOGON_INTERACTIVE_TOKEN ) ;
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot put principal logon type: %x " , hr ) ;
}
// Run the task with the highest available privileges.
hr = pPrincipal - > put_RunLevel ( TASK_RUNLEVEL_LUA ) ;
pPrincipal - > Release ( ) ;
ExitOnFailure ( hr , " Cannot put principal run level: %x " , hr ) ;
// ------------------------------------------------------
// Save the task in the PowerToys folder.
{
_variant_t SDDL_FULL_ACCESS_FOR_EVERYONE = L " D:(A;;FA;;;WD) " ;
hr = pTaskFolder - > RegisterTaskDefinition (
_bstr_t ( wstrTaskName . c_str ( ) ) ,
pTask ,
TASK_CREATE_OR_UPDATE ,
_variant_t ( username_domain ) ,
_variant_t ( ) ,
TASK_LOGON_INTERACTIVE_TOKEN ,
SDDL_FULL_ACCESS_FOR_EVERYONE ,
& pRegisteredTask ) ;
ExitOnFailure ( hr , " Error saving the Task : %x " , hr ) ;
}
WcaLog ( LOGMSG_STANDARD , " Scheduled task created for the current user. " ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
ReleaseStr ( wszExecutablePath ) ;
if ( pService )
{
pService - > Release ( ) ;
}
if ( pTaskFolder )
{
pTaskFolder - > Release ( ) ;
}
if ( pTask )
{
pTask - > Release ( ) ;
}
if ( pRegInfo )
{
pRegInfo - > Release ( ) ;
}
if ( pSettings )
{
pSettings - > Release ( ) ;
}
if ( pTriggerCollection )
{
pTriggerCollection - > Release ( ) ;
}
if ( pRegisteredTask )
{
pRegisteredTask - > Release ( ) ;
}
if ( ! SUCCEEDED ( hr ) )
{
PMSIHANDLE hRecord = MsiCreateRecord ( 0 ) ;
MsiRecordSetString ( hRecord , 0 , TEXT ( " Failed to create a scheduled task to start PowerToys at user login. You can re-try to create the scheduled task using the PowerToys settings. " ) ) ;
MsiProcessMessage ( hInstall , INSTALLMESSAGE ( INSTALLMESSAGE_WARNING + MB_OK ) , hRecord ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
// Removes all Scheduled Tasks in the PowerToys folder and deletes the folder afterwards.
// Based on the Task Scheduler Displaying Task Names and State example:
2022-09-29 00:18:55 +08:00
// https://learn.microsoft.com/windows/desktop/TaskSchd/displaying-task-names-and-state--c---/
2020-04-13 21:00:51 +08:00
UINT __stdcall RemoveScheduledTasksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2020-11-13 20:57:01 +08:00
ITaskService * pService = nullptr ;
ITaskFolder * pTaskFolder = nullptr ;
IRegisteredTaskCollection * pTaskCollection = nullptr ;
2021-09-21 20:15:59 +08:00
ITaskFolder * pRootFolder = nullptr ;
2020-11-13 20:57:01 +08:00
LONG numTasks = 0 ;
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " RemoveScheduledTasksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
WcaLog ( LOGMSG_STANDARD , " Initialized. " ) ;
// COM and Security Initialization is expected to have been done by the MSI.
// It couldn't be done in the DLL, anyway.
// ------------------------------------------------------
// Create an instance of the Task Service.
hr = CoCreateInstance ( CLSID_TaskScheduler ,
2020-11-13 20:57:01 +08:00
nullptr ,
2020-04-13 21:00:51 +08:00
CLSCTX_INPROC_SERVER ,
IID_ITaskService ,
( void * * ) & pService ) ;
ExitOnFailure ( hr , " Failed to create an instance of ITaskService: %x " , hr ) ;
// Connect to the task service.
hr = pService - > Connect ( _variant_t ( ) , _variant_t ( ) , _variant_t ( ) , _variant_t ( ) ) ;
ExitOnFailure ( hr , " ITaskService::Connect failed: %x " , hr ) ;
// ------------------------------------------------------
// Get the PowerToys task folder.
hr = pService - > GetFolder ( _bstr_t ( L " \\ PowerToys " ) , & pTaskFolder ) ;
if ( FAILED ( hr ) )
{
// Folder doesn't exist. No need to delete anything.
WcaLog ( LOGMSG_STANDARD , " The PowerToys scheduled task folder wasn't found. Nothing to delete. " ) ;
hr = S_OK ;
ExitFunction ( ) ;
}
// -------------------------------------------------------
// Get the registered tasks in the folder.
hr = pTaskFolder - > GetTasks ( TASK_ENUM_HIDDEN , & pTaskCollection ) ;
ExitOnFailure ( hr , " Cannot get the registered tasks: %x " , hr ) ;
hr = pTaskCollection - > get_Count ( & numTasks ) ;
for ( LONG i = 0 ; i < numTasks ; i + + )
{
// Delete all the tasks found.
// If some tasks can't be deleted, the folder won't be deleted later and the user will still be notified.
2020-11-13 20:57:01 +08:00
IRegisteredTask * pRegisteredTask = nullptr ;
2020-04-13 21:00:51 +08:00
hr = pTaskCollection - > get_Item ( _variant_t ( i + 1 ) , & pRegisteredTask ) ;
if ( SUCCEEDED ( hr ) )
{
2020-11-13 20:57:01 +08:00
BSTR taskName = nullptr ;
2020-04-13 21:00:51 +08:00
hr = pRegisteredTask - > get_Name ( & taskName ) ;
if ( SUCCEEDED ( hr ) )
{
2020-11-13 20:57:01 +08:00
hr = pTaskFolder - > DeleteTask ( taskName , 0 ) ;
2020-04-13 21:00:51 +08:00
if ( FAILED ( hr ) )
{
WcaLogError ( hr , " Cannot delete the '%S' task: %x " , taskName , hr ) ;
}
SysFreeString ( taskName ) ;
}
else
{
WcaLogError ( hr , " Cannot get the registered task name: %x " , hr ) ;
}
pRegisteredTask - > Release ( ) ;
}
else
{
WcaLogError ( hr , " Cannot get the registered task item at index=%d: %x " , i + 1 , hr ) ;
2019-09-05 00:26:26 +08:00
}
}
2020-04-13 21:00:51 +08:00
// ------------------------------------------------------
// Get the pointer to the root task folder and delete the PowerToys subfolder.
hr = pService - > GetFolder ( _bstr_t ( L " \\ " ) , & pRootFolder ) ;
ExitOnFailure ( hr , " Cannot get Root Folder pointer: %x " , hr ) ;
2020-11-13 20:57:01 +08:00
hr = pRootFolder - > DeleteFolder ( _bstr_t ( L " PowerToys " ) , 0 ) ;
2020-04-13 21:00:51 +08:00
pRootFolder - > Release ( ) ;
ExitOnFailure ( hr , " Cannot delete the PowerToys folder: %x " , hr ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
WcaLog ( LOGMSG_STANDARD , " Deleted the PowerToys Task Scheduler folder. " ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
if ( pService )
{
pService - > Release ( ) ;
}
if ( pTaskFolder )
{
pTaskFolder - > Release ( ) ;
}
if ( pTaskCollection )
{
pTaskCollection - > Release ( ) ;
}
if ( ! SUCCEEDED ( hr ) )
{
PMSIHANDLE hRecord = MsiCreateRecord ( 0 ) ;
MsiRecordSetString ( hRecord , 0 , TEXT ( " Failed to remove the PowerToys folder from the scheduled task. These can be removed manually later. " ) ) ;
MsiProcessMessage ( hInstall , INSTALLMESSAGE ( INSTALLMESSAGE_WARNING + MB_OK ) , hRecord ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogInstallSuccessCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogInstallSuccessCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" Install_Success " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogInstallCancelCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogInstallCancelCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" Install_Cancel " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogInstallFailCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogInstallFailCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" Install_Fail " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogUninstallSuccessCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogUninstallSuccessCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" UnInstall_Success " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogUninstallCancelCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogUninstallCancelCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" UnInstall_Cancel " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogUninstallFailCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogUninstallFailCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" UnInstall_Fail " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogRepairCancelCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogRepairCancelCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" Repair_Cancel " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-13 21:00:51 +08:00
UINT __stdcall TelemetryLogRepairFailCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
hr = WcaInitialize ( hInstall , " TelemetryLogRepairFailCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
2019-09-05 00:26:26 +08:00
2020-04-13 21:00:51 +08:00
TraceLoggingWrite (
g_hProvider ,
" Repair_Fail " ,
2021-03-18 23:55:01 +08:00
TraceLoggingWideString ( get_product_version ( ) . c_str ( ) , " Version " ) ,
2020-04-13 21:00:51 +08:00
ProjectTelemetryPrivacyDataTag ( ProjectTelemetryTag_ProductAndServicePerformance ) ,
TraceLoggingBoolean ( TRUE , " UTCReplace_AppSessionGuid " ) ,
TraceLoggingKeyword ( PROJECT_KEYWORD_MEASURE ) ) ;
2019-09-05 00:26:26 +08:00
LExit :
2020-04-13 21:00:51 +08:00
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
2019-09-05 00:26:26 +08:00
}
2020-04-22 01:52:28 +08:00
UINT __stdcall DetectPrevInstallPathCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
hr = WcaInitialize ( hInstall , " DetectPrevInstallPathCA " ) ;
2022-01-06 02:28:09 +08:00
MsiSetPropertyW ( hInstall , L " PREVIOUSINSTALLFOLDER " , L " " ) ;
2020-04-22 01:52:28 +08:00
try
{
2021-06-14 17:55:59 +08:00
if ( auto install_path = GetMsiPackageInstalledPath ( ) )
2020-04-22 01:52:28 +08:00
{
2022-01-06 02:28:09 +08:00
MsiSetPropertyW ( hInstall , L " PREVIOUSINSTALLFOLDER " , install_path - > data ( ) ) ;
2020-04-22 01:52:28 +08:00
}
}
2021-09-21 20:15:59 +08:00
catch ( . . . )
2020-04-22 01:52:28 +08:00
{
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2021-06-29 18:06:12 +08:00
UINT __stdcall CertifyVirtualCameraDriverCA ( MSIHANDLE hInstall )
{
# ifdef CIBuild // On pipeline we are using microsoft certification
WcaInitialize ( hInstall , " CertifyVirtualCameraDriverCA " ) ;
return WcaFinalize ( ERROR_SUCCESS ) ;
# else
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
LPWSTR certificatePath = nullptr ;
HCERTSTORE hCertStore = nullptr ;
HANDLE hfile = nullptr ;
DWORD size = INVALID_FILE_SIZE ;
2021-09-21 20:15:59 +08:00
char * pFileContent = nullptr ;
2021-06-29 18:06:12 +08:00
hr = WcaInitialize ( hInstall , " CertifyVirtualCameraDriverCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " , hr ) ;
hr = WcaGetProperty ( L " CustomActionData " , & certificatePath ) ;
2022-04-12 23:13:22 +08:00
ExitOnFailure ( hr , " Failed to get install property " , hr ) ;
2021-06-29 18:06:12 +08:00
hCertStore = CertOpenStore ( CERT_STORE_PROV_SYSTEM , 0 , 0 , CERT_SYSTEM_STORE_LOCAL_MACHINE , L " AuthRoot " ) ;
if ( ! hCertStore )
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Cannot put principal run level: %x " , hr ) ;
}
hfile = CreateFile ( certificatePath , GENERIC_READ , FILE_SHARE_READ , nullptr , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , nullptr ) ;
if ( hfile = = INVALID_HANDLE_VALUE )
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Certificate file open failed " , hr ) ;
}
size = GetFileSize ( hfile , nullptr ) ;
if ( size = = INVALID_FILE_SIZE )
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Certificate file size not valid " , hr ) ;
}
pFileContent = ( char * ) malloc ( size ) ;
DWORD sizeread ;
if ( ! ReadFile ( hfile , pFileContent , size , & sizeread , nullptr ) )
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Certificate file read failed " , hr ) ;
}
if ( ! CertAddEncodedCertificateToStore ( hCertStore ,
2021-09-21 20:15:59 +08:00
X509_ASN_ENCODING ,
( const BYTE * ) pFileContent ,
size ,
CERT_STORE_ADD_ALWAYS ,
nullptr ) )
2021-06-29 18:06:12 +08:00
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Adding certificate failed " , hr ) ;
}
free ( pFileContent ) ;
LExit :
ReleaseStr ( certificatePath ) ;
if ( hCertStore )
{
CertCloseStore ( hCertStore , 0 ) ;
}
if ( hfile )
{
CloseHandle ( hfile ) ;
}
if ( ! SUCCEEDED ( hr ) )
{
PMSIHANDLE hRecord = MsiCreateRecord ( 0 ) ;
MsiRecordSetString ( hRecord , 0 , TEXT ( " Failed to add certificate to store " ) ) ;
MsiProcessMessage ( hInstall , INSTALLMESSAGE ( INSTALLMESSAGE_WARNING + MB_OK ) , hRecord ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
# endif
}
UINT __stdcall InstallVirtualCameraDriverCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
LPWSTR driverPath = nullptr ;
hr = WcaInitialize ( hInstall , " InstallVirtualCameraDriverCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = WcaGetProperty ( L " CustomActionData " , & driverPath ) ;
2022-04-12 23:13:22 +08:00
ExitOnFailure ( hr , " Failed to get install property " ) ;
2021-06-29 18:06:12 +08:00
BOOL requiresReboot ;
DiInstallDriverW ( GetConsoleWindow ( ) , driverPath , DIIRFLAG_FORCE_INF , & requiresReboot ) ;
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Failed to install driver " ) ;
LExit :
if ( ! SUCCEEDED ( hr ) )
{
PMSIHANDLE hRecord = MsiCreateRecord ( 0 ) ;
MsiRecordSetString ( hRecord , 0 , TEXT ( " Failed to install virtual camera driver " ) ) ;
MsiProcessMessage ( hInstall , INSTALLMESSAGE ( INSTALLMESSAGE_WARNING + MB_OK ) , hRecord ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
UINT __stdcall UninstallVirtualCameraDriverCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
LPWSTR driverPath = nullptr ;
hr = WcaInitialize ( hInstall , " UninstallVirtualCameraDriverCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = WcaGetProperty ( L " CustomActionData " , & driverPath ) ;
2022-04-12 23:13:22 +08:00
ExitOnFailure ( hr , " Failed to get uninstall property " ) ;
2021-06-29 18:06:12 +08:00
BOOL requiresReboot ;
DiUninstallDriverW ( GetConsoleWindow ( ) , driverPath , 0 , & requiresReboot ) ;
switch ( GetLastError ( ) )
{
case ERROR_ACCESS_DENIED :
case ERROR_FILE_NOT_FOUND :
case ERROR_INVALID_FLAGS :
case ERROR_IN_WOW64 :
{
hr = GetLastError ( ) ;
ExitOnFailure ( hr , " Failed to uninstall driver " ) ;
break ;
}
}
LExit :
if ( ! SUCCEEDED ( hr ) )
{
PMSIHANDLE hRecord = MsiCreateRecord ( 0 ) ;
2022-07-01 04:10:14 +08:00
MsiRecordSetString ( hRecord , 0 , TEXT ( " Failed to uninstall virtual camera driver " ) ) ;
2021-06-29 18:06:12 +08:00
MsiProcessMessage ( hInstall , INSTALLMESSAGE ( INSTALLMESSAGE_WARNING + MB_OK ) , hRecord ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2020-05-15 00:20:06 +08:00
2022-07-01 04:10:14 +08:00
UINT __stdcall UnRegisterContextMenuPackagesCA ( MSIHANDLE hInstall )
{
using namespace winrt : : Windows : : Foundation ;
using namespace winrt : : Windows : : Management : : Deployment ;
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
hr = WcaInitialize ( hInstall , " UnRegisterContextMenuPackagesCA " ) ; // original func name is too long
try
{
// Packages to unregister
const std : : vector < std : : wstring > packagesToRemoveDisplayName { { L " PowerRenameContextMenu " } , { L " ImageResizerContextMenu " } } ;
PackageManager packageManager ;
for ( auto const & package : packageManager . FindPackages ( ) )
{
const auto & packageFullName = std : : wstring { package . Id ( ) . FullName ( ) } ;
for ( const auto & packageToRemove : packagesToRemoveDisplayName )
{
if ( packageFullName . contains ( packageToRemove ) )
{
auto deploymentOperation { packageManager . RemovePackageAsync ( packageFullName ) } ;
deploymentOperation . get ( ) ;
// Check the status of the operation
if ( deploymentOperation . Status ( ) = = AsyncStatus : : Error )
{
auto deploymentResult { deploymentOperation . GetResults ( ) } ;
auto errorCode = deploymentOperation . ErrorCode ( ) ;
auto errorText = deploymentResult . ErrorText ( ) ;
Logger : : error ( L " Unregister {} package failed. ErrorCode: {}, ErrorText: {} " , packageFullName , std : : to_wstring ( errorCode ) , errorText ) ;
er = ERROR_INSTALL_FAILURE ;
}
else if ( deploymentOperation . Status ( ) = = AsyncStatus : : Canceled )
{
Logger : : error ( L " Unregister {} package canceled. " , packageFullName ) ;
er = ERROR_INSTALL_FAILURE ;
}
else if ( deploymentOperation . Status ( ) = = AsyncStatus : : Completed )
{
Logger : : info ( L " Unregister {} package completed. " , packageFullName ) ;
}
else
{
Logger : : debug ( L " Unregister {} package started. " , packageFullName ) ;
}
}
}
}
}
2022-09-12 00:50:13 +08:00
catch ( std : : exception & e )
2022-07-01 04:10:14 +08:00
{
std : : string errorMessage { " Exception thrown while trying to unregister sparse packages: " } ;
errorMessage + = e . what ( ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
er = er = = ERROR_SUCCESS ? ( SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ) : er ;
return WcaFinalize ( er ) ;
}
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
const std : : wstring WinAppSDKConsumers [ ] =
{
L " Settings " ,
L " modules \\ PowerRename " ,
L " modules \\ MeasureTool " ,
L " modules \\ FileLocksmith " ,
L " modules \\ Hosts " ,
} ;
2022-09-28 01:04:04 +08:00
UINT __stdcall CreateWinAppSDKHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : wstring installationFolder , winAppSDKFilesSrcDir ;
2022-09-28 01:04:04 +08:00
hr = WcaInitialize ( hInstall , " CreateWinAppSDKHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
winAppSDKFilesSrcDir = installationFolder + L " dll \\ WinAppSDK \\ " ;
for ( auto file : winAppSdkFiles )
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
for ( auto consumer : WinAppSDKConsumers )
2022-09-28 01:04:04 +08:00
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : error_code ec ;
std : : filesystem : : create_hard_link ( ( winAppSDKFilesSrcDir + file ) . c_str ( ) , ( installationFolder + consumer + L " \\ " + file ) . c_str ( ) , ec ) ;
if ( ec . value ( ) ! = S_OK )
{
std : : wstring errorMessage { L " Error creating hard link for: " } ;
errorMessage + = file ;
errorMessage + = L " , error code: " + std : : to_wstring ( ec . value ( ) ) ;
Logger : : error ( errorMessage ) ;
}
2022-09-28 01:04:04 +08:00
}
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
const std : : wstring PTInteropConsumers [ ] =
{
L " modules \\ ColorPicker " ,
L " modules \\ PowerOCR " ,
L " modules \\ launcher " ,
L " modules \\ FancyZones " ,
L " modules \\ ImageResizer " ,
L " Settings " ,
L " modules \\ Awake " ,
L " modules \\ MeasureTool " ,
L " modules \\ PowerAccent " ,
L " modules \\ FileLocksmith " ,
L " modules \\ Hosts " ,
2022-12-14 20:37:23 +08:00
L " modules \\ FileExplorerPreview " ,
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
} ;
2022-09-28 01:04:04 +08:00
UINT __stdcall CreatePTInteropHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : wstring installationFolder , interopFilesSrcDir ;
2022-09-28 01:04:04 +08:00
hr = WcaInitialize ( hInstall , " CreatePTInteropHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
interopFilesSrcDir = installationFolder + L " dll \\ Interop \\ " ;
for ( auto file : powerToysInteropFiles )
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
for ( auto consumer : PTInteropConsumers )
2022-09-28 01:04:04 +08:00
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : error_code ec ;
std : : filesystem : : create_hard_link ( ( interopFilesSrcDir + file ) . c_str ( ) , ( installationFolder + consumer + L " \\ " + file ) . c_str ( ) , ec ) ;
if ( ec . value ( ) ! = S_OK )
{
std : : wstring errorMessage { L " Error creating hard link for: " } ;
errorMessage + = file ;
errorMessage + = L " , error code: " + std : : to_wstring ( ec . value ( ) ) ;
Logger : : error ( errorMessage ) ;
}
2022-09-28 01:04:04 +08:00
}
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2022-12-14 20:37:23 +08:00
UINT __stdcall CreateDotnetRuntimeHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
std : : wstring installationFolder , dotnetRuntimeFilesSrcDir , colorPickerDir , powerOCRDir , launcherDir , fancyZonesDir ,
imageResizerDir , settingsDir , awakeDir , measureToolDir , powerAccentDir , fileExplorerAddOnsDir , hostsDir , fileLocksmithDir ;
hr = WcaInitialize ( hInstall , " CreateDotnetRuntimeHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
dotnetRuntimeFilesSrcDir = installationFolder + L " dll \\ dotnet \\ " ;
colorPickerDir = installationFolder + L " modules \\ ColorPicker \\ " ;
powerOCRDir = installationFolder + L " modules \\ PowerOCR \\ " ;
launcherDir = installationFolder + L " modules \\ launcher \\ " ;
fancyZonesDir = installationFolder + L " modules \\ FancyZones \\ " ;
imageResizerDir = installationFolder + L " modules \\ ImageResizer \\ " ;
settingsDir = installationFolder + L " Settings \\ " ;
awakeDir = installationFolder + L " modules \\ Awake \\ " ;
measureToolDir = installationFolder + L " modules \\ MeasureTool \\ " ;
powerAccentDir = installationFolder + L " modules \\ PowerAccent \\ " ;
fileExplorerAddOnsDir = installationFolder + L " modules \\ FileExplorerPreview \\ " ;
hostsDir = installationFolder + L " modules \\ Hosts \\ " ;
fileLocksmithDir = installationFolder + L " modules \\ FileLocksmith \\ " ;
for ( auto file : dotnetRuntimeFiles )
{
std : : error_code ec ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( colorPickerDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( powerOCRDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( launcherDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( fancyZonesDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( imageResizerDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( settingsDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( awakeDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( measureToolDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( powerAccentDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( fileExplorerAddOnsDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( hostsDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( fileLocksmithDir + file ) . c_str ( ) , ec ) ;
if ( ec . value ( ) ! = S_OK )
{
std : : wstring errorMessage { L " Error creating hard link for: " } ;
errorMessage + = file ;
errorMessage + = L " , error code: " + std : : to_wstring ( ec . value ( ) ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
}
for ( auto file : dotnetRuntimeWPFFiles )
{
std : : error_code ec ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( awakeDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( colorPickerDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( powerOCRDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( launcherDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( fancyZonesDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( imageResizerDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( powerAccentDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( fileExplorerAddOnsDir + file ) . c_str ( ) , ec ) ;
std : : filesystem : : create_hard_link ( ( dotnetRuntimeFilesSrcDir + file ) . c_str ( ) , ( hostsDir + file ) . c_str ( ) , ec ) ;
if ( ec . value ( ) ! = S_OK )
{
std : : wstring errorMessage { L " Error creating hard link for: " } ;
errorMessage + = file ;
errorMessage + = L " , error code: " + std : : to_wstring ( ec . value ( ) ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2022-09-28 01:04:04 +08:00
UINT __stdcall DeleteWinAppSDKHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : wstring installationFolder ;
2022-09-28 01:04:04 +08:00
hr = WcaInitialize ( hInstall , " DeleteWinAppSDKHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
try
{
for ( auto file : winAppSdkFiles )
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
for ( auto consumer : WinAppSDKConsumers )
{
DeleteFile ( ( installationFolder + consumer + L " \\ " + file ) . c_str ( ) ) ;
}
2022-09-28 01:04:04 +08:00
}
}
catch ( std : : exception e )
{
std : : string errorMessage { " Exception thrown while trying to delete WAS hardlinks: " } ;
errorMessage + = e . what ( ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
UINT __stdcall DeletePTInteropHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
std : : wstring installationFolder , interopFilesSrcDir ;
2022-09-28 01:04:04 +08:00
hr = WcaInitialize ( hInstall , " DeletePTInteropHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
try
{
for ( auto file : powerToysInteropFiles )
{
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
for ( auto consumer : PTInteropConsumers )
{
DeleteFile ( ( installationFolder + consumer + L " \\ " + file ) . c_str ( ) ) ;
}
2022-09-28 01:04:04 +08:00
}
}
catch ( std : : exception e )
{
std : : string errorMessage { " Exception thrown while trying to delete PowerToys Interop and VC Redist hardlinks: " } ;
errorMessage + = e . what ( ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2022-07-01 04:10:14 +08:00
2022-12-14 20:37:23 +08:00
UINT __stdcall DeleteDotnetRuntimeHardlinksCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
std : : wstring installationFolder , colorPickerDir , powerOCRDir , launcherDir , fancyZonesDir ,
imageResizerDir , settingsDir , awakeDir , measureToolDir , powerAccentDir , fileExplorerAddOnsDir ,
hostsDir , fileLocksmithDir ;
hr = WcaInitialize ( hInstall , " DeleteDotnetRuntimeHardlinksCA " ) ;
ExitOnFailure ( hr , " Failed to initialize " ) ;
hr = getInstallFolder ( hInstall , installationFolder ) ;
ExitOnFailure ( hr , " Failed to get installation folder " ) ;
colorPickerDir = installationFolder + L " modules \\ ColorPicker \\ " ;
powerOCRDir = installationFolder + L " modules \\ PowerOCR \\ " ;
launcherDir = installationFolder + L " modules \\ launcher \\ " ;
fancyZonesDir = installationFolder + L " modules \\ FancyZones \\ " ;
imageResizerDir = installationFolder + L " modules \\ ImageResizer \\ " ;
settingsDir = installationFolder + L " Settings \\ " ;
awakeDir = installationFolder + L " modules \\ Awake \\ " ;
measureToolDir = installationFolder + L " modules \\ MeasureTool \\ " ;
powerAccentDir = installationFolder + L " modules \\ PowerAccent \\ " ;
fileExplorerAddOnsDir = installationFolder + L " modules \\ FileExplorerPreview \\ " ;
hostsDir = installationFolder + L " modules \\ Hosts \\ " ;
fileLocksmithDir = installationFolder + L " modules \\ FileLocksmith \\ " ;
try
{
for ( auto file : dotnetRuntimeFiles )
{
DeleteFile ( ( colorPickerDir + file ) . c_str ( ) ) ;
DeleteFile ( ( powerOCRDir + file ) . c_str ( ) ) ;
DeleteFile ( ( launcherDir + file ) . c_str ( ) ) ;
DeleteFile ( ( fancyZonesDir + file ) . c_str ( ) ) ;
DeleteFile ( ( imageResizerDir + file ) . c_str ( ) ) ;
DeleteFile ( ( settingsDir + file ) . c_str ( ) ) ;
DeleteFile ( ( awakeDir + file ) . c_str ( ) ) ;
DeleteFile ( ( measureToolDir + file ) . c_str ( ) ) ;
DeleteFile ( ( powerAccentDir + file ) . c_str ( ) ) ;
DeleteFile ( ( fileExplorerAddOnsDir + file ) . c_str ( ) ) ;
DeleteFile ( ( hostsDir + file ) . c_str ( ) ) ;
DeleteFile ( ( fileLocksmithDir + file ) . c_str ( ) ) ;
}
for ( auto file : dotnetRuntimeWPFFiles )
{
DeleteFile ( ( awakeDir + file ) . c_str ( ) ) ;
DeleteFile ( ( colorPickerDir + file ) . c_str ( ) ) ;
DeleteFile ( ( powerOCRDir + file ) . c_str ( ) ) ;
DeleteFile ( ( launcherDir + file ) . c_str ( ) ) ;
DeleteFile ( ( fancyZonesDir + file ) . c_str ( ) ) ;
DeleteFile ( ( imageResizerDir + file ) . c_str ( ) ) ;
DeleteFile ( ( powerAccentDir + file ) . c_str ( ) ) ;
DeleteFile ( ( fileExplorerAddOnsDir + file ) . c_str ( ) ) ;
DeleteFile ( ( hostsDir + file ) . c_str ( ) ) ;
}
}
catch ( std : : exception e )
{
std : : string errorMessage { " Exception thrown while trying to delete dotnet runtime hardlinks: " } ;
errorMessage + = e . what ( ) ;
Logger : : error ( errorMessage ) ;
er = ERROR_INSTALL_FAILURE ;
}
LExit :
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2020-05-15 00:20:06 +08:00
UINT __stdcall TerminateProcessesCA ( MSIHANDLE hInstall )
{
HRESULT hr = S_OK ;
UINT er = ERROR_SUCCESS ;
hr = WcaInitialize ( hInstall , " TerminateProcessesCA " ) ;
std : : vector < DWORD > processes ;
const size_t maxProcesses = 4096 ;
DWORD bytes = maxProcesses * sizeof ( processes [ 0 ] ) ;
processes . resize ( maxProcesses ) ;
if ( ! EnumProcesses ( processes . data ( ) , bytes , & bytes ) )
{
return 1 ;
}
processes . resize ( bytes / sizeof ( processes [ 0 ] ) ) ;
2021-12-30 01:33:20 +08:00
std : : array < std : : wstring_view , 9 > processesToTerminate = {
2021-12-10 17:50:46 +08:00
L " PowerToys.PowerLauncher.exe " ,
2021-02-12 00:29:56 +08:00
L " PowerToys.Settings.exe " ,
2021-07-27 06:23:34 +08:00
L " PowerToys.Awake.exe " ,
L " PowerToys.FancyZones.exe " ,
2021-12-10 17:50:46 +08:00
L " PowerToys.FancyZonesEditor.exe " ,
[New PowerToy] File Locksmith (#20930)
* Imported offline solution
* Make solution compile
* Add Windows sample, doesn't work?
* Added new project to implement the dll
* Remove unneeded header
* Implemented IUnknown part of ExplorerCommand
* Implemented IExplorerCommand methods
* Implemented ClassFactory
* Implemented DLL register/unregister
* Implemented other DLL exports, not working?
* Implemented IShellExtInit inferface
* Implemented IContextMenu, it works!
* Implement command data fetching
* Make sample project compile on VS 2022
* Add plan
* Implement Lib as separate project
* Implemented IPC, not tested
* Console UI project skeleton
* Implemented basic console UI
* Implemented piping, there are bugs
* Prototype works
* Remove old project
* Added GUI project skeleton
* Mitigate issue with WinUI3
* Added a control for displaying results
* Add button
* Implement core functions in lib project
* Call new library function from console main
* Implement showing results
* Improve UI
* Implemented subdirectory search
* Remove useless code
* Set window size
* UI adjustments
* Implement killing process
* Rename variable
* Add lib project to main solution
* Add Ext and GUI projects to solution
* Tweak packages for GUI project
* Add a settings page
* Add a few resource strings
* Add one more resources string
* VS keeps trying to correct this
* Add references to File Locksmith in /,github
* Implement some parts of FileLocksmithModule
* Change output directory
* Change target name and add to runner
* Add logger
* Started implementing settings backend
* Fix log folder
* Settings work
* Add some basic tracing
* Attempt at adding resources
* Remove junk files
* Added missing defines
* Replaced some constants with resources
Something's not working
* Move resources to the Ext project
* Remove experiment
* Add binaries for signing
* Improve tracing
* Remove old Settings calls
* Show something when there are no results
* Change window title
* Move computation to another thread, improve UX
* Increase font size for default text
* Remove entries for killed processes
* Show user name
* Remove nonrecursive implementation
* Implement back end for getting file names
* Show list of files, UI tweaks
* Remove useless includes
* Implement back end for getting full process path
* Dark title bar on dark themes
* Using Expander, other UI adjustments
* Show "No results" after killing all processes
* Show progress ring
* Update configuration mapping
* Revert "Update configuration mapping"
This reverts commit d8e13206f3c7de3c6dbf880299bfff3bf9f27a37.
* Fixed solution configuration, ARM64 should build
* Backend for refreshing
* Variable window size
* Add refresh button
* New WinUI3 C# project for FL
* Started porting functionality
* Add Interop project
* Move IPC to Ext project
* Ported native functions to Interop
* Ported finding processes
* Ported most of Main Window functionality
* Display paths of files
* Implement killing processes
* Use resource string for "End Task"
* Remove entries for terminated processes
* Show User name
* Set default window size
* Make the new UI the default
* Reading paths from stdin, completed port to C#
* Fix small bug
* Moving to MVVM
* Adding Labs
* Merge branch 'ivan/file-locksmith' of https://github.com/microsoft/PowerToys into ivan/file-locksmith
Removing one parent commit for cleaner history
Co-Authored-By: Niels Laute <niels.laute@live.nl>
* Reintroducing features
* Moving UI strings to resources file
* Restored functionality
* Add missing dlls
* Add FIle Locksmith to publish.cmd
* Rebase fixes
* Try updating nuget.config
* Fix copy-paste blunder
* Add File Locksmith UI for publishing
* Add .pubxml file in FileLocksmith
* Change build output folder
* Fix installer build issues
Remove old projects from solution so MSBuild doesn't build them.
Downgrade target framework to what most other projects are using.
Fix publishing profile and project runtimes.
Remove unused CsWinRT references.
* [CI] Add clear to nuget packages
* Fix module reference counting
* Fix nuget for release CI
* Fix version and signing
* Fix path for resources
* Fix incorrect results when running 2 instances
* Fix default nuget source
* Windows 10 icon and fallback for UI
* Code clean-up and spaces instead of tabs
* Add gif showcasing FL
* Add screenshot of File Locksmith for Settings
* Add new files to the installer
* Add OOBE page
* Showing selected paths in the header
* Tweak path list
* Added new, wider gif
* Add GPO
* Add some logs
* [CI]Get CommunityToolkit.Labs from BigPark feed
* [CI]Use azure package feed for Nuget in release
* [CI]Another try for the labs source
* Revert changes to feed
* Use RestoreAdditionalProjectSources
* Add tooltip to file list
* Change tooltip to not trim the lines
* Add Tips and tricks section mentioning elevated
* Add some more logs messages.
* Grammar fix
* Add to bug report tool
* Fix UI virtualization not working
* Disable virtualization to avoid crashes
* Get better virtualization
* Add dialog instead of tooltip to show list of items
* No results refresh icon is now a button too
* Use managed methods for handling processes
* Remove registry code from Ext.
* Support drives too
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2022-10-28 21:51:21 +08:00
L " PowerToys.FileLocksmithUI.exe " ,
2021-12-10 17:50:46 +08:00
L " PowerToys.ColorPickerUI.exe " ,
2021-12-30 01:33:20 +08:00
L " PowerToys.AlwaysOnTop.exe " ,
2020-05-15 00:20:06 +08:00
L " PowerToys.exe "
} ;
for ( const auto procID : processes )
{
if ( ! procID )
{
continue ;
}
wchar_t processName [ MAX_PATH ] = L " <unknown> " ;
2021-09-21 20:15:59 +08:00
HANDLE hProcess { OpenProcess ( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE , FALSE , procID ) } ;
2020-05-15 00:20:06 +08:00
if ( ! hProcess )
{
continue ;
}
HMODULE hMod ;
DWORD cbNeeded ;
if ( ! EnumProcessModules ( hProcess , & hMod , sizeof ( hMod ) , & cbNeeded ) )
{
CloseHandle ( hProcess ) ;
continue ;
}
GetModuleBaseNameW ( hProcess , hMod , processName , sizeof ( processName ) / sizeof ( wchar_t ) ) ;
for ( const auto processToTerminate : processesToTerminate )
{
if ( processName = = processToTerminate )
{
const DWORD timeout = 500 ;
auto windowEnumerator = [ ] ( HWND hwnd , LPARAM procIDPtr ) - > BOOL {
auto targetProcID = * reinterpret_cast < const DWORD * > ( procIDPtr ) ;
DWORD windowProcID = 0 ;
GetWindowThreadProcessId ( hwnd , & windowProcID ) ;
if ( windowProcID = = targetProcID )
{
2021-09-21 20:15:59 +08:00
DWORD_PTR _ { } ;
2020-05-15 00:20:06 +08:00
SendMessageTimeoutA ( hwnd , WM_CLOSE , 0 , 0 , SMTO_BLOCK , timeout , & _ ) ;
}
return TRUE ;
} ;
EnumWindows ( windowEnumerator , reinterpret_cast < LPARAM > ( & procID ) ) ;
Sleep ( timeout ) ;
TerminateProcess ( hProcess , 0 ) ;
break ;
}
}
CloseHandle ( hProcess ) ;
}
er = SUCCEEDED ( hr ) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE ;
return WcaFinalize ( er ) ;
}
2019-09-05 00:26:26 +08:00
// DllMain - Initialize and cleanup WiX custom action utils.
2020-04-13 21:00:51 +08:00
extern " C " BOOL WINAPI DllMain ( __in HINSTANCE hInst , __in ULONG ulReason , __in LPVOID )
{
switch ( ulReason )
{
case DLL_PROCESS_ATTACH :
WcaGlobalInitialize ( hInst ) ;
TraceLoggingRegister ( g_hProvider ) ;
2021-09-21 20:15:59 +08:00
DLL_HANDLE = hInst ;
2020-04-13 21:00:51 +08:00
break ;
case DLL_PROCESS_DETACH :
TraceLoggingUnregister ( g_hProvider ) ;
WcaGlobalFinalize ( ) ;
break ;
}
return TRUE ;
2019-09-05 00:26:26 +08:00
}