Discussion:
AcquireCredentialsHandle (PInvoke) returning garbage handle on a 64-bit box
(too old to reply)
dB.
2010-02-10 17:40:15 UTC
Permalink
I can't see anything wrong with my PInvoke declaration for
AcquireCredentialsHandle, but it keeps coming back with garbage for
the credential handle (high part = 0, low part = some number). Both
should be filled.

Anyone has a working sample that uses AcquireCredentialsHandle in C#,
tested on Windows 64bit?

[DllImport("secur32.dll", CharSet = CharSet.Auto)]
public static extern int AcquireCredentialsHandle(
[In] string pszPrincipal,
[In] string pszPackage,
[In] uint fCredentialUse,
[In] IntPtr pvLogonID,
[In] IntPtr pAuthData,
[In] IntPtr pGetKeyFn,
[In] IntPtr pvGetKeyArgument,
[Out] out SecHandle phCredential,
[Out] out SECURITY_INTEGER ptsExpiry);

Thanks,
dB.
dB.
2010-02-11 18:36:25 UTC
Permalink
Found the solution. SecHandle are 2 IntPtrs, not 2 uints.

[StructLayout(LayoutKind.Sequential)]
public struct SecHandle //=PCtxtHandle
{
IntPtr dwLower; // ULONG_PTR translates to IntPtr not to uint
IntPtr dwUpper; // this is crucial for 64-Bit Platforms
}

Loading...