The error is because sessionData
is null
. That's because LsaGetLogonSessionData
is failing. To diagnose this further, you need to start paying attention to the return value of the API functions and checking error codes in case of failure. That's your next step.
As an aside, you have declared the count
variable incorrectly. In the C header file it is declared as ULONG
. That's an unsigned 32 bit integer which makes it uint
in C#. I've not checked anything more than this.