Skip to content

Commit

Permalink
Fix inconsistency in p/invoke arguments introduced when switching som…
Browse files Browse the repository at this point in the history
…e to be blittable (#61071)
  • Loading branch information
elinor-fung authored Nov 10, 2021
1 parent 4e3eed5 commit 213020c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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;
}
}
}

0 comments on commit 213020c

Please sign in to comment.