我正在使用Windows Defender 功能扫描文件夹。
首先,我使用 MpManagerOpen 打开 Windows Defender 管理器。接下来我开始使用 MpScanStart 函数进行扫描。然后,我使用 MpThreatOpen 函数枚举了所有威胁。
我的目标是如何使用 Windows Defender 功能消除这些威胁。
在 MSDN 中没有威胁删除功能。
谷歌搜索后,我找到了 MpCleanStart 功能,但我不知道如何使用。
请帮我。
谢谢你的帮助。
这是我的代码。
MPHANDLE w_handle = NULL;
MPHANDLE w_scan_handle = NULL;
MPHANDLE w_threat_handle = NULL;
HRESULT w_result = S_OK;
MPSCAN_TYPE w_type = MPSCAN_TYPE_RESOURCE;
MPSCAN_RESOURCES w_scan_resource = {0};
MPRESOURCE_INFO w_resource_info[1] = {0};
LPWSTR w_err_msg = NULL;
MPCALLBACK_DATA w_callback_data;
PMPTHREAT_INFO w_threat_info_list = NULL;
// Open
w_result = MpManagerOpen(0, &w_handle);
if (w_result != S_OK)
{
goto L_EXIT;
}
// Scan
w_resource_info[0].Path = L"N:\\";
w_resource_info[0].Scheme = L"folder";
w_resource_info[0].Class = 0;
w_scan_resource.dwResourceCount = 1;
w_scan_resource.pResourceList = w_resource_info;
w_result = MpScanStart(w_handle, w_type, 0, (PMPSCAN_RESOURCES)&w_scan_resource, NULL, &w_scan_handle);
if (w_result != S_OK)
{
MpErrorMessageFormat(w_handle, w_result, &w_err_msg);
goto L_EXIT;
}
// Threat Open
w_result = MpThreatOpen(w_scan_handle, MPTHREAT_SOURCE_SCAN, MPTHREAT_TYPE_KNOWNBAD, &w_threat_handle);
if (w_result != S_OK)
{
MpErrorMessageFormat(w_handle, w_result, &w_err_msg);
goto L_EXIT;
}
// Threat Enum
while (TRUE)
{
w_result = MpThreatEnumerate(w_threat_handle, &w_threat_info_list);
if (w_result != S_OK)
{
break;
}
}
// Remove Threat
L_EXIT:
if (w_handle)
{
MpHandleClose(w_handle);
}
if (w_scan_handle)
{
MpHandleClose(w_scan_handle);
}
if (w_err_msg)
{
MpFreeMemory(w_err_msg);
}
return w_result;