@@ -17,17 +17,17 @@ namespace Microsoft.Data.SqlClient
17
17
{
18
18
internal static class SniNativeWrapper
19
19
{
20
- #if NETFRAMEWORK
20
+ #if NETFRAMEWORK
21
21
private static readonly ISniNativeMethods NativeMethods = RuntimeInformation . ProcessArchitecture switch
22
22
{
23
23
Architecture . Arm64 => new SniNativeMethodsArm64 ( ) ,
24
24
Architecture . X64 => new SniNativeMethodsX64 ( ) ,
25
25
Architecture . X86 => new SniNativeMethodsX86 ( ) ,
26
26
_ => new SniNativeMethodsNotSupported ( RuntimeInformation . ProcessArchitecture )
27
27
} ;
28
- #else
28
+ #else
29
29
private static readonly ISniNativeMethods NativeMethods = new SniNativeMethods ( ) ;
30
- #endif
30
+ #endif
31
31
32
32
private static int s_sniMaxComposedSpnLength = - 1 ;
33
33
@@ -47,7 +47,7 @@ internal static int SniMaxComposedSpnLength
47
47
}
48
48
}
49
49
50
- #if NETFRAMEWORK
50
+ #if NETFRAMEWORK
51
51
static AppDomain GetDefaultAppDomainInternal ( )
52
52
{
53
53
return AppDomain . CurrentDomain ;
@@ -85,10 +85,10 @@ internal unsafe static void SetData(Byte[] data)
85
85
SqlDependencyProcessDispatcherStorage . NativeSetData ( pin_dispatcher , data . Length ) ;
86
86
}
87
87
}
88
- #endif
88
+ #endif
89
89
90
90
#region DLL Imports
91
-
91
+
92
92
internal static uint SNIAddProvider ( SNIHandle pConn , Provider ProvNum , [ In ] ref uint pInfo ) =>
93
93
NativeMethods . SniAddProvider ( pConn , ProvNum , ref pInfo ) ;
94
94
@@ -146,10 +146,10 @@ private static uint GetSniMaxComposedSpnLength() =>
146
146
private static uint SNIGetInfoWrapper ( [ In ] SNIHandle pConn , QueryType QType , out Guid pbQInfo ) =>
147
147
NativeMethods . SniGetInfoWrapper ( pConn , QType , out pbQInfo ) ;
148
148
149
- #if NETFRAMEWORK
149
+ #if NETFRAMEWORK
150
150
private static uint SNIGetInfoWrapper ( [ In ] SNIHandle pConn , QueryType QType , [ MarshalAs ( UnmanagedType . Bool ) ] out bool pbQInfo ) =>
151
151
NativeMethods . SniGetInfoWrapper ( pConn , QType , out pbQInfo ) ;
152
- #endif
152
+ #endif
153
153
154
154
private static uint SNIGetInfoWrapper ( [ In ] SNIHandle pConn , QueryType QType , out ushort portNum ) =>
155
155
NativeMethods . SniGetInfoWrapper ( pConn , QType , out portNum ) ;
@@ -191,11 +191,11 @@ private static uint SNIPacketGetDataWrapper([In] IntPtr packet, [In, Out] byte[]
191
191
192
192
private static unsafe void SNIPacketSetData ( SNIPacket pPacket , [ In ] byte * pbBuf , uint cbBuf ) =>
193
193
NativeMethods . SniPacketSetData ( pPacket , pbBuf , cbBuf ) ;
194
-
194
+
195
195
private static unsafe uint SNISecGenClientContextWrapper (
196
196
[ In ] SNIHandle pConn ,
197
197
[ In , Out ] ReadOnlySpan < byte > pIn ,
198
- [ In , Out ] byte [ ] pOut ,
198
+ [ In , Out ] Span < byte > pOut ,
199
199
[ In ] ref uint pcbOut ,
200
200
[ MarshalAsAttribute ( UnmanagedType . Bool ) ]
201
201
out bool pfDone ,
@@ -207,12 +207,13 @@ private static unsafe uint SNISecGenClientContextWrapper(
207
207
string pwszPassword )
208
208
{
209
209
fixed ( byte * pInPtr = pIn )
210
+ fixed ( byte * pOutPtr = pOut )
210
211
{
211
212
return NativeMethods . SniSecGenClientContextWrapper (
212
213
pConn ,
213
214
pInPtr ,
214
215
( uint ) pIn . Length ,
215
- pOut ,
216
+ pOutPtr ,
216
217
ref pcbOut ,
217
218
out pfDone ,
218
219
szServerInfo ,
@@ -227,7 +228,7 @@ private static uint SNIWriteAsyncWrapper(SNIHandle pConn, [In] SNIPacket pPacket
227
228
228
229
private static uint SNIWriteSyncOverAsync ( SNIHandle pConn , [ In ] SNIPacket pPacket ) =>
229
230
NativeMethods . SniWriteSyncOverAsync ( pConn , pPacket ) ;
230
-
231
+
231
232
internal static IntPtr SNIServerEnumOpen ( ) =>
232
233
NativeMethods . SniServerEnumOpen ( ) ;
233
234
@@ -236,11 +237,11 @@ internal static void SNIServerEnumClose([In] IntPtr packet) =>
236
237
237
238
internal static int SNIServerEnumRead (
238
239
[ In ] IntPtr packet ,
239
- [ In ] [ MarshalAs ( UnmanagedType . LPArray ) ] char [ ] readBuffer ,
240
+ [ In ] [ MarshalAs ( UnmanagedType . LPArray ) ] char [ ] readBuffer ,
240
241
[ In ] int bufferLength ,
241
242
[ MarshalAs ( UnmanagedType . Bool ) ] out bool more ) =>
242
243
NativeMethods . SniServerEnumRead ( packet , readBuffer , bufferLength , out more ) ;
243
-
244
+
244
245
#endregion
245
246
246
247
internal static uint SniGetConnectionId ( SNIHandle pConn , ref Guid connId )
@@ -303,12 +304,12 @@ internal static unsafe uint SNIOpenSyncEx(
303
304
bool fSync ,
304
305
int timeout ,
305
306
bool fParallel ,
306
-
307
- #if NETFRAMEWORK
307
+
308
+ #if NETFRAMEWORK
308
309
Int32 transparentNetworkResolutionStateNo ,
309
310
Int32 totalTimeout ,
310
- #endif
311
-
311
+ #endif
312
+
312
313
SqlConnectionIPAddressPreference ipPreference ,
313
314
SQLDNSInfo cachedDNSInfo ,
314
315
string hostNameInCertificate )
@@ -330,7 +331,7 @@ internal static unsafe uint SNIOpenSyncEx(
330
331
clientConsumerInfo . timeout = timeout ;
331
332
clientConsumerInfo . fParallel = fParallel ;
332
333
333
- #if NETFRAMEWORK
334
+ #if NETFRAMEWORK
334
335
switch ( transparentNetworkResolutionStateNo )
335
336
{
336
337
case ( 0 ) :
@@ -344,10 +345,10 @@ internal static unsafe uint SNIOpenSyncEx(
344
345
break ;
345
346
} ;
346
347
clientConsumerInfo . totalTimeout = totalTimeout ;
347
- #else
348
+ #else
348
349
clientConsumerInfo . transparentNetworkResolution = TransparentNetworkResolutionMode . DisabledMode ;
349
350
clientConsumerInfo . totalTimeout = SniOpenTimeOut ;
350
- #endif
351
+ #endif
351
352
352
353
clientConsumerInfo . isAzureSqlServerEndpoint = ADP . IsAzureSqlServerEndpoint ( constring ) ;
353
354
@@ -374,7 +375,7 @@ internal static unsafe uint SNIOpenSyncEx(
374
375
}
375
376
}
376
377
377
- #if NETFRAMEWORK
378
+ #if NETFRAMEWORK
378
379
[ ResourceExposure ( ResourceScope . None ) ]
379
380
[ ResourceConsumption ( ResourceScope . Machine , ResourceScope . Machine ) ]
380
381
internal static uint SNIAddProvider ( SNIHandle pConn ,
@@ -397,7 +398,7 @@ internal static uint SNIAddProvider(SNIHandle pConn,
397
398
398
399
return ret ;
399
400
}
400
- #endif
401
+ #endif
401
402
402
403
internal static void SNIPacketAllocate ( SafeHandle pConn , IoType IOType , ref IntPtr pPacket )
403
404
{
@@ -417,7 +418,7 @@ internal static unsafe void SNIPacketSetData(SNIPacket packet, byte[] data, int
417
418
}
418
419
}
419
420
420
- #if NETFRAMEWORK
421
+ #if NETFRAMEWORK
421
422
//[ResourceExposure(ResourceScope::None)]
422
423
//
423
424
// Notes on SecureString: Writing out security sensitive information to managed buffer should be avoid as these can be moved
@@ -541,10 +542,10 @@ Int32[] passwordOffsets // Offset into data buffer where the password to be w
541
542
}
542
543
}
543
544
}
544
- #endif
545
+ #endif
545
546
546
547
547
- internal static unsafe uint SNISecGenClientContext ( SNIHandle pConnectionObject , ReadOnlySpan < byte > inBuff , byte [ ] OutBuff , ref uint sendLength , byte [ ] serverUserName )
548
+ internal static unsafe uint SNISecGenClientContext ( SNIHandle pConnectionObject , ReadOnlySpan < byte > inBuff , Span < byte > OutBuff , ref uint sendLength , byte [ ] serverUserName )
548
549
{
549
550
fixed ( byte * pin_serverUserName = & serverUserName [ 0 ] )
550
551
//netcore fixed (byte* pInBuff = inBuff)
0 commit comments