From a2b17933786eb38a5f5dbf732a3d0a7be5101af9 Mon Sep 17 00:00:00 2001 From: es3n1n Date: Fri, 16 May 2025 19:36:41 +0900 Subject: [PATCH] feat(wsc): add more IWscAVStatus methods --- defendnot/bootstrap/bootstrap.cpp | 4 +-- defendnot/core/com.hpp | 46 ++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/defendnot/bootstrap/bootstrap.cpp b/defendnot/bootstrap/bootstrap.cpp index 878d170..d869caa 100644 --- a/defendnot/bootstrap/bootstrap.cpp +++ b/defendnot/bootstrap/bootstrap.cpp @@ -16,7 +16,7 @@ namespace defendnot { auto inst = IWscAVStatus::get(); /// This can fail if we dont have any avs registered so no com_checked - logln("unregister: {:#x}", com_retry_while_pending([&inst]() -> HRESULT { return inst->Unregister(); })); + logln("unregister: {:#x}", com_retry_while_pending([&inst]() -> HRESULT { return inst->Unregister(); }) & 0xFFFFFFFF); if (shared::ctx.state == shared::State::OFF) { return; } @@ -34,7 +34,7 @@ namespace defendnot { }; /// Register and activate our AV - logln("register: {:#x}", com_checked(inst->Register(name, name))); + logln("register: {:#x}", com_checked(inst->Register(name, name, 0, 0))); logln("update: {:#x}", com_checked(inst->UpdateStatus(WSCSecurityProductState::ON, 3))); } } // namespace defendnot diff --git a/defendnot/core/com.hpp b/defendnot/core/com.hpp index d081436..3baee4f 100644 --- a/defendnot/core/com.hpp +++ b/defendnot/core/com.hpp @@ -10,7 +10,7 @@ namespace defendnot { namespace detail { - inline GUID RCLSID = {0x0F2102C37, 0x90C3, 0x450C, {0x0B3, 0x0F6, 0x92, 0x0BE, 0x16, 0x93, 0x0BD, 0x0F2}}; + inline GUID CLSID_IWscAVStatus = {0x0F2102C37, 0x90C3, 0x450C, {0x0B3, 0x0F6, 0x92, 0x0BE, 0x16, 0x93, 0x0BD, 0x0F2}}; inline GUID IID_IWscAVStatus = {0x3901A765, 0x0AB91, 0x4BA9, {0xA5, 0x53, 0x5B, 0x85, 0x38, 0xDE, 0xB8, 0x40}}; } // namespace detail @@ -21,6 +21,13 @@ namespace defendnot { EXPIRED = 3 }; + enum class WSCSecurityProductSubStatus : std::uint32_t { + NOT_SET = 0, + NO_ACTION = 1, + ACTION_RECOMMENDED = 2, + ACTION_NEEDED = 3 + }; + inline HRESULT com_checked(HRESULT result, const std::source_location loc = std::source_location::current()) { if (result == 0) { return result; @@ -53,20 +60,39 @@ namespace defendnot { } class IWscAVStatus { - private: - /// Incomplete stubs to just increase the vfunc id + public: virtual HRESULT QueryInterface() = 0; - virtual HRESULT AddRef() = 0; - virtual HRESULT Release() = 0; + virtual std::uint32_t AddRef() = 0; + virtual std::uint32_t Release() = 0; + virtual HRESULT Register(BSTR path_to_signed_product_exe, BSTR display_name, std::uint32_t, std::uint32_t) = 0; + virtual HRESULT Unregister() = 0; + virtual HRESULT UpdateStatus(WSCSecurityProductState state, std::uint32_t) = 0; + virtual HRESULT InitiateOfflineCleaning(std::uint16_t*, std::uint16_t*) = 0; + virtual HRESULT NotifyUserForNearExpiration(std::uint32_t) = 0; + virtual HRESULT MakeDefaultProductRequest() = 0; + virtual HRESULT IsDefaultProductEnforced(std::uint32_t* result) = 0; + virtual HRESULT UpdateScanSubstatus(WSCSecurityProductSubStatus status) = 0; + virtual HRESULT UpdateSettingsSubstatus(WSCSecurityProductSubStatus status) = 0; + virtual HRESULT UpdateProtectionUpdateSubstatus(WSCSecurityProductSubStatus status) = 0; + virtual HRESULT RegisterAV(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0; + virtual HRESULT UnregisterAV() = 0; + virtual HRESULT UpdateStatusAV(WSCSecurityProductState state, std::uint32_t) = 0; + virtual HRESULT InitiateOfflineCleaningAV(std::uint16_t*, std::uint16_t*) = 0; + virtual HRESULT NotifyUserForNearExpirationAV(std::uint32_t) = 0; + virtual HRESULT RegisterFW(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0; + virtual HRESULT UnregisterFW() = 0; + virtual HRESULT UpdateStatusFW(WSCSecurityProductState state) = 0; + virtual HRESULT RegisterAS(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0; + virtual HRESULT UnregisterAS() = 0; + virtual HRESULT UpdateStatusAS(WSCSecurityProductState state, std::uint32_t) = 0; + + private: + virtual void dtor() = 0; public: - virtual HRESULT Register(BSTR path_to_signed_product_exe, BSTR display_name) = 0; - virtual HRESULT Unregister() = 0; - virtual HRESULT UpdateStatus(WSCSecurityProductState state, std::uint32_t idk) = 0; - static IWscAVStatus* get() { IWscAVStatus* result = nullptr; - com_checked(CoCreateInstance(detail::RCLSID, 0, 1, detail::IID_IWscAVStatus, reinterpret_cast(&result))); + com_checked(CoCreateInstance(detail::CLSID_IWscAVStatus, 0, 1, detail::IID_IWscAVStatus, reinterpret_cast(&result))); return result; } };