Added Vanara.PInvoke.WscApi project for Windows Security Center functions.

pull/350/head
David Hall 2022-10-28 18:42:29 -06:00
parent 7456cb991f
commit 95cdb906b5
4 changed files with 593 additions and 2 deletions

377
PInvoke/WscApi/IWscApi.cs Normal file
View File

@ -0,0 +1,377 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke;
public static partial class WscApi
{
public enum SECURITY_PRODUCT_TYPE
{
SECURITY_PRODUCT_TYPE_ANTIVIRUS = 0,
SECURITY_PRODUCT_TYPE_FIREWALL = 1,
SECURITY_PRODUCT_TYPE_ANTISPYWARE = 2
}
/// <summary>Defines the current state of the security product that is made available to Windows Security Center.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/ne-iwscapi-wsc_security_product_state typedef enum
// WSC_SECURITY_PRODUCT_STATE { WSC_SECURITY_PRODUCT_STATE_ON = 0, WSC_SECURITY_PRODUCT_STATE_OFF = 1, WSC_SECURITY_PRODUCT_STATE_SNOOZED
// = 2, WSC_SECURITY_PRODUCT_STATE_EXPIRED = 3 } ;
[PInvokeData("iwscapi.h", MSDNShortId = "NE:iwscapi.WSC_SECURITY_PRODUCT_STATE")]
public enum WSC_SECURITY_PRODUCT_STATE
{
/// <summary>
/// <para>Value:</para>
/// <para>0</para>
/// <para>The security product software is turned on and protecting the user.</para>
/// </summary>
WSC_SECURITY_PRODUCT_STATE_ON,
/// <summary>
/// <para>Value:</para>
/// <para>1</para>
/// <para>The security product software is turned off and protection is disabled.</para>
/// </summary>
WSC_SECURITY_PRODUCT_STATE_OFF,
/// <summary>
/// <para>Value:</para>
/// <para>2</para>
/// <para>The security product software is in the snoozed state, temporarily off, and not actively protecting the computer.</para>
/// </summary>
WSC_SECURITY_PRODUCT_STATE_SNOOZED,
/// <summary>
/// <para>Value:</para>
/// <para>3</para>
/// <para>The security product software has expired and is no longer actively protecting the computer.</para>
/// </summary>
WSC_SECURITY_PRODUCT_STATE_EXPIRED,
}
public enum WSC_SECURITY_PRODUCT_SUBSTATUS
{
WSC_SECURITY_PRODUCT_SUBSTATUS_NOT_SET = 0,
WSC_SECURITY_PRODUCT_SUBSTATUS_NO_ACTION = 1,
WSC_SECURITY_PRODUCT_SUBSTATUS_ACTION_RECOMMENDED = 2,
WSC_SECURITY_PRODUCT_SUBSTATUS_ACTION_NEEDED = 3
}
/// <summary>Reports the current version status of the security product to Windows Security Center.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/ne-iwscapi-wsc_security_signature_status typedef enum
// _WSC_SECURITY_SIGNATURE_STATUS { WSC_SECURITY_PRODUCT_OUT_OF_DATE = 0, WSC_SECURITY_PRODUCT_UP_TO_DATE = 1 } WSC_SECURITY_SIGNATURE_STATUS;
[PInvokeData("iwscapi.h", MSDNShortId = "NE:iwscapi._WSC_SECURITY_SIGNATURE_STATUS")]
public enum WSC_SECURITY_SIGNATURE_STATUS
{
/// <summary>
/// <para>Value:</para>
/// <para>0</para>
/// <para>The security software reports that it is not the most recent version.</para>
/// </summary>
WSC_SECURITY_PRODUCT_OUT_OF_DATE,
/// <summary>
/// <para>Value:</para>
/// <para>1</para>
/// <para>The security software reports that it is the most recent version.</para>
/// </summary>
WSC_SECURITY_PRODUCT_UP_TO_DATE,
}
[PInvokeData("iwscapi.h")]
[ComImport, Guid("0476d69c-f21a-11e5-9ce9-5e5517507c66"), InterfaceType(ComInterfaceType.InterfaceIsDual), CoClass(typeof(WSCDefaultProduct))]
public interface IWSCDefaultProduct
{
[PreserveSig]
HRESULT SetDefaultProduct(SECURITY_PRODUCT_TYPE eType, [MarshalAs(UnmanagedType.BStr)] string pGuid);
}
/// <summary>Provides methods for getting product information for an individual provider to interact with Windows Security Center.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nn-iwscapi-iwscproduct
[PInvokeData("iwscapi.h", MSDNShortId = "NN:iwscapi.IWscProduct")]
[ComImport, Guid("8C38232E-3A45-4A27-92B0-1A16A975F669"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IWscProduct
{
/// <summary>Returns the current product information for the security product.</summary>
/// <value>A pointer to the name of the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productname HRESULT get_ProductName( [out]
// BSTR *pVal );
string ProductName
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current state of the signature data for the security product.</summary>
/// <value>A pointer to the state value of the signature of the security product.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstate HRESULT get_ProductState(
// [out] WSC_SECURITY_PRODUCT_STATE *pVal );
WSC_SECURITY_PRODUCT_STATE ProductState { get; }
/// <summary>Returns the current status of the signature data for the security product.</summary>
/// <value>
/// A pointer to the status value of the signature of the security product. If the security product is a Firewall product, the return
/// value is always <c>WSC_SECURITY_PRODUCT_UP_TO_DATE</c> because firewalls do not contain signature data.
/// </value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_signaturestatus HRESULT
// get_SignatureStatus( [out] WSC_SECURITY_SIGNATURE_STATUS *pVal );
WSC_SECURITY_SIGNATURE_STATUS SignatureStatus { get; }
/// <summary>Returns the current remediation path for the security product.</summary>
/// <value>A pointer to the remediation path for the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_remediationpath HRESULT
// get_RemediationPath( [out] BSTR *pVal );
string RemediationPath
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current time stamp for the security product.</summary>
/// <returns>A pointer to the time stamp of the security product. This is displayed in the Windows Security Center user interface.</returns>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstatetimestamp HRESULT
// get_ProductStateTimestamp( [out] BSTR *pVal );
string ProductStateTimestamp
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets the product unique identifier.</summary>
/// <value>The product unique identifier.</value>
string ProductGuid
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets a value indicating whether [product is default].</summary>
/// <value><see langword="true"/> if [product is default]; otherwise, <see langword="false"/>.</value>
bool ProductIsDefault
{
[return: MarshalAs(UnmanagedType.Bool)]
get;
}
}
[PInvokeData("iwscapi.h")]
[ComImport, Guid("F896CA54-FE09-4403-86D4-23CB488D81D8"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IWscProduct2 : IWscProduct
{
/// <summary>Returns the current product information for the security product.</summary>
/// <value>A pointer to the name of the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productname HRESULT get_ProductName( [out]
// BSTR *pVal );
new string ProductName
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current state of the signature data for the security product.</summary>
/// <value>A pointer to the state value of the signature of the security product.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstate HRESULT get_ProductState(
// [out] WSC_SECURITY_PRODUCT_STATE *pVal );
new WSC_SECURITY_PRODUCT_STATE ProductState { get; }
/// <summary>Returns the current status of the signature data for the security product.</summary>
/// <value>
/// A pointer to the status value of the signature of the security product. If the security product is a Firewall product, the return
/// value is always <c>WSC_SECURITY_PRODUCT_UP_TO_DATE</c> because firewalls do not contain signature data.
/// </value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_signaturestatus HRESULT
// get_SignatureStatus( [out] WSC_SECURITY_SIGNATURE_STATUS *pVal );
new WSC_SECURITY_SIGNATURE_STATUS SignatureStatus { get; }
/// <summary>Returns the current remediation path for the security product.</summary>
/// <value>A pointer to the remediation path for the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_remediationpath HRESULT
// get_RemediationPath( [out] BSTR *pVal );
new string RemediationPath
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current time stamp for the security product.</summary>
/// <returns>A pointer to the time stamp of the security product. This is displayed in the Windows Security Center user interface.</returns>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstatetimestamp HRESULT
// get_ProductStateTimestamp( [out] BSTR *pVal );
new string ProductStateTimestamp
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets the product unique identifier.</summary>
/// <value>The product unique identifier.</value>
new string ProductGuid
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets a value indicating whether [product is default].</summary>
/// <value><see langword="true"/> if [product is default]; otherwise, <see langword="false"/>.</value>
new bool ProductIsDefault
{
[return: MarshalAs(UnmanagedType.Bool)]
get;
}
WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusScanSubstatus { get; }
WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusSettingsSubstatus { get; }
WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusProtectionUpdateSubstatus { get; }
WSC_SECURITY_PRODUCT_SUBSTATUS FirewallDomainProfileSubstatus { get; }
WSC_SECURITY_PRODUCT_SUBSTATUS FirewallPrivateProfileSubstatus { get; }
WSC_SECURITY_PRODUCT_SUBSTATUS FirewallPublicProfileSubstatus { get; }
}
[PInvokeData("iwscapi.h")]
[ComImport, Guid("55536524-D1D1-4726-8C7C-04996A1904E7"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IWscProduct3 : IWscProduct2
{
/// <summary>Returns the current product information for the security product.</summary>
/// <value>A pointer to the name of the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productname HRESULT get_ProductName( [out]
// BSTR *pVal );
new string ProductName
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current state of the signature data for the security product.</summary>
/// <value>A pointer to the state value of the signature of the security product.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstate HRESULT get_ProductState(
// [out] WSC_SECURITY_PRODUCT_STATE *pVal );
new WSC_SECURITY_PRODUCT_STATE ProductState { get; }
/// <summary>Returns the current status of the signature data for the security product.</summary>
/// <value>
/// A pointer to the status value of the signature of the security product. If the security product is a Firewall product, the return
/// value is always <c>WSC_SECURITY_PRODUCT_UP_TO_DATE</c> because firewalls do not contain signature data.
/// </value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_signaturestatus HRESULT
// get_SignatureStatus( [out] WSC_SECURITY_SIGNATURE_STATUS *pVal );
new WSC_SECURITY_SIGNATURE_STATUS SignatureStatus { get; }
/// <summary>Returns the current remediation path for the security product.</summary>
/// <value>A pointer to the remediation path for the security product. This is displayed in the Windows Security Center user interface.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_remediationpath HRESULT
// get_RemediationPath( [out] BSTR *pVal );
new string RemediationPath
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Returns the current time stamp for the security product.</summary>
/// <returns>A pointer to the time stamp of the security product. This is displayed in the Windows Security Center user interface.</returns>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproduct-get_productstatetimestamp HRESULT
// get_ProductStateTimestamp( [out] BSTR *pVal );
new string ProductStateTimestamp
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets the product unique identifier.</summary>
/// <value>The product unique identifier.</value>
new string ProductGuid
{
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
/// <summary>Gets a value indicating whether [product is default].</summary>
/// <value><see langword="true"/> if [product is default]; otherwise, <see langword="false"/>.</value>
new bool ProductIsDefault
{
[return: MarshalAs(UnmanagedType.Bool)]
get;
}
new WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusScanSubstatus { get; }
new WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusSettingsSubstatus { get; }
new WSC_SECURITY_PRODUCT_SUBSTATUS AntivirusProtectionUpdateSubstatus { get; }
new WSC_SECURITY_PRODUCT_SUBSTATUS FirewallDomainProfileSubstatus { get; }
new WSC_SECURITY_PRODUCT_SUBSTATUS FirewallPrivateProfileSubstatus { get; }
new WSC_SECURITY_PRODUCT_SUBSTATUS FirewallPublicProfileSubstatus { get; }
uint AntivirusDaysUntilExpired { get; }
}
/// <summary>Provides methods to collect product information for the selected type of providers installed on the computer.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nn-iwscapi-iwscproductlist
[PInvokeData("iwscapi.h", MSDNShortId = "NN:iwscapi.IWSCProductList")]
[ComImport, Guid("722A338C-6E8E-4E72-AC27-1417FB0C81C2"), InterfaceType(ComInterfaceType.InterfaceIsDual), CoClass(typeof(WSCProductList))]
public interface IWscProductList
{
/// <summary>Gathers information on all of the providers of the specified type on the computer.</summary>
/// <param name="provider">
/// <para>
/// A value from the WSC_SECURITY_PROVIDER enumeration with the name of the provider as one of the following values. Note that the
/// possible values can't be combined in a logical OR as they can when used with the WscGetSecurityProviderHealth function.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>WSC_SECURITY_PROVIDER_ANTIVIRUS</c></term>
/// <term>Antivirus products.</term>
/// </item>
/// <item>
/// <term><c>WSC_SECURITY_PROVIDER_ANTISPYWARE</c></term>
/// <term>Anti-spyware products.</term>
/// </item>
/// <item>
/// <term><c>WSC_SECURITY_PROVIDER_FIREWALL</c></term>
/// <term>Firewall products.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the method succeeds, returns S_OK.</para>
/// <para>If the method fails, returns a Win32 error code.</para>
/// </returns>
/// <remarks>
/// Once the client gets an IWSCProductList pointer, they must call <c>Initialize</c> with a provider type, which gathers information
/// on all the providers of that type installed on the system. Only one type of provider can be specified when calling
/// <c>Initialize</c>, and the <c>Initialize</c> method may only be called once for each instance of an <c>IWSCProductList</c>
/// pointer. After the list has been initialized, the user is free to call Count to obtain the number of providers in the list and
/// Item to retrieve an individual provider.
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproductlist-initialize HRESULT Initialize( [in] ULONG
// provider );
void Initialize(WSC_SECURITY_PROVIDER provider);
/// <summary>Gathers the total number of all security product providers of the specified type on the computer.</summary>
/// <value>The number of providers in the list of security products on the computer.</value>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproductlist-get_count HRESULT get_Count( [out] LONG
// *pVal );
int Count { get; }
/// <summary>Returns one of the types of providers on the computer.</summary>
/// <param name="index">The list of the providers.</param>
/// <returns>A pointer to the IWscProduct product information.</returns>
/// <remarks>
/// A provider is obtained by calling the <c>Item</c> method, which returns an interface pointer to an initialized IWscProduct
/// object. The user is then able to retrieve the name, product state, and signature status through the methods of the
/// <c>IWscProduct</c> interface.
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/iwscapi/nf-iwscapi-iwscproductlist-get_item HRESULT get_Item( [in] ULONG
// index, [out] IWscProduct **pVal );
IWscProduct this[uint index] { get; }
}
/// <summary>CLSID_WSCDefaultProduct</summary>
[ComImport, Guid("2981a36e-f22d-11e5-9ce9-5e5517507c66"), ClassInterface(ClassInterfaceType.None)]
public class WSCDefaultProduct { }
/// <summary>CLSID_WSCProductList</summary>
[ComImport, Guid("17072F7B-9ABE-4A74-A261-1EB76B55107A"), ClassInterface(ClassInterfaceType.None)]
public class WSCProductList { }
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<ProjectExtensions>
<SupportedDlls>wscapi.dll</SupportedDlls>
</ProjectExtensions>
<PropertyGroup>
<Description>PInvoke API (methods, structures and constants) imported from Windows Security Center (WscApi.dll).</Description>
<AssemblyName>Vanara.PInvoke.WscApi</AssemblyName>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<PackageId>$(AssemblyName)</PackageId>
<PackageTags>pinvoke;vanara;net-extensions;interop;wscapi;windows security center;wsc</PackageTags>
<PackageReleaseNotes />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />
<ProjectReference Include="..\Kernel32\Vanara.PInvoke.Kernel32.csproj" />
<ProjectReference Include="..\Shared\Vanara.PInvoke.Shared.csproj" />
</ItemGroup>
</Project>

174
PInvoke/WscApi/WscApi.cs Normal file
View File

@ -0,0 +1,174 @@
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Kernel32;
namespace Vanara.PInvoke;
/// <summary>Items from the WscApi.dll.</summary>
public static partial class WscApi
{
private const string Lib_Wscapi = "wscapi.dll";
/// <summary>Defines all the services that are monitored by Windows Security Center (WSC).</summary>
/// <remarks>
/// <para>Note</para>
/// <para>
/// WSC_SECURITY_PROVIDER::WSC_SECURITY_PROVIDER_ANTISPYWARE should be used only in operating systems prior to Windows 10, version 1607.
/// As of Windows 10, version 1607, WSC continues to track the status for antivirus, but not for anti-spyware.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/wscapi/ne-wscapi-wsc_security_provider typedef enum _WSC_SECURITY_PROVIDER {
// WSC_SECURITY_PROVIDER_FIREWALL = 0x1, WSC_SECURITY_PROVIDER_AUTOUPDATE_SETTINGS = 0x2, WSC_SECURITY_PROVIDER_ANTIVIRUS = 0x4,
// WSC_SECURITY_PROVIDER_ANTISPYWARE = 0x8, WSC_SECURITY_PROVIDER_INTERNET_SETTINGS = 0x10, WSC_SECURITY_PROVIDER_USER_ACCOUNT_CONTROL =
// 0x20, WSC_SECURITY_PROVIDER_SERVICE = 0x40, WSC_SECURITY_PROVIDER_NONE = 0, WSC_SECURITY_PROVIDER_ALL } WSC_SECURITY_PROVIDER, *PWSC_SECURITY_PROVIDER;
[PInvokeData("wscapi.h", MSDNShortId = "NE:wscapi._WSC_SECURITY_PROVIDER")]
[Flags]
public enum WSC_SECURITY_PROVIDER
{
/// <summary>
/// <para>Value:</para>
/// <para>0</para>
/// <para>None of the items that WSC monitors.</para>
/// </summary>
WSC_SECURITY_PROVIDER_NONE = 0,
/// <summary>
/// <para>Value:</para>
/// <para>0x1</para>
/// <para>The aggregation of all firewalls for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_FIREWALL = 0x01,
/// <summary>
/// <para>Value:</para>
/// <para>0x2</para>
/// <para>The automatic update settings for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_AUTOUPDATE_SETTINGS = 0x02,
/// <summary>
/// <para>Value:</para>
/// <para>0x4</para>
/// <para>The aggregation of all antivirus products for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_ANTIVIRUS = 0x04,
/// <summary>
/// <para>Value:</para>
/// <para>0x8</para>
/// <para>The aggregation of all anti-spyware products for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_ANTISPYWARE = 0x08,
/// <summary>
/// <para>Value:</para>
/// <para>0x10</para>
/// <para>The settings that restrict the access of web sites in each of the Internet zones for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_INTERNET_SETTINGS = 0x10,
/// <summary>
/// <para>Value:</para>
/// <para>0x20</para>
/// <para>The User Account Control (UAC) settings for this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_USER_ACCOUNT_CONTROL = 0x20,
/// <summary>
/// <para>Value:</para>
/// <para>0x40</para>
/// <para>The running state of the WSC service on this computer.</para>
/// </summary>
WSC_SECURITY_PROVIDER_SERVICE = 0x40,
/// <summary>All of the items that the WSC monitors.</summary>
WSC_SECURITY_PROVIDER_ALL = WSC_SECURITY_PROVIDER_FIREWALL | WSC_SECURITY_PROVIDER_AUTOUPDATE_SETTINGS | WSC_SECURITY_PROVIDER_ANTIVIRUS | WSC_SECURITY_PROVIDER_INTERNET_SETTINGS | WSC_SECURITY_PROVIDER_USER_ACCOUNT_CONTROL | WSC_SECURITY_PROVIDER_SERVICE,
}
/// <summary>Defines the possible states for any service monitored by Windows Security Center (WSC).</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/wscapi/ne-wscapi-wsc_security_provider_health typedef enum
// _WSC_SECURITY_PROVIDER_HEALTH { WSC_SECURITY_PROVIDER_HEALTH_GOOD, WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED,
// WSC_SECURITY_PROVIDER_HEALTH_POOR, WSC_SECURITY_PROVIDER_HEALTH_SNOOZE } WSC_SECURITY_PROVIDER_HEALTH, *PWSC_SECURITY_PROVIDER_HEALTH;
[PInvokeData("wscapi.h", MSDNShortId = "NE:wscapi._WSC_SECURITY_PROVIDER_HEALTH")]
public enum WSC_SECURITY_PROVIDER_HEALTH
{
/// <summary>The status of the security provider category is good and does not need user attention.</summary>
WSC_SECURITY_PROVIDER_HEALTH_GOOD,
/// <summary>The status of the security provider category is not monitored by WSC.</summary>
WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED,
/// <summary>The status of the security provider category is poor and the computer may be at risk.</summary>
WSC_SECURITY_PROVIDER_HEALTH_POOR,
/// <summary>The security provider category is in snooze state. Snooze indicates that WSC is not actively protecting the computer.</summary>
WSC_SECURITY_PROVIDER_HEALTH_SNOOZE,
}
/// <summary>
/// Gets the aggregate health state of the security provider categories represented by the specified WSC_SECURITY_PROVIDER enumeration values.
/// </summary>
/// <param name="Providers">
/// One or more of the values in the WSC_SECURITY_PROVIDER enumeration. To specify more than one value, combine the individual values by
/// performing a bitwise OR operation.
/// </param>
/// <param name="pHealth">
/// A pointer to a variable that takes the value of one of the members of the WSC_SECURITY_PROVIDER_HEALTH enumeration. If more than one
/// provider is specified in the <c>Providers</c> parameter, the value of this parameter is the health of the least healthy of the
/// specified provider categories.
/// </param>
/// <returns>
/// Returns <c>S_OK</c> if the function succeeds, otherwise returns an error code. If the WSC service is not running, the return value is
/// always <c>S_FALSE</c> and the <c>pHealth</c> out parameter is always set to <c>WSC_SECURITY_PROVIDER_HEALTH_POOR</c>.
/// </returns>
/// <remarks>
/// <para>Note</para>
/// <para>
/// WSC_SECURITY_PROVIDER::WSC_SECURITY_PROVIDER_ANTISPYWARE should be used only in operating systems prior to Windows 10, version 1607.
/// As of Windows 10, version 1607, WSC continues to track the status for antivirus, but not for anti-spyware.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/wscapi/nf-wscapi-wscgetsecurityproviderhealth HRESULT
// WscGetSecurityProviderHealth( [in] DWORD Providers, [out] PWSC_SECURITY_PROVIDER_HEALTH pHealth );
[PInvokeData("wscapi.h", MSDNShortId = "NF:wscapi.WscGetSecurityProviderHealth")]
[DllImport(Lib_Wscapi, SetLastError = false, ExactSpelling = true)]
public static extern HRESULT WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER Providers, out WSC_SECURITY_PROVIDER_HEALTH pHealth);
/// <summary>
/// Registers a callback function to be run when Windows Security Center (WSC) detects a change that could affect the health of one of
/// the security providers.
/// </summary>
/// <param name="Reserved">Reserved. Must be <c>NULL</c>.</param>
/// <param name="phCallbackRegistration">
/// A pointer to a handle to the callback registration. When you are finished using the callback function, unregister it by calling the
/// WscUnRegisterChanges function.
/// </param>
/// <param name="lpCallbackAddress">
/// A pointer to the application-defined function to be called when a change to the WSC service occurs. This function is also called when
/// the WSC service is started or stopped.
/// </param>
/// <param name="pContext">
/// A pointer to a variable to be passed as the <c>lpParameter</c> parameter to the function pointed to by the <c>lpCallbackAddress</c> parameter.
/// </param>
/// <returns>Returns S_OK if the function succeeds, otherwise returns an error code.</returns>
/// <remarks>
/// When you want to cease receiving notification to your callback method, you can unregister it by calling the WscUnRegisterChanges function.
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/wscapi/nf-wscapi-wscregisterforchanges HRESULT WscRegisterForChanges( [in] LPVOID
// Reserved, [out] PHANDLE phCallbackRegistration, [in] LPTHREAD_START_ROUTINE lpCallbackAddress, [in] PVOID pContext );
[PInvokeData("wscapi.h", MSDNShortId = "NF:wscapi.WscRegisterForChanges")]
[DllImport(Lib_Wscapi, SetLastError = false, ExactSpelling = true)]
public static extern HRESULT WscRegisterForChanges([In, Optional] IntPtr Reserved, out HANDLE phCallbackRegistration,
[In] ThreadProc lpCallbackAddress, [In, Optional] IntPtr pContext);
/// <summary>Cancels a callback registration that was made by a call to the WscRegisterForChanges function.</summary>
/// <param name="hRegistrationHandle">
/// The handle to the registration context returned as the <c>phCallbackRegistration</c> of the WscRegisterForChanges function.
/// </param>
/// <returns>Returns <c>S_OK</c> if the function succeeds, otherwise returns an error code.</returns>
// https://learn.microsoft.com/en-us/windows/win32/api/wscapi/nf-wscapi-wscunregisterchanges HRESULT WscUnRegisterChanges( [in] HANDLE
// hRegistrationHandle );
[PInvokeData("wscapi.h", MSDNShortId = "NF:wscapi.WscUnRegisterChanges")]
[DllImport(Lib_Wscapi, SetLastError = false, ExactSpelling = true)]
public static extern HRESULT WscUnRegisterChanges([In] HANDLE hRegistrationHandle);
}

View File

@ -407,9 +407,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net", "UnitTests\Net\Net.cs
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HttpApi", "UnitTests\PInvoke\HttpApi\HttpApi.csproj", "{EDEC2A6D-2CCD-4370-A84B-D64DB546BC79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.QoS", "PInvoke\QoS\Vanara.PInvoke.QoS.csproj", "{785E136E-B34E-43A6-9257-3D78206DA55D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.QoS", "PInvoke\QoS\Vanara.PInvoke.QoS.csproj", "{785E136E-B34E-43A6-9257-3D78206DA55D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QoS", "UnitTests\PInvoke\QoS\QoS.csproj", "{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QoS", "UnitTests\PInvoke\QoS\QoS.csproj", "{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.WscApi", "PInvoke\WscApi\Vanara.PInvoke.WscApi.csproj", "{48F95024-8539-4958-A804-ED1C18A28F3C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -2728,6 +2730,24 @@ Global
{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5}.Release|x64.Build.0 = Release|Any CPU
{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5}.Release|x86.ActiveCfg = Release|Any CPU
{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5}.Release|x86.Build.0 = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|x64.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|x64.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|x86.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Debug|x86.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|x64.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|x64.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|x86.ActiveCfg = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.DebugNoTests|x86.Build.0 = Debug|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|Any CPU.Build.0 = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|x64.ActiveCfg = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|x64.Build.0 = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|x86.ActiveCfg = Release|Any CPU
{48F95024-8539-4958-A804-ED1C18A28F3C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2907,6 +2927,7 @@ Global
{EDEC2A6D-2CCD-4370-A84B-D64DB546BC79} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{785E136E-B34E-43A6-9257-3D78206DA55D} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
{D8B0FBB6-8BBF-42BD-8844-8A2915CC95E5} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{48F95024-8539-4958-A804-ED1C18A28F3C} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}