namespace Vanara.PInvoke;
public static partial class NdfApi
{
///
[PInvokeData("ndhelper.h", MSDNShortId = "NS:ndhelper.tagDiagnosticsInfo")]
[Flags]
public enum DF : uint
{
///
DF_IMPERSONATION = 0x80000000,
///
DF_TRACELESS = 0x40000000,
}
///
/// The DIAGNOSIS_STATUS enumeration describes the result of a hypothesis submitted to a helper class in which the health of a
/// component has been determined.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ne-ndhelper-diagnosis_status typedef enum tagDIAGNOSIS_STATUS {
// DS_NOT_IMPLEMENTED = 0, DS_CONFIRMED, DS_REJECTED, DS_INDETERMINATE, DS_DEFERRED, DS_PASSTHROUGH } DIAGNOSIS_STATUS;
[PInvokeData("ndhelper.h", MSDNShortId = "NE:ndhelper.tagDIAGNOSIS_STATUS")]
public enum DIAGNOSIS_STATUS
{
///
/// Value:
/// 0
/// A helper class is not implemented
///
DS_NOT_IMPLEMENTED,
/// The helper class has confirmed a problem existing in its component.
DS_CONFIRMED,
/// The helper class has determined that no problem exists.
DS_REJECTED,
/// The helper class is unable to determine whether there is a problem.
DS_INDETERMINATE,
/// The helper class is unable to perform the diagnosis at this time.
DS_DEFERRED,
///
/// The helper class has identified hypotheses to investigate further, but did not identify any problems in its own component.
/// Equivalent to
/// DS_INDETERMINATE
/// , but is later updated to
/// DS_REJECTED
/// if no hypothesis is confirmed.
/// Note Available only in Windows 7, Windows Server 2008 R2, and later.
///
DS_PASSTHROUGH,
}
/// The PROBLEM_TYPE enumeration describes the type of problem a helper class indicates is present.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ne-ndhelper-problem_type typedef enum tagPROBLEM_TYPE { PT_INVALID = 0,
// PT_LOW_HEALTH = 1, PT_LOWER_HEALTH = 2, PT_DOWN_STREAM_HEALTH = 4, PT_HIGH_UTILIZATION = 8, PT_HIGHER_UTILIZATION = 16,
// PT_UP_STREAM_UTILIZATION = 32 } PROBLEM_TYPE;
[PInvokeData("ndhelper.h", MSDNShortId = "NE:ndhelper.tagPROBLEM_TYPE")]
[Flags]
public enum PROBLEM_TYPE
{
///
/// Value:
/// 0
///
PT_INVALID = 0,
///
/// Value:
/// 1
///
/// A low-health problem exists within the component itself. No problems were found within local components on which this component depends.
///
///
PT_LOW_HEALTH = 1,
///
/// Value:
/// 2
/// A low-health problem exists within local components on which this component depends.
///
PT_LOWER_HEALTH = 2,
///
/// Value:
/// 4
/// The low-health problem is in the out-of-box components this component depends on.
///
PT_DOWN_STREAM_HEALTH = 4,
///
/// Value:
/// 8
///
/// The component's resource is being highly utilized. No high utilization was found within local components on which this component depends.
///
///
PT_HIGH_UTILIZATION = 8,
///
/// Value:
/// 16
/// The causes of the component's high-utilization problem are from local components that depend on it.
///
PT_HIGHER_UTILIZATION = 16,
///
/// Value:
/// 32
/// The causes of the component's high-utilization problem are from upstream network components that depend on it.
///
PT_UP_STREAM_UTILIZATION = 32,
}
/// The REPAIR_STATUS enumeration describes the result of a helper class attempting a repair option.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ne-ndhelper-repair_status typedef enum tagREPAIR_STATUS {
// RS_NOT_IMPLEMENTED = 0, RS_REPAIRED, RS_UNREPAIRED, RS_DEFERRED, RS_USER_ACTION } REPAIR_STATUS;
[PInvokeData("ndhelper.h", MSDNShortId = "NE:ndhelper.tagREPAIR_STATUS")]
public enum REPAIR_STATUS
{
///
/// Value:
/// 0
/// The helper class does not have a repair option implemented.
///
RS_NOT_IMPLEMENTED,
/// The helper class has repaired a problem.
RS_REPAIRED,
/// The helper class has attempted to repair a problem but validation indicates the repair operation has not succeeded.
RS_UNREPAIRED,
/// The helper class is unable to perform the repair at this time.
RS_DEFERRED,
/// The helper class needs the user to perform an action before the repair can continue.
RS_USER_ACTION,
}
/// interface implemented by Extensible Helper Class
[ComImport, Guid("c0b35748-ebf5-11d8-bbe9-505054503030"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INetDiagExtensibleHelper
{
///
[PreserveSig]
HRESULT ResolveAttributes([In] uint celt, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HELPER_ATTRIBUTE[] rgKeyAttributes,
out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out HELPER_ATTRIBUTE[] prgMatchValues);
}
///
/// The INetDiagHelper interface provides methods that capture and provide information associated with diagnoses and resolution of
/// network-related issues.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nn-ndhelper-inetdiaghelper
[PInvokeData("ndhelper.h", MSDNShortId = "NN:ndhelper.INetDiagHelper")]
[ComImport, Guid("c0b35746-ebf5-11d8-bbe9-505054503030"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INetDiagHelper
{
///
/// The Initialize method passes in attributes to the Helper Class Extension from the hypothesis. The helper class should
/// store these parameters for use in the main diagnostics functions. This method must be called before any diagnostics function.
///
/// A pointer to a count of elements in HELPER_ATTRIBUTE array.
/// A reference to the HELPER_ATTRIBUTE array.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// The Initialize method is required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-initialize HRESULT Initialize( [in] ULONG
// celt, HELPER_ATTRIBUTE [] rgAttributes );
[PreserveSig]
HRESULT Initialize([In] uint celt, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HELPER_ATTRIBUTE[] rgAttributes);
///
/// The GetDiagnosticsInfo method enables the Helper Class Extension instance to provide an estimate of how long the diagnosis
/// may take.
///
/// A pointer to a pointer to a DiagnosticsInfo structure.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// The GetDiagnosticsInfo method is required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getdiagnosticsinfo HRESULT
// GetDiagnosticsInfo( [out] DiagnosticsInfo **ppInfo );
[PreserveSig]
unsafe HRESULT GetDiagnosticsInfo(out DiagnosticsInfo* ppInfo);
/// The GetKeyAttributes method retrieves the key attributes of the Helper Class Extension.
/// A pointer to a count of elements in the HELPER_ATTRIBUTE array.
/// A pointer to an array of HELPER_ATTRIBUTE structures.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getkeyattributes HRESULT GetKeyAttributes(
// [out] ULONG *pcelt, [out] HELPER_ATTRIBUTE **pprgAttributes );
[PreserveSig]
HRESULT GetKeyAttributes(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HELPER_ATTRIBUTE[] pprgAttributes);
///
/// The LowHealth method enables the Helper Class Extension to check whether the component being diagnosed is healthy.
///
///
/// A pointer to a null-terminated string containing the user-friendly description of the information being diagnosed. For example,
/// if a class were to diagnosis a connectivity issue with an IP address, the pwszInstanceDescription parameter would contain
/// the host name.
///
///
/// A pointer to a null-terminated string containing the description of the issue found if the component is found to be unhealthy.
///
///
/// A pointer to the time, in seconds, to be deferred if the diagnosis cannot be started immediately. This is used when the
/// pStatus parameter is set to DS_DEFERRED.
///
/// A pointer to the DIAGNOSIS_STATUS that is returned from the diagnosis.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
///
/// The LowHealth method is required when building a Helper Class Extension.
///
/// If LowHealth returns DS_CONFIRMED, ppwszDescription will also contain a user-friendly description of the diagnosis
/// result. The out parameter pDeferredTime contains the number of seconds this diagnosis needs to be deferred if pStatus
/// returns DS_DEFERRED.
///
///
/// When LowHealth is confirmed, it may also optionally generate hypotheses in the GetLowerHypotheses method for other helper classes
/// if the problem may be caused by other components. If not confirmed, NDF may further diagnose the problem by calling HighUtilization.
///
///
/// LowHealth may also return DS_INDETERMINATE if it is unable to diagnose the problem, but cannot confirm that the component
/// is healthy. In this case, NDF will treat it as DS_CONFIRMED if none of the other hypotheses are confirmed.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-lowhealth HRESULT LowHealth( [in] LPCWSTR
// pwszInstanceDescription, [out] LPWSTR *ppwszDescription, [out] long *pDeferredTime, [out] DIAGNOSIS_STATUS *pStatus );
[PreserveSig]
HRESULT LowHealth([Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszInstanceDescription,
[MarshalAs(UnmanagedType.LPWStr)] out string ppwszDescription, out long pDeferredTime, out DIAGNOSIS_STATUS pStatus);
///
/// The HighUtilization method enables the Helper Class Extension to check whether the corresponding component is highly utilized.
///
///
/// A pointer to a null-terminated string containing the user-friendly description of the information being diagnosed. For example,
/// if a class were to diagnosis a connectivity issue with an IP address, the pwszInstanceDescription parameter would contain
/// the host name.
///
///
/// A pointer to a null-terminated string containing the description of high utilization diagnosis result.
///
///
/// A pointer to the time, in seconds, to be deferred if the diagnosis cannot be started immediately. This is used when the
/// pStatus parameter is set to DS_DEFERRED.
///
/// A pointer to the DIAGNOSIS_STATUS that is returned from the diagnosis.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-highutilization HRESULT HighUtilization(
// [in] LPCWSTR pwszInstanceDescription, [out] LPWSTR *ppwszDescription, [out] long *pDeferredTime, [out] DIAGNOSIS_STATUS *pStatus );
[PreserveSig]
HRESULT HighUtilization([Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszInstanceDescription,
[MarshalAs(UnmanagedType.LPWStr)] out string ppwszDescription, out long pDeferredTime, out DIAGNOSIS_STATUS pStatus);
///
/// The GetLowerHypotheses method asks the Helper Class Extension to generate hypotheses for possible causes of low health in
/// the local components that depend on it.
///
/// A pointer to a count of elements in the HYPOTHESIS array.
/// A pointer to a HYPOTHESIS array.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getlowerhypotheses HRESULT
// GetLowerHypotheses( [out] ULONG *pcelt, [out] HYPOTHESIS **pprgHypotheses );
[PreserveSig]
HRESULT GetLowerHypotheses(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HYPOTHESIS[] pprgHypotheses);
///
/// The GetDownStreamHypotheses method asks the Helper Class Extension to generate hypotheses for possible causes of low
/// health in the downstream network components it depends on.
///
/// A pointer to a count of elements in the HYPOTHESIS array.
/// A pointer to an array of HYPOTHESIS structures.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getdownstreamhypotheses HRESULT
// GetDownStreamHypotheses( [out] ULONG *pcelt, [out] HYPOTHESIS **pprgHypotheses );
[PreserveSig]
HRESULT GetDownStreamHypotheses(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HYPOTHESIS[] pprgHypotheses);
///
/// The GetHigherHypotheses method asks the Helper Class Extension to generate hypotheses for possible causes of high
/// utilization in the local components that depend on it.
///
/// A pointer to a count of elements in the HYPOTHESIS array.
/// A pointer to an array of HYPOTHESIS structures.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-gethigherhypotheses HRESULT
// GetHigherHypotheses( [out] ULONG *pcelt, [out] HYPOTHESIS **pprgHypotheses );
[PreserveSig]
HRESULT GetHigherHypotheses(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HYPOTHESIS[] pprgHypotheses);
///
/// The GetUpStreamHypotheses method asks the Helper Class Extension to generate hypotheses for possible causes of high
/// utilization in the upstream network components that depend on it.
///
/// A pointer to a count of elements in the HYPOTHESIS array.
/// A pointer to a HYPOTHESIS array.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getupstreamhypotheses HRESULT
// GetUpStreamHypotheses( [out] ULONG *pcelt, [out] HYPOTHESIS **pprgHypotheses );
[PreserveSig]
HRESULT GetUpStreamHypotheses(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HYPOTHESIS[] pprgHypotheses);
/// The Repair method performs a repair specified by the input parameter.
/// A pointer to a RepairInfo structure.
///
/// A pointer to the time, in seconds, to be deferred if the repair cannot be started immediately. This is only valid when the
/// pStatus parameter is set to DS_DEFERRED.
///
/// A pointer to the REPAIR_STATUS that is returned from the repair.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-repair HRESULT Repair( [in] RepairInfo
// *pInfo, [out] long *pDeferredTime, [out] REPAIR_STATUS *pStatus );
[PreserveSig]
HRESULT Repair(in RepairInfo pInfo, out long pDeferredTime, out REPAIR_STATUS pStatus);
///
/// The Validate method is called by NDF after a repair is successfully completed in order to validate that a previously
/// diagnosed problem has been fixed.
///
/// The PROBLEM_TYPE that the helper class has previously diagnosed.
///
/// A pointer to the time to be deferred, in seconds, if the diagnosis cannot be started immediately. This is used only when the
/// pStatus member is set to DS_DEFERRED.
///
/// A pointer to the DIAGNOSIS_STATUS that is returned from the diagnosis.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
///
/// This method is not required when building a Helper Class Extension.
///
/// This method only returns an error code if it encounters failures that impede validation. If necessary, the pStatus
/// parameter is the expected way to communicate that the component is still in low health. DS_REJECTED is used to indicate
/// that the issue has been resolved.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-validate HRESULT Validate( [in]
// PROBLEM_TYPE problem, [out] long *pDeferredTime, [out] REPAIR_STATUS *pStatus );
[PreserveSig]
HRESULT Validate([In] PROBLEM_TYPE problem, out long pDeferredTime, out REPAIR_STATUS pStatus);
///
/// The GetRepairInfo method retrieves the repair information that the Helper Class Extension has for a given problem type.
///
/// A PROBLEM_TYPE value that specifies the problem type that the helper class has previously diagnosed.
/// A pointer to a count of elements in the RepairInfo array.
/// A pointer to an array of RepairInfo structures.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getrepairinfo HRESULT GetRepairInfo( [in]
// PROBLEM_TYPE problem, [out] ULONG *pcelt, [out] RepairInfo **ppInfo );
[PreserveSig]
HRESULT GetRepairInfo([In] PROBLEM_TYPE problem, out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out RepairInfo[] ppInfo);
/// The GetLifeTime method retrieves the lifetime of the Helper Class Extension instance.
/// A pointer to a LIFE_TIME structure.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
///
/// This method is not required when building a Helper Class Extension.
///
/// Lifetime data is used to limit the time scope of a problem instance. This is particularly useful when doing history-based
/// diagnoses such as tracing and logging where it can be used in scoping down the diagnosis to events that occurred during the
/// specified time interval.
///
///
/// For example, Windows Filtering Platform (WFP) helper classes use lifetime to determine which filter blocked a packet by checking
/// the trace log. By default, a lifetime of a helper class instance inherits the lifetime of its dependent helper class instance.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getlifetime HRESULT GetLifeTime( [out]
// LIFE_TIME *pLifeTime );
[PreserveSig]
HRESULT GetLifeTime(out LIFE_TIME pLifeTime);
///
/// The SetLifeTime method is called by NDF to set the start and end time of interest to diagnostics so that the Helper Class
/// Extension can limit its diagnosis to events within that time period.
///
/// A LIFE_TIME structure.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-setlifetime HRESULT SetLifeTime( [in]
// LIFE_TIME lifeTime );
[PreserveSig]
HRESULT SetLifeTime([In] LIFE_TIME lifeTime);
/// The GetCacheTime method specifies the time when cached results of a diagnosis and repair operation have expired.
/// A pointer to a FILETIME structure.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
///
/// This method is not required when building a Helper Class Extension.
///
/// The default behavior is to return the current time so that the results will not be cached. Setting a cache time can increase
/// diagnosis efficiency since NDF will not call on the extension to re-diagnose an issue unless the cache time has expired.
///
///
/// The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getcachetime HRESULT GetCacheTime( [out]
// FILETIME *pCacheTime );
[PreserveSig]
HRESULT GetCacheTime(out FILETIME pCacheTime);
///
/// The GetAttributes method retrieves additional information about a problem that the helper class extension has diagnosed.
///
/// A pointer to a count of elements in the HELPER_ATTRIBUTE array.
/// A pointer to an array of HELPER_ATTRIBUTE structures.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_NOTIMPL
/// This optional method is not implemented.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
///
/// This method is not required when building a Helper Class Extension.
///
/// During the process of diagnosis and repair, a helper class may optionally return attributes to NDF that improve NDF's handling of
/// the diagnosis. The predefined attributes that can be returned to NDF are as follows.
///
///
///
/// Term
/// Description
///
/// -
/// werperameter (Type: AT_UINT32)
///
/// When diagnosis fails, an optional attribute for additional helper class specific Windows Error Reporting (WER) bucketing parameter.
///
///
/// -
/// werfile (Type: AT_STRING)
/// An optional attribute for adding helper class-specific files to Windows Error Reporting (WER) reports.
///
/// -
/// rootcauseid (Type: AT_GUID)
///
/// Helper Classes can often diagnose more than one problem at once. Analysis of the problem encountered can be improved in NDF if
/// the extension returns a HelperAttribute of type AT_GUID with the pszName parameter set to rootcauseid and the Guid field set to a
/// GUID identifying the specific problem encountered. These GUIDs are custom defined by the helper extension.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-getattributes HRESULT GetAttributes( [out]
// ULONG *pcelt, [out] HELPER_ATTRIBUTE **pprgAttributes );
[PreserveSig]
HRESULT GetAttributes(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HELPER_ATTRIBUTE[] pprgAttributes);
/// The Cancel method cancels an ongoing diagnosis or repair.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// The Cancel method is required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-cancel HRESULT Cancel();
[PreserveSig]
HRESULT Cancel();
///
/// The Cleanup method allows the Helper Class Extension to clean up resources following a diagnosis or repair operation.
///
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
/// -
/// E_ABORT
/// The diagnosis or repair operation has been canceled.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the failures encountered in the function.
///
/// The Cleanup method is required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelper-cleanup HRESULT Cleanup();
[PreserveSig]
HRESULT Cleanup();
}
///
/// The INetDiagHelperEx interface provides methods that extend on the INetDiagHelper interface to capture and provide information
/// associated with diagnoses and resolution of network-related issues.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nn-ndhelper-inetdiaghelperex
[PInvokeData("ndhelper.h", MSDNShortId = "NN:ndhelper.INetDiagHelperEx")]
[ComImport, Guid("972DAB4D-E4E3-4fc6-AE54-5F65CCDE4A15"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INetDiagHelperEx
{
///
/// The ReconfirmLowHealth method is used to add a second Low Health pass after hypotheses have been diagnosed and before
/// repairs are retrieved. This method allows the helper class to see the diagnostics results and to change the diagnosis if needed.
/// The method is only called if a diagnosis is not rejected and hypotheses were generated.
///
/// The number of HypothesisResult structures pointed to by pResults.
///
/// Pointer to HypothesisResult structure(s) containing the HYPOTHESIS information obtained via the GetLowerHypotheses method along
/// with the status of that hypothesis. Includes one HypothesisResult structure for each hypothesis generated by the helper
/// class's call to GetLowerHypotheses.
///
/// An updated description of the incident being diagnosed.
/// A DIAGNOSIS_STATUS value which indicates the status of the incident.
///
/// Possible return values include, but are not limited to, the following.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
///
/// Any result other than S_OK will be interpreted as an error and will cause the function results to be discarded.
///
/// This method is not required when building a Helper Class Extension.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelperex-reconfirmlowhealth HRESULT
// ReconfirmLowHealth( [in] ULONG celt, [in] HypothesisResult *pResults, [out] LPWSTR *ppwszUpdatedDescription, [out]
// DIAGNOSIS_STATUS *pUpdatedStatus );
[PreserveSig]
HRESULT ReconfirmLowHealth([In] uint celt, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HypothesisResult[] pResults,
[MarshalAs(UnmanagedType.LPWStr)] out string ppwszUpdatedDescription, out DIAGNOSIS_STATUS pUpdatedStatus);
///
/// The SetUtilities method is used by the Network Diagnostics Framework (NDF). This method is reserved for system use.
///
/// Reserved for system use.
/// This method does not return a value.
/// This method is reserved for system use.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelperex-setutilities HRESULT SetUtilities( [in]
// INetDiagHelperUtilFactory *pUtilities );
[PreserveSig]
HRESULT SetUtilities([In] INetDiagHelperUtilFactory pUtilities);
///
/// The ReproduceFailure method is used by the Network Diagnostics Framework (NDF). This method is reserved for system use.
///
/// This method does not return a value.
/// This method is reserved for system use.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelperex-reproducefailure HRESULT ReproduceFailure();
[PreserveSig]
HRESULT ReproduceFailure();
}
///
/// The INetDiagHelperInfo interface provides a method that is called by the Network Diagnostics Framework (NDF) when it needs to
/// validate that it has the necessary information for a helper class and that it has chosen the correct helper class.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nn-ndhelper-inetdiaghelperinfo
[PInvokeData("ndhelper.h", MSDNShortId = "NN:ndhelper.INetDiagHelperInfo")]
[ComImport, Guid("c0b35747-ebf5-11d8-bbe9-505054503030"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INetDiagHelperInfo
{
/// The GetAttributeInfo method retrieves the list of key parameters needed by the Helper Class Extension.
/// A pointer to a count of elements in the array pointed to by pprgAttributeInfos.
/// A pointer to an array of HelperAttributeInfo structures that contain helper class key parameters.
///
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The operation succeeded.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory available to complete this operation.
///
/// -
/// E_INVALIDARG
/// One or more parameters has not been provided correctly.
///
/// -
/// E_ACCESSDENIED
/// The caller does not have sufficient privileges to perform the diagnosis or repair operation.
///
///
/// Helper Class Extensions may return HRESULTS that are specific to the diagnoses or repairs.
///
///
/// The key parameter list is used by NDF to determine whether enough information is available for the extension to perform
/// diagnosis. If the hypothesis to call the extension lacks a key attribute, the extension will not be called. Optional attributes
/// will not be returned by this call.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelperinfo-getattributeinfo HRESULT
// GetAttributeInfo( [out] ULONG *pcelt, [out] HelperAttributeInfo **pprgAttributeInfos );
[PreserveSig]
HRESULT GetAttributeInfo(out uint pcelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out HelperAttributeInfo[] pprgAttributeInfos);
}
///
/// The INetDiagHelperUtilFactory interface provides a reserved method that is used by the Network Diagnostics Framework (NDF).
/// This interface is reserved for system use.
///
/// This interface is reserved for system use.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nn-ndhelper-inetdiaghelperutilfactory
[PInvokeData("ndhelper.h", MSDNShortId = "NN:ndhelper.INetDiagHelperUtilFactory")]
[ComImport, Guid("104613FB-BC57-4178-95BA-88809698354A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INetDiagHelperUtilFactory
{
///
/// The CreateUtilityInstance method is used by the Network Diagnostics Framework (NDF). This method is reserved for system use.
///
/// Reserved for system use.
/// Reserved for system use.
/// This method does not return a value.
/// This method is reserved for system use.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/nf-ndhelper-inetdiaghelperutilfactory-createutilityinstance HRESULT
// CreateUtilityInstance( [in] REFIID riid, [out] void **ppvObject );
[PreserveSig]
HRESULT CreateUtilityInstance(in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] out object ppvObject);
}
/// The DiagnosticsInfo structure contains the estimate of diagnosis time, and flags for invocation.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ns-ndhelper-diagnosticsinfo typedef struct tagDiagnosticsInfo { long cost;
// ULONG flags; } DiagnosticsInfo, *PDiagnosticsInfo;
[PInvokeData("ndhelper.h", MSDNShortId = "NS:ndhelper.tagDiagnosticsInfo")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DiagnosticsInfo
{
///
/// Type: long
///
/// The length of time, in seconds, that the diagnosis should take to complete. A value of zero or a negative value means the cost is
/// negligible. Any positive value will cause the engine to adjust the overall diagnostics process.
///
///
public long cost;
///
/// Type: ULONG
/// Reserved.
///
public DF flags;
}
/// The HelperAttributeInfo structure contains the name of the helper attribute and its type.
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ns-ndhelper-helperattributeinfo typedef struct tagHelperAttributeInfo {
// LPWSTR pwszName; ATTRIBUTE_TYPE type; } HelperAttributeInfo, *PHelperAttributeInfo;
[PInvokeData("ndhelper.h", MSDNShortId = "NS:ndhelper.tagHelperAttributeInfo")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HelperAttributeInfo
{
///
/// Type: [string] LPWSTR
/// Pointer to a null-terminated string that contains the name of the helper attribute.
///
[MarshalAs(UnmanagedType.LPWStr)]
public string pwszName;
///
/// Type: ATTRIBUTE_TYPE
/// The type of helper attribute.
///
public ATTRIBUTE_TYPE type;
}
///
/// The HYPOTHESIS structure contains data used to submit a hypothesis to NDF for another helper class. The name of the helper
/// class, the number of parameters that the helper class requires, and the parameters to pass to the helper class are contained in this structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ns-ndhelper-hypothesis typedef struct tagHYPOTHESIS { LPWSTR
// pwszClassName; LPWSTR pwszDescription; ULONG celt; PHELPER_ATTRIBUTE rgAttributes; } HYPOTHESIS, *PHYPOTHESIS;
[PInvokeData("ndhelper.h", MSDNShortId = "NS:ndhelper.tagHYPOTHESIS")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HYPOTHESIS
{
///
/// Type: [string] LPWSTR
/// A pointer to a null-terminated string that contains the name of the helper class.
///
[MarshalAs(UnmanagedType.LPWStr)]
public string pwszClassName;
///
/// Type: [string] LPWSTR
///
/// A pointer to a null-terminated string that contains a user-friendly description of the data being passed to the helper class..
///
///
[MarshalAs(UnmanagedType.LPWStr)]
public string pwszDescription;
///
/// Type: ULONG
/// The count of attributes in this hypothesis.
///
public uint celt;
///
/// Type: [size_is(celt)]PHELPER_ATTRIBUTE[ ]
/// A pointer to an array of HELPER_ATTRIBUTE structures that contains key attributes for this hypothesis.
///
public IntPtr rgAttributes;
}
///
/// The HypothesisResult structure contains information about a hypothesis returned from a helper class. The hypothesis is
/// obtained via a call to GetLowerHypotheses.
///
// https://docs.microsoft.com/en-us/windows/win32/api/ndhelper/ns-ndhelper-hypothesisresult typedef struct tagHypothesisResult {
// HYPOTHESIS hypothesis; DIAGNOSIS_STATUS pathStatus; } HypothesisResult;
[PInvokeData("ndhelper.h", MSDNShortId = "NS:ndhelper.tagHypothesisResult")]
[StructLayout(LayoutKind.Sequential)]
public struct HypothesisResult
{
///
/// Type: HYPOTHESIS
/// Information for a specific hypothesis.
///
public HYPOTHESIS hypothesis;
///
/// Type: DIAGNOSIS_STATUS
/// The status of the child helper class and its children.
///
/// If the hypothesis or any of its children indicated DS_CONFIRMED in a call to LowHealth, then this value will be
/// DS_CONFIRMED. If no problems exist in such a call, the value will be DS_REJECTED. The value will be
/// DS_INDETERMINATE if the health of the component is not clear.
///
///
public DIAGNOSIS_STATUS pathStatus;
}
}