While updating a third party library to work correctly on x64 (it's using int for pointers), I was looking at the P/Invoke signatures.
One of them requires
__out LPSCARDCONTEXT phContext
This is defined in WinSCard.h
typedef ULONG_PTR SCARDCONTEXT;
typedef SCARDCONTEXT *PSCARDCONTEXT, *LPSCARDCONTEXT;
I'm not really familiar with C++, so correct me if I'm wrong. This means LPSCARDCONTEXT is a pointer to a ULONG_PTR, which is a pointer too. This also explains why IntPtr phContext doesn't work and ref IntPtr phContext does work, in the P/Invoke signature.
I'm confused by the design. Why is a pointer to a pointer needed/used?