mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-23 19:49:17 +08:00
[General]Add an option for telemetry opt-in and visualization(#34078)
* Data diagnostics opt-in
* [c++] Drop DROP_PII flag
* Bump telemtry package to 2.0.2
* Drop DropPii from custom actions
* Cleanup
* Do not start manually C# EtwTrace. FZ engine exit event.
* ImageResizer, PowerRename, FileLocksmith prev handlers
* Revert C# handlers exe logging
* Revert "Revert C# handlers exe logging"
This reverts commit 4c75a3953b
.
* Do not recreate EtwTrace
* consume package
* xaml formatting
* Fix deps.json audit
* Update telem package paths
* Address PR comments
* Fix AdvancedPaste close on PT close
* Override etl file name for explorer loaded dlls
Start/stop tracer when needed for explorer loaded dlls to prevent explorer overload
* Fix setting desc
* Fix missing events
* Add infobar to restart when enable data viewing
* Flush on timer every 30s
* [Settings] Update View Data diagnostic description text
[New+] Add tracer
* Show Restart info bar for both enable/disable data viewer
* Fix newplus
* Fix stuck on restart and terminate AdvPaste exe on destroy()
* [Installer] Add tracer
* Address PR comment
* Add missing tracers
* Exclude etw dir from BugReport
* Fix bad merge
* [Hosts] Proper exit on initial dialog
* [OOBE] Make Data diagnostic setting visible without scroll
* [OOBE] Add hiperlynk to open general settings
* Disable data view on disabling data diagnostics
* Don't disable View data button
* Fix disabling data viewing
* Add missing dot
* Revert formatting
This commit is contained in:
parent
f9127b63a5
commit
133aa85f2b
27
.github/actions/spell-check/expect.txt
vendored
27
.github/actions/spell-check/expect.txt
vendored
@ -43,6 +43,7 @@ AMPROPSETID
|
||||
amr
|
||||
ANDSCANS
|
||||
animatedvisuals
|
||||
anr
|
||||
ansicolor
|
||||
ANull
|
||||
AOC
|
||||
@ -57,14 +58,12 @@ APPBARDATA
|
||||
appdata
|
||||
APPEXECLINK
|
||||
Appium
|
||||
applayout
|
||||
Applicationcan
|
||||
APPLICATIONFRAMEHOST
|
||||
appmanifest
|
||||
APPNAME
|
||||
appref
|
||||
appsettings
|
||||
appsfolder
|
||||
appwindow
|
||||
appwiz
|
||||
APSTUDIO
|
||||
@ -145,7 +144,6 @@ BTNFACE
|
||||
bugreport
|
||||
BUILDARCH
|
||||
BUILDNUMBER
|
||||
buildtask
|
||||
buildtransitive
|
||||
BVal
|
||||
BValue
|
||||
@ -269,7 +267,6 @@ CSettings
|
||||
cso
|
||||
CSRW
|
||||
CStyle
|
||||
cswinrt
|
||||
CSY
|
||||
CTest
|
||||
currentculture
|
||||
@ -351,7 +348,6 @@ devpkey
|
||||
DEVSOURCE
|
||||
DIIRFLAG
|
||||
dimm
|
||||
directshow
|
||||
DISABLEASACTIONKEY
|
||||
diskmgmt
|
||||
DISPLAYCHANGE
|
||||
@ -367,7 +363,6 @@ dllmain
|
||||
DNLEN
|
||||
DONOTROUND
|
||||
DONTVALIDATEPATH
|
||||
DOPUS
|
||||
dotnet
|
||||
DPICHANGED
|
||||
DPIs
|
||||
@ -450,12 +445,13 @@ erwrite
|
||||
ESettings
|
||||
esrp
|
||||
etl
|
||||
ETW
|
||||
etw
|
||||
EUQ
|
||||
eurochange
|
||||
eventlog
|
||||
eventvwr
|
||||
everytime
|
||||
evntrace
|
||||
evt
|
||||
EWXFORCE
|
||||
EWXFORCEIFHUNG
|
||||
@ -527,7 +523,6 @@ FZE
|
||||
gacutil
|
||||
Gaeilge
|
||||
Gaidhlig
|
||||
GBarm
|
||||
GCLP
|
||||
gdi
|
||||
gdiplus
|
||||
@ -997,7 +992,6 @@ NCRENDERING
|
||||
ndp
|
||||
NEEDDISPATCH
|
||||
needinfo
|
||||
netcore
|
||||
netcoreapp
|
||||
netcpl
|
||||
netframework
|
||||
@ -1006,6 +1000,7 @@ netsh
|
||||
newcolor
|
||||
newdev
|
||||
NEWDIALOGSTYLE
|
||||
NEWFILE
|
||||
newitem
|
||||
newpath
|
||||
newplus
|
||||
@ -1074,7 +1069,6 @@ NTAPI
|
||||
ntdll
|
||||
ntfs
|
||||
NTSTATUS
|
||||
nugets
|
||||
nullonfailure
|
||||
numberbox
|
||||
nwc
|
||||
@ -1225,6 +1219,7 @@ proactively
|
||||
PROCESSENTRY
|
||||
PROCESSKEY
|
||||
processthreadsapi
|
||||
PROCESSTRACE
|
||||
PRODEXT
|
||||
PRODUCTVERSION
|
||||
Progman
|
||||
@ -1266,7 +1261,6 @@ PWSTR
|
||||
pwsz
|
||||
pwtd
|
||||
QDC
|
||||
QDir
|
||||
qianlifeng
|
||||
qit
|
||||
QITAB
|
||||
@ -1590,9 +1584,7 @@ SYSKEYUP
|
||||
SYSLIB
|
||||
SYSMENU
|
||||
SYSTEMAPPS
|
||||
SYSTEMSETTINGS
|
||||
SYSTEMTIME
|
||||
SYSTEMWOW
|
||||
tapp
|
||||
TApplication
|
||||
TApplied
|
||||
@ -1612,7 +1604,6 @@ TCustom
|
||||
tdbuild
|
||||
TDefault
|
||||
TDevice
|
||||
telem
|
||||
telephon
|
||||
templatenamespace
|
||||
testprocess
|
||||
@ -1644,11 +1635,12 @@ toolkitconverters
|
||||
Toolset
|
||||
toolwindow
|
||||
TOPDOWNDIB
|
||||
TOTALCMD
|
||||
TOUCHEVENTF
|
||||
TOUCHINPUT
|
||||
touchpad
|
||||
TRACEHANDLE
|
||||
tracelogging
|
||||
tracerpt
|
||||
trafficmanager
|
||||
traies
|
||||
transicc
|
||||
@ -1706,11 +1698,9 @@ urlmon
|
||||
Usb
|
||||
USEDEFAULT
|
||||
USEFILEATTRIBUTES
|
||||
USEPOSITION
|
||||
USERDATA
|
||||
Userenv
|
||||
USESHOWWINDOW
|
||||
USESIZE
|
||||
USESTDHANDLES
|
||||
USRDLL
|
||||
UType
|
||||
@ -1803,7 +1793,6 @@ wgpocpl
|
||||
WIC
|
||||
wil
|
||||
winapi
|
||||
winappdriver
|
||||
wincodec
|
||||
Wincodecsdk
|
||||
wincolor
|
||||
@ -1867,6 +1856,7 @@ WNDCLASSEX
|
||||
WNDCLASSEXW
|
||||
WNDCLASSW
|
||||
WNDPROC
|
||||
wnode
|
||||
workarounds
|
||||
WORKSPACESEDITOR
|
||||
WORKSPACESLAUNCHER
|
||||
@ -1912,7 +1902,6 @@ XNamespace
|
||||
Xoshiro
|
||||
XPels
|
||||
XPixel
|
||||
xplorer
|
||||
XResource
|
||||
xsi
|
||||
XStr
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.PowerToys.Telemetry" version="2.0" />
|
||||
<package id="Microsoft.PowerToys.Telemetry" version="2.0.2" />
|
||||
</packages>
|
||||
|
@ -90,8 +90,8 @@ extends:
|
||||
|
||||
- script: |
|
||||
call nuget.exe restore -configFile .pipelines/release-nuget.config -PackagesDirectory . .pipelines/packages.config || exit /b 1
|
||||
move /Y "Microsoft.PowerToys.Telemetry.2.0.0\build\include\TraceLoggingDefines.h" "src\common\Telemetry\TraceLoggingDefines.h" || exit /b 1
|
||||
move /Y "Microsoft.PowerToys.Telemetry.2.0.0\build\include\TelemetryBase.cs" "src\common\Telemetry\TelemetryBase.cs" || exit /b 1
|
||||
move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TraceLoggingDefines.h" "src\common\Telemetry\TraceLoggingDefines.h" || exit /b 1
|
||||
move /Y "Microsoft.PowerToys.Telemetry.2.0.2\build\include\TelemetryBase.cs" "src\common\Telemetry\TelemetryBase.cs" || exit /b 1
|
||||
displayName: Emplace telemetry files
|
||||
|
||||
- stage: Publish
|
||||
|
@ -28,6 +28,7 @@
|
||||
<PackageVersion Include="MessagePack" Version="2.5.187" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.7" />
|
||||
<PackageVersion Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.16" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
|
@ -1320,6 +1320,7 @@ EXHIBIT A -Mozilla Public License.
|
||||
- MessagePack 2.5.187
|
||||
- Microsoft.CodeAnalysis.NetAnalyzers 8.0.0
|
||||
- Microsoft.Data.Sqlite 8.0.7
|
||||
- Microsoft.Diagnostics.Tracing.TraceEvent 3.1.16
|
||||
- Microsoft.Extensions.DependencyInjection 8.0.0
|
||||
- Microsoft.Extensions.Hosting 8.0.0
|
||||
- Microsoft.Extensions.Hosting.WindowsServices 8.0.0
|
||||
|
@ -298,6 +298,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Telemetry", "Telemetry", "{
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
src\common\Telemetry\ProjectTelemetry.h = src\common\Telemetry\ProjectTelemetry.h
|
||||
src\common\Telemetry\TelemetryBase.cs = src\common\Telemetry\TelemetryBase.cs
|
||||
src\common\Telemetry\TraceBase.h = src\common\Telemetry\TraceBase.h
|
||||
src\common\Telemetry\TraceLoggingDefines.h = src\common\Telemetry\TraceLoggingDefines.h
|
||||
EndProjectSection
|
||||
EndProject
|
||||
@ -625,6 +626,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WorkspacesLauncher", "src\m
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WorkspacesWindowArranger", "src\modules\Workspaces\WorkspacesWindowArranger\WorkspacesWindowArranger.vcxproj", "{37D07516-4185-43A4-924F-3C7A5D95ECF6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EtwTrace", "src\common\Telemetry\EtwTrace\EtwTrace.vcxproj", "{8F021B46-362B-485C-BFBA-CCF83E820CBD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MouseWithoutBorders.UnitTests", "src\modules\MouseWithoutBorders\MouseWithoutBorders.UnitTests\MouseWithoutBorders.UnitTests.csproj", "{66614C26-314C-4B91-9071-76133422CFEF}"
|
||||
EndProject
|
||||
Global
|
||||
@ -2751,6 +2754,18 @@ Global
|
||||
{37D07516-4185-43A4-924F-3C7A5D95ECF6}.Release|x64.Build.0 = Release|x64
|
||||
{37D07516-4185-43A4-924F-3C7A5D95ECF6}.Release|x86.ActiveCfg = Release|x64
|
||||
{37D07516-4185-43A4-924F-3C7A5D95ECF6}.Release|x86.Build.0 = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x64.Build.0 = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x86.Build.0 = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x64.ActiveCfg = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x64.Build.0 = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x86.ActiveCfg = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x86.Build.0 = Release|x64
|
||||
{66614C26-314C-4B91-9071-76133422CFEF}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{66614C26-314C-4B91-9071-76133422CFEF}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{66614C26-314C-4B91-9071-76133422CFEF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@ -2992,6 +3007,7 @@ Global
|
||||
{367D7543-7DBA-4381-99F1-BF6142A996C4} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF}
|
||||
{2CAC093E-5FCF-4102-9C2C-AC7DD5D9EB96} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF}
|
||||
{37D07516-4185-43A4-924F-3C7A5D95ECF6} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF}
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD} = {8F62026A-294B-41C6-8839-87463613F216}
|
||||
{66614C26-314C-4B91-9071-76133422CFEF} = {B6C42F16-73EB-477E-8B0D-4E6CF6C20AAC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
|
@ -15,6 +15,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "PowerToysBootstrapper", "Po
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Version", "..\src\common\version\version.vcxproj", "{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EtwTrace", "..\src\common\Telemetry\EtwTrace\EtwTrace.vcxproj", "{8F021B46-362B-485C-BFBA-CCF83E820CBD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
@ -68,6 +70,14 @@ Global
|
||||
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.ActiveCfg = Release|x64
|
||||
{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.Build.0 = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Debug|x64.Build.0 = Debug|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x64.ActiveCfg = Release|x64
|
||||
{8F021B46-362B-485C-BFBA-CCF83E820CBD}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../../src/common/utils/modulesRegistry.h"
|
||||
#include "../../src/common/updating/installer.h"
|
||||
#include "../../src/common/version/version.h"
|
||||
#include "../../src/common/Telemetry/EtwTrace/EtwTrace.h"
|
||||
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
@ -27,9 +28,9 @@ HINSTANCE DLL_HANDLE = nullptr;
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToysInstaller",
|
||||
// {e1d8165d-5cb6-5c74-3b51-bdfbfe4f7a3b}
|
||||
(0xe1d8165d, 0x5cb6, 0x5c74, 0x3b, 0x51, 0xbd, 0xfb, 0xfe, 0x4f, 0x7a, 0x3b),
|
||||
"Microsoft.PowerToys",
|
||||
// {38e8889b-9731-53f5-e901-e8a7c1753074}
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
const DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2; // Domain Name + '\' + User Name + '\0'
|
||||
@ -38,6 +39,53 @@ const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0'
|
||||
static const wchar_t* POWERTOYS_EXE_COMPONENT = L"{A2C66D91-3485-4D00-B04D-91844E6B345B}";
|
||||
static const wchar_t* POWERTOYS_UPGRADE_CODE = L"{42B84BF7-5FBF-473B-9C8B-049DC16F7708}";
|
||||
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
|
||||
|
||||
#define TraceLoggingWriteWrapper(provider, eventName, ...) \
|
||||
if (isDataDiagnosticEnabled()) \
|
||||
{ \
|
||||
trace.UpdateState(true); \
|
||||
TraceLoggingWrite(provider, eventName, __VA_ARGS__); \
|
||||
trace.Flush(); \
|
||||
trace.UpdateState(false); \
|
||||
}
|
||||
|
||||
static Shared::Trace::ETWTrace trace{ L"PowerToys_Installer" };
|
||||
|
||||
inline bool isDataDiagnosticEnabled()
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
KEY_READ,
|
||||
&key) != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD isDataDiagnosticsEnabled = 0;
|
||||
DWORD size = sizeof(isDataDiagnosticsEnabled);
|
||||
|
||||
if (RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
DataDiagnosticsRegValueName,
|
||||
RRF_RT_REG_DWORD,
|
||||
nullptr,
|
||||
&isDataDiagnosticsEnabled,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return false;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
|
||||
return isDataDiagnosticsEnabled == 1;
|
||||
}
|
||||
|
||||
|
||||
HRESULT getInstallFolder(MSIHANDLE hInstall, std::wstring& installationDir)
|
||||
{
|
||||
DWORD len = 0;
|
||||
@ -793,13 +841,14 @@ UINT __stdcall TelemetryLogInstallSuccessCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogInstallSuccessCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Install_Success",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)
|
||||
);
|
||||
|
||||
LExit:
|
||||
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
|
||||
@ -814,7 +863,7 @@ UINT __stdcall TelemetryLogInstallCancelCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogInstallCancelCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Install_Cancel",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -835,7 +884,7 @@ UINT __stdcall TelemetryLogInstallFailCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogInstallFailCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Install_Fail",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -856,7 +905,7 @@ UINT __stdcall TelemetryLogUninstallSuccessCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogUninstallSuccessCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"UnInstall_Success",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -877,7 +926,7 @@ UINT __stdcall TelemetryLogUninstallCancelCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogUninstallCancelCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"UnInstall_Cancel",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -898,7 +947,7 @@ UINT __stdcall TelemetryLogUninstallFailCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogUninstallFailCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"UnInstall_Fail",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -919,7 +968,7 @@ UINT __stdcall TelemetryLogRepairCancelCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogRepairCancelCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Repair_Cancel",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
@ -940,7 +989,7 @@ UINT __stdcall TelemetryLogRepairFailCA(MSIHANDLE hInstall)
|
||||
hr = WcaInitialize(hInstall, "TelemetryLogRepairFailCA");
|
||||
ExitOnFailure(hr, "Failed to initialize");
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"Repair_Fail",
|
||||
TraceLoggingWideString(get_product_version().c_str(), "Version"),
|
||||
|
@ -161,6 +161,9 @@
|
||||
<ProjectReference Include="..\..\src\common\logger\logger.vcxproj">
|
||||
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -224,4 +224,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredNewPlusHideTemplateFilenameExtensionValue());
|
||||
}
|
||||
GpoRuleConfigured GPOWrapper::GetAllowDataDiagnosticsValue()
|
||||
{
|
||||
return static_cast<GpoRuleConfigured>(powertoys_gpo::getAllowDataDiagnosticsValue());
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
|
||||
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
||||
static winrt::hstring GPOWrapper::GetConfiguredMwbPolicyDefinedIpMappingRules();
|
||||
static GpoRuleConfigured GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||
static GpoRuleConfigured GetAllowDataDiagnosticsValue();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ namespace PowerToys
|
||||
static GpoRuleConfigured GetConfiguredMwbDisableUserDefinedIpMappingRulesValue();
|
||||
static String GetConfiguredMwbPolicyDefinedIpMappingRules();
|
||||
static GpoRuleConfigured GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
|
||||
static GpoRuleConfigured GetAllowDataDiagnosticsValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
107
src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs
Normal file
107
src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs
Normal file
@ -0,0 +1,107 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Microsoft.PowerToys.Telemetry
|
||||
{
|
||||
public static class DataDiagnosticsSettings
|
||||
{
|
||||
private static readonly string DataDiagnosticsRegistryKey = @"HKEY_CURRENT_USER\Software\Classes\PowerToys\";
|
||||
private static readonly string DataDiagnosticsRegistryValueName = @"AllowDataDiagnostics";
|
||||
private static readonly string DataDiagnosticsDataDiagnosticsUserActionRegistryValueName = @"DataDiagnosticsUserAction";
|
||||
private static readonly string DataDiagnosticsDataDiagnosticsViewDataRegistryValueName = @"DataDiagnosticsViewEnabled";
|
||||
|
||||
public static bool GetEnabledValue()
|
||||
{
|
||||
object registryValue = null;
|
||||
try
|
||||
{
|
||||
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (registryValue is not null)
|
||||
{
|
||||
return (int)registryValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetEnabledValue(bool value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Registry.SetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, value ? 1 : 0);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GetUserActionValue()
|
||||
{
|
||||
object registryValue = null;
|
||||
try
|
||||
{
|
||||
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsUserActionRegistryValueName, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (registryValue is not null)
|
||||
{
|
||||
return (int)registryValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetUserActionValue(bool value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Registry.SetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsUserActionRegistryValueName, value ? 1 : 0);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GetViewEnabledValue()
|
||||
{
|
||||
object registryValue = null;
|
||||
try
|
||||
{
|
||||
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsViewDataRegistryValueName, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (registryValue is not null)
|
||||
{
|
||||
return (int)registryValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetViewEnabledValue(bool value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Registry.SetValue(DataDiagnosticsRegistryKey, DataDiagnosticsDataDiagnosticsViewDataRegistryValueName, value ? 1 : 0);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
158
src/common/ManagedTelemetry/Telemetry/EtwTrace.cs
Normal file
158
src/common/ManagedTelemetry/Telemetry/EtwTrace.cs
Normal file
@ -0,0 +1,158 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Diagnostics.Tracing.Session;
|
||||
|
||||
namespace Microsoft.PowerToys.Telemetry
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is based loosely on the C++ ETWTrace class in Win32client/Framework project.
|
||||
/// It is intended to record telemetry events generated by the PowerToys processes so that end users
|
||||
/// can view them if they want.
|
||||
/// </summary>
|
||||
public class ETWTrace : IDisposable
|
||||
{
|
||||
internal const EventKeywords TelemetryKeyword = (EventKeywords)0x0000200000000000;
|
||||
internal const EventKeywords MeasuresKeyword = (EventKeywords)0x0000400000000000;
|
||||
internal const EventKeywords CriticalDataKeyword = (EventKeywords)0x0000800000000000;
|
||||
|
||||
private readonly bool telemetryEnabled = DataDiagnosticsSettings.GetEnabledValue(); // This is the global telemetry setting on whether to log events
|
||||
private readonly bool telemetryRecordingEnabled = DataDiagnosticsSettings.GetViewEnabledValue(); // This is the setting for recording telemetry events to disk for viewing
|
||||
private readonly string etwFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\PowerToys\", "etw");
|
||||
private bool disposedValue;
|
||||
private string sessionName;
|
||||
private string etwFilePath;
|
||||
private bool started;
|
||||
#nullable enable
|
||||
private TraceEventSession? traceSession;
|
||||
|
||||
internal sealed class Lister : EventListener
|
||||
{
|
||||
public Lister()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private Lister? listener;
|
||||
#nullable disable
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ETWTrace"/> class.
|
||||
/// </summary>
|
||||
public ETWTrace()
|
||||
{
|
||||
if (File.Exists(etwFolderPath))
|
||||
{
|
||||
File.Delete(etwFolderPath);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(etwFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(etwFolderPath);
|
||||
}
|
||||
|
||||
if (this.telemetryEnabled && this.telemetryRecordingEnabled)
|
||||
{
|
||||
this.Start();
|
||||
}
|
||||
|
||||
listener = new Lister();
|
||||
listener.EnableEvents(PowerToysTelemetry.Log, EventLevel.LogAlways);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
this.Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the trace session.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (this.started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new Task(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(30 * 1000);
|
||||
|
||||
this.traceSession.Flush();
|
||||
}
|
||||
}).Start();
|
||||
|
||||
string executable = Process.GetCurrentProcess().ProcessName;
|
||||
string dateTimeNow = DateTime.Now.ToString("MM-d-yyyy__H_mm_ss", CultureInfo.InvariantCulture);
|
||||
this.sessionName = string.Format(CultureInfo.InvariantCulture, "{0}-{1}-{2}", executable, Environment.ProcessId, dateTimeNow);
|
||||
this.etwFilePath = Path.Combine(etwFolderPath, $"{this.sessionName}.etl");
|
||||
|
||||
this.traceSession = new TraceEventSession(
|
||||
this.sessionName, this.etwFilePath, (TraceEventSessionOptions)(TraceEventSessionOptions.Create | TraceEventSessionOptions.PrivateLogger | TraceEventSessionOptions.PrivateInProcLogger));
|
||||
TraceEventProviderOptions args = new TraceEventProviderOptions();
|
||||
|
||||
this.traceSession.EnableProvider(
|
||||
PowerToysTelemetry.Log.Guid,
|
||||
matchAnyKeywords: (ulong)TelemetryKeyword | (ulong)MeasuresKeyword | (ulong)CriticalDataKeyword);
|
||||
|
||||
this.started = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the trace session.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (!this.started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.traceSession != null)
|
||||
{
|
||||
Trace.TraceInformation("Disposing EventTraceSession");
|
||||
this.traceSession.Dispose();
|
||||
this.traceSession = null;
|
||||
this.started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the object.
|
||||
/// </summary>
|
||||
/// <param name="disposing">boolean for disposing.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.Stop();
|
||||
}
|
||||
|
||||
this.disposedValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,4 +11,8 @@
|
||||
<Compile Include="..\..\Telemetry\TelemetryBase.cs" Link="TelemetryBase.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" />
|
||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -36,6 +36,8 @@ namespace Microsoft.PowerToys.Telemetry
|
||||
/// </summary>
|
||||
public void WriteEvent<T>(T telemetryEvent)
|
||||
where T : EventBase, IEvent
|
||||
{
|
||||
if (DataDiagnosticsSettings.GetEnabledValue())
|
||||
{
|
||||
this.Write<T>(
|
||||
telemetryEvent.EventName,
|
||||
@ -48,3 +50,4 @@ namespace Microsoft.PowerToys.Telemetry
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace PTSettingsHelper
|
||||
constexpr inline const wchar_t* last_version_run_filename = L"last_version_run.json";
|
||||
constexpr inline const wchar_t* opened_at_first_launch_json_field_name = L"openedAtFirstLaunch";
|
||||
constexpr inline const wchar_t* last_version_json_field_name = L"last_version";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
|
||||
|
||||
std::wstring get_root_save_folder_location()
|
||||
{
|
||||
@ -129,7 +131,6 @@ namespace PTSettingsHelper
|
||||
|
||||
std::wstring get_last_version_run()
|
||||
{
|
||||
|
||||
std::filesystem::path lastVersionRunPath(PTSettingsHelper::get_root_save_folder_location());
|
||||
lastVersionRunPath = lastVersionRunPath.append(last_version_run_filename);
|
||||
if (std::filesystem::exists(lastVersionRunPath))
|
||||
@ -157,4 +158,29 @@ namespace PTSettingsHelper
|
||||
json::to_file(lastVersionRunPath.c_str(), obj);
|
||||
}
|
||||
|
||||
void save_data_diagnostics(bool enabled)
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&key,
|
||||
nullptr) != ERROR_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const bool value = enabled;
|
||||
const size_t buf_size = sizeof(bool);
|
||||
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_QWORD, reinterpret_cast<const BYTE*>(&value), buf_size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,6 @@ namespace PTSettingsHelper
|
||||
void save_oobe_opened_state();
|
||||
std::wstring get_last_version_run();
|
||||
void save_last_version_run(const std::wstring& version);
|
||||
|
||||
void save_data_diagnostics(bool enabled);
|
||||
}
|
||||
|
310
src/common/Telemetry/EtwTrace/EtwTrace.cpp
Normal file
310
src/common/Telemetry/EtwTrace/EtwTrace.cpp
Normal file
@ -0,0 +1,310 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
#include "ETWTrace.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <wil\stl.h>
|
||||
#include <wil\win32_helpers.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
|
||||
constexpr inline const wchar_t* ViewDataDiagnosticsRegValueName = L"DataDiagnosticsViewEnabled";
|
||||
|
||||
inline std::wstring get_root_save_folder_location()
|
||||
{
|
||||
PWSTR local_app_path;
|
||||
winrt::check_hresult(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &local_app_path));
|
||||
std::wstring result{ local_app_path };
|
||||
CoTaskMemFree(local_app_path);
|
||||
|
||||
result += L"\\Microsoft\\PowerToys";
|
||||
std::filesystem::path save_path(result);
|
||||
if (!std::filesystem::exists(save_path))
|
||||
{
|
||||
std::filesystem::create_directories(save_path);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsDataDiagnosticsEnabled()
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
KEY_READ,
|
||||
&key) != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD isDataDiagnosticsEnabled = 0;
|
||||
DWORD size = sizeof(isDataDiagnosticsEnabled);
|
||||
|
||||
if (RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
DataDiagnosticsRegValueName,
|
||||
RRF_RT_REG_DWORD,
|
||||
nullptr,
|
||||
&isDataDiagnosticsEnabled,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return false;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
|
||||
return isDataDiagnosticsEnabled;
|
||||
}
|
||||
|
||||
bool isViewDataDiagnosticEnabled()
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
KEY_READ,
|
||||
&key) != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD isDataDiagnosticsEnabled = 0;
|
||||
DWORD size = sizeof(isDataDiagnosticsEnabled);
|
||||
|
||||
if (RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
ViewDataDiagnosticsRegValueName,
|
||||
RRF_RT_REG_DWORD,
|
||||
nullptr,
|
||||
&isDataDiagnosticsEnabled,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return false;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
|
||||
return isDataDiagnosticsEnabled == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Trace
|
||||
{
|
||||
ETWTrace::ETWTrace()
|
||||
{
|
||||
GUID id;
|
||||
if (SUCCEEDED(CLSIDFromString(PowerToysProviderGUID, &id)))
|
||||
{
|
||||
m_providerGUID = id;
|
||||
}
|
||||
|
||||
fs::path outputFolder = get_root_save_folder_location();
|
||||
m_etwFolder = (outputFolder / c_etwFolderName);
|
||||
}
|
||||
|
||||
ETWTrace::ETWTrace(const std::wstring& etlFileNameOverride) :
|
||||
ETWTrace()
|
||||
{
|
||||
m_etlFileNameOverride = etlFileNameOverride;
|
||||
}
|
||||
|
||||
ETWTrace::~ETWTrace()
|
||||
{
|
||||
Flush();
|
||||
Stop();
|
||||
m_etwFolder.clear();
|
||||
m_providerGUID = {};
|
||||
}
|
||||
|
||||
void ETWTrace::UpdateState(bool tracing)
|
||||
{
|
||||
if (tracing)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void ETWTrace::Flush()
|
||||
{
|
||||
if (m_tracing)
|
||||
{
|
||||
Control(EVENT_TRACE_CONTROL_FLUSH);
|
||||
// Control(EVENT_TRACE_CONTROL_INCREMENT_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
void ETWTrace::CreateEtwFolderIfNeeded()
|
||||
{
|
||||
if (!std::filesystem::exists(m_etwFolder))
|
||||
{
|
||||
std::filesystem::create_directories(m_etwFolder);
|
||||
}
|
||||
else if (!std::filesystem::is_directory(m_etwFolder))
|
||||
{
|
||||
std::filesystem::remove(m_etwFolder);
|
||||
std::filesystem::create_directory(m_etwFolder);
|
||||
}
|
||||
|
||||
THROW_HR_IF(E_UNEXPECTED, !std::filesystem::exists(m_etwFolder));
|
||||
}
|
||||
|
||||
void ETWTrace::InitEventTraceProperties()
|
||||
{
|
||||
const std::filesystem::path exePath(wil::GetModuleFileNameW<std::wstring>(nullptr));
|
||||
const auto exeName = exePath.stem().wstring();
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto timeNow = std::chrono::system_clock::to_time_t(now);
|
||||
std::wstringstream dateTime;
|
||||
struct tm timeInfo
|
||||
{
|
||||
};
|
||||
errno_t err = localtime_s(&timeInfo, &timeNow);
|
||||
if (err == 0)
|
||||
{
|
||||
dateTime << std::put_time(&timeInfo, L"-%m-%d-%Y__%H_%M_%S");
|
||||
}
|
||||
|
||||
if (m_etlFileNameOverride.empty())
|
||||
{
|
||||
m_sessionName = wil::str_printf<std::wstring>(L"%ws-%d%ws", exeName.c_str(), GetCurrentProcessId(), dateTime.str().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sessionName = wil::str_printf<std::wstring>(L"%ws-%d%ws", m_etlFileNameOverride.c_str(), GetCurrentProcessId(), dateTime.str().c_str());
|
||||
}
|
||||
|
||||
std::replace(m_sessionName.begin(), m_sessionName.end(), '.', '_');
|
||||
|
||||
const ULONG etwSessionNameCharCount = static_cast<ULONG>(m_sessionName.size() + 1);
|
||||
const ULONG etwSessionNameByteSize = etwSessionNameCharCount * sizeof(m_sessionName[0]);
|
||||
|
||||
auto etlFileNameFormattedCounter = m_sessionName + c_etwNewFileFormattedCounter;
|
||||
std::filesystem::path etlFilePath = m_etwFolder / etlFileNameFormattedCounter;
|
||||
etlFilePath.replace_extension(c_etwFileNameEnd);
|
||||
THROW_HR_IF(E_UNEXPECTED, etlFilePath.empty());
|
||||
|
||||
const auto etlFilePathStr = etlFilePath.wstring();
|
||||
// std::string/wstring returns number of characters not including the null terminator, so add +1 for that.
|
||||
const ULONG etwFilePathCharCount = static_cast<ULONG>(etlFilePathStr.size() + 1);
|
||||
const ULONG etwFilePathByteSize = etwFilePathCharCount * sizeof(etlFilePathStr[0]);
|
||||
|
||||
const ULONG bufferSizeInBytes = sizeof(EVENT_TRACE_PROPERTIES) + etwSessionNameByteSize + etwFilePathByteSize;
|
||||
auto eventTracePropertiesBuffer = std::make_unique<unsigned char[]>(bufferSizeInBytes);
|
||||
ZeroMemory(eventTracePropertiesBuffer.get(), bufferSizeInBytes);
|
||||
auto eventTraceProperties = reinterpret_cast<EVENT_TRACE_PROPERTIES*>(eventTracePropertiesBuffer.get());
|
||||
|
||||
eventTraceProperties->Wnode.BufferSize = bufferSizeInBytes;
|
||||
eventTraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
|
||||
eventTraceProperties->Wnode.ClientContext = 1;
|
||||
eventTraceProperties->Wnode.Guid = m_providerGUID;
|
||||
eventTraceProperties->BufferSize = 4; // 4KB, the minimum size
|
||||
eventTraceProperties->LogFileMode = EVENT_TRACE_PRIVATE_LOGGER_MODE | EVENT_TRACE_PRIVATE_IN_PROC | EVENT_TRACE_FILE_MODE_NEWFILE;
|
||||
eventTraceProperties->MaximumFileSize = 1; // 1 MB
|
||||
|
||||
// LoggerName is placed at the end of EVENT_TRACE_PROPERTIES structure
|
||||
eventTraceProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
|
||||
wcsncpy_s(reinterpret_cast<LPWSTR>(eventTracePropertiesBuffer.get() + eventTraceProperties->LoggerNameOffset), etwSessionNameCharCount, m_sessionName.c_str(), etwSessionNameCharCount);
|
||||
|
||||
// LogFileName is placed at the end of the Logger Name
|
||||
eventTraceProperties->LogFileNameOffset = eventTraceProperties->LoggerNameOffset + etwSessionNameByteSize;
|
||||
wcsncpy_s(reinterpret_cast<LPWSTR>(eventTracePropertiesBuffer.get() + eventTraceProperties->LogFileNameOffset), etwFilePathCharCount, etlFilePathStr.c_str(), etwFilePathCharCount);
|
||||
|
||||
m_eventTracePropertiesBuffer = std::move(eventTracePropertiesBuffer);
|
||||
}
|
||||
|
||||
void ETWTrace::Start()
|
||||
{
|
||||
if (m_tracing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsDataDiagnosticsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isViewDataDiagnosticEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CreateEtwFolderIfNeeded();
|
||||
InitEventTraceProperties();
|
||||
|
||||
auto eventTraceProperties = reinterpret_cast<EVENT_TRACE_PROPERTIES*>(m_eventTracePropertiesBuffer.get());
|
||||
THROW_IF_WIN32_ERROR(StartTrace(&m_traceHandle, m_sessionName.c_str(), eventTraceProperties));
|
||||
Enable(EVENT_CONTROL_CODE_ENABLE_PROVIDER);
|
||||
|
||||
m_tracing = true;
|
||||
|
||||
m_flushing_thread = std::thread([this] { FlushWorker(); });
|
||||
}
|
||||
|
||||
void ETWTrace::Stop()
|
||||
{
|
||||
if (!m_tracing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Enable(EVENT_CONTROL_CODE_DISABLE_PROVIDER);
|
||||
|
||||
// ControlTrace with EVENT_TRACE_CONTROL_STOP on the trace handle,
|
||||
// which is equivalent to calling CloseTrace() on the trace handle.
|
||||
Control(EVENT_TRACE_CONTROL_STOP);
|
||||
|
||||
m_traceHandle = INVALID_PROCESSTRACE_HANDLE;
|
||||
m_eventTracePropertiesBuffer.reset();
|
||||
m_tracing = false;
|
||||
m_terminate_flushing_thread.notify_one();
|
||||
m_flushing_thread.join();
|
||||
}
|
||||
|
||||
void ETWTrace::Control(ULONG traceControlCode)
|
||||
{
|
||||
auto eventTraceProperties = reinterpret_cast<EVENT_TRACE_PROPERTIES*>(m_eventTracePropertiesBuffer.get());
|
||||
const ULONG result = ControlTrace(m_traceHandle, m_sessionName.c_str(), eventTraceProperties, traceControlCode);
|
||||
THROW_IF_FAILED(HRESULT_FROM_WIN32(result));
|
||||
}
|
||||
|
||||
void ETWTrace::Enable(ULONG eventControlCode)
|
||||
{
|
||||
// Control the main provider
|
||||
THROW_IF_WIN32_ERROR(EnableTraceEx2(m_traceHandle, &m_providerGUID, eventControlCode, TRACE_LEVEL_VERBOSE, 0, 0, 0, nullptr));
|
||||
}
|
||||
|
||||
void ETWTrace::FlushWorker()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
while (m_tracing)
|
||||
{
|
||||
m_terminate_flushing_thread.wait_for(lock,
|
||||
std::chrono::seconds(30),
|
||||
[this]() { return !m_tracing.load(); });
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
src/common/Telemetry/EtwTrace/EtwTrace.h
Normal file
54
src/common/Telemetry/EtwTrace/EtwTrace.h
Normal file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
#include <evntrace.h>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
namespace Trace
|
||||
{
|
||||
class ETWTrace
|
||||
{
|
||||
public:
|
||||
static inline const wchar_t* PowerToysProviderGUID = L"{38e8889b-9731-53f5-e901-e8a7c1753074}";
|
||||
|
||||
ETWTrace();
|
||||
ETWTrace(const std::wstring& etlFileNameOverride);
|
||||
~ETWTrace();
|
||||
|
||||
void UpdateState(bool tracing);
|
||||
void Flush();
|
||||
|
||||
private:
|
||||
void CreateEtwFolderIfNeeded();
|
||||
void InitEventTraceProperties();
|
||||
void Start();
|
||||
void Stop();
|
||||
void Control(const ULONG traceControlCode);
|
||||
void Enable(const ULONG eventControlCode);
|
||||
void FlushWorker();
|
||||
|
||||
GUID m_providerGUID{};
|
||||
std::filesystem::path m_etwFolder;
|
||||
std::wstring m_sessionName;
|
||||
TRACEHANDLE m_traceHandle{ INVALID_PROCESSTRACE_HANDLE };
|
||||
std::unique_ptr<unsigned char[]> m_eventTracePropertiesBuffer;
|
||||
std::atomic_bool m_tracing{ false };
|
||||
std::wstring m_etlFileNameOverride{};
|
||||
std::thread m_flushing_thread;
|
||||
std::condition_variable m_terminate_flushing_thread;
|
||||
std::mutex m_mutex;
|
||||
|
||||
static constexpr PCWSTR c_etwFolderName = L"etw";
|
||||
static constexpr PCWSTR c_etwNewFileFormattedCounter = L"-%d";
|
||||
static constexpr PCWSTR c_etwFileNameEnd = L".etl";
|
||||
};
|
||||
}
|
||||
}
|
51
src/common/Telemetry/EtwTrace/EtwTrace.vcxproj
Normal file
51
src/common/Telemetry/EtwTrace/EtwTrace.vcxproj
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build"
|
||||
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8f021b46-362b-485c-bfba-ccf83e820cbd}</ProjectGuid>
|
||||
<RootNamespace>EtwTrace</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EtwTrace.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EtwTrace.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.231216.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
39
src/common/Telemetry/EtwTrace/EtwTrace.vcxproj.filters
Normal file
39
src/common/Telemetry/EtwTrace/EtwTrace.vcxproj.filters
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EtwTrace.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EtwTrace.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
|
||||
</ItemGroup>
|
||||
</Project>
|
5
src/common/Telemetry/EtwTrace/packages.config
Normal file
5
src/common/Telemetry/EtwTrace/packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.240111.5" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.231216.1" targetFramework="native" />
|
||||
</packages>
|
5
src/common/Telemetry/EtwTrace/pch.cpp
Normal file
5
src/common/Telemetry/EtwTrace/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
23
src/common/Telemetry/EtwTrace/pch.h
Normal file
23
src/common/Telemetry/EtwTrace/pch.h
Normal file
@ -0,0 +1,23 @@
|
||||
// pch.h: This is a precompiled header file.
|
||||
// Files listed below are compiled only once, improving build performance for future builds.
|
||||
// This also affects IntelliSense performance, including code completion and many code browsing features.
|
||||
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
|
||||
// Do not add files here that you will be updating frequently as this negates the performance advantage.
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <ShlObj.h>
|
||||
#include <sstream>
|
||||
#include <strsafe.h>
|
||||
|
||||
#include <winrt/base.h>
|
||||
|
||||
#endif //PCH_H
|
63
src/common/Telemetry/TraceBase.h
Normal file
63
src/common/Telemetry/TraceBase.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "ProjectTelemetry.h"
|
||||
|
||||
#define TraceLoggingWriteWrapper(provider, eventName, ...) \
|
||||
if (IsDataDiagnosticsEnabled()) \
|
||||
{ \
|
||||
TraceLoggingWrite(provider, eventName, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
namespace telemetry
|
||||
{
|
||||
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegKey = L"Software\\Classes\\PowerToys";
|
||||
constexpr inline const wchar_t* DataDiagnosticsRegValueName = L"AllowDataDiagnostics";
|
||||
|
||||
class TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider()
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
static void UnregisterProvider()
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
static bool IsDataDiagnosticsEnabled()
|
||||
{
|
||||
HKEY key{};
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
0,
|
||||
KEY_READ,
|
||||
&key) != ERROR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD isDataDiagnosticsEnabled = 0;
|
||||
DWORD size = sizeof(isDataDiagnosticsEnabled);
|
||||
|
||||
if (RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
DataDiagnosticsRegKey,
|
||||
DataDiagnosticsRegValueName,
|
||||
RRF_RT_REG_DWORD,
|
||||
nullptr,
|
||||
&isDataDiagnosticsEnabled,
|
||||
&size) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return false;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
|
||||
return isDataDiagnosticsEnabled;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace telemetry
|
@ -51,6 +51,10 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::TerminateColorPickerSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_COLOR_PICKER_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::AdvancedPasteShowUIMessage()
|
||||
{
|
||||
return CommonSharedConstants::ADVANCED_PASTE_SHOW_UI_MESSAGE;
|
||||
@ -71,10 +75,18 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::ADVANCED_PASTE_CUSTOM_ACTION_MESSAGE;
|
||||
}
|
||||
hstring Constants::AdvancedPasteTerminateAppMessage()
|
||||
{
|
||||
return CommonSharedConstants::ADVANCED_PASTE_TERMINATE_APP_MESSAGE;
|
||||
}
|
||||
hstring Constants::ShowPowerOCRSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::TerminatePowerOCRSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_POWEROCR_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::MouseJumpShowPreviewEvent()
|
||||
{
|
||||
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
||||
@ -87,6 +99,10 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::SHOW_PEEK_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::TerminatePeekEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_PEEK_SHARED_EVENT;
|
||||
}
|
||||
hstring Constants::PowerAccentExitEvent()
|
||||
{
|
||||
return CommonSharedConstants::POWERACCENT_EXIT_EVENT;
|
||||
@ -135,6 +151,10 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT;
|
||||
}
|
||||
hstring Constants::TerminateHostsSharedEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_HOSTS_EVENT;
|
||||
}
|
||||
hstring Constants::CropAndLockThumbnailEvent()
|
||||
{
|
||||
return CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT;
|
||||
@ -159,4 +179,8 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
{
|
||||
return CommonSharedConstants::WORKSPACES_HOTKEY_EVENT;
|
||||
}
|
||||
hstring Constants::PowerToysRunnerTerminateSettingsEvent()
|
||||
{
|
||||
return CommonSharedConstants::TERMINATE_SETTINGS_SHARED_EVENT;
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,19 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
static hstring FZEToggleEvent();
|
||||
static hstring ColorPickerSendSettingsTelemetryEvent();
|
||||
static hstring ShowColorPickerSharedEvent();
|
||||
static hstring TerminateColorPickerSharedEvent();
|
||||
static hstring AdvancedPasteShowUIMessage();
|
||||
static hstring AdvancedPasteMarkdownMessage();
|
||||
static hstring AdvancedPasteJsonMessage();
|
||||
static hstring AdvancedPasteAdditionalActionMessage();
|
||||
static hstring AdvancedPasteCustomActionMessage();
|
||||
static hstring AdvancedPasteTerminateAppMessage();
|
||||
static hstring ShowPowerOCRSharedEvent();
|
||||
static hstring TerminatePowerOCRSharedEvent();
|
||||
static hstring MouseJumpShowPreviewEvent();
|
||||
static hstring AwakeExitEvent();
|
||||
static hstring ShowPeekEvent();
|
||||
static hstring TerminatePeekEvent();
|
||||
static hstring PowerAccentExitEvent();
|
||||
static hstring ShortcutGuideTriggerEvent();
|
||||
static hstring RegistryPreviewTriggerEvent();
|
||||
@ -37,12 +41,14 @@ namespace winrt::PowerToys::Interop::implementation
|
||||
static hstring SvgPreviewResizeEvent();
|
||||
static hstring ShowHostsSharedEvent();
|
||||
static hstring ShowHostsAdminSharedEvent();
|
||||
static hstring TerminateHostsSharedEvent();
|
||||
static hstring CropAndLockThumbnailEvent();
|
||||
static hstring CropAndLockReparentEvent();
|
||||
static hstring ShowEnvironmentVariablesSharedEvent();
|
||||
static hstring ShowEnvironmentVariablesAdminSharedEvent();
|
||||
static hstring WorkspacesLaunchEditorEvent();
|
||||
static hstring WorkspacesHotkeyEvent();
|
||||
static hstring PowerToysRunnerTerminateSettingsEvent();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,19 @@ namespace PowerToys
|
||||
static String FZEToggleEvent();
|
||||
static String ColorPickerSendSettingsTelemetryEvent();
|
||||
static String ShowColorPickerSharedEvent();
|
||||
static String TerminateColorPickerSharedEvent();
|
||||
static String AdvancedPasteShowUIMessage();
|
||||
static String AdvancedPasteMarkdownMessage();
|
||||
static String AdvancedPasteJsonMessage();
|
||||
static String AdvancedPasteAdditionalActionMessage();
|
||||
static String AdvancedPasteCustomActionMessage();
|
||||
static String AdvancedPasteTerminateAppMessage();
|
||||
static String ShowPowerOCRSharedEvent();
|
||||
static String TerminatePowerOCRSharedEvent();
|
||||
static String MouseJumpShowPreviewEvent();
|
||||
static String AwakeExitEvent();
|
||||
static String ShowPeekEvent();
|
||||
static String TerminatePeekEvent();
|
||||
static String PowerAccentExitEvent();
|
||||
static String ShortcutGuideTriggerEvent();
|
||||
static String RegistryPreviewTriggerEvent();
|
||||
@ -34,12 +38,14 @@ namespace PowerToys
|
||||
static String SvgPreviewResizeEvent();
|
||||
static String ShowHostsSharedEvent();
|
||||
static String ShowHostsAdminSharedEvent();
|
||||
static String TerminateHostsSharedEvent();
|
||||
static String CropAndLockThumbnailEvent();
|
||||
static String CropAndLockReparentEvent();
|
||||
static String ShowEnvironmentVariablesSharedEvent();
|
||||
static String ShowEnvironmentVariablesAdminSharedEvent();
|
||||
static String WorkspacesLaunchEditorEvent();
|
||||
static String WorkspacesHotkeyEvent();
|
||||
static String PowerToysRunnerTerminateSettingsEvent();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,9 @@ namespace CommonSharedConstants
|
||||
|
||||
const wchar_t APPDATA_PATH[] = L"Microsoft\\PowerToys";
|
||||
|
||||
// Path to the event used by runner to terminate Settings app
|
||||
const wchar_t TERMINATE_SETTINGS_SHARED_EVENT[] = L"Local\\PowerToysRunnerTerminateSettingsEvent-c34cb661-2e69-4613-a1f8-4e39c25d7ef6";
|
||||
|
||||
// Path to the event used by PowerLauncher
|
||||
const wchar_t POWER_LAUNCHER_SHARED_EVENT[] = L"Local\\PowerToysRunInvokeEvent-30f26ad7-d36d-4c0e-ab02-68bb5ff3c4ab";
|
||||
|
||||
@ -36,9 +39,13 @@ namespace CommonSharedConstants
|
||||
|
||||
const wchar_t ADVANCED_PASTE_CUSTOM_ACTION_MESSAGE[] = L"CustomAction";
|
||||
|
||||
const wchar_t ADVANCED_PASTE_TERMINATE_APP_MESSAGE[] = L"TerminateApp";
|
||||
|
||||
// Path to the event used to show Color Picker
|
||||
const wchar_t SHOW_COLOR_PICKER_SHARED_EVENT[] = L"Local\\ShowColorPickerEvent-8c46be2a-3e05-4186-b56b-4ae986ef2525";
|
||||
|
||||
const wchar_t TERMINATE_COLOR_PICKER_SHARED_EVENT[] = L"Local\\TerminateColorPickerEvent-3d676258-c4d5-424e-a87a-4be22020e813";
|
||||
|
||||
const wchar_t SHORTCUT_GUIDE_TRIGGER_EVENT[] = L"Local\\ShortcutGuide-TriggerEvent-d4275ad3-2531-4d19-9252-c0becbd9b496";
|
||||
|
||||
const wchar_t SHORTCUT_GUIDE_EXIT_EVENT[] = L"Local\\ShortcutGuide-ExitEvent-35697cdd-a3d2-47d6-a246-34efcc73eac0";
|
||||
@ -53,18 +60,24 @@ namespace CommonSharedConstants
|
||||
|
||||
const wchar_t SHOW_HOSTS_ADMIN_EVENT[] = L"Local\\Hosts-ShowHostsAdminEvent-60ff44e2-efd3-43bf-928a-f4d269f98bec";
|
||||
|
||||
const wchar_t TERMINATE_HOSTS_EVENT[] = L"Local\\Hosts-TerminateHostsEvent-d5410d5e-45a6-4d11-bbf0-a4ec2d064888";
|
||||
|
||||
// Path to the event used by Awake
|
||||
const wchar_t AWAKE_EXIT_EVENT[] = L"Local\\PowerToysAwakeExitEvent-c0d5e305-35fc-4fb5-83ec-f6070cfaf7fe";
|
||||
|
||||
// Path to the event used by AlwaysOnTop
|
||||
const wchar_t ALWAYS_ON_TOP_PIN_EVENT[] = L"Local\\AlwaysOnTopPinEvent-892e0aa2-cfa8-4cc4-b196-ddeb32314ce8";
|
||||
|
||||
const wchar_t ALWAYS_ON_TOP_TERMINATE_EVENT[] = L"Local\\AlwaysOnTopTerminateEvent-cfdf1eae-791f-4953-8021-2f18f3837eae";
|
||||
|
||||
// Path to the event used by PowerAccent
|
||||
const wchar_t POWERACCENT_EXIT_EVENT[] = L"Local\\PowerToysPowerAccentExitEvent-53e93389-d19a-4fbb-9b36-1981c8965e17";
|
||||
|
||||
// Path to the event used by PowerOCR
|
||||
const wchar_t SHOW_POWEROCR_SHARED_EVENT[] = L"Local\\PowerOCREvent-dc864e06-e1af-4ecc-9078-f98bee745e3a";
|
||||
|
||||
const wchar_t TERMINATE_POWEROCR_SHARED_EVENT[] = L"Local\\TerminatePowerOCREvent-08e5de9d-15df-4ea8-8840-487c13435a67";
|
||||
|
||||
// Path to the events used by Mouse Jump
|
||||
const wchar_t MOUSE_JUMP_SHOW_PREVIEW_EVENT[] = L"Local\\MouseJumpEvent-aa0be051-3396-4976-b7ba-1a9cc7d236a5";
|
||||
|
||||
@ -94,6 +107,11 @@ namespace CommonSharedConstants
|
||||
|
||||
// Path to the event used to show Peek
|
||||
const wchar_t SHOW_PEEK_SHARED_EVENT[] = L"Local\\ShowPeekEvent";
|
||||
// Path to the event used to terminate Peek
|
||||
const wchar_t TERMINATE_PEEK_SHARED_EVENT[] = L"Local\\TerminatePeekEvent-267149fe-7ed2-427d-a3ad-9e18203c037c";
|
||||
|
||||
// Path to the event used to terminate KBM
|
||||
const wchar_t TERMINATE_KBM_SHARED_EVENT[] = L"Local\\TerminateKBMSharedEvent-a787c967-55b6-47de-94d9-56f39fed839e";
|
||||
|
||||
// Path to the events used by CropAndLock
|
||||
const wchar_t CROP_AND_LOCK_REPARENT_EVENT[] = L"Local\\PowerToysCropAndLockReparentEvent-6060860a-76a1-44e8-8d0e-6355785e9c36";
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
@ -72,6 +72,7 @@ namespace powertoys_gpo {
|
||||
|
||||
// The registry value names for other PowerToys policies.
|
||||
const std::wstring POLICY_ALLOW_EXPERIMENTATION = L"AllowExperimentation";
|
||||
const std::wstring POLICY_ALLOW_DATA_DIAGNOSTICS = L"AllowDataDiagnostics";
|
||||
const std::wstring POLICY_CONFIGURE_ENABLED_POWER_LAUNCHER_ALL_PLUGINS = L"PowerLauncherAllPluginsEnabledState";
|
||||
const std::wstring POLICY_ALLOW_ADVANCED_PASTE_ONLINE_AI_MODELS = L"AllowPowerToysAdvancedPasteOnlineAIModels";
|
||||
const std::wstring POLICY_MWB_CLIPBOARD_SHARING_ENABLED = L"MwbClipboardSharingEnabled";
|
||||
@ -487,6 +488,11 @@ namespace powertoys_gpo {
|
||||
return getConfiguredValue(POLICY_ALLOW_EXPERIMENTATION);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getAllowDataDiagnosticsValue()
|
||||
{
|
||||
return getConfiguredValue(POLICY_ALLOW_DATA_DIAGNOSTICS);
|
||||
}
|
||||
|
||||
inline gpo_rule_configured_t getRunPluginEnabledValue(std::string pluginID)
|
||||
{
|
||||
if (pluginID == "" || pluginID == " ")
|
||||
|
@ -5,7 +5,7 @@
|
||||
<policyNamespaces>
|
||||
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
|
||||
</policyNamespaces>
|
||||
<resources minRequiredRevision="1.13"/><!-- Last changed with PowerToys v0.85.0 -->
|
||||
<resources minRequiredRevision="1.14"/><!-- Last changed with PowerToys v0.86.0 -->
|
||||
<supportedOn>
|
||||
<definitions>
|
||||
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
|
||||
@ -22,6 +22,7 @@
|
||||
<definition name="SUPPORTED_POWERTOYS_0_83_0" displayName="$(string.SUPPORTED_POWERTOYS_0_83_0)"/>
|
||||
<definition name="SUPPORTED_POWERTOYS_0_84_0" displayName="$(string.SUPPORTED_POWERTOYS_0_84_0)"/>
|
||||
<definition name="SUPPORTED_POWERTOYS_0_85_0" displayName="$(string.SUPPORTED_POWERTOYS_0_85_0)"/>
|
||||
<definition name="SUPPORTED_POWERTOYS_0_86_0" displayName="$(string.SUPPORTED_POWERTOYS_0_86_0)"/>
|
||||
</definitions>
|
||||
</supportedOn>
|
||||
<categories>
|
||||
@ -509,6 +510,16 @@
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="AllowDiagnosticData" class="Both" displayName="$(string.AllowDiagnosticData)" explainText="$(string.AllowDiagnosticDataDescription)" key="Software\Policies\PowerToys" valueName="AllowDataDiagnostics">
|
||||
<parentCategory ref="GeneralSettings" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_86_0" />
|
||||
<enabledValue>
|
||||
<decimal value="1" />
|
||||
</enabledValue>
|
||||
<disabledValue>
|
||||
<decimal value="0" />
|
||||
</disabledValue>
|
||||
</policy>
|
||||
<policy name="PowerToysRunAllPluginsEnabledState" class="Both" displayName="$(string.PowerToysRunAllPluginsEnabledState)" explainText="$(string.PowerToysRunAllPluginsEnabledStateDescription)" key="Software\Policies\PowerToys" valueName="PowerLauncherAllPluginsEnabledState">
|
||||
<parentCategory ref="PowerToysRun" />
|
||||
<supportedOn ref="SUPPORTED_POWERTOYS_0_75_0" />
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) Microsoft Corporation.
|
||||
Licensed under the MIT License. -->
|
||||
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.13" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
|
||||
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.14" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
|
||||
<displayName>PowerToys</displayName>
|
||||
<description>PowerToys</description>
|
||||
<resources>
|
||||
@ -28,6 +28,7 @@
|
||||
<string id="SUPPORTED_POWERTOYS_0_83_0">PowerToys version 0.83.0 or later</string>
|
||||
<string id="SUPPORTED_POWERTOYS_0_84_0">PowerToys version 0.84.0 or later</string>
|
||||
<string id="SUPPORTED_POWERTOYS_0_85_0">PowerToys version 0.85.0 or later</string>
|
||||
<string id="SUPPORTED_POWERTOYS_0_86_0">PowerToys version 0.86.0 or later</string>
|
||||
|
||||
<string id="ConfigureAllUtilityGlobalEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities.
|
||||
|
||||
@ -101,6 +102,12 @@ If disabled or not configured, the user can control this in the settings of Powe
|
||||
If this setting is enabled or not configured, the user can control experimentation in the PowerToys settings menu.
|
||||
|
||||
If this setting is disabled, experimentation is not allowed.
|
||||
</string>
|
||||
<string id="AllowDiagnosticDataDescription">This policy configures whether sending of PowerToys diagnostic data is allowed. With diagnostic data sending allowed the user helps inform bug fixes, performance and improvements.
|
||||
|
||||
If this setting is enabled or not configured, the user can control diagnostic data sending in the PowerToys settings menu.
|
||||
|
||||
If this setting is disabled, diagnostic data sending is not allowed.
|
||||
</string>
|
||||
<string id="PowerToysRunAllPluginsEnabledStateDescription">This policy configures the enabled state for all PowerToys Run plugins. All plugins will have the same state.
|
||||
|
||||
@ -258,6 +265,7 @@ If you don't configure this policy, the user takes control over the setting and
|
||||
<string id="MwbDisableUserDefinedIpMappingRules">Disable user defined IP Address mapping rules</string>
|
||||
<string id="MwbPolicyDefinedIpMappingRules">Predefined IP Address mapping rules</string>
|
||||
<string id="NewPlusHideTemplateFilenameExtension">Hide template filename extension</string>
|
||||
<string id="AllowDiagnosticData">Allow sending diagnostic data</string>
|
||||
</stringTable>
|
||||
|
||||
<presentationTable>
|
||||
|
@ -18,6 +18,7 @@ using AdvancedPaste.ViewModels;
|
||||
using ManagedCommon;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Windows.Graphics;
|
||||
@ -38,6 +39,8 @@ namespace AdvancedPaste
|
||||
{
|
||||
public IHost Host { get; private set; }
|
||||
|
||||
public ETWTrace EtwTrace { get; private set; } = new ETWTrace();
|
||||
|
||||
private static readonly Dictionary<string, PasteFormats> AdditionalActionIPCKeys =
|
||||
typeof(PasteFormats).GetFields()
|
||||
.Where(field => field.IsLiteral)
|
||||
@ -111,8 +114,12 @@ namespace AdvancedPaste
|
||||
{
|
||||
RunnerHelper.WaitForPowerToysRunner(powerToysRunnerPid, () =>
|
||||
{
|
||||
_dispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
Dispose();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,6 +161,11 @@ namespace AdvancedPaste
|
||||
{
|
||||
await OnAdvancedPasteCustomActionHotkey(messageParts);
|
||||
}
|
||||
else if (messageType == PowerToys.Interop.Constants.AdvancedPasteTerminateAppMessage())
|
||||
{
|
||||
Dispose();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
|
||||
@ -244,6 +256,7 @@ namespace AdvancedPaste
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
EtwTrace?.Dispose();
|
||||
window.Dispose();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ using AdvancedPaste.Settings;
|
||||
using AdvancedPaste.ViewModels;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUIEx;
|
||||
@ -96,6 +97,7 @@ namespace AdvancedPaste
|
||||
if (!_disposedValue)
|
||||
{
|
||||
_msgMonitor?.Dispose();
|
||||
(Application.Current as App).EtwTrace?.Dispose();
|
||||
|
||||
_disposedValue = true;
|
||||
}
|
||||
|
@ -384,7 +384,6 @@ private:
|
||||
m_hProcess = sei.hProcess;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::wstring> get_pipe_name(const std::wstring& prefix) const
|
||||
{
|
||||
UUID temp_uuid;
|
||||
@ -761,6 +760,8 @@ public:
|
||||
// Destroy the powertoy and free memory
|
||||
virtual void destroy() override
|
||||
{
|
||||
Disable(false);
|
||||
|
||||
Logger::trace("AdvancedPaste::destroy()");
|
||||
delete this;
|
||||
}
|
||||
@ -851,15 +852,21 @@ public:
|
||||
launch_process_and_named_pipe();
|
||||
};
|
||||
|
||||
virtual void disable()
|
||||
void Disable(bool traceEvent)
|
||||
{
|
||||
Logger::trace("AdvancedPaste::disable()");
|
||||
if (m_enabled)
|
||||
{
|
||||
send_named_pipe_message(CommonSharedConstants::ADVANCED_PASTE_TERMINATE_APP_MESSAGE);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
|
||||
m_write_pipe = nullptr;
|
||||
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
|
||||
if (traceEvent)
|
||||
{
|
||||
Trace::AdvancedPaste_Enable(false);
|
||||
}
|
||||
|
||||
CloseHandle(m_hProcess);
|
||||
m_hProcess = 0;
|
||||
@ -868,6 +875,12 @@ public:
|
||||
m_enabled = false;
|
||||
}
|
||||
|
||||
virtual void disable()
|
||||
{
|
||||
Logger::trace("AdvancedPaste::disable()");
|
||||
Disable(true);
|
||||
}
|
||||
|
||||
virtual bool on_hotkey(size_t hotkeyId) override
|
||||
{
|
||||
Logger::trace(L"AdvancedPaste hotkey pressed");
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <windows.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <shellapi.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <filesystem>
|
@ -8,20 +8,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider()
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider()
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has AdvancedPaste enabled or disabled
|
||||
void Trace::AdvancedPaste_Enable(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"AdvancedPaste_EnableAdvancedPaste",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +22,7 @@ void Trace::AdvancedPaste_Enable(const bool enabled) noexcept
|
||||
// Log if the user has invoked AdvancedPaste
|
||||
void Trace::AdvancedPaste_Invoked(std::wstring mode) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"AdvancedPaste_InvokeAdvancedPaste",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -43,7 +33,7 @@ void Trace::AdvancedPaste_Invoked(std::wstring mode) noexcept
|
||||
// Log if an error occurs in AdvancedPaste
|
||||
void Trace::AdvancedPaste_Error(const DWORD errorCode, std::wstring errorMessage, std::wstring methodName) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"AdvancedPaste_Error",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -83,7 +73,7 @@ void Trace::AdvancedPaste_SettingsTelemetry(const PowertoyModuleIface::Hotkey& p
|
||||
return it != additionalActionsHotkeys.end() ? getHotkeyCStr(it->second) : L"";
|
||||
};
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"AdvancedPaste_Settings",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,13 +1,11 @@
|
||||
#pragma once
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
#include <interface/powertoy_module_interface.h>
|
||||
#include <unordered_map>
|
||||
|
||||
class Trace
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider();
|
||||
static void UnregisterProvider();
|
||||
|
||||
// Log if the user has AdvancedPaste enabled or disabled
|
||||
static void AdvancedPaste_Enable(const bool enabled) noexcept;
|
||||
|
||||
|
@ -151,6 +151,9 @@
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Import Project="..\..\..\..\deps\spdlog.props" />
|
||||
|
@ -27,6 +27,7 @@
|
||||
<ClInclude Include="ChildWindow.h" />
|
||||
<ClInclude Include="trace.h" />
|
||||
<ClInclude Include="ModuleConstants.h" />
|
||||
<ClInclude Include="DispatcherQueue.desktop.interop.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CropAndLock.rc" />
|
||||
|
@ -4,15 +4,19 @@
|
||||
#include "CropAndLockWindow.h"
|
||||
#include "ThumbnailCropAndLockWindow.h"
|
||||
#include "ReparentCropAndLockWindow.h"
|
||||
#include <common/interop/shared_constants.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/gpo.h>
|
||||
#include "ModuleConstants.h"
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/interop/shared_constants.h>
|
||||
|
||||
#include <common/utils/gpo.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/ProcessWaiter.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
|
||||
namespace winrt
|
||||
@ -36,6 +40,11 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
|
||||
// Initialize COM
|
||||
winrt::init_apartment(winrt::apartment_type::single_threaded);
|
||||
|
||||
Trace::CropAndLock::RegisterProvider();
|
||||
|
||||
Shared::Trace::ETWTrace trace;
|
||||
trace.UpdateState(true);
|
||||
|
||||
// Initialize logger automatic logging of exceptions.
|
||||
LoggerHelpers::init_logger(NonLocalizable::ModuleKey, L"", LogSettings::cropAndLockLoggerName);
|
||||
InitUnhandledExceptionHandler();
|
||||
@ -107,8 +116,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
|
||||
HANDLE m_exit_event_handle;
|
||||
std::thread m_event_triggers_thread;
|
||||
|
||||
std::function<void(HWND)> removeWindowCallback = [&](HWND windowHandle)
|
||||
{
|
||||
std::function<void(HWND)> removeWindowCallback = [&](HWND windowHandle) {
|
||||
if (!m_running)
|
||||
{
|
||||
// If we're not running, the reference to croppedWindows might no longer be valid and cause a crash at exit time, due to being called by destructors after wWinMain returns.
|
||||
@ -122,8 +130,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
|
||||
}
|
||||
};
|
||||
|
||||
std::function<void(CropAndLockType)> ProcessCommand = [&](CropAndLockType mode)
|
||||
{
|
||||
std::function<void(CropAndLockType)> ProcessCommand = [&](CropAndLockType mode) {
|
||||
std::function<void(HWND, RECT)> windowCroppedCallback = [&, mode](HWND targetWindow, RECT cropRect) {
|
||||
auto targetInfo = util::WindowInfo(targetWindow);
|
||||
// TODO: Fix WindowInfo.h to not contain the null char at the end.
|
||||
@ -258,6 +265,10 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
|
||||
trace.Flush();
|
||||
|
||||
Trace::CropAndLock::UnregisterProvider();
|
||||
|
||||
m_running = false;
|
||||
// Needed to unblock MsgWaitForMultipleObjects one last time
|
||||
SetEvent(m_reparent_event_handle);
|
||||
|
@ -74,7 +74,6 @@
|
||||
#include "WindowRectUtil.h"
|
||||
|
||||
// PowerToys
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <common/logger/logger.h>
|
||||
|
||||
// Application resources
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
// Telemetry strings should not be localized.
|
||||
#define LoggingProviderKey "Microsoft.PowerToys"
|
||||
|
||||
@ -11,19 +13,9 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::CropAndLock::Enable(bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_EnableCropAndLock",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -33,7 +25,7 @@ void Trace::CropAndLock::Enable(bool enabled) noexcept
|
||||
|
||||
void Trace::CropAndLock::ActivateReparent() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_ActivateReparent",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -42,7 +34,7 @@ void Trace::CropAndLock::ActivateReparent() noexcept
|
||||
|
||||
void Trace::CropAndLock::ActivateThumbnail() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_ActivateThumbnail",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -51,7 +43,7 @@ void Trace::CropAndLock::ActivateThumbnail() noexcept
|
||||
|
||||
void Trace::CropAndLock::CreateReparentWindow() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_CreateReparentWindow",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -60,7 +52,7 @@ void Trace::CropAndLock::CreateReparentWindow() noexcept
|
||||
|
||||
void Trace::CropAndLock::CreateThumbnailWindow() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_CreateThumbnailWindow",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -84,12 +76,11 @@ void Trace::CropAndLock::SettingsTelemetry(PowertoyModuleIface::Hotkey& reparent
|
||||
std::wstring(thumbnailHotkey.alt ? L"Alt + " : L"") +
|
||||
std::wstring(L"VK ") + std::to_wstring(thumbnailHotkey.key);
|
||||
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"CropAndLock_Settings",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingWideString(hotKeyStrReparent.c_str(), "ReparentHotKey"),
|
||||
TraceLoggingWideString(hotKeyStrThumbnail.c_str(), "ThumbnailHotkey")
|
||||
);
|
||||
TraceLoggingWideString(hotKeyStrThumbnail.c_str(), "ThumbnailHotkey"));
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
#include <modules/interface/powertoy_module_interface.h>
|
||||
|
||||
class Trace
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
class CropAndLock
|
||||
class CropAndLock : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void Enable(bool enabled) noexcept;
|
||||
|
@ -40,13 +40,13 @@ BOOL APIENTRY DllMain( HMODULE /*hModule*/,
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
Trace::RegisterProvider();
|
||||
Trace::CropAndLock::RegisterProvider();
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
Trace::UnregisterProvider();
|
||||
Trace::CropAndLock::UnregisterProvider();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -6,7 +6,5 @@
|
||||
#include <winrt/base.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <TraceLoggingActivity.h>
|
||||
#include <wil\common.h>
|
||||
#include <wil\result.h>
|
||||
|
@ -26,6 +26,8 @@ namespace EnvironmentVariables
|
||||
{
|
||||
public IHost Host { get; }
|
||||
|
||||
public ETWTrace EtwTrace { get; } = new ETWTrace();
|
||||
|
||||
public static T GetService<T>()
|
||||
where T : class
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<winuiex:WindowEx
|
||||
x:Class="EnvironmentVariables.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
@ -10,6 +10,7 @@
|
||||
x:Uid="Window"
|
||||
MinWidth="700"
|
||||
MinHeight="480"
|
||||
Closed="Window_Closed"
|
||||
mc:Ignorable="d">
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
|
@ -88,5 +88,10 @@ namespace EnvironmentVariables
|
||||
|
||||
return NativeMethods.CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, WindowEventArgs args)
|
||||
{
|
||||
(App.Current as EnvironmentVariables.App).EtwTrace?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files
|
||||
#include <windows.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has Environment Variables enabled or disabled
|
||||
void Trace::EnableEnvironmentVariables(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"EnvironmentVariables_EnableEnvironmentVariables",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +24,7 @@ void Trace::EnableEnvironmentVariables(const bool enabled) noexcept
|
||||
// Log that the user tried to activate the editor
|
||||
void Trace::ActivateEnvironmentVariables() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"EnvironmentVariables_Activate",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has EnvironmentVariables enabled or disabled
|
||||
static void EnableEnvironmentVariables(const bool enabled) noexcept;
|
||||
|
||||
|
@ -128,6 +128,9 @@ MakeAppx.exe pack /d . /p $(OutDir)FileLocksmithContextMenuPackage.msix /nv</Com
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\version\version.vcxproj">
|
||||
<Project>{cc6e41ac-8174-4e8a-8d22-85dd7f4851df}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0"
|
||||
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
|
@ -1,6 +1,7 @@
|
||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||
#include "pch.h"
|
||||
|
||||
#include <common/telemetry/EtwTrace/EtwTrace.h>
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/resources.h>
|
||||
#include <common/utils/elevation.h>
|
||||
@ -20,6 +21,7 @@
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
HINSTANCE g_hInst = 0;
|
||||
Shared::Trace::ETWTrace trace(L"FileLocksmithContextMenu");
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
@ -91,6 +93,8 @@ public:
|
||||
|
||||
IFACEMETHODIMP Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept
|
||||
{
|
||||
trace.UpdateState(true);
|
||||
|
||||
Trace::Invoked();
|
||||
ipc::Writer writer;
|
||||
|
||||
@ -102,6 +106,9 @@ public:
|
||||
if (HRESULT result = writer.start(); FAILED(result))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
|
||||
trace.Flush();
|
||||
trace.UpdateState(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -114,6 +121,10 @@ public:
|
||||
{
|
||||
result = E_FAIL;
|
||||
Trace::InvokedRet(result);
|
||||
|
||||
trace.Flush();
|
||||
trace.UpdateState(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -140,6 +151,10 @@ public:
|
||||
}
|
||||
|
||||
Trace::InvokedRet(S_OK);
|
||||
|
||||
trace.Flush();
|
||||
trace.UpdateState(false);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,13 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
|
||||
|
||||
if (!InsertMenuItem(hmenu, indexMenu, TRUE, &mii))
|
||||
{
|
||||
m_etwTrace.UpdateState(true);
|
||||
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
Trace::QueryContextMenuError(hr);
|
||||
|
||||
m_etwTrace.Flush();
|
||||
m_etwTrace.UpdateState(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -166,6 +171,8 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
|
||||
|
||||
IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
|
||||
{
|
||||
m_etwTrace.UpdateState(true);
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
if (FileLocksmithSettingsInstance().GetEnabled() &&
|
||||
@ -178,12 +185,16 @@ IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
|
||||
if (HRESULT result = writer.start(); FAILED(result))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
m_etwTrace.Flush();
|
||||
m_etwTrace.UpdateState(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
m_etwTrace.Flush();
|
||||
m_etwTrace.UpdateState(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -217,6 +228,9 @@ IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
|
||||
}
|
||||
|
||||
Trace::InvokedRet(hr);
|
||||
|
||||
m_etwTrace.Flush();
|
||||
m_etwTrace.UpdateState(false);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "FileLocksmithLib/IPC.h"
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
#define EXPLORER_COMMAND_UUID_STR "84d68575-e186-46ad-b0cb-baeb45ee29c0"
|
||||
|
||||
class __declspec(uuid(EXPLORER_COMMAND_UUID_STR)) ExplorerCommand : public IExplorerCommand, public IShellExtInit, public IContextMenu
|
||||
@ -50,4 +52,6 @@ private:
|
||||
std::atomic<ULONG> m_ref_count = 1;
|
||||
IDataObject* m_data_obj = NULL;
|
||||
std::wstring context_menu_caption;
|
||||
|
||||
Shared::Trace::ETWTrace m_etwTrace{ L"FileExplorerExt" };
|
||||
};
|
||||
|
@ -103,6 +103,9 @@
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
|
||||
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "Trace.h"
|
||||
#include "../common/Telemetry/ProjectTelemetry.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
@ -10,19 +11,9 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::EnableFileLocksmith(_In_ bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FileLocksmith_EnableFileLocksmith",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +23,7 @@ void Trace::EnableFileLocksmith(_In_ bool enabled) noexcept
|
||||
|
||||
void Trace::Invoked() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FileLocksmith_Invoked",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -41,7 +32,7 @@ void Trace::Invoked() noexcept
|
||||
|
||||
void Trace::InvokedRet(_In_ HRESULT hr) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FileLocksmith_InvokedRet",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -51,7 +42,7 @@ void Trace::InvokedRet(_In_ HRESULT hr) noexcept
|
||||
|
||||
void Trace::QueryContextMenuError(_In_ HRESULT hr) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FileLocksmith_QueryContextMenuError",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
static void EnableFileLocksmith(_In_ bool enabled) noexcept;
|
||||
static void Invoked() noexcept;
|
||||
static void InvokedRet(_In_ HRESULT hr) noexcept;
|
||||
|
30
src/modules/Hosts/Hosts/Helpers/NativeEventWaiter.cs
Normal file
30
src/modules/Hosts/Hosts/Helpers/NativeEventWaiter.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using Microsoft.UI.Dispatching;
|
||||
|
||||
namespace Hosts.Helpers
|
||||
{
|
||||
public static class NativeEventWaiter
|
||||
{
|
||||
public static void WaitForEventLoop(string eventName, Action callback)
|
||||
{
|
||||
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
new Thread(() =>
|
||||
{
|
||||
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, eventName);
|
||||
while (true)
|
||||
{
|
||||
if (eventHandle.WaitOne())
|
||||
{
|
||||
dispatcherQueue.TryEnqueue(() => callback());
|
||||
}
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
using PowerToys.Interop;
|
||||
using static HostsUILib.Settings.IUserSettings;
|
||||
|
||||
using Host = Hosts.Helpers.Host;
|
||||
@ -93,6 +93,12 @@ namespace Hosts
|
||||
cleanupBackupThread.Start();
|
||||
|
||||
UnhandledException += App_UnhandledException;
|
||||
|
||||
Hosts.Helpers.NativeEventWaiter.WaitForEventLoop(Constants.TerminateHostsSharedEvent(), () =>
|
||||
{
|
||||
EtwTrace?.Dispose();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,6 +118,7 @@ namespace Hosts
|
||||
RunnerHelper.WaitForPowerToysRunner(powerToysRunnerPid, () =>
|
||||
{
|
||||
Logger.LogInfo("PowerToys Runner exited. Exiting Hosts");
|
||||
EtwTrace?.Dispose();
|
||||
dispatcher.TryEnqueue(App.Current.Exit);
|
||||
});
|
||||
}
|
||||
@ -133,5 +140,7 @@ namespace Hosts
|
||||
}
|
||||
|
||||
private Window window;
|
||||
|
||||
public ETWTrace EtwTrace { get; private set; } = new ETWTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<winuiex:WindowEx
|
||||
<winuiex:WindowEx
|
||||
x:Class="Hosts.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
@ -10,6 +10,7 @@
|
||||
Width="680"
|
||||
MinWidth="520"
|
||||
MinHeight="320"
|
||||
Closed="WindowEx_Closed"
|
||||
mc:Ignorable="d">
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
|
@ -62,5 +62,10 @@ namespace Hosts
|
||||
MainGrid.Children.Add(MainPage);
|
||||
Grid.SetRow(MainPage, 1);
|
||||
}
|
||||
|
||||
private void WindowEx_Closed(object sender, WindowEventArgs args)
|
||||
{
|
||||
(Application.Current as App).EtwTrace?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ private:
|
||||
|
||||
HANDLE m_hShowAdminEvent{};
|
||||
|
||||
HANDLE m_hTerminateEvent{};
|
||||
|
||||
bool is_process_running()
|
||||
{
|
||||
return WaitForSingleObject(m_hProcess, 0) == WAIT_TIMEOUT;
|
||||
@ -142,6 +144,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
m_hTerminateEvent = CreateDefaultEvent(CommonSharedConstants::TERMINATE_HOSTS_EVENT);
|
||||
if (!m_hTerminateEvent)
|
||||
{
|
||||
Logger::error(L"Failed to create terminate hosts event");
|
||||
auto message = get_last_error_message(GetLastError());
|
||||
if (message.has_value())
|
||||
{
|
||||
Logger::error(message.value());
|
||||
}
|
||||
}
|
||||
|
||||
m_showEventWaiter = EventWaiter(CommonSharedConstants::SHOW_HOSTS_EVENT, [&](int err)
|
||||
{
|
||||
if (m_enabled && err == ERROR_SUCCESS)
|
||||
@ -264,6 +277,8 @@ public:
|
||||
ResetEvent(m_hShowAdminEvent);
|
||||
}
|
||||
|
||||
SetEvent(m_hTerminateEvent);
|
||||
WaitForSingleObject(m_hProcess, 1500);
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,3 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <ProjectTelemetry.h>
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has HostsFileEditor enabled or disabled
|
||||
void Trace::EnableHostsFileEditor(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"HostsFileEditor_EnableHostsFileEditor",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +24,7 @@ void Trace::EnableHostsFileEditor(const bool enabled) noexcept
|
||||
// Log that the user tried to activate the editor
|
||||
void Trace::ActivateEditor() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"HostsFileEditor_Activate",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has HostsFileEditor enabled or disabled
|
||||
static void EnableHostsFileEditor(const bool enabled) noexcept;
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace HostsUILib.Views
|
||||
|
||||
public ICommand UpdateAdditionalLinesCommand => new RelayCommand(UpdateAdditionalLines);
|
||||
|
||||
public ICommand ExitCommand => new RelayCommand(() => { Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread().TryEnqueue(Application.Current.Exit); });
|
||||
public ICommand ExitCommand => new RelayCommand(() => { Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread().TryEnqueue(() => { Environment.Exit(0); }); });
|
||||
|
||||
public HostsMainPage(MainViewModel viewModel)
|
||||
{
|
||||
|
@ -111,7 +111,11 @@ namespace winrt::PowerToys::MeasureToolCore::implementation
|
||||
#endif
|
||||
_overlayUIStates.push_back(std::move(overlayUI));
|
||||
}
|
||||
|
||||
trace.UpdateState(true);
|
||||
Trace::BoundsToolActivated();
|
||||
trace.Flush();
|
||||
trace.UpdateState(false);
|
||||
}
|
||||
|
||||
void Core::StartMeasureTool(const bool horizontal, const bool vertical)
|
||||
@ -160,7 +164,10 @@ namespace winrt::PowerToys::MeasureToolCore::implementation
|
||||
_screenCaptureThreads.emplace_back(std::move(thread));
|
||||
}
|
||||
|
||||
trace.UpdateState(true);
|
||||
Trace::MeasureToolActivated();
|
||||
trace.Flush();
|
||||
trace.UpdateState(false);
|
||||
}
|
||||
|
||||
void MeasureToolCore::implementation::Core::SetToolCompletionEvent(ToolSessionCompleted sessionCompletedTrigger)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "OverlayUI.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
#include <common/utils/serialized.h>
|
||||
#include "ScreenCapturing.h"
|
||||
|
||||
@ -50,6 +51,7 @@ namespace winrt::PowerToys::MeasureToolCore::implementation
|
||||
BoundsToolState _boundsToolState;
|
||||
CommonState _commonState;
|
||||
Settings _settings;
|
||||
Shared::Trace::ETWTrace trace{};
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,9 @@
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
|
||||
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <string_view>
|
||||
#include <chrono>
|
||||
#include <stdio.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
|
||||
// Undefine GetCurrentTime macro to prevent
|
||||
// conflict with Storyboard::GetCurrentTime
|
||||
|
@ -9,6 +9,5 @@
|
||||
#include <thread>
|
||||
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/logger/logger.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,19 +10,9 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::EnableMeasureTool(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MeasureTool_EnableMeasureTool",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -30,7 +22,7 @@ void Trace::EnableMeasureTool(const bool enabled) noexcept
|
||||
|
||||
void Trace::BoundsToolActivated() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MeasureTool_BoundsToolActivated",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -39,7 +31,7 @@ void Trace::BoundsToolActivated() noexcept
|
||||
|
||||
void Trace::MeasureToolActivated() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MeasureTool_MeasureToolActivated",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
static void EnableMeasureTool(const bool enabled) noexcept;
|
||||
|
||||
static void BoundsToolActivated() noexcept;
|
||||
|
@ -15,6 +15,5 @@
|
||||
#endif
|
||||
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/logger/logger.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has FindMyMouse enabled or disabled
|
||||
void Trace::EnableFindMyMouse(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FindMyMouse_EnableFindMyMouse",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +24,7 @@ void Trace::EnableFindMyMouse(const bool enabled) noexcept
|
||||
// Log that the user activated the module by focusing the mouse pointer
|
||||
void Trace::MousePointerFocused() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"FindMyMouse_MousePointerFocused",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has FindMyMouse enabled or disabled
|
||||
static void EnableFindMyMouse(const bool enabled) noexcept;
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#endif
|
||||
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/logger/logger.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has MouseHighlighter enabled or disabled
|
||||
void Trace::EnableMouseHighlighter(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseHighlighter_EnableMouseHighlighter",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +24,7 @@ void Trace::EnableMouseHighlighter(const bool enabled) noexcept
|
||||
// Log that the user activated the module by starting a highlighting session
|
||||
void Trace::StartHighlightingSession() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseHighlighter_StartHighlightingSession",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has MouseHighlighter enabled or disabled
|
||||
static void EnableMouseHighlighter(const bool enabled) noexcept;
|
||||
|
||||
|
@ -5,6 +5,5 @@
|
||||
#include <shellapi.h>
|
||||
|
||||
//#include <common/common.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/logger/logger.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,19 +10,9 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider()
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider()
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::EnableJumpTool(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseJump_EnableJumpTool",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -30,7 +22,7 @@ void Trace::EnableJumpTool(const bool enabled) noexcept
|
||||
|
||||
void Trace::InvokeJumpTool() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseJump_InvokeJumpTool",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider();
|
||||
static void UnregisterProvider();
|
||||
|
||||
static void EnableJumpTool(const bool enabled) noexcept;
|
||||
|
||||
static void InvokeJumpTool() noexcept;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.System.h>
|
||||
#include <winrt/Windows.UI.Composition.Desktop.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <thread>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
#include <common/logger/logger.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
@ -8,20 +10,10 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
// Log if the user has MousePointerCrosshairs enabled or disabled
|
||||
void Trace::EnableMousePointerCrosshairs(const bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MousePointerCrosshairs_EnableMousePointerCrosshairs",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -32,7 +24,7 @@ void Trace::EnableMousePointerCrosshairs(const bool enabled) noexcept
|
||||
// Log that the user activated the module by having the crosshairs be drawn
|
||||
void Trace::StartDrawingCrosshairs() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MousePointerCrosshairs_StartDrawingCrosshairs",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Trace
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
// Log if the user has MousePointerCrosshairs enabled or disabled
|
||||
static void EnableMousePointerCrosshairs(const bool enabled) noexcept;
|
||||
|
||||
|
@ -3,9 +3,10 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using MouseWithoutBorders.Class;
|
||||
|
||||
using Logger = MouseWithoutBorders.Core.Logger;
|
||||
|
||||
@ -13,12 +14,13 @@ namespace MouseWithoutBorders
|
||||
{
|
||||
internal class ShutdownWithPowerToys
|
||||
{
|
||||
public static void WaitForPowerToysRunner()
|
||||
public static void WaitForPowerToysRunner(ETWTrace etwTrace)
|
||||
{
|
||||
try
|
||||
{
|
||||
RunnerHelper.WaitForPowerToysRunnerExitFallback(() =>
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
Common.MainForm.Quit(true, false);
|
||||
});
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace MouseWithoutBorders.Class
|
||||
ManagedCommon.Logger.InitializeLogger("\\MouseWithoutBorders\\Logs");
|
||||
Logger.Log(Application.ProductName + " Started!");
|
||||
|
||||
ETWTrace etwTrace = new ETWTrace();
|
||||
|
||||
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
||||
{
|
||||
Logger.Log("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
||||
@ -117,7 +119,7 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
ShutdownWithPowerToys.WaitForPowerToysRunner();
|
||||
ShutdownWithPowerToys.WaitForPowerToysRunner(etwTrace);
|
||||
|
||||
if (firstArg != string.Empty)
|
||||
{
|
||||
@ -225,6 +227,8 @@ namespace MouseWithoutBorders.Class
|
||||
var formScreen = new FrmScreen();
|
||||
|
||||
Application.Run(formScreen);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace MouseWithoutBorders
|
||||
{
|
||||
@ -38,8 +39,11 @@ namespace MouseWithoutBorders
|
||||
return;
|
||||
}
|
||||
|
||||
ETWTrace etwTrace = new ETWTrace();
|
||||
|
||||
RunnerHelper.WaitForPowerToysRunnerExitFallback(() =>
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
Application.Exit();
|
||||
});
|
||||
|
||||
@ -76,6 +80,8 @@ namespace MouseWithoutBorders
|
||||
|
||||
dotForm = new FormDot();
|
||||
Application.Run(FormHelper = new FormHelper());
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpRese
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
g_hInst_MouseWithoutBorders = hModule;
|
||||
Trace::RegisterProvider();
|
||||
Trace::MouseWithoutBorders::RegisterProvider();
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
Trace::UnregisterProvider();
|
||||
Trace::MouseWithoutBorders::UnregisterProvider();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include <winrt/base.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <TraceLoggingActivity.h>
|
||||
|
||||
#include <wil\common.h>
|
||||
#include <wil\result.h>
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
// Telemetry strings should not be localized.
|
||||
#define LoggingProviderKey "Microsoft.PowerToys"
|
||||
|
||||
@ -14,19 +16,9 @@ TRACELOGGING_DEFINE_PROVIDER(
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::MouseWithoutBorders::Enable(bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
EventEnableMouseWithoutBordersKey,
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -36,7 +28,7 @@ void Trace::MouseWithoutBorders::Enable(bool enabled) noexcept
|
||||
|
||||
void Trace::MouseWithoutBorders::ToggleServiceRegistration(bool enabled) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseWithoutBorders_ToggleServiceRegistration",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -46,7 +38,7 @@ void Trace::MouseWithoutBorders::ToggleServiceRegistration(bool enabled) noexcep
|
||||
|
||||
void Trace::MouseWithoutBorders::Activate() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseWithoutBorders_Activate",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
@ -56,7 +48,7 @@ void Trace::MouseWithoutBorders::Activate() noexcept
|
||||
// Log that the user tried to activate the editor
|
||||
void Trace::MouseWithoutBorders::AddFirewallRule() noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
TraceLoggingWriteWrapper(
|
||||
g_hProvider,
|
||||
"MouseWithoutBorders_AddFirewallRule",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
|
@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Telemetry/TraceBase.h>
|
||||
|
||||
class Trace
|
||||
{
|
||||
public:
|
||||
static void RegisterProvider() noexcept;
|
||||
static void UnregisterProvider() noexcept;
|
||||
|
||||
class MouseWithoutBorders
|
||||
class MouseWithoutBorders : public telemetry::TraceBase
|
||||
{
|
||||
public:
|
||||
static void Enable(bool enabled) noexcept;
|
||||
|
@ -167,6 +167,9 @@ MakeAppx.exe pack /d . /p $(OutDir)NewPlusPackage.msix /nv</Command>
|
||||
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
|
||||
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Telemetry\EtwTrace\EtwTrace.vcxproj">
|
||||
<Project>{8f021b46-362b-485c-bfba-ccf83e820cbd}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
|
||||
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -4,7 +4,10 @@
|
||||
#include "dll_main.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
HMODULE module_instance_handle = 0;
|
||||
Shared::Trace::ETWTrace trace(L"NewPlusShellExtension");
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE module_handle, DWORD ul_reason_for_call, LPVOID reserved)
|
||||
{
|
||||
|
@ -1,3 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Telemetry/EtwTrace/EtwTrace.h>
|
||||
|
||||
extern HMODULE module_instance_handle;
|
||||
extern Shared::Trace::ETWTrace trace;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user