mirror of
https://github.com/es3n1n/defendnot.git
synced 2026-08-02 10:32:01 +00:00
feat(loader): check for wsc service before starting
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\ctx.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\defer.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\ipc.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\names.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\strings.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\native.hpp" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)shared\util.hpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace names {
|
||||
constexpr std::string_view kProjectName = "defendnot";
|
||||
constexpr std::string_view kRepoUrl = "https://github.com/es3n1n/defendnot";
|
||||
constexpr std::string_view kDefaultAVName = "dnot.sh";
|
||||
|
||||
constexpr std::string_view kVictimProcess = "Taskmgr.exe";
|
||||
constexpr std::string_view kDllName = "defendnot.dll";
|
||||
|
||||
constexpr std::string_view kVersion = "1.2.0";
|
||||
} // namespace names
|
||||
@@ -23,7 +23,7 @@ namespace native {
|
||||
|
||||
auto function = reinterpret_cast<Ty>(GetProcAddress(mod, function_name.data()));
|
||||
if (function == nullptr) {
|
||||
throw std::runtime_error(std::format("unable to obtain {} from {}", module_name, function_name));
|
||||
throw std::runtime_error(std::format("unable to obtain {} from {}", function_name, module_name));
|
||||
}
|
||||
return function;
|
||||
}
|
||||
|
||||
30
cxx-shared/shared/strings.hpp
Normal file
30
cxx-shared/shared/strings.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "shared/util.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace strings {
|
||||
constexpr std::string_view kProjectName = "defendnot";
|
||||
constexpr std::string_view kRepoUrl = "https://github.com/es3n1n/defendnot";
|
||||
constexpr std::string_view kVersion = "1.2.0";
|
||||
|
||||
constexpr std::string_view kDefaultAVName = "dnot.sh";
|
||||
|
||||
constexpr std::string_view kVictimProcess = "Taskmgr.exe";
|
||||
constexpr std::string_view kDllName = "defendnot.dll";
|
||||
|
||||
constexpr std::string_view kWSCUnavailableError = /// !winserver
|
||||
"Windows Security Center (WSC) is not available on this machine.\n"
|
||||
"For more details, please refer to: https://github.com/es3n1n/defendnot/issues/25";
|
||||
|
||||
constexpr std::string_view kWSCUnavailableErrorWinServer = /// winserver
|
||||
"Windows Security Center (WSC) is not available on this machine.\n"
|
||||
"This typically occurs on Windows Server operating systems, which are not supported by this tool.\n"
|
||||
"For more details, please refer to: https://github.com/es3n1n/defendnot/issues/17";
|
||||
|
||||
inline std::string_view wsc_unavailable_error() noexcept {
|
||||
if (shared::is_winserver()) {
|
||||
return kWSCUnavailableErrorWinServer;
|
||||
}
|
||||
return kWSCUnavailableError;
|
||||
}
|
||||
} // namespace strings
|
||||
@@ -27,4 +27,10 @@ namespace shared {
|
||||
freopen_s(reinterpret_cast<FILE**>(stderr), "CONOUT$", "w", stderr);
|
||||
});
|
||||
}
|
||||
|
||||
inline bool is_winserver() {
|
||||
OSVERSIONINFOEXW osvi = {sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, VER_NT_WORKSTATION};
|
||||
const auto cond_mask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
|
||||
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, cond_mask);
|
||||
}
|
||||
} // namespace shared
|
||||
|
||||
Reference in New Issue
Block a user