diff --git a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs index fc950025174c0..c8aece74e5885 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs @@ -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 Status ImportPrincipalName( 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 Status InitiateCredWithPassword( 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 Status AcceptSecContext( 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( diff --git a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs index 7d1c8874191a9..2ab6998096704 100644 --- a/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs +++ b/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs @@ -52,15 +52,12 @@ public override bool IsInvalid 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 @@ public override bool IsInvalid 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 @@ public override bool IsInvalid 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; } } }