using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Ole32
{
/// Represents all the options supported for the interface identified by riid in IObjectSafety methods.
[PInvokeData("Objsafe.h")]
[Flags]
public enum INTERFACEUSE : uint
{
/// Indicates that the caller of the interface identified by riid might be untrusted.
INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001,// Caller of interface may be untrusted")
/// Indicates that the data passed into the interface identified by riid might be untrusted.
INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002,// Data passed into interface may be untrusted")
/// Indicates that the caller of the interface identified by riid knows to use IDispatchEx.
INTERFACE_USES_DISPEX = 0x00000004,// Object knows to use IDispatchEx")
/// Indicates that the data passed into the interface identified by riid knows to use IInternetHostSecurityManager.
INTERFACE_USES_SECURITY_MANAGER = 0x00000008, // Object knows to use IInternetHostSecurityManager")
}
/// Provides methods to get and set safety options.
///
///
/// The IObjectSafety interface should be implemented by objects that have interfaces which support "untrusted" clients, such
/// as scripts. It allows the owner of the object to specify which interfaces must be protected from "untrusted" use.
///
/// Examples of interfaces that might be protected in this way are:
/// IID_IDispatch
/// (safe for automating with untrusted automation client or script),
/// IID_IPersist
/// (safe for initializing with untrusted data), and
/// IID_IActiveScript
/// (safe for running untrusted scripts).
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768224(v=vs.85)
[PInvokeData("Objsafe.h")]
[ComImport, Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
///
/// This method retrieves the safety options supported by an object as well as the safety options that are currently set for
/// that object.
///
/// Interface identifier for a given object.
///
/// Address of a DWORD containing options supported for the interface identified by riid.
///
///
/// Address of a DWORD containing options currently enabled for the interface identified by riid.
///
///
/// Returns S_OK if successful, or E_NOINTERFACE if the riid parameter specifies an interface that is unknown to the object.
///
///
///
/// This method returns a set of bits in the pdwSupportedOptions parameter for each capability that the control knows about, and
/// a set of bits in the pdwEnabledOptions parameter for each capability for which the control is currently safe.
///
///
/// For example, a control might say that it knows about INTERFACESAFE_FOR_UNTRUSTED_DATA and
/// INTERFACESAFE_FOR_UNTRUSTED_CALLER, and that it is currently safe only for INTERFACESAFE_FOR_UNTRUSTED_DATA.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms882879(v=msdn.10)
[PreserveSig]
HRESULT GetInterfaceSafetyOptions(in Guid riid, out INTERFACEUSE pdwSupportedOptions, out INTERFACEUSE pdwEnabledOptions);
/// This method makes an object safe for initialization or scripting.
/// Interface identifier for the object to be made safe.
/// Options to be changed.
/// Settings for the options that are to be changed.
///
/// Returns one of the following values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The object is safe for loading.
///
/// -
/// E_NOINTERFACE
/// The riid parameter specifies an interface that is unknown to the object.
///
/// -
/// E_FAIL
/// The dwOptionSetMask parameter specifies an option that is not supported by the object.
///
///
///
///
///
/// A control client, such as Internet Explorer, calls this method prior to loading a control to determine whether the control
/// is safe for scripting or initialization.
///
///
/// If this method returns E_FAIL, its client displays the user interface for the user to confirm whether the action should be allowed.
///
/// This method takes an interface (either IDispatch for scripting or IPersist for initialization).
///
// https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms882881(v=msdn.10)
[PreserveSig]
HRESULT SetInterfaceSafetyOptions(in Guid riid, INTERFACEUSE dwOptionSetMask, INTERFACEUSE dwEnabledOptions);
}
}
}