mirror of
https://github.com/es3n1n/defendnot.git
synced 2026-08-02 10:32:01 +00:00
initial
This commit is contained in:
40
defendnot/bootstrap/bootstrap.cpp
Normal file
40
defendnot/bootstrap/bootstrap.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "bootstrap.hpp"
|
||||
#include "core/com.hpp"
|
||||
#include "core/log.hpp"
|
||||
#include "shared/ctx.hpp"
|
||||
#include "shared/defer.hpp"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace defendnot {
|
||||
void startup() {
|
||||
/// Setup
|
||||
shared::ctx.deserialize();
|
||||
logln("init: {:#x}", com_checked(CoInitialize(nullptr)));
|
||||
|
||||
/// Get the main WSC interface we will be dealing with
|
||||
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(); }));
|
||||
if (shared::ctx.state == shared::State::OFF) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// WSC will reject the register request if name is empty
|
||||
auto name_w = std::wstring(shared::ctx.name.begin(), shared::ctx.name.end());
|
||||
if (name_w.empty()) {
|
||||
throw std::runtime_error("AV Name can not be empty!");
|
||||
}
|
||||
|
||||
/// Convert to BSTR
|
||||
auto name = SysAllocString(name_w.c_str());
|
||||
defer->void {
|
||||
SysFreeString(name);
|
||||
};
|
||||
|
||||
/// Register and activate our AV
|
||||
logln("register: {:#x}", com_checked(inst->Register(name, name)));
|
||||
logln("update: {:#x}", com_checked(inst->UpdateStatus(WSCSecurityProductState::ON, 3)));
|
||||
}
|
||||
} // namespace defendnot
|
||||
5
defendnot/bootstrap/bootstrap.hpp
Normal file
5
defendnot/bootstrap/bootstrap.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace defendnot {
|
||||
void startup();
|
||||
}
|
||||
Reference in New Issue
Block a user