From 7aebf45737714e5fa2b1e8e7d3193b78f0d27da3 Mon Sep 17 00:00:00 2001 From: Kaur-Parminder Date: Mon, 7 Mar 2022 09:49:11 -0800 Subject: [PATCH 1/7] SNI Update SNI Update --- tools/props/Versions.props | 6 +++--- tools/specs/Microsoft.Data.SqlClient.nuspec | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/props/Versions.props b/tools/props/Versions.props index 44002cbbae..d58b93e218 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -6,7 +6,7 @@ 5.0.0.0 - 5.0.0-dev + 5.0.0-preview1.22062.1 $(NugetPackageVersion) @@ -20,7 +20,7 @@ - 4.0.0 + 5.0.0-preview1.22062.1 4.3.1 4.3.0 @@ -38,7 +38,7 @@ 5.0.0 - 4.0.0 + 5.0.0-preview1.22062.1 5.0.0 5.0.0 5.0.0 diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 750ee2f48a..7f5ed91f43 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -28,7 +28,7 @@ When using NuGet 3.x this package requires at least version 3.4. sqlclient microsoft.data.sqlclient - + @@ -42,7 +42,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + @@ -60,7 +60,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + @@ -78,7 +78,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + From e7931b534e06d5eae68421c3eb5d7e52ee19d6e0 Mon Sep 17 00:00:00 2001 From: Kaur-Parminder Date: Mon, 7 Mar 2022 10:11:45 -0800 Subject: [PATCH 2/7] Revert "SNI Update" This reverts commit 7aebf45737714e5fa2b1e8e7d3193b78f0d27da3. --- tools/props/Versions.props | 6 +++--- tools/specs/Microsoft.Data.SqlClient.nuspec | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/props/Versions.props b/tools/props/Versions.props index d58b93e218..44002cbbae 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -6,7 +6,7 @@ 5.0.0.0 - 5.0.0-preview1.22062.1 + 5.0.0-dev $(NugetPackageVersion) @@ -20,7 +20,7 @@ - 5.0.0-preview1.22062.1 + 4.0.0 4.3.1 4.3.0 @@ -38,7 +38,7 @@ 5.0.0 - 5.0.0-preview1.22062.1 + 4.0.0 5.0.0 5.0.0 5.0.0 diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 7f5ed91f43..750ee2f48a 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -28,7 +28,7 @@ When using NuGet 3.x this package requires at least version 3.4. sqlclient microsoft.data.sqlclient - + @@ -42,7 +42,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + @@ -60,7 +60,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + @@ -78,7 +78,7 @@ When using NuGet 3.x this package requires at least version 3.4. - + From 27cb8a332bf182022ee24de923aa5860b27c5978 Mon Sep 17 00:00:00 2001 From: pkaur Date: Fri, 7 Oct 2022 16:12:20 +0000 Subject: [PATCH 3/7] ARM SNI references --- .../netfx/src/Microsoft.Data.SqlClient.csproj | 16 +- .../Interop/SNINativeManagedWrapperARM.cs | 150 ++++ .../Interop/SNINativeManagedWrapperARM64.cs | 150 ++++ .../Data/Interop/SNINativeMethodWrapper.cs | 650 ++++++++++++++---- 4 files changed, 831 insertions(+), 135 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs create mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index 12323365bf..229f46445b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -482,6 +482,9 @@ Microsoft\Data\SqlClient\SqlInfoMessageEventHandler.cs + + Microsoft\Data\SqlClient\SqlInternalConnection.cs + Microsoft\Data\SqlClient\SqlInternalTransaction.cs @@ -554,12 +557,18 @@ Microsoft\Data\SqlClient\TdsParameterSetter.cs + + Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs + Microsoft\Data\SqlClient\TdsParserStaticMethods.cs Microsoft\Data\SqlClient\TdsRecordBufferSetter.cs + + Microsoft\Data\SqlClient\TdsParserSessionPool.cs + Microsoft\Data\SqlClient\TdsValueSetter.cs @@ -591,6 +600,8 @@ + + @@ -639,7 +650,6 @@ - @@ -648,8 +658,6 @@ - - @@ -731,4 +739,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs new file mode 100644 index 0000000000..8f5ed70425 --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs @@ -0,0 +1,150 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using System.Text; +using static Microsoft.Data.SqlClient.SNINativeMethodWrapper; + +namespace Microsoft.Data.SqlClient +{ + internal static class SNINativeManagedWrapperARM + { + private const string SNI = "Microsoft.Data.SqlClient.SNI.arm.dll"; + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProvider(SNIHandle pConn, ProviderEnum ProvNum, [In] ref uint pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref SNICTAIPProviderInfo pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref AuthProviderInfo pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICheckConnectionWrapper")] + internal static extern uint SNICheckConnection([In] SNIHandle pConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICloseWrapper")] + internal static extern uint SNIClose(IntPtr pConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern void SNIGetLastError(out SNI_Error pErrorStruct); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern void SNIPacketRelease(IntPtr pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIPacketResetWrapper")] + internal static extern void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPacket pPacket, ConsumerNumber ConsNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIQueryInfo(QTypes QType, ref uint pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIReadAsyncWrapper")] + internal static extern uint SNIReadAsync(SNIHandle pConn, ref IntPtr ppNewPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIReadSyncOverAsync(SNIHandle pConn, ref IntPtr ppNewPacket, int timeout); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIRemoveProviderWrapper")] + internal static extern uint SNIRemoveProvider(SNIHandle pConn, ProviderEnum ProvNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNISecInitPackage(ref uint pcbMaxToken); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISetInfoWrapper")] + internal static extern uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNITerminate(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIWaitForSSLHandshakeToCompleteWrapper")] + internal static extern uint SNIWaitForSSLHandshakeToComplete([In] SNIHandle pConn, int dwMilliseconds, out uint pProtocolVersion); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint UnmanagedIsTokenRestricted([In] IntPtr token, [MarshalAs(UnmanagedType.Bool)] out bool isRestricted); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint GetSniMaxComposedSpnLength(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out Guid pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, [MarshalAs(UnmanagedType.Bool)] out bool pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, ref IntPtr pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ushort portNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] + internal static extern uint SNIGetPeerAddrStrWrapper([In] SNIHandle pConn, int bufferSize, StringBuilder addrBuffer, out uint addrLen); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] + internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIOpenWrapper( + [In] ref Sni_Consumer_Info pConsumerInfo, + [MarshalAs(UnmanagedType.LPWStr)] string szConnect, + [In] SNIHandle pConn, + out IntPtr ppConn, + [MarshalAs(UnmanagedType.Bool)] bool fSync, + SqlConnectionIPAddressPreference ipPreference, + [In] ref SNI_DNSCache_Info pDNSCachedInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr SNIPacketAllocateWrapper([In] SafeHandle pConn, IOType IOType); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[] readBuffer, uint readBufferLength, out uint dataSize); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, uint cbBuf); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISecGenClientContextWrapper")] + internal static extern unsafe uint SNISecGenClientContextWrapper( + [In] SNIHandle pConn, + [In, Out] byte[] pIn, + uint cbIn, + [In, Out] byte[] pOut, + [In] ref uint pcbOut, + [MarshalAsAttribute(UnmanagedType.Bool)] out bool pfDone, + byte* szServerInfo, + uint cbServerInfo, + [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszUserName, + [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszPassword); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIWriteSyncOverAsync(SNIHandle pConn, [In] SNIPacket pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr SNIClientCertificateFallbackWrapper(IntPtr pCallbackContext); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumOpenWrapper")] + internal static extern IntPtr SNIServerEnumOpen(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumCloseWrapper")] + internal static extern void SNIServerEnumClose([In] IntPtr packet); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumReadWrapper", CharSet = CharSet.Unicode)] + internal static extern int SNIServerEnumRead([In] IntPtr packet, + [In, Out][MarshalAs(UnmanagedType.LPArray)] char[] readBuffer, + [In] int bufferLength, + [MarshalAs(UnmanagedType.Bool)] out bool more); + } +} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs new file mode 100644 index 0000000000..296eb66a15 --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs @@ -0,0 +1,150 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using System.Text; +using static Microsoft.Data.SqlClient.SNINativeMethodWrapper; + +namespace Microsoft.Data.SqlClient +{ + internal static class SNINativeManagedWrapperARM64 + { + private const string SNI = "Microsoft.Data.SqlClient.SNI.arm64.dll"; + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProvider(SNIHandle pConn, ProviderEnum ProvNum, [In] ref uint pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref SNICTAIPProviderInfo pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] + internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref AuthProviderInfo pInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICheckConnectionWrapper")] + internal static extern uint SNICheckConnection([In] SNIHandle pConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICloseWrapper")] + internal static extern uint SNIClose(IntPtr pConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern void SNIGetLastError(out SNI_Error pErrorStruct); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern void SNIPacketRelease(IntPtr pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIPacketResetWrapper")] + internal static extern void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPacket pPacket, ConsumerNumber ConsNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIQueryInfo(QTypes QType, ref uint pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIReadAsyncWrapper")] + internal static extern uint SNIReadAsync(SNIHandle pConn, ref IntPtr ppNewPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIReadSyncOverAsync(SNIHandle pConn, ref IntPtr ppNewPacket, int timeout); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIRemoveProviderWrapper")] + internal static extern uint SNIRemoveProvider(SNIHandle pConn, ProviderEnum ProvNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNISecInitPackage(ref uint pcbMaxToken); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISetInfoWrapper")] + internal static extern uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNITerminate(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIWaitForSSLHandshakeToCompleteWrapper")] + internal static extern uint SNIWaitForSSLHandshakeToComplete([In] SNIHandle pConn, int dwMilliseconds, out uint pProtocolVersion); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint UnmanagedIsTokenRestricted([In] IntPtr token, [MarshalAs(UnmanagedType.Bool)] out bool isRestricted); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint GetSniMaxComposedSpnLength(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out Guid pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, [MarshalAs(UnmanagedType.Bool)] out bool pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, ref IntPtr pbQInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ushort portNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] + internal static extern uint SNIGetPeerAddrStrWrapper([In] SNIHandle pConn, int bufferSize, StringBuilder addrBuffer, out uint addrLen); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] + internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIOpenWrapper( + [In] ref Sni_Consumer_Info pConsumerInfo, + [MarshalAs(UnmanagedType.LPWStr)] string szConnect, + [In] SNIHandle pConn, + out IntPtr ppConn, + [MarshalAs(UnmanagedType.Bool)] bool fSync, + SqlConnectionIPAddressPreference ipPreference, + [In] ref SNI_DNSCache_Info pDNSCachedInfo); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr SNIPacketAllocateWrapper([In] SafeHandle pConn, IOType IOType); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[] readBuffer, uint readBufferLength, out uint dataSize); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, uint cbBuf); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISecGenClientContextWrapper")] + internal static extern unsafe uint SNISecGenClientContextWrapper( + [In] SNIHandle pConn, + [In, Out] byte[] pIn, + uint cbIn, + [In, Out] byte[] pOut, + [In] ref uint pcbOut, + [MarshalAsAttribute(UnmanagedType.Bool)] out bool pfDone, + byte* szServerInfo, + uint cbServerInfo, + [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszUserName, + [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszPassword); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint SNIWriteSyncOverAsync(SNIHandle pConn, [In] SNIPacket pPacket); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr SNIClientCertificateFallbackWrapper(IntPtr pCallbackContext); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumOpenWrapper")] + internal static extern IntPtr SNIServerEnumOpen(); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumCloseWrapper")] + internal static extern void SNIServerEnumClose([In] IntPtr packet); + + [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumReadWrapper", CharSet = CharSet.Unicode)] + internal static extern int SNIServerEnumRead([In] IntPtr packet, + [In, Out][MarshalAs(UnmanagedType.LPArray)] char[] readBuffer, + [In] int bufferLength, + [MarshalAs(UnmanagedType.Bool)] out bool more); + } +} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index 18ca7c68c2..2426d1601d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -14,13 +14,16 @@ using Microsoft.Data.Common; using Microsoft.Data.SqlClient; using System.Text; +using System.Net.NetworkInformation; +using System.Drawing; +using System.Net.Sockets; namespace Microsoft.Data.SqlClient { internal static class SNINativeMethodWrapper { private static int s_sniMaxComposedSpnLength = -1; - private static readonly bool s_is64bitProcess = Environment.Is64BitProcess; + private static readonly System.Runtime.InteropServices.Architecture s_architecture = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture; private const int SniOpenTimeOut = -1; // infinite @@ -405,206 +408,476 @@ internal struct SNI_Error internal static uint SNIAddProvider(SNIHandle pConn, ProviderEnum ProvNum, [In] ref uint pInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIAddProvider(pConn, ProvNum, ref pInfo) : - SNINativeManagedWrapperX86.SNIAddProvider(pConn, ProvNum, ref pInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIAddProvider(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIAddProvider(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIAddProvider(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIAddProvider(pConn, ProvNum, ref pInfo); + default: + return SNINativeManagedWrapperX86.SNIAddProvider(pConn, ProvNum, ref pInfo); + } } internal static uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref SNICTAIPProviderInfo pInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo) : - SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + default: + return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + } } internal static uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref AuthProviderInfo pInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo) : - SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + default: + return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + } } internal static uint SNICheckConnection([In] SNIHandle pConn) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNICheckConnection(pConn) : - SNINativeManagedWrapperX86.SNICheckConnection(pConn); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNICheckConnection(pConn); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNICheckConnection(pConn); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNICheckConnection(pConn); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNICheckConnection(pConn); + default: + return SNINativeManagedWrapperX86.SNICheckConnection(pConn); + } } internal static uint SNIClose(IntPtr pConn) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIClose(pConn) : - SNINativeManagedWrapperX86.SNIClose(pConn); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIClose(pConn); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIClose(pConn); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIClose(pConn); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIClose(pConn); + default: + return SNINativeManagedWrapperX86.SNIClose(pConn); + } } internal static void SNIGetLastError(out SNI_Error pErrorStruct) { - if (s_is64bitProcess) - { - SNINativeManagedWrapperX64.SNIGetLastError(out pErrorStruct); - } - else + switch (s_architecture) { - SNINativeManagedWrapperX86.SNIGetLastError(out pErrorStruct); + case System.Runtime.InteropServices.Architecture.Arm64: + SNINativeManagedWrapperARM64.SNIGetLastError(out pErrorStruct); + break; + case System.Runtime.InteropServices.Architecture.Arm: + SNINativeManagedWrapperARM.SNIGetLastError(out pErrorStruct); + break; + case System.Runtime.InteropServices.Architecture.X64: + SNINativeManagedWrapperX64.SNIGetLastError(out pErrorStruct); + break; + case System.Runtime.InteropServices.Architecture.X86: + SNINativeManagedWrapperX86.SNIGetLastError(out pErrorStruct); + break; + default: + SNINativeManagedWrapperX86.SNIGetLastError(out pErrorStruct); + break; } } internal static void SNIPacketRelease(IntPtr pPacket) { - if (s_is64bitProcess) - { - SNINativeManagedWrapperX64.SNIPacketRelease(pPacket); - } - else + switch (s_architecture) { - SNINativeManagedWrapperX86.SNIPacketRelease(pPacket); + case System.Runtime.InteropServices.Architecture.Arm64: + SNINativeManagedWrapperARM64.SNIPacketRelease(pPacket); + break; + case System.Runtime.InteropServices.Architecture.Arm: + SNINativeManagedWrapperARM.SNIPacketRelease(pPacket); + break; + case System.Runtime.InteropServices.Architecture.X64: + SNINativeManagedWrapperX64.SNIPacketRelease(pPacket); + break; + case System.Runtime.InteropServices.Architecture.X86: + SNINativeManagedWrapperX86.SNIPacketRelease(pPacket); + break; + default: + SNINativeManagedWrapperX86.SNIPacketRelease(pPacket); + break; } } internal static void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPacket pPacket, ConsumerNumber ConsNum) { - if (s_is64bitProcess) + switch (s_architecture) { - SNINativeManagedWrapperX64.SNIPacketReset(pConn, IOType, pPacket, ConsNum); - } - else - { - SNINativeManagedWrapperX86.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + case System.Runtime.InteropServices.Architecture.Arm64: + SNINativeManagedWrapperARM64.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + break; + case System.Runtime.InteropServices.Architecture.Arm: + SNINativeManagedWrapperARM.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + break; + case System.Runtime.InteropServices.Architecture.X64: + SNINativeManagedWrapperX64.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + break; + case System.Runtime.InteropServices.Architecture.X86: + SNINativeManagedWrapperX86.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + break; + default: + SNINativeManagedWrapperX86.SNIPacketReset(pConn, IOType, pPacket, ConsNum); + break; } } internal static uint SNIQueryInfo(QTypes QType, ref uint pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo) : - SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + default: + return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + } } internal static uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo) : - SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + default: + return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + } } internal static uint SNIReadAsync(SNIHandle pConn, ref IntPtr ppNewPacket) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIReadAsync(pConn, ref ppNewPacket) : - SNINativeManagedWrapperX86.SNIReadAsync(pConn, ref ppNewPacket); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIReadAsync(pConn, ref ppNewPacket); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIReadAsync(pConn, ref ppNewPacket); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIReadAsync(pConn, ref ppNewPacket); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIReadAsync(pConn, ref ppNewPacket); + default: + return SNINativeManagedWrapperX86.SNIReadAsync(pConn, ref ppNewPacket); + } } internal static uint SNIReadSyncOverAsync(SNIHandle pConn, ref IntPtr ppNewPacket, int timeout) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout) : - SNINativeManagedWrapperX86.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + default: + return SNINativeManagedWrapperX86.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + } } internal static uint SNIRemoveProvider(SNIHandle pConn, ProviderEnum ProvNum) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIRemoveProvider(pConn, ProvNum) : - SNINativeManagedWrapperX86.SNIRemoveProvider(pConn, ProvNum); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIRemoveProvider(pConn, ProvNum); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIRemoveProvider(pConn, ProvNum); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIRemoveProvider(pConn, ProvNum); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIRemoveProvider(pConn, ProvNum); + default: + return SNINativeManagedWrapperX86.SNIRemoveProvider(pConn, ProvNum); + } } internal static uint SNISecInitPackage(ref uint pcbMaxToken) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNISecInitPackage(ref pcbMaxToken) : - SNINativeManagedWrapperX86.SNISecInitPackage(ref pcbMaxToken); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNISecInitPackage(ref pcbMaxToken); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNISecInitPackage(ref pcbMaxToken); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNISecInitPackage(ref pcbMaxToken); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNISecInitPackage(ref pcbMaxToken); + default: + return SNINativeManagedWrapperX86.SNISecInitPackage(ref pcbMaxToken); + } } internal static uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNISetInfo(pConn, QType, ref pbQInfo) : - SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNISetInfo(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNISetInfo(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNISetInfo(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo); + default: + return SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo); + } } internal static uint SNITerminate() { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNITerminate() : - SNINativeManagedWrapperX86.SNITerminate(); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNITerminate(); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNITerminate(); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNITerminate(); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNITerminate(); + default: + return SNINativeManagedWrapperX86.SNITerminate(); + } } internal static uint SNIWaitForSSLHandshakeToComplete([In] SNIHandle pConn, int dwMilliseconds, out uint pProtocolVersion) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion) : - SNINativeManagedWrapperX86.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + default: + return SNINativeManagedWrapperX86.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + } } internal static uint UnmanagedIsTokenRestricted([In] IntPtr token, [MarshalAs(UnmanagedType.Bool)] out bool isRestricted) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.UnmanagedIsTokenRestricted(token, out isRestricted) : - SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(token, out isRestricted); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.UnmanagedIsTokenRestricted(token, out isRestricted); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.UnmanagedIsTokenRestricted(token, out isRestricted); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.UnmanagedIsTokenRestricted(token, out isRestricted); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(token, out isRestricted); + default: + return SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(token, out isRestricted); + } } private static uint GetSniMaxComposedSpnLength() { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.GetSniMaxComposedSpnLength() : - SNINativeManagedWrapperX86.GetSniMaxComposedSpnLength(); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.GetSniMaxComposedSpnLength(); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.GetSniMaxComposedSpnLength(); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.GetSniMaxComposedSpnLength(); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.GetSniMaxComposedSpnLength(); + default: + return SNINativeManagedWrapperX86.GetSniMaxComposedSpnLength(); + } } private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out Guid pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo) : - SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + default: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + } } private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, [MarshalAs(UnmanagedType.Bool)] out bool pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo) : - SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + default: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + } } private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, ref IntPtr pbQInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, ref pbQInfo) : - SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + default: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + } } private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ushort portNum) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out portNum) : - SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out portNum); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out portNum); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out portNum); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out portNum); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out portNum); + default: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out portNum); + } } private static uint SNIGetPeerAddrStrWrapper([In] SNIHandle pConn, int bufferSize, StringBuilder addrBuffer, out uint addrLen) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen) : - SNINativeManagedWrapperX86.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + default: + return SNINativeManagedWrapperX86.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + } } private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out provNum) : - SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out provNum); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out provNum); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out provNum); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum); + default: + return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum); + } } private static uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIInitialize(useSystemDefaultSecureProtocols, pmo) : - SNINativeManagedWrapperX86.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + default: + return SNINativeManagedWrapperX86.SNIInitialize(useSystemDefaultSecureProtocols, pmo); + } } private static uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn) : - SNINativeManagedWrapperX86.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + default: + return SNINativeManagedWrapperX86.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + } } private static uint SNIOpenWrapper( @@ -616,34 +889,74 @@ private static uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientCon SqlConnectionIPAddressPreference ipPreference, [In] ref SNI_DNSCache_Info pDNSCachedInfo) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo) : - SNINativeManagedWrapperX86.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + default: + return SNINativeManagedWrapperX86.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + } } private static IntPtr SNIPacketAllocateWrapper([In] SafeHandle pConn, IOType IOType) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIPacketAllocateWrapper(pConn, IOType) : - SNINativeManagedWrapperX86.SNIPacketAllocateWrapper(pConn, IOType); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIPacketAllocateWrapper(pConn, IOType); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIPacketAllocateWrapper(pConn, IOType); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIPacketAllocateWrapper(pConn, IOType); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIPacketAllocateWrapper(pConn, IOType); + default: + return SNINativeManagedWrapperX86.SNIPacketAllocateWrapper(pConn, IOType); + } } private static uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[] readBuffer, uint readBufferLength, out uint dataSize) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize) : - SNINativeManagedWrapperX86.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + default: + return SNINativeManagedWrapperX86.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + } } private static unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, uint cbBuf) { - if (s_is64bitProcess) + switch (s_architecture) { - SNINativeManagedWrapperX64.SNIPacketSetData(pPacket, pbBuf, cbBuf); - } - else - { - SNINativeManagedWrapperX86.SNIPacketSetData(pPacket, pbBuf, cbBuf); + case System.Runtime.InteropServices.Architecture.Arm64: + SNINativeManagedWrapperARM64.SNIPacketSetData(pPacket, pbBuf, cbBuf); + break; + case System.Runtime.InteropServices.Architecture.Arm: + SNINativeManagedWrapperARM.SNIPacketSetData(pPacket, pbBuf, cbBuf); + break; + case System.Runtime.InteropServices.Architecture.X64: + SNINativeManagedWrapperX64.SNIPacketSetData(pPacket, pbBuf, cbBuf); + break; + case System.Runtime.InteropServices.Architecture.X86: + SNINativeManagedWrapperX86.SNIPacketSetData(pPacket, pbBuf, cbBuf); + break; + default: + SNINativeManagedWrapperX86.SNIPacketSetData(pPacket, pbBuf, cbBuf); + break; } } @@ -659,30 +972,70 @@ private static unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszUserName, [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszPassword) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword) : - SNINativeManagedWrapperX86.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + default: + return SNINativeManagedWrapperX86.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + } } private static uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIWriteAsyncWrapper(pConn, pPacket) : - SNINativeManagedWrapperX86.SNIWriteAsyncWrapper(pConn, pPacket); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIWriteAsyncWrapper(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIWriteAsyncWrapper(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIWriteAsyncWrapper(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIWriteAsyncWrapper(pConn, pPacket); + default: + return SNINativeManagedWrapperX86.SNIWriteAsyncWrapper(pConn, pPacket); + } } private static uint SNIWriteSyncOverAsync(SNIHandle pConn, [In] SNIPacket pPacket) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIWriteSyncOverAsync(pConn, pPacket) : - SNINativeManagedWrapperX86.SNIWriteSyncOverAsync(pConn, pPacket); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIWriteSyncOverAsync(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIWriteSyncOverAsync(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIWriteSyncOverAsync(pConn, pPacket); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIWriteSyncOverAsync(pConn, pPacket); + default: + return SNINativeManagedWrapperX86.SNIWriteSyncOverAsync(pConn, pPacket); + } } private static IntPtr SNIClientCertificateFallbackWrapper(IntPtr pCallbackContext) { - return s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIClientCertificateFallbackWrapper(pCallbackContext) : - SNINativeManagedWrapperX86.SNIClientCertificateFallbackWrapper(pCallbackContext); + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIClientCertificateFallbackWrapper(pCallbackContext); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIClientCertificateFallbackWrapper(pCallbackContext); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIClientCertificateFallbackWrapper(pCallbackContext); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIClientCertificateFallbackWrapper(pCallbackContext); + default: + return SNINativeManagedWrapperX86.SNIClientCertificateFallbackWrapper(pCallbackContext); + } } #endregion @@ -768,23 +1121,58 @@ internal static uint SNIInitialize() return SNIInitialize(LocalAppContextSwitches.UseSystemDefaultSecureProtocols, IntPtr.Zero); } - internal static IntPtr SNIServerEnumOpen() => s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIServerEnumOpen() : - SNINativeManagedWrapperX86.SNIServerEnumOpen(); - - internal static int SNIServerEnumRead([In] IntPtr packet, [In, Out] char[] readbuffer, int bufferLength, out bool more) => s_is64bitProcess ? - SNINativeManagedWrapperX64.SNIServerEnumRead(packet, readbuffer, bufferLength, out more) : - SNINativeManagedWrapperX86.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); - - internal static void SNIServerEnumClose([In] IntPtr packet) + internal static IntPtr SNIServerEnumOpen() { - if (s_is64bitProcess) + switch (s_architecture) { - SNINativeManagedWrapperX64.SNIServerEnumClose(packet); + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIServerEnumOpen(); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIServerEnumOpen(); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIServerEnumOpen(); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIServerEnumOpen(); + default: + return SNINativeManagedWrapperX86.SNIServerEnumOpen(); } - else + } + internal static int SNIServerEnumRead([In] IntPtr packet, [In, Out] char[] readbuffer, int bufferLength, out bool more) + { + switch (s_architecture) + { + case System.Runtime.InteropServices.Architecture.Arm64: + return SNINativeManagedWrapperARM64.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + case System.Runtime.InteropServices.Architecture.Arm: + return SNINativeManagedWrapperARM.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + case System.Runtime.InteropServices.Architecture.X64: + return SNINativeManagedWrapperX64.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + case System.Runtime.InteropServices.Architecture.X86: + return SNINativeManagedWrapperX86.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + default: + return SNINativeManagedWrapperX86.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + } + } + + internal static void SNIServerEnumClose([In] IntPtr packet) + { + switch (s_architecture) { - SNINativeManagedWrapperX86.SNIServerEnumClose(packet); + case System.Runtime.InteropServices.Architecture.Arm64: + SNINativeManagedWrapperARM64.SNIServerEnumClose(packet); + break; + case System.Runtime.InteropServices.Architecture.Arm: + SNINativeManagedWrapperARM.SNIServerEnumClose(packet); + break; + case System.Runtime.InteropServices.Architecture.X64: + SNINativeManagedWrapperX64.SNIServerEnumClose(packet); + break; + case System.Runtime.InteropServices.Architecture.X86: + SNINativeManagedWrapperX86.SNIServerEnumClose(packet); + break; + default: + SNINativeManagedWrapperX86.SNIServerEnumClose(packet); + break; } } From a7c9de20f869638cc9018c7d40a47532d81ec5ab Mon Sep 17 00:00:00 2001 From: David Engel Date: Fri, 4 Nov 2022 14:27:58 -0700 Subject: [PATCH 4/7] Fix SNI interface differences Remove ARM(32) --- .../netfx/src/Microsoft.Data.SqlClient.csproj | 1 - .../Interop/SNINativeManagedWrapperARM.cs | 150 ---------------- .../Interop/SNINativeManagedWrapperX64.cs | 2 +- .../Interop/SNINativeManagedWrapperX86.cs | 2 +- .../Data/Interop/SNINativeMethodWrapper.cs | 170 +++++------------- .../netfx/src/Resources/Strings.Designer.cs | 9 + .../netfx/src/Resources/Strings.resx | 5 +- .../src/Microsoft/Data/Common/AdapterUtil.cs | 5 + 8 files changed, 62 insertions(+), 282 deletions(-) delete mode 100644 src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index a71e954406..bd09301069 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -603,7 +603,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs deleted file mode 100644 index 8f5ed70425..0000000000 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Text; -using static Microsoft.Data.SqlClient.SNINativeMethodWrapper; - -namespace Microsoft.Data.SqlClient -{ - internal static class SNINativeManagedWrapperARM - { - private const string SNI = "Microsoft.Data.SqlClient.SNI.arm.dll"; - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] - internal static extern uint SNIAddProvider(SNIHandle pConn, ProviderEnum ProvNum, [In] ref uint pInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] - internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref SNICTAIPProviderInfo pInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIAddProviderWrapper")] - internal static extern uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum, [In] ref AuthProviderInfo pInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICheckConnectionWrapper")] - internal static extern uint SNICheckConnection([In] SNIHandle pConn); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNICloseWrapper")] - internal static extern uint SNIClose(IntPtr pConn); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern void SNIGetLastError(out SNI_Error pErrorStruct); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern void SNIPacketRelease(IntPtr pPacket); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIPacketResetWrapper")] - internal static extern void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPacket pPacket, ConsumerNumber ConsNum); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIQueryInfo(QTypes QType, ref uint pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIReadAsyncWrapper")] - internal static extern uint SNIReadAsync(SNIHandle pConn, ref IntPtr ppNewPacket); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIReadSyncOverAsync(SNIHandle pConn, ref IntPtr ppNewPacket, int timeout); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIRemoveProviderWrapper")] - internal static extern uint SNIRemoveProvider(SNIHandle pConn, ProviderEnum ProvNum); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNISecInitPackage(ref uint pcbMaxToken); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISetInfoWrapper")] - internal static extern uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNITerminate(); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIWaitForSSLHandshakeToCompleteWrapper")] - internal static extern uint SNIWaitForSSLHandshakeToComplete([In] SNIHandle pConn, int dwMilliseconds, out uint pProtocolVersion); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint UnmanagedIsTokenRestricted([In] IntPtr token, [MarshalAs(UnmanagedType.Bool)] out bool isRestricted); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint GetSniMaxComposedSpnLength(); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out Guid pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, [MarshalAs(UnmanagedType.Bool)] out bool pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, ref IntPtr pbQInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ushort portNum); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)] - internal static extern uint SNIGetPeerAddrStrWrapper([In] SNIHandle pConn, int bufferSize, StringBuilder addrBuffer, out uint addrLen); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIOpenWrapper( - [In] ref Sni_Consumer_Info pConsumerInfo, - [MarshalAs(UnmanagedType.LPWStr)] string szConnect, - [In] SNIHandle pConn, - out IntPtr ppConn, - [MarshalAs(UnmanagedType.Bool)] bool fSync, - SqlConnectionIPAddressPreference ipPreference, - [In] ref SNI_DNSCache_Info pDNSCachedInfo); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr SNIPacketAllocateWrapper([In] SafeHandle pConn, IOType IOType); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[] readBuffer, uint readBufferLength, out uint dataSize); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, uint cbBuf); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNISecGenClientContextWrapper")] - internal static extern unsafe uint SNISecGenClientContextWrapper( - [In] SNIHandle pConn, - [In, Out] byte[] pIn, - uint cbIn, - [In, Out] byte[] pOut, - [In] ref uint pcbOut, - [MarshalAsAttribute(UnmanagedType.Bool)] out bool pfDone, - byte* szServerInfo, - uint cbServerInfo, - [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszUserName, - [MarshalAsAttribute(UnmanagedType.LPWStr)] string pwszPassword); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern uint SNIWriteSyncOverAsync(SNIHandle pConn, [In] SNIPacket pPacket); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr SNIClientCertificateFallbackWrapper(IntPtr pCallbackContext); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumOpenWrapper")] - internal static extern IntPtr SNIServerEnumOpen(); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumCloseWrapper")] - internal static extern void SNIServerEnumClose([In] IntPtr packet); - - [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIServerEnumReadWrapper", CharSet = CharSet.Unicode)] - internal static extern int SNIServerEnumRead([In] IntPtr packet, - [In, Out][MarshalAs(UnmanagedType.LPArray)] char[] readBuffer, - [In] int bufferLength, - [MarshalAs(UnmanagedType.Bool)] out bool more); - } -} diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs index f4970e1cda..13e35363a8 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs @@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX64 internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] IntPtr pmo); + internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs index 6e1a0abf5f..5517ba8c0e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs @@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX86 internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] IntPtr pmo); + internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index 1c26365495..4305dd2bce 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -412,14 +412,12 @@ internal static uint SNIAddProvider(SNIHandle pConn, ProviderEnum ProvNum, [In] { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIAddProvider(pConn, ProvNum, ref pInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIAddProvider(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIAddProvider(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIAddProvider(pConn, ProvNum, ref pInfo); default: - return SNINativeManagedWrapperX86.SNIAddProvider(pConn, ProvNum, ref pInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -429,14 +427,12 @@ internal static uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); default: - return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -446,14 +442,12 @@ internal static uint SNIAddProviderWrapper(SNIHandle pConn, ProviderEnum ProvNum { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); default: - return SNINativeManagedWrapperX86.SNIAddProviderWrapper(pConn, ProvNum, ref pInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -463,14 +457,12 @@ internal static uint SNICheckConnection([In] SNIHandle pConn) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNICheckConnection(pConn); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNICheckConnection(pConn); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNICheckConnection(pConn); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNICheckConnection(pConn); default: - return SNINativeManagedWrapperX86.SNICheckConnection(pConn); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -480,14 +472,12 @@ internal static uint SNIClose(IntPtr pConn) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIClose(pConn); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIClose(pConn); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIClose(pConn); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIClose(pConn); default: - return SNINativeManagedWrapperX86.SNIClose(pConn); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -498,9 +488,6 @@ internal static void SNIGetLastError(out SNI_Error pErrorStruct) case System.Runtime.InteropServices.Architecture.Arm64: SNINativeManagedWrapperARM64.SNIGetLastError(out pErrorStruct); break; - case System.Runtime.InteropServices.Architecture.Arm: - SNINativeManagedWrapperARM.SNIGetLastError(out pErrorStruct); - break; case System.Runtime.InteropServices.Architecture.X64: SNINativeManagedWrapperX64.SNIGetLastError(out pErrorStruct); break; @@ -508,8 +495,7 @@ internal static void SNIGetLastError(out SNI_Error pErrorStruct) SNINativeManagedWrapperX86.SNIGetLastError(out pErrorStruct); break; default: - SNINativeManagedWrapperX86.SNIGetLastError(out pErrorStruct); - break; + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -520,9 +506,6 @@ internal static void SNIPacketRelease(IntPtr pPacket) case System.Runtime.InteropServices.Architecture.Arm64: SNINativeManagedWrapperARM64.SNIPacketRelease(pPacket); break; - case System.Runtime.InteropServices.Architecture.Arm: - SNINativeManagedWrapperARM.SNIPacketRelease(pPacket); - break; case System.Runtime.InteropServices.Architecture.X64: SNINativeManagedWrapperX64.SNIPacketRelease(pPacket); break; @@ -530,8 +513,7 @@ internal static void SNIPacketRelease(IntPtr pPacket) SNINativeManagedWrapperX86.SNIPacketRelease(pPacket); break; default: - SNINativeManagedWrapperX86.SNIPacketRelease(pPacket); - break; + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -542,9 +524,6 @@ internal static void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPack case System.Runtime.InteropServices.Architecture.Arm64: SNINativeManagedWrapperARM64.SNIPacketReset(pConn, IOType, pPacket, ConsNum); break; - case System.Runtime.InteropServices.Architecture.Arm: - SNINativeManagedWrapperARM.SNIPacketReset(pConn, IOType, pPacket, ConsNum); - break; case System.Runtime.InteropServices.Architecture.X64: SNINativeManagedWrapperX64.SNIPacketReset(pConn, IOType, pPacket, ConsNum); break; @@ -552,8 +531,7 @@ internal static void SNIPacketReset([In] SNIHandle pConn, IOType IOType, SNIPack SNINativeManagedWrapperX86.SNIPacketReset(pConn, IOType, pPacket, ConsNum); break; default: - SNINativeManagedWrapperX86.SNIPacketReset(pConn, IOType, pPacket, ConsNum); - break; + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -563,14 +541,12 @@ internal static uint SNIQueryInfo(QTypes QType, ref uint pbQInfo) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIQueryInfo(QType, ref pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIQueryInfo(QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); default: - return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -580,14 +556,12 @@ internal static uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIQueryInfo(QType, ref pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIQueryInfo(QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); default: - return SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -597,14 +571,12 @@ internal static uint SNIReadAsync(SNIHandle pConn, ref IntPtr ppNewPacket) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIReadAsync(pConn, ref ppNewPacket); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIReadAsync(pConn, ref ppNewPacket); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIReadAsync(pConn, ref ppNewPacket); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIReadAsync(pConn, ref ppNewPacket); default: - return SNINativeManagedWrapperX86.SNIReadAsync(pConn, ref ppNewPacket); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -614,14 +586,12 @@ internal static uint SNIReadSyncOverAsync(SNIHandle pConn, ref IntPtr ppNewPacke { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); default: - return SNINativeManagedWrapperX86.SNIReadSyncOverAsync(pConn, ref ppNewPacket, timeout); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -631,14 +601,12 @@ internal static uint SNIRemoveProvider(SNIHandle pConn, ProviderEnum ProvNum) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIRemoveProvider(pConn, ProvNum); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIRemoveProvider(pConn, ProvNum); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIRemoveProvider(pConn, ProvNum); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIRemoveProvider(pConn, ProvNum); default: - return SNINativeManagedWrapperX86.SNIRemoveProvider(pConn, ProvNum); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -648,14 +616,12 @@ internal static uint SNISecInitPackage(ref uint pcbMaxToken) { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNISecInitPackage(ref pcbMaxToken); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNISecInitPackage(ref pcbMaxToken); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNISecInitPackage(ref pcbMaxToken); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNISecInitPackage(ref pcbMaxToken); default: - return SNINativeManagedWrapperX86.SNISecInitPackage(ref pcbMaxToken); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -665,14 +631,12 @@ internal static uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQ { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNISetInfo(pConn, QType, ref pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNISetInfo(pConn, QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNISetInfo(pConn, QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo); default: - return SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -682,14 +646,12 @@ internal static uint SNITerminate() { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNITerminate(); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNITerminate(); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNITerminate(); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNITerminate(); default: - return SNINativeManagedWrapperX86.SNITerminate(); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -699,14 +661,12 @@ internal static uint SNIWaitForSSLHandshakeToComplete([In] SNIHandle pConn, int { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); default: - return SNINativeManagedWrapperX86.SNIWaitForSSLHandshakeToComplete(pConn, dwMilliseconds, out pProtocolVersion); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -716,14 +676,12 @@ internal static uint UnmanagedIsTokenRestricted([In] IntPtr token, [MarshalAs(Un { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.UnmanagedIsTokenRestricted(token, out isRestricted); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.UnmanagedIsTokenRestricted(token, out isRestricted); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.UnmanagedIsTokenRestricted(token, out isRestricted); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(token, out isRestricted); default: - return SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(token, out isRestricted); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -733,14 +691,12 @@ private static uint GetSniMaxComposedSpnLength() { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.GetSniMaxComposedSpnLength(); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.GetSniMaxComposedSpnLength(); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.GetSniMaxComposedSpnLength(); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.GetSniMaxComposedSpnLength(); default: - return SNINativeManagedWrapperX86.GetSniMaxComposedSpnLength(); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -750,14 +706,12 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); default: - return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -767,14 +721,12 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); default: - return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -784,14 +736,12 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); default: - return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, ref pbQInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -801,14 +751,12 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out portNum); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out portNum); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out portNum); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out portNum); default: - return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out portNum); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -818,14 +766,12 @@ private static uint SNIGetPeerAddrStrWrapper([In] SNIHandle pConn, int bufferSiz { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); default: - return SNINativeManagedWrapperX86.SNIGetPeerAddrStrWrapper(pConn, bufferSize, addrBuffer, out addrLen); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -835,14 +781,12 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIGetInfoWrapper(pConn, QType, out provNum); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIGetInfoWrapper(pConn, QType, out provNum); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIGetInfoWrapper(pConn, QType, out provNum); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum); default: - return SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -851,15 +795,13 @@ private static uint SNIInitialize([In] IntPtr pmo) switch (s_architecture) { case System.Runtime.InteropServices.Architecture.Arm64: - return SNINativeManagedWrapperARM64.SNIInitialize(pmo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIInitialize(pmo); + return SNINativeManagedWrapperARM64.SNIInitialize(false, pmo); case System.Runtime.InteropServices.Architecture.X64: - return SNINativeManagedWrapperX64.SNIInitialize(pmo); + return SNINativeManagedWrapperX64.SNIInitialize(false, pmo); case System.Runtime.InteropServices.Architecture.X86: - return SNINativeManagedWrapperX86.SNIInitialize(pmo); + return SNINativeManagedWrapperX86.SNIInitialize(false, pmo); default: - return SNINativeManagedWrapperX86.SNIInitialize(pmo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -869,14 +811,12 @@ private static uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientCon { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); default: - return SNINativeManagedWrapperX86.SNIOpenSyncExWrapper(ref pClientConsumerInfo, out ppConn); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -893,14 +833,12 @@ private static uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientCon { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); default: - return SNINativeManagedWrapperX86.SNIOpenWrapper(ref pConsumerInfo, szConnect, pConn, out ppConn, fSync, ipPreference, ref pDNSCachedInfo); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -910,14 +848,12 @@ private static IntPtr SNIPacketAllocateWrapper([In] SafeHandle pConn, IOType IOT { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIPacketAllocateWrapper(pConn, IOType); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIPacketAllocateWrapper(pConn, IOType); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIPacketAllocateWrapper(pConn, IOType); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIPacketAllocateWrapper(pConn, IOType); default: - return SNINativeManagedWrapperX86.SNIPacketAllocateWrapper(pConn, IOType); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -927,14 +863,12 @@ private static uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[] { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); default: - return SNINativeManagedWrapperX86.SNIPacketGetDataWrapper(packet, readBuffer, readBufferLength, out dataSize); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -945,9 +879,6 @@ private static unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, case System.Runtime.InteropServices.Architecture.Arm64: SNINativeManagedWrapperARM64.SNIPacketSetData(pPacket, pbBuf, cbBuf); break; - case System.Runtime.InteropServices.Architecture.Arm: - SNINativeManagedWrapperARM.SNIPacketSetData(pPacket, pbBuf, cbBuf); - break; case System.Runtime.InteropServices.Architecture.X64: SNINativeManagedWrapperX64.SNIPacketSetData(pPacket, pbBuf, cbBuf); break; @@ -955,8 +886,7 @@ private static unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, SNINativeManagedWrapperX86.SNIPacketSetData(pPacket, pbBuf, cbBuf); break; default: - SNINativeManagedWrapperX86.SNIPacketSetData(pPacket, pbBuf, cbBuf); - break; + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -976,14 +906,12 @@ private static unsafe void SNIPacketSetData(SNIPacket pPacket, [In] byte* pbBuf, { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); default: - return SNINativeManagedWrapperX86.SNISecGenClientContextWrapper(pConn, pIn, cbIn, pOut, ref pcbOut, out pfDone, szServerInfo, cbServerInfo, pwszUserName, pwszPassword); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -993,14 +921,12 @@ private static uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIWriteAsyncWrapper(pConn, pPacket); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIWriteAsyncWrapper(pConn, pPacket); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIWriteAsyncWrapper(pConn, pPacket); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIWriteAsyncWrapper(pConn, pPacket); default: - return SNINativeManagedWrapperX86.SNIWriteAsyncWrapper(pConn, pPacket); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -1010,14 +936,12 @@ private static uint SNIWriteSyncOverAsync(SNIHandle pConn, [In] SNIPacket pPacke { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIWriteSyncOverAsync(pConn, pPacket); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIWriteSyncOverAsync(pConn, pPacket); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIWriteSyncOverAsync(pConn, pPacket); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIWriteSyncOverAsync(pConn, pPacket); default: - return SNINativeManagedWrapperX86.SNIWriteSyncOverAsync(pConn, pPacket); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -1027,14 +951,12 @@ private static IntPtr SNIClientCertificateFallbackWrapper(IntPtr pCallbackContex { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIClientCertificateFallbackWrapper(pCallbackContext); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIClientCertificateFallbackWrapper(pCallbackContext); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIClientCertificateFallbackWrapper(pCallbackContext); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIClientCertificateFallbackWrapper(pCallbackContext); default: - return SNINativeManagedWrapperX86.SNIClientCertificateFallbackWrapper(pCallbackContext); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } #endregion @@ -1118,7 +1040,7 @@ internal static uint SniGetConnectionIPString(SNIHandle pConn, ref string connIP internal static uint SNIInitialize() { - return SNIInitialize(LocalAppContextSwitches.UseSystemDefaultSecureProtocols, IntPtr.Zero); + return SNIInitialize(IntPtr.Zero); } internal static IntPtr SNIServerEnumOpen() @@ -1127,14 +1049,12 @@ internal static IntPtr SNIServerEnumOpen() { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIServerEnumOpen(); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIServerEnumOpen(); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIServerEnumOpen(); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIServerEnumOpen(); default: - return SNINativeManagedWrapperX86.SNIServerEnumOpen(); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } internal static int SNIServerEnumRead([In] IntPtr packet, [In, Out] char[] readbuffer, int bufferLength, out bool more) @@ -1143,14 +1063,12 @@ internal static int SNIServerEnumRead([In] IntPtr packet, [In, Out] char[] readb { case System.Runtime.InteropServices.Architecture.Arm64: return SNINativeManagedWrapperARM64.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); - case System.Runtime.InteropServices.Architecture.Arm: - return SNINativeManagedWrapperARM.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); case System.Runtime.InteropServices.Architecture.X64: return SNINativeManagedWrapperX64.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); case System.Runtime.InteropServices.Architecture.X86: return SNINativeManagedWrapperX86.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); default: - return SNINativeManagedWrapperX86.SNIServerEnumRead(packet, readbuffer, bufferLength, out more); + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } @@ -1161,9 +1079,6 @@ internal static void SNIServerEnumClose([In] IntPtr packet) case System.Runtime.InteropServices.Architecture.Arm64: SNINativeManagedWrapperARM64.SNIServerEnumClose(packet); break; - case System.Runtime.InteropServices.Architecture.Arm: - SNINativeManagedWrapperARM.SNIServerEnumClose(packet); - break; case System.Runtime.InteropServices.Architecture.X64: SNINativeManagedWrapperX64.SNIServerEnumClose(packet); break; @@ -1171,8 +1086,7 @@ internal static void SNIServerEnumClose([In] IntPtr packet) SNINativeManagedWrapperX86.SNIServerEnumClose(packet); break; default: - SNINativeManagedWrapperX86.SNIServerEnumClose(packet); - break; + throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs index fdbc830cb6..79c4c8f2eb 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs @@ -8649,6 +8649,15 @@ internal class Strings { } } + /// + /// Looks up a localized string similar to The '{0}' platform is not supported when targeting .NET Framework.. + /// + internal static string SNI_PlatformNotSupportedNetFx { + get { + return ResourceManager.GetString("SNI_PlatformNotSupportedNetFx", resourceCulture); + } + } + /// /// Looks up a localized string similar to HTTP Provider. /// diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx index 66683219cc..2ad076ca84 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx +++ b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx @@ -4626,4 +4626,7 @@ The service principal name (SPN) of the server. - + + The '{0}' platform is not supported when targeting .NET Framework. + + \ No newline at end of file diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index 24f56b4b32..8f48131f8d 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -1421,6 +1421,11 @@ internal static InvalidOperationException ComputerNameEx(int lastError) return InvalidOperation(StringsHelper.GetString(Strings.ADP_ComputerNameEx, lastError)); } + // + // : SNI + // + internal static PlatformNotSupportedException SNIPlatformNotSupported(string platform) => new(StringsHelper.GetString(Strings.SNI_PlatformNotSupportedNetFx, platform)); + // global constant strings internal const float FailoverTimeoutStepForTnir = 0.125F; // Fraction of timeout to use in case of Transparent Network IP resolution. internal const int MinimumTimeoutForTnirMs = 500; // The first login attempt in Transparent network IP Resolution From a00622e9cdd2d1dff012cd9316b953649410f986 Mon Sep 17 00:00:00 2001 From: David Engel Date: Fri, 4 Nov 2022 14:33:15 -0700 Subject: [PATCH 5/7] Remove and sort usings Minor edits --- .../netfx/src/Microsoft.Data.SqlClient.csproj | 2 +- .../src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs | 6 +----- .../netfx/src/Resources/Strings.resx | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index bd09301069..88b0cd276c 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -741,4 +741,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index 4305dd2bce..56a2c9ecff 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -4,19 +4,15 @@ using System; using System.Diagnostics; -using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography.X509Certificates; +using System.Text; using System.Threading; using Microsoft.Data.Common; using Microsoft.Data.SqlClient; -using System.Text; -using System.Net.NetworkInformation; -using System.Drawing; -using System.Net.Sockets; namespace Microsoft.Data.SqlClient { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx index 2ad076ca84..4408ffcf78 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx +++ b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx @@ -4629,4 +4629,4 @@ The '{0}' platform is not supported when targeting .NET Framework. - \ No newline at end of file + From ab2da4c00e7531f62be2289d09a5da481811943e Mon Sep 17 00:00:00 2001 From: David Engel Date: Fri, 4 Nov 2022 18:09:55 -0700 Subject: [PATCH 6/7] Another SNI API mismatch on the netcore side --- .../netcore/src/Interop/SNINativeMethodWrapper.Windows.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs index 87e6e9e19e..210a6fe20d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs @@ -287,7 +287,7 @@ internal struct SNI_Error private static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - private static extern uint SNIInitialize([In] IntPtr pmo); + private static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] private static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); @@ -375,7 +375,7 @@ internal static uint SniGetConnectionIPString(SNIHandle pConn, ref string connIP internal static uint SNIInitialize() { - return SNIInitialize(IntPtr.Zero); + return SNIInitialize(false, IntPtr.Zero); } internal static unsafe uint SNIOpenMarsSession(ConsumerInfo consumerInfo, SNIHandle parent, ref IntPtr pConn, bool fSync, SqlConnectionIPAddressPreference ipPreference, SQLDNSInfo cachedDNSInfo) From 25a7902e021637e42ddb549ee9d95348676813d8 Mon Sep 17 00:00:00 2001 From: Lawrence LCI Date: Tue, 8 Nov 2022 10:11:39 -0800 Subject: [PATCH 7/7] Remove the useSystemDefaultSecureProtocols to keep it compatible with the new SNI version --- .../netcore/src/Interop/SNINativeMethodWrapper.Windows.cs | 4 ++-- .../Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs | 2 +- .../Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs | 2 +- .../Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs | 2 +- .../src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs index 210a6fe20d..87e6e9e19e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs @@ -287,7 +287,7 @@ internal struct SNI_Error private static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] - private static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + private static extern uint SNIInitialize([In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] private static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); @@ -375,7 +375,7 @@ internal static uint SniGetConnectionIPString(SNIHandle pConn, ref string connIP internal static uint SNIInitialize() { - return SNIInitialize(false, IntPtr.Zero); + return SNIInitialize(IntPtr.Zero); } internal static unsafe uint SNIOpenMarsSession(ConsumerInfo consumerInfo, SNIHandle parent, ref IntPtr pConn, bool fSync, SqlConnectionIPAddressPreference ipPreference, SQLDNSInfo cachedDNSInfo) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs index 296eb66a15..50552a3fb3 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperARM64.cs @@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperARM64 internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + internal static extern uint SNIInitialize([In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs index 13e35363a8..f4970e1cda 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs @@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX64 internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + internal static extern uint SNIInitialize([In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs index 5517ba8c0e..6e1a0abf5f 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs @@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX86 internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")] - internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo); + internal static extern uint SNIInitialize([In] IntPtr pmo); [DllImport(SNI, CallingConvention = CallingConvention.Cdecl)] internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index 56a2c9ecff..c9bd6fbc21 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -791,11 +791,11 @@ private static uint SNIInitialize([In] IntPtr pmo) switch (s_architecture) { case System.Runtime.InteropServices.Architecture.Arm64: - return SNINativeManagedWrapperARM64.SNIInitialize(false, pmo); + return SNINativeManagedWrapperARM64.SNIInitialize(pmo); case System.Runtime.InteropServices.Architecture.X64: - return SNINativeManagedWrapperX64.SNIInitialize(false, pmo); + return SNINativeManagedWrapperX64.SNIInitialize(pmo); case System.Runtime.InteropServices.Architecture.X86: - return SNINativeManagedWrapperX86.SNIInitialize(false, pmo); + return SNINativeManagedWrapperX86.SNIInitialize(pmo); default: throw ADP.SNIPlatformNotSupported(s_architecture.ToString()); }