コード例 #1
0
        internal static unsafe void InitializeReferencedDomainsPointer(SafeLsaMemoryHandle referencedDomains)
        {
            referencedDomains.Initialize((ulong)Marshal.SizeOf(typeof(Win32Native.LSA_REFERENCED_DOMAIN_LIST)));
            Win32Native.LSA_REFERENCED_DOMAIN_LIST lsa_referenced_domain_list = referencedDomains.Read <Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0L);
            byte *pointer = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                referencedDomains.AcquirePointer(ref pointer);
                if (!lsa_referenced_domain_list.Domains.IsNull())
                {
                    Win32Native.LSA_TRUST_INFORMATION *domains = (Win32Native.LSA_TRUST_INFORMATION *)lsa_referenced_domain_list.Domains;
                    domains += lsa_referenced_domain_list.Entries;
                    long num = (long)((domains - pointer) / 1);
                    referencedDomains.Initialize((ulong)num);
                }
            }
            finally
            {
                if (pointer != null)
                {
                    referencedDomains.ReleasePointer();
                }
            }
        }
コード例 #2
0
        internal unsafe static void InitializeReferencedDomainsPointer(SafeLsaMemoryHandle referencedDomains)
        {
            referencedDomains.Initialize((ulong)Marshal.SizeOf(typeof(Win32Native.LSA_REFERENCED_DOMAIN_LIST)));
            Win32Native.LSA_REFERENCED_DOMAIN_LIST lsa_REFERENCED_DOMAIN_LIST = referencedDomains.Read <Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0UL);
            byte *ptr = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                referencedDomains.AcquirePointer(ref ptr);
                if (!lsa_REFERENCED_DOMAIN_LIST.Domains.IsNull())
                {
                    Win32Native.LSA_TRUST_INFORMATION *ptr2 = (Win32Native.LSA_TRUST_INFORMATION *)((void *)lsa_REFERENCED_DOMAIN_LIST.Domains);
                    ptr2 += lsa_REFERENCED_DOMAIN_LIST.Entries;
                    long numBytes = (long)((byte *)ptr2 - (byte *)ptr);
                    referencedDomains.Initialize((ulong)numBytes);
                }
            }
            finally
            {
                if (ptr != null)
                {
                    referencedDomains.ReleasePointer();
                }
            }
        }
コード例 #3
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static void InitializeReferencedDomainsPointer(SafeLsaMemoryHandle referencedDomains)
        {
            Contract.Assert(referencedDomains != null, "referencedDomains != null");

            // We don't know the real size of the referenced domains yet, so we need to set an initial
            // size based on the LSA_REFERENCED_DOMAIN_LIST structure, then resize it to include all of
            // the domains.
            referencedDomains.Initialize((uint)Marshal.SizeOf(typeof(Win32Native.LSA_REFERENCED_DOMAIN_LIST)));
            Win32Native.LSA_REFERENCED_DOMAIN_LIST domainList = referencedDomains.Read <Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0);

            unsafe
            {
                byte *pRdl = null;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    referencedDomains.AcquirePointer(ref pRdl);

                    // If there is a trust information list, then the buffer size is the end of that list minus
                    // the beginning of the domain list. Otherwise, then the buffer is just the size of the
                    // referenced domain list structure, which is what we defaulted to.
                    if (!domainList.Domains.IsNull())
                    {
                        Win32Native.LSA_TRUST_INFORMATION *pTrustInformation = (Win32Native.LSA_TRUST_INFORMATION *)domainList.Domains;
                        pTrustInformation = pTrustInformation + domainList.Entries;

                        long bufferSize = (byte *)pTrustInformation - pRdl;
                        Contract.Assert(bufferSize > 0, "bufferSize > 0");
                        referencedDomains.Initialize((ulong)bufferSize);
                    }
                }
                finally
                {
                    if (pRdl != null)
                    {
                        referencedDomains.ReleasePointer();
                    }
                }
            }
        }