如何在 C# 中启用 Windows Defender
How to enable Windows Defender in C#
我正在寻找一种在 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.
没有简单的方法可以通过您的程序既不打开也不关闭 Windows Defender。如果如此简单,Windows Defender 将无法保护您的计算机,因为任何恶意软件都会将其关闭。
有一些注册表项定义了 Windows Defender 的实时保护是否启用。您可以阅读这些值以了解它是否处于活动状态。但是您不能修改这些键,甚至不能修改具有 SYSTEM 用户的服务中的 运行。这些注册表项受 Windows 保护,禁止篡改。
开启或关闭WindowsDefender的唯一方法:
- 手动通过 Windows Defender 配置面板 (MsAscUi.exe)
- 安装另一个自动禁用 Windows Defender 的防病毒软件。
如果您对注册表项感兴趣,请阅读我在另一个主题中的回答:
Find out if Windows Defender disc scan is running?
第一步是按“Windows”键和“R”键打开运行对话框
然后在“打开”对话框中键入“services.msc”
按回车键或单击确定按钮
在服务列表中检查“安全中心”
右键单击安全中心
点击重启
我正在寻找一种在 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.
没有简单的方法可以通过您的程序既不打开也不关闭 Windows Defender。如果如此简单,Windows Defender 将无法保护您的计算机,因为任何恶意软件都会将其关闭。
有一些注册表项定义了 Windows Defender 的实时保护是否启用。您可以阅读这些值以了解它是否处于活动状态。但是您不能修改这些键,甚至不能修改具有 SYSTEM 用户的服务中的 运行。这些注册表项受 Windows 保护,禁止篡改。
开启或关闭WindowsDefender的唯一方法:
- 手动通过 Windows Defender 配置面板 (MsAscUi.exe)
- 安装另一个自动禁用 Windows Defender 的防病毒软件。
如果您对注册表项感兴趣,请阅读我在另一个主题中的回答: Find out if Windows Defender disc scan is running?
第一步是按“Windows”键和“R”键打开运行对话框 然后在“打开”对话框中键入“services.msc” 按回车键或单击确定按钮 在服务列表中检查“安全中心” 右键单击安全中心 点击重启