using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { /// Valid values for the field. [PInvokeData("winnt.h")] public enum ObjectTypeListLevel : ushort { /// Indicates the object itself at level zero. ACCESS_OBJECT_GUID = 0, /// Indicates a property set at level one. ACCESS_PROPERTY_SET_GUID = 1, /// Indicates a property at level two. ACCESS_PROPERTY_GUID = 2, /// Indicates a property set at the max level. ACCESS_MAX_LEVEL = 4, } /// /// The OBJECT_TYPE_LIST structure identifies an object type element in a hierarchy of object types. The AccessCheckByType /// functions use an array of OBJECT_TYPE_LIST structures to define a hierarchy of an object and its subobjects, such as property /// sets and properties. /// // https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_object_type_list // typedef struct _OBJECT_TYPE_LIST { WORD Level; WORD Sbz; GUID *ObjectType; } OBJECT_TYPE_LIST, *POBJECT_TYPE_LIST; [PInvokeData("winnt.h", MSDNShortId = "c729ff1a-65f3-4f6f-84dd-5700aead75ce")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 2)] public unsafe struct OBJECT_TYPE_LIST { /// /// Specifies the level of the object type in the hierarchy of an object and its subobjects. Level zero indicates the object itself. /// Level one indicates a subobject of the object, such as a property set. Level two indicates a subobject of the level one /// subobject, such as a property. There can be a maximum of five levels numbered zero through four. /// public ObjectTypeListLevel level; /// Should be zero. Reserved for future use. public ushort Sbz; /// A pointer to the GUID for the object or subobject. public Guid* guidObjectType; /// Initializes a new instance of the struct. /// The level of the object type in the hierarchy of an object and its subobjects. /// The object or subobject identifier. public OBJECT_TYPE_LIST(ObjectTypeListLevel level, in Guid objType = default) { Sbz = 0; this.level = level; unsafe { if (objType == default) fixed (Guid* pGuid = &Guid.Empty) { guidObjectType = pGuid; } else fixed (Guid* pGuid = &objType) { guidObjectType = pGuid; } } } /// Represents an object that is itself. public static readonly OBJECT_TYPE_LIST Self = new OBJECT_TYPE_LIST(); } }