mirror of
https://github.com/es3n1n/defendnot.git
synced 2026-08-02 10:32:01 +00:00
feat(bootstrap): apply IWscASStatus, pass true to updatestatus
This commit is contained in:
@@ -7,20 +7,36 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
namespace defendnot {
|
namespace defendnot {
|
||||||
|
namespace {
|
||||||
|
template <com::ComObject Ty>
|
||||||
|
void apply(const std::string_view log_prefix, const BSTR name) {
|
||||||
|
/// Get the WSC interface
|
||||||
|
auto inst = com::query<Ty>();
|
||||||
|
|
||||||
|
/// This can fail if we dont have any products registered so no com_checked
|
||||||
|
logln("{}_unregister: {:#x}", log_prefix, com::retry_while_pending([&inst]() -> HRESULT { return inst->Unregister(); }) & 0xFFFFFFFF);
|
||||||
|
if (shared::ctx.state == shared::State::OFF) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Register and activate
|
||||||
|
logln("{}_register: {:#x}", log_prefix, com::checked(inst->Register(name, name, 0, 0)));
|
||||||
|
logln("{}_update: {:#x}", log_prefix, com::checked(inst->UpdateStatus(WSCSecurityProductState::ON, static_cast<BOOL>(true))));
|
||||||
|
|
||||||
|
/// Update the substatuses, if the interface supports this
|
||||||
|
if constexpr (std::is_same_v<Ty, IWscAVStatus4>) {
|
||||||
|
logln("{}_scan_update: {:#x}", log_prefix, com::checked(inst->UpdateScanSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
||||||
|
logln("{}_settings_update: {:#x}", log_prefix, com::checked(inst->UpdateSettingsSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
||||||
|
logln("{}_prot_update: {:#x}", log_prefix, com::checked(inst->UpdateProtectionUpdateSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void startup() {
|
void startup() {
|
||||||
/// Setup
|
/// Setup
|
||||||
shared::ctx.deserialize();
|
shared::ctx.deserialize();
|
||||||
logln("init: {:#x}", com::checked(CoInitialize(nullptr)));
|
logln("init: {:#x}", com::checked(CoInitialize(nullptr)));
|
||||||
|
|
||||||
/// Get the main WSC interface we will be dealing with
|
|
||||||
auto inst = com::query<IWscAVStatus4>();
|
|
||||||
|
|
||||||
/// 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(); }) & 0xFFFFFFFF);
|
|
||||||
if (shared::ctx.state == shared::State::OFF) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// WSC will reject the register request if name is empty
|
/// WSC will reject the register request if name is empty
|
||||||
auto name_w = std::wstring(shared::ctx.name.begin(), shared::ctx.name.end());
|
auto name_w = std::wstring(shared::ctx.name.begin(), shared::ctx.name.end());
|
||||||
if (name_w.empty()) {
|
if (name_w.empty()) {
|
||||||
@@ -33,11 +49,8 @@ namespace defendnot {
|
|||||||
SysFreeString(name);
|
SysFreeString(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Register and activate our AV
|
/// Register our stuff in the WSC interfaces
|
||||||
logln("register: {:#x}", com::checked(inst->Register(name, name, 0, 0)));
|
apply<IWscASStatus>("IWscASStatus", name);
|
||||||
logln("update: {:#x}", com::checked(inst->UpdateStatus(WSCSecurityProductState::ON, WSCSecurityProductState::ON)));
|
apply<IWscAVStatus4>("IWscAVStatus4", name);
|
||||||
logln("scan_update: {:#x}", com::checked(inst->UpdateScanSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
|
||||||
logln("settings_update: {:#x}", com::checked(inst->UpdateSettingsSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
|
||||||
logln("prot_update: {:#x}", com::checked(inst->UpdateProtectionUpdateSubstatus(WSCSecurityProductSubStatus::NO_ACTION)));
|
|
||||||
}
|
}
|
||||||
} // namespace defendnot
|
} // namespace defendnot
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace defendnot {
|
|||||||
public:
|
public:
|
||||||
virtual HRESULT Register(BSTR path_to_signed_product_exe, BSTR display_name, std::uint32_t, std::uint32_t) = 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 Unregister() = 0;
|
||||||
virtual HRESULT UpdateStatus(WSCSecurityProductState state, WSCSecurityProductState state2) = 0;
|
virtual HRESULT UpdateStatus(WSCSecurityProductState state, BOOL unk) = 0;
|
||||||
virtual HRESULT InitiateOfflineCleaning(std::uint16_t*, std::uint16_t*) = 0;
|
virtual HRESULT InitiateOfflineCleaning(std::uint16_t*, std::uint16_t*) = 0;
|
||||||
virtual HRESULT NotifyUserForNearExpiration(std::uint32_t) = 0;
|
virtual HRESULT NotifyUserForNearExpiration(std::uint32_t) = 0;
|
||||||
virtual HRESULT MakeDefaultProductRequest() = 0;
|
virtual HRESULT MakeDefaultProductRequest() = 0;
|
||||||
@@ -52,7 +52,7 @@ namespace defendnot {
|
|||||||
virtual HRESULT UpdateProtectionUpdateSubstatus(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 RegisterAV(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0;
|
||||||
virtual HRESULT UnregisterAV() = 0;
|
virtual HRESULT UnregisterAV() = 0;
|
||||||
virtual HRESULT UpdateStatusAV(WSCSecurityProductState state, WSCSecurityProductState state2) = 0;
|
virtual HRESULT UpdateStatusAV(WSCSecurityProductState state, BOOL unk) = 0;
|
||||||
virtual HRESULT InitiateOfflineCleaningAV(std::uint16_t*, std::uint16_t*) = 0;
|
virtual HRESULT InitiateOfflineCleaningAV(std::uint16_t*, std::uint16_t*) = 0;
|
||||||
virtual HRESULT NotifyUserForNearExpirationAV(std::uint32_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 RegisterFW(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0;
|
||||||
@@ -60,6 +60,13 @@ namespace defendnot {
|
|||||||
virtual HRESULT UpdateStatusFW(WSCSecurityProductState state) = 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 RegisterAS(std::uint16_t*, std::uint16_t*, std::uint32_t, std::uint32_t) = 0;
|
||||||
virtual HRESULT UnregisterAS() = 0;
|
virtual HRESULT UnregisterAS() = 0;
|
||||||
virtual HRESULT UpdateStatusAS(WSCSecurityProductState state, WSCSecurityProductState state2) = 0;
|
virtual HRESULT UpdateStatusAS(WSCSecurityProductState state, BOOL unk) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IWscASStatus : public com::IBaseObject<detail::CLSID_WscIsv, detail::IID_IWscASStatus> {
|
||||||
|
public:
|
||||||
|
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, BOOL unk) = 0;
|
||||||
};
|
};
|
||||||
} // namespace defendnot
|
} // namespace defendnot
|
||||||
|
|||||||
Reference in New Issue
Block a user