Fix inconsistency in p/invoke arguments introduced when switching some to be blittabl...
authorElinor Fung <elfung@microsoft.com>
Wed, 10 Nov 2021 21:18:43 +0000 (13:18 -0800)
committerGitHub <noreply@github.com>
Wed, 10 Nov 2021 21:18:43 +0000 (13:18 -0800)
src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs

index fc95002..c8aece7 100644 (file)
@@ -11,8 +11,8 @@ internal static partial class Interop
 {
     internal static partial class NetSecurityNative
     {
-        [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseGssBuffer")]
-        internal static extern void ReleaseGssBuffer(
+        [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseGssBuffer")]
+        internal static partial void ReleaseGssBuffer(
             IntPtr bufferPtr,
             ulong length);
 
@@ -42,10 +42,10 @@ internal static partial class Interop
             int inputNameByteCount,
             out SafeGssNameHandle outputName);
 
-        [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseName")]
-        internal static unsafe extern Status ReleaseName(
-            Status* minorStatus,
-            IntPtr* inputName);
+        [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseName")]
+        internal static partial Status ReleaseName(
+            out Status minorStatus,
+            ref IntPtr inputName);
 
         [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcquireAcceptorCred")]
         internal static partial Status AcquireAcceptorCred(
@@ -67,10 +67,10 @@ internal static partial class Interop
             int passwordLen,
             out SafeGssCredHandle outputCredHandle);
 
-        [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseCred")]
-        internal static unsafe extern Status ReleaseCred(
-            Status* minorStatus,
-            IntPtr* credHandle);
+        [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseCred")]
+        internal static partial Status ReleaseCred(
+            out Status minorStatus,
+            ref IntPtr credHandle);
 
         [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContext")]
         internal static partial Status InitSecContext(
@@ -113,10 +113,10 @@ internal static partial class Interop
             out uint retFlags,
             out bool isNtlmUsed);
 
-        [DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")]
-        internal static unsafe extern Status DeleteSecContext(
-            Status* minorStatus,
-            IntPtr* contextHandle);
+        [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")]
+        internal static partial Status DeleteSecContext(
+            out Status minorStatus,
+            ref IntPtr contextHandle);
 
         [GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_GetUser")]
         internal static partial Status GetUser(
index 7d1c887..2ab6998 100644 (file)
@@ -52,15 +52,12 @@ namespace Microsoft.Win32.SafeHandles
             get { return handle == IntPtr.Zero; }
         }
 
-        protected override unsafe bool ReleaseHandle()
+        protected override bool ReleaseHandle()
         {
             Interop.NetSecurityNative.Status minorStatus;
-            fixed (IntPtr* handleRef = &handle)
-            {
-                Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(&minorStatus, handleRef);
-                SetHandle(IntPtr.Zero);
-                return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
-            }
+            Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(out minorStatus, ref handle);
+            SetHandle(IntPtr.Zero);
+            return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
         }
 
         public SafeGssNameHandle()
@@ -144,15 +141,12 @@ namespace Microsoft.Win32.SafeHandles
             get { return handle == IntPtr.Zero; }
         }
 
-        protected override unsafe bool ReleaseHandle()
+        protected override bool ReleaseHandle()
         {
             Interop.NetSecurityNative.Status minorStatus;
-            fixed (IntPtr* handlePtr = &handle)
-            {
-                Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(&minorStatus, handlePtr);
-                SetHandle(IntPtr.Zero);
-                return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
-            }
+            Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(out minorStatus, ref handle);
+            SetHandle(IntPtr.Zero);
+            return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
         }
 
         private static bool InitIsNtlmInstalled()
@@ -176,12 +170,9 @@ namespace Microsoft.Win32.SafeHandles
         protected override unsafe bool ReleaseHandle()
         {
             Interop.NetSecurityNative.Status minorStatus;
-            fixed (IntPtr* handlePtr = &handle)
-            {
-                Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(&minorStatus, handlePtr);
-                SetHandle(IntPtr.Zero);
-                return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
-            }
+            Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(out minorStatus, ref handle);
+            SetHandle(IntPtr.Zero);
+            return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
         }
     }
 }