Do not start manually C# EtwTrace. FZ engine exit event.

This commit is contained in:
Stefan Markovic
2024-10-14 13:52:36 +02:00
parent b1f260e3cc
commit 9f00966e67
16 changed files with 15 additions and 22 deletions

View File

@@ -61,8 +61,6 @@ namespace AdvancedPaste
this.InitializeComponent();
EtwTrace.Start();
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder().UseContentRoot(AppContext.BaseDirectory).ConfigureServices((context, services) =>
{
services.AddSingleton<OptionsViewModel>();

View File

@@ -80,8 +80,6 @@ namespace EnvironmentVariables
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
EtwTrace.Start();
var cmdArgs = Environment.GetCommandLineArgs();
if (cmdArgs?.Length > 1)
{

View File

@@ -107,8 +107,6 @@ namespace Hosts
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
EtwTrace.Start();
var cmdArgs = Environment.GetCommandLineArgs();
if (cmdArgs?.Length > 1)
{

View File

@@ -57,8 +57,6 @@ namespace MouseWithoutBorders.Class
ETWTrace etwTrace = new ETWTrace();
etwTrace.Start();
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
{
Common.Log("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");

View File

@@ -40,7 +40,6 @@ namespace MouseWithoutBorders
}
ETWTrace etwTrace = new ETWTrace();
etwTrace.Start();
RunnerHelper.WaitForPowerToysRunnerExitFallback(() =>
{

View File

@@ -47,8 +47,6 @@ public partial class App : Application, IDisposable
NativeThreadCTS = new CancellationTokenSource();
etwTrace.Start();
NativeEventWaiter.WaitForEventLoop(
Constants.TerminatePowerOCRSharedEvent(),
this.Shutdown,

View File

@@ -36,7 +36,6 @@ namespace WorkspacesEditor
public App()
{
etwTrace.Start();
WorkspacesEditorIO = new WorkspacesEditorIO();
}

View File

@@ -52,7 +52,6 @@ namespace Awake
private static int Main(string[] args)
{
_etwTrace.Start();
_settingsUtils = new SettingsUtils();
LockMutex = new Mutex(true, Core.Constants.AppName, out bool instantiated);
Logger.InitializeLogger(Path.Combine("\\", Core.Constants.AppName, "Logs"));

View File

@@ -46,7 +46,6 @@ namespace ColorPickerUI
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
EtwTrace.Start();
NativeThreadCTS = new CancellationTokenSource();
ExitToken = NativeThreadCTS.Token;

View File

@@ -5,6 +5,7 @@
#include <common/utils/logger_helper.h>
#include <common/utils/resources.h>
#include <common/utils/UnhandledExceptionHandler.h>
#include <common/interop/shared_constants.h>
#include <FancyZonesLib/Generated Files/resource.h>
#include <FancyZonesLib/FancyZonesData.h>
@@ -20,6 +21,14 @@ FancyZonesApp::FancyZonesApp(const std::wstring& appName, const std::wstring& ap
InitializeWinhookEventIds();
m_app = MakeFancyZones(reinterpret_cast<HINSTANCE>(&__ImageBase), std::bind(&FancyZonesApp::DisableModule, this));
m_mainThreadId = GetCurrentThreadId();
m_exitEventWaiter = EventWaiter(CommonSharedConstants::FZE_EXIT_EVENT, [&](int err) {
if (err == ERROR_SUCCESS)
{
DisableModule();
}
});
InitHooks();
s_instance = this;
@@ -111,7 +120,7 @@ void FancyZonesApp::InitHooks()
void FancyZonesApp::DisableModule() noexcept
{
PostQuitMessage(0);
PostThreadMessage(m_mainThreadId, WM_QUIT, 0, 0);
}
void FancyZonesApp::HandleWinHookEvent(WinHookEvent* data) noexcept

View File

@@ -1,6 +1,7 @@
#pragma once
#include <common/hooks/LowlevelKeyboardEvent.h>
#include <common/utils/EventWaiter.h>
#include <FancyZonesLib/FancyZones.h>
@@ -15,11 +16,14 @@ public:
private:
static inline FancyZonesApp* s_instance = nullptr;
static inline HHOOK s_llKeyboardHook = nullptr;
winrt::com_ptr<IFancyZones> m_app;
HWINEVENTHOOK m_objectLocationWinEventHook = nullptr;
std::vector<HWINEVENTHOOK> m_staticWinEventHooks;
EventWaiter m_exitEventWaiter;
DWORD m_mainThreadId;
void DisableModule() noexcept;
void InitHooks();

View File

@@ -96,7 +96,6 @@ namespace PowerLauncher
using (var application = new App())
{
application.InitializeComponent();
application.etwTrace.Start();
Common.UI.NativeEventWaiter.WaitForEventLoop(
Constants.RunExitEvent(),

View File

@@ -51,8 +51,6 @@ namespace Peek.UI
InitializeComponent();
Logger.InitializeLogger("\\Peek\\Logs");
EtwTrace.Start();
Host = Microsoft.Extensions.Hosting.Host.
CreateDefaultBuilder().
UseContentRoot(AppContext.BaseDirectory).

View File

@@ -31,7 +31,6 @@ namespace PowerAccent.UI
}
base.OnStartup(e);
_etwTrace.Start();
}
protected override void OnExit(ExitEventArgs e)

View File

@@ -47,7 +47,6 @@ namespace RegistryPreview
// #if DEBUG
// System.Diagnostics.Debugger.Launch();
// #endif
EtwTrace.Start();
// Open With... handler - gets activation arguments if they are available.
AppActivationArguments activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs();

View File

@@ -81,7 +81,6 @@ namespace Microsoft.PowerToys.Settings.UI
Logger.InitializeLogger(@"\Settings\Logs");
EtwTrace = new ETWTrace();
EtwTrace.Start();
string appLanguage = LanguageHelper.LoadLanguage();
if (!string.IsNullOrEmpty(appLanguage))