c# - 如何在 C# 中启用 Windows Defender

标签 c# windows msdn

我正在寻找一种在 C# 中启用(而不是禁用)Windows Defender 的方法。

我在msdn上找到了这个函数

HRESULT WDEnable(
  _In_  BOOL fEnable
);

我可以使用它,但是它的 MpClient.dll 部分在我的系统上找不到,所以我不能使用 LoadLibrary/GetProcAddress/GetDelegateForFunctionPointer

有人知道另一种方法吗?

我应该指出,这是针对需要检查 Windows Defender 是否已启用(已经编码并运行)以及是否未启用的合法软件。

谢谢

最佳答案

注册表项有一些访问限制,以防止在用户上下文中运行的任何进程将其关闭。对于病毒来说,防止它被发现真的很容易。要启用它,您必须在管理员上下文中运行。尝试以管理员身份运行您的进程,看看您是否可以通过这种方式更改注册表项。

来自 msdn 文档: 备注

The application calling this function must run with administrator permissions on the local computer. Windows Defender also validates (1) the proper signing of the calling process and all loaded modules and (2) that the IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY flag is set on the calling process and all loaded modules before allowing the calling application to change the status. If the calling process image (or any loaded modules) is not signed or is flagged as a threat by the Windows Defender signature, then the call fails with the appropriate error code.

关于c# - 如何在 C# 中启用 Windows Defender,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30616109/

相关文章:

wpf - MVVM 中的命令

c# - 如何找出 AppCrash 的原因?

c# - 在数据绑定(bind)后对更新的 gridview 进行排序

c# - 如何模拟表单的 unicode 文本输入

c++ - 在 C++ 中填充 GUID 时出错

visual-studio-2010 - 适用于 x64 的 Visual Studio 2010 Ultimate?

c# - 过分热心的字符串常量

windows - 什么是 Windows 命令行 EXE 的 "side-by-side configuration",我该如何更正它?

Windows Batch - 如何修改文件并仅保留以 "<?xml"开头并以 "</testsuites>"结尾的子字符串?

python - 在 Python 中更改键盘锁