Help for use WinStationShadow Win32 function #1124
-
I would like to use the WinStationShadow function in my small project. I would like to write a console RDP shadow switch utility. I found the Process Hacker use this function. See: https://github.com/processhacker/processhacker/blob/master/ProcessHacker/sessshad.c (at line 215) My POC code:
But I get True as WinStationShadow result, and Win32 last error: 120 (This function is not supported on this system.) I tested on same machine and with same (source/target) session and with same user account as like tested with Process Hacker. My shadow switching drop the error above, until Process Explorer shadow switch working as expected. What I wrong? Thank you for suggestion... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
C# boolean is 4 bytes, C boolean is 1 byte. Your dllimport is missing
Your dllimport is missing
Don't cast C# chars (UTF16) to C chars (ANSI).
Fix the type mashaling:
Use the correct types:
|
Beta Was this translation helpful? Give feedback.
C# boolean is 4 bytes, C boolean is 1 byte. Your dllimport is missing
MarshalAs(UnmanagedType.I1)
so that result is incorrect.Your dllimport is missing
SetLastError = true
. C# interop won't return the error code for the dllimport without it.Don't cast C# chars (UTF16) to C chars (ANSI).
Fix the type mashaling:
Use the correct types: