diff --git a/Source/Build/Execute/SystemAccessTracker.h b/Source/Build/Execute/SystemAccessTracker.h index 27474898..ec95413d 100644 --- a/Source/Build/Execute/SystemAccessTracker.h +++ b/Source/Build/Execute/SystemAccessTracker.h @@ -21,13 +21,19 @@ namespace Soup::Build return m_output; } + void OnInitialize() override final + { + Log::Diag("SystemAccessTracker::OnInitialize"); + } + void OnShutdown() override final { + Log::Diag("SystemAccessTracker::OnShutdown"); } void OnError(std::string_view message) override final { - Log::Error("SystemAccessTracker Error: " + std::string(message)); + Log::Error("SystemAccessTracker::Error - " + std::string(message)); } // FileApi diff --git a/Source/Client/CLI/Commands/VersionCommand.h b/Source/Client/CLI/Commands/VersionCommand.h index c4025cc1..d8bd5b8a 100644 --- a/Source/Client/CLI/Commands/VersionCommand.h +++ b/Source/Client/CLI/Commands/VersionCommand.h @@ -31,7 +31,7 @@ namespace Soup::Client // TODO var version = Assembly.GetExecutingAssembly().GetName().Version; // Log::Message($"{version.Major}.{version.Minor}.{version.Build}"); - Log::HighPriority("0.8.1"); + Log::HighPriority("0.8.2"); } private: diff --git a/Source/Client/CLI/Recipe.toml b/Source/Client/CLI/Recipe.toml index f597d729..66c223ca 100644 --- a/Source/Client/CLI/Recipe.toml +++ b/Source/Client/CLI/Recipe.toml @@ -1,5 +1,5 @@ Name = "Soup" -Version = "0.8.0" +Version = "0.8.2" Type = "Executable" # Ensure the core build extensions are runtime dependencies diff --git a/Source/Monitor/Detours/EventLogger.h b/Source/Monitor/Detours/EventLogger.h index 5f7f7f23..004477c3 100644 --- a/Source/Monitor/Detours/EventLogger.h +++ b/Source/Monitor/Detours/EventLogger.h @@ -8,40 +8,13 @@ class EventLogger public: static void Initialize() { - std::stringstream pipeNameBuilder; - pipeNameBuilder << TBLOG_PIPE_NAMEA << "." << s_nTraceProcessId; - auto pipeName = pipeNameBuilder.str(); - - auto lock = std::lock_guard(s_pipeMutex); - for (int retries = 0; retries < 10; retries++) - { - // Wait up to 1 seconds for a pipe to appear. - auto timoutMilliseconds = 1000; - if (WaitNamedPipeA(pipeName.c_str(), timoutMilliseconds) != 0) - { - // Attempt to open the pipe - s_pipeHandle = Functions::FileApi::Cache::CreateFileA( - pipeName.c_str(), - GENERIC_WRITE, - 0, - nullptr, - OPEN_EXISTING, - 0, - nullptr); - if (s_pipeHandle != INVALID_HANDLE_VALUE) - { - DWORD pipeMode = PIPE_READMODE_MESSAGE; - if (SetNamedPipeHandleState(s_pipeHandle, &pipeMode, nullptr, nullptr)) - { - // All good! - return; - } - } - } - } + Connect(); - // Couldn't open pipe. - throw std::runtime_error("Failed to open pipe for event logger."); + // Notify that we are connected + Monitor::DetourMessage message; + message.Type = Monitor::DetourMessageType::Info_Initialize; + message.ContentSize = 0; + WriteMessage(message); } static void Shutdown() @@ -163,6 +136,44 @@ class EventLogger } private: + static void Connect() + { + std::stringstream pipeNameBuilder; + pipeNameBuilder << TBLOG_PIPE_NAMEA << "." << s_nTraceProcessId; + auto pipeName = pipeNameBuilder.str(); + + auto lock = std::lock_guard(s_pipeMutex); + for (int retries = 0; retries < 10; retries++) + { + // Wait up to 1 seconds for a pipe to appear. + auto timoutMilliseconds = 1000; + if (WaitNamedPipeA(pipeName.c_str(), timoutMilliseconds) != 0) + { + // Attempt to open the pipe + s_pipeHandle = Functions::FileApi::Cache::CreateFileA( + pipeName.c_str(), + GENERIC_WRITE, + 0, + nullptr, + OPEN_EXISTING, + 0, + nullptr); + if (s_pipeHandle != INVALID_HANDLE_VALUE) + { + DWORD pipeMode = PIPE_READMODE_MESSAGE; + if (SetNamedPipeHandleState(s_pipeHandle, &pipeMode, nullptr, nullptr)) + { + // All good! + return; + } + } + } + } + + // Couldn't open pipe. + throw std::runtime_error("Failed to open pipe for event logger."); + } + static void UnsafeWriteMessage(const Monitor::DetourMessage& message) { if (s_pipeHandle == INVALID_HANDLE_VALUE) diff --git a/Source/Monitor/Shared/EventListener.h b/Source/Monitor/Shared/EventListener.h index 0c21edf7..6b5c92d8 100644 --- a/Source/Monitor/Shared/EventListener.h +++ b/Source/Monitor/Shared/EventListener.h @@ -28,6 +28,11 @@ namespace Monitor switch (message.Type) { // Info + case DetourMessageType::Info_Initialize: + { + m_callback->OnInitialize(); + break; + } case DetourMessageType::Info_Shutdown: { m_callback->OnShutdown(); diff --git a/Source/Monitor/Shared/IDetourCallback.h b/Source/Monitor/Shared/IDetourCallback.h index 8fd4057d..f8e876fe 100644 --- a/Source/Monitor/Shared/IDetourCallback.h +++ b/Source/Monitor/Shared/IDetourCallback.h @@ -5,6 +5,7 @@ namespace Monitor export class IDetourCallback { public: + virtual void OnInitialize() = 0; virtual void OnShutdown() = 0; virtual void OnError(std::string_view message) = 0; diff --git a/Source/Monitor/Shared/Module.cpp b/Source/Monitor/Shared/Module.cpp index 4c54c161..70efbfd9 100644 --- a/Source/Monitor/Shared/Module.cpp +++ b/Source/Monitor/Shared/Module.cpp @@ -43,6 +43,7 @@ namespace Monitor { export enum class DetourMessageType : uint32_t { + Info_Initialize, Info_Shutdown, Info_Error,