Beispiel #1
0
        internal TokenGroup(MemoryMarshaler m)
        {
            SID_AND_ATTRIBUTES sa = (SID_AND_ATTRIBUTES)m.ParseStruct(typeof(SID_AND_ATTRIBUTES));

            _sid        = new Sid(sa.Sid);
            _attributes = (GroupAttributes)sa.Attributes;
        }
Beispiel #2
0
        internal TokenPrivilege(MemoryMarshaler m)
        {
            LUID_AND_ATTRIBUTES la = (LUID_AND_ATTRIBUTES)m.ParseStruct(typeof(LUID_AND_ATTRIBUTES));

            _luid       = new Luid(la.Luid);
            _attributes = (PrivilegeAttributes)la.Attributes;
        }
Beispiel #3
0
        internal AceAccess(MemoryMarshaler m, bool allowed)
        {
            _allowed = allowed;

            ACCESS_ALLOWED_ACE ace = (ACCESS_ALLOWED_ACE)m.ParseStruct(typeof(ACCESS_ALLOWED_ACE), false);

            m.Advance(OffsetOfSid());
            BaseInit(ace.Header, (AccessType)ace.Mask, new Sid(m.Ptr));
        }
 internal TokenPrivileges(UnmanagedHeapAlloc ptr)
 {
     MemoryMarshaler m = new MemoryMarshaler(ptr.Ptr);
     TOKEN_PRIVILEGES privs = (TOKEN_PRIVILEGES)m.ParseStruct(typeof(TOKEN_PRIVILEGES));
     for(int i = 0 ; i < privs.PrivilegeCount; i++)
     {
         TokenPrivilege priv = new TokenPrivilege(m);
         base.InnerList.Add(priv);
     }
 }
Beispiel #5
0
        internal TokenGroups(UnmanagedHeapAlloc ptr)
        {
            MemoryMarshaler m    = new MemoryMarshaler(ptr.Ptr);
            TOKEN_GROUPS    grps = (TOKEN_GROUPS)m.ParseStruct(typeof(TOKEN_GROUPS));

            for (int i = 0; i < grps.GroupCount; i++)
            {
                TokenGroup grp = new TokenGroup(m);
                base.InnerList.Add(grp);
            }
        }
Beispiel #6
0
        internal TokenPrivileges(UnmanagedHeapAlloc ptr)
        {
            MemoryMarshaler  m     = new MemoryMarshaler(ptr.Ptr);
            TOKEN_PRIVILEGES privs = (TOKEN_PRIVILEGES)m.ParseStruct(typeof(TOKEN_PRIVILEGES));

            for (int i = 0; i < privs.PrivilegeCount; i++)
            {
                TokenPrivilege priv = new TokenPrivilege(m);
                base.InnerList.Add(priv);
            }
        }
Beispiel #7
0
 protected internal Acl(IntPtr pacl)
 {
     // If NULL for the pacl, create an empty DACL
     if (pacl == IntPtr.Zero)
     {
         _revision = AclRevision.ACL_REVISION;
         return;
     }
     MemoryMarshaler m = new MemoryMarshaler(pacl);
     ACL acl = (ACL)m.ParseStruct(typeof(ACL));
     _revision = acl.AclRevision;
     for(int i = 0; i < acl.AceCount; i++)
     {
         Ace ace = Ace.Create(m);
         _aces.Add(ace);
     }
 }
Beispiel #8
0
        internal protected Acl(IntPtr pacl)
        {
            // If NULL for the pacl, create an empty DACL
            if (pacl == IntPtr.Zero)
            {
                _revision = AclRevision.ACL_REVISION;
                return;
            }
            MemoryMarshaler m   = new MemoryMarshaler(pacl);
            ACL             acl = (ACL)m.ParseStruct(typeof(ACL));

            _revision = acl.AclRevision;
            for (int i = 0; i < acl.AceCount; i++)
            {
                Ace ace = Ace.Create(m);
                _aces.Add(ace);
            }
        }
Beispiel #9
0
        internal static Ace Create(MemoryMarshaler m)
        {
            IntPtr initialPtr = m.Ptr;                  // Save current ptr

            Debug.Assert(Marshal.SizeOf(typeof(ACE_HEADER)) == 4);
            ACE_HEADER head = (ACE_HEADER)m.ParseStruct(typeof(ACE_HEADER), false);
            Ace        ace;

            switch (head.AceType)
            {
            case AceType.ACCESS_ALLOWED_ACE_TYPE:
                ace = new AceAccessAllowed(m);
                break;

            case AceType.ACCESS_DENIED_ACE_TYPE:
                ace = new AceAccessDenied(m);
                break;

            // Object ACE not yet supported

/*
 *                              case AceType.ACCESS_ALLOWED_OBJECT_ACE_TYPE:
 *                                      ace = new AceAccessAllowedObject(m);
 *                                      break;
 *
 *                              case AceType.ACCESS_DENIED_OBJECT_ACE_TYPE:
 *                                      ace = new AceAccessDeniedObject(m);
 *                                      break;
 */
            default:
                throw new NotSupportedException("Unsupported ACE type: " + head.AceType);
            }

            // Restore initial ptr and move forward the size of the ACE
            m.Ptr = initialPtr;
            m.Advance(head.AceSize);
            return(ace);
        }
Beispiel #10
0
        internal static Ace Create(MemoryMarshaler m)
        {
            IntPtr initialPtr = m.Ptr;	// Save current ptr

            Debug.Assert(Marshal.SizeOf(typeof(ACE_HEADER)) == 4);
            ACE_HEADER head = (ACE_HEADER)m.ParseStruct(typeof(ACE_HEADER), false);
            Ace ace;
            switch(head.AceType)
            {
                case AceType.ACCESS_ALLOWED_ACE_TYPE:
                    ace = new AceAccessAllowed(m);
                    break;

                case AceType.ACCESS_DENIED_ACE_TYPE:
                    ace = new AceAccessDenied(m);
                    break;

                // Object ACE not yet supported
            /*
                case AceType.ACCESS_ALLOWED_OBJECT_ACE_TYPE:
                    ace = new AceAccessAllowedObject(m);
                    break;

                case AceType.ACCESS_DENIED_OBJECT_ACE_TYPE:
                    ace = new AceAccessDeniedObject(m);
                    break;
            */
                default:
                    throw new NotSupportedException("Unsupported ACE type: " + head.AceType);
            }

            // Restore initial ptr and move forward the size of the ACE
            m.Ptr = initialPtr;
            m.Advance(head.AceSize);
            return ace;
        }
Beispiel #11
0
 internal TokenGroup(MemoryMarshaler m)
 {
     SID_AND_ATTRIBUTES sa = (SID_AND_ATTRIBUTES)m.ParseStruct(typeof(SID_AND_ATTRIBUTES));
     _sid = new Sid(sa.Sid);
     _attributes = (GroupAttributes)sa.Attributes;
 }
Beispiel #12
0
 internal TokenPrivilege(MemoryMarshaler m)
 {
     LUID_AND_ATTRIBUTES la = (LUID_AND_ATTRIBUTES)m.ParseStruct(typeof(LUID_AND_ATTRIBUTES));
     _luid = new Luid(la.Luid);
     _attributes = (PrivilegeAttributes)la.Attributes;
 }
Beispiel #13
0
 internal AceAccessDenied(MemoryMarshaler m) : base(m, false)
 {
 }
Beispiel #14
0
 /// <summary>
 ///  Internal: Create an ACE from a given memory marshaler
 /// </summary>
 internal AceAccessAllowed(MemoryMarshaler m)
     : base(m, true)
 {
 }