diff --git a/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp b/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp
index efefa0aa2e..aae7c637ea 100644
--- a/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp
+++ b/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp
@@ -4,6 +4,7 @@
#include "Constants.h"
#include "Settings.h"
#include "dllmain.h"
+#include "Trace.h"
// Implementations of inherited IUnknown methods
@@ -130,6 +131,7 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
if (!InsertMenuItem(hmenu, indexMenu, TRUE, &mii))
{
hr = HRESULT_FROM_WIN32(GetLastError());
+ Trace::QueryContextMenuError(hr);
}
else
{
@@ -142,15 +144,18 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
{
+ Trace::Invoked();
ipc::Writer writer;
if (HRESULT result = writer.start(); FAILED(result))
{
+ Trace::InvokedRet(result);
return result;
}
if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
{
+ Trace::InvokedRet(result);
return result;
}
@@ -182,6 +187,7 @@ IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
shell_item_array->Release();
}
+ Trace::InvokedRet(S_OK);
return S_OK;
}
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj b/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj
index 8075248a10..2de73f94a0 100644
--- a/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj
+++ b/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj
@@ -167,6 +167,7 @@
+
@@ -181,6 +182,7 @@
+
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj.filters b/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj.filters
index 77f58eaf4f..e85407525c 100644
--- a/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj.filters
+++ b/src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj.filters
@@ -36,6 +36,9 @@
Header Files
+
+ Header Files
+
@@ -59,6 +62,9 @@
Source Files
+
+ Source Files
+
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/PowerToysModule.cpp b/src/modules/FileLocksmith/FileLocksmithExt/PowerToysModule.cpp
index 114e603799..5b828c211f 100644
--- a/src/modules/FileLocksmith/FileLocksmithExt/PowerToysModule.cpp
+++ b/src/modules/FileLocksmith/FileLocksmithExt/PowerToysModule.cpp
@@ -9,6 +9,7 @@
#include "Constants.h"
#include "dllmain.h"
#include "Settings.h"
+#include "Trace.h"
class FileLocksmithModule : public PowertoyModuleIface
{
@@ -70,6 +71,7 @@ public:
Logger::info(L"File Locksmith enabled");
m_enabled = true;
save_settings();
+ Trace::EnableFileLocksmith(m_enabled);
}
virtual void disable() override
@@ -77,6 +79,7 @@ public:
Logger::info(L"File Locksmith disabled");
m_enabled = false;
save_settings();
+ Trace::EnableFileLocksmith(m_enabled);
}
virtual bool is_enabled() override
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/Trace.cpp b/src/modules/FileLocksmith/FileLocksmithExt/Trace.cpp
new file mode 100644
index 0000000000..98b2f9985d
--- /dev/null
+++ b/src/modules/FileLocksmith/FileLocksmithExt/Trace.cpp
@@ -0,0 +1,60 @@
+#include "pch.h"
+
+#include "Trace.h"
+#include "../common/Telemetry/ProjectTelemetry.h"
+
+TRACELOGGING_DEFINE_PROVIDER(
+ g_hProvider,
+ "Microsoft.PowerToys",
+ // {38e8889b-9731-53f5-e901-e8a7c1753074}
+ (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(
+ g_hProvider,
+ "FileLocksmith_EnableFileLocksmith",
+ ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
+ TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
+ TraceLoggingBoolean(enabled, "Enabled"));
+}
+
+void Trace::Invoked() noexcept
+{
+ TraceLoggingWrite(
+ g_hProvider,
+ "FileLocksmith_Invoked",
+ ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
+ TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
+}
+
+void Trace::InvokedRet(_In_ HRESULT hr) noexcept
+{
+ TraceLoggingWrite(
+ g_hProvider,
+ "FileLocksmith_InvokedRet",
+ ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
+ TraceLoggingHResult(hr),
+ TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
+}
+
+void Trace::QueryContextMenuError(_In_ HRESULT hr) noexcept
+{
+ TraceLoggingWrite(
+ g_hProvider,
+ "FileLocksmith_QueryContextMenuError",
+ ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
+ TraceLoggingHResult(hr),
+ TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
+}
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/Trace.h b/src/modules/FileLocksmith/FileLocksmithExt/Trace.h
new file mode 100644
index 0000000000..a9516b5d5c
--- /dev/null
+++ b/src/modules/FileLocksmith/FileLocksmithExt/Trace.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "pch.h"
+
+class Trace
+{
+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;
+ static void QueryContextMenuError(_In_ HRESULT hr) noexcept;
+};
diff --git a/src/modules/FileLocksmith/FileLocksmithExt/dllmain.cpp b/src/modules/FileLocksmith/FileLocksmithExt/dllmain.cpp
index 3fb8aa2cf3..32405d61e9 100644
--- a/src/modules/FileLocksmith/FileLocksmithExt/dllmain.cpp
+++ b/src/modules/FileLocksmith/FileLocksmithExt/dllmain.cpp
@@ -6,6 +6,7 @@
#include "Registry.h"
#include "ClassFactory.h"
+#include "Trace.h"
namespace globals
{
@@ -23,16 +24,15 @@ BOOL APIENTRY DllMain( HMODULE hModule,
{
case DLL_PROCESS_ATTACH:
globals::instance = hModule;
+ Trace::RegisterProvider();
break;
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
+ Trace::UnregisterProvider();
break;
}
return TRUE;
}
-
STDAPI DllRegisterServer()
{
if (!add_registry_keys())
@@ -68,14 +68,3 @@ STDAPI DllCanUnloadNow(void)
{
return globals::ref_count == 0 ? S_OK : S_FALSE;
}
-
-// Things to implement:
-// 1. (DONE) A class which implements IExplorerCommand
-// 2. (DONE) A class which implements IClassFactory
-// 3. (DONE) DLL register/unregister functions which will create registry entries
-// 4. (DONE) Other DLL exported functions
-// 5. (DONE) Implement IShellExtInit in ExplorerCommand
-// 6. (DONE) Implement IContextMenu in ExplorerCommand
-// 7. (DONE) Extract useful functions from HandlesExperiment to a static library
-// 8. (DONE) Implement IPC in Lib - to be used between UI and DLL
-// 9. Implement UI