Repository: dotnet/runtime
File: src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs (C#)

Code before:
                SCH_CRED_NO_SYSTEM_MAPPER = 0x02,
                SCH_CRED_NO_SERVERNAME_CHECK = 0x04,
                SCH_CRED_MANUAL_CRED_VALIDATION = 0x08,
                SCH_CRED_NO_DEFAULT_CREDS = 0x10,
                SCH_CRED_AUTO_CRED_VALIDATION = 0x20,
                SCH_SEND_AUX_RECORD = 0x00200000,
                SCH_USE_STRONG_CRYPTO = 0x00400000,
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        internal unsafe struct SCH_CREDENTIALS
        {
            public const int CurrentVersion = 0x5;

            public int dwVersion;
            public int dwCredformat;
            public int cCreds;

            // ptr to an array of pointers
            // There is a hack done with this field.  AcquireCredentialsHandle requires an array of
            // certificate handles; we only ever use one.  In order to avoid pinning a one element array,
            // we copy this value onto the stack, create a pointer on the stack to the copied value,
            // and replace this field with the pointer, during the call to AcquireCredentialsHandle.
            // Then we fix it up afterwards.  Fine as long as all the SSPI credentials are not
            // supposed to be threadsafe.
            public IntPtr paCred;

            public IntPtr hRootStore;               // == always null, OTHERWISE NOT RELIABLE
            public int cMappers;
            public IntPtr aphMappers;               // == always null, OTHERWISE NOT RELIABLE

            public int dwSessionLifespan;
            public SCH_CREDENTIALS.Flags dwFlags;
            public int cTlsParameters;
            public TLS_PARAMETERS* pTlsParameters;

            [Flags]
            public enum Flags
            {
                Zero = 0,
                SCH_CRED_NO_SYSTEM_MAPPER = 0x02,
                SCH_CRED_NO_SERVERNAME_CHECK = 0x04,
                SCH_CRED_MANUAL_CRED_VALIDATION = 0x08,
                SCH_CRED_NO_DEFAULT_CREDS = 0x10,
                SCH_CRED_AUTO_CRED_VALIDATION = 0x20,
                SCH_CRED_USE_DEFAULT_CREDS = 0x40,
                SCH_DISABLE_RECONNECTS = 0x80,
                SCH_CRED_REVOCATION_CHECK_END_CERT = 0x100,
                SCH_CRED_REVOCATION_CHECK_CHAIN = 0x200,
                SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x400,

Review comment (suggestion):
I don't understand this comment.  There shouldn't need to be any hacks here, and we shouldn't need to pin anything.

Code after:
                SCH_CRED_NO_SERVERNAME_CHECK = 0x04,
                SCH_CRED_MANUAL_CRED_VALIDATION = 0x08,
                SCH_CRED_NO_DEFAULT_CREDS = 0x10,
                SCH_CRED_AUTO_CRED_VALIDATION = 0x20,
                SCH_SEND_AUX_RECORD = 0x00200000,
                SCH_USE_STRONG_CRYPTO = 0x00400000,
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        internal unsafe struct SCH_CREDENTIALS
        {
            public const int CurrentVersion = 0x5;

            public int dwVersion;
            public int dwCredformat;
            public int cCreds;

            // This is pointer to arry of CERT_CONTEXT*
            // We do not use it directly in .NET. Instead, we wrap returned OS pointer in safe handle.
            public void* paCred;

            public IntPtr hRootStore;               // == always null, OTHERWISE NOT RELIABLE
            public int cMappers;
            public IntPtr aphMappers;               // == always null, OTHERWISE NOT RELIABLE

            public int dwSessionLifespan;
            public SCH_CREDENTIALS.Flags dwFlags;
            public int cTlsParameters;
            public TLS_PARAMETERS* pTlsParameters;

            [Flags]
            public enum Flags
            {
                Zero = 0,
                SCH_CRED_NO_SYSTEM_MAPPER = 0x02,
                SCH_CRED_NO_SERVERNAME_CHECK = 0x04,
                SCH_CRED_MANUAL_CRED_VALIDATION = 0x08,
                SCH_CRED_NO_DEFAULT_CREDS = 0x10,
                SCH_CRED_AUTO_CRED_VALIDATION = 0x20,
                SCH_CRED_USE_DEFAULT_CREDS = 0x40,
                SCH_DISABLE_RECONNECTS = 0x80,
                SCH_CRED_REVOCATION_CHECK_END_CERT = 0x100,
                SCH_CRED_REVOCATION_CHECK_CHAIN = 0x200,
                SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x400,
                SCH_CRED_IGNORE_NO_REVOCATION_CHECK = 0x800,
                SCH_CRED_IGNORE_REVOCATION_OFFLINE = 0x1000,
                SCH_CRED_CACHE_ONLY_URL_RETRIEVAL_ON_CREATE = 0x2000,
                SCH_SEND_ROOT_CERT = 0x40000,
                SCH_SEND_AUX_RECORD =   0x00200000,
                SCH_USE_STRONG_CRYPTO = 0x00400000,