C#C
C#3y ago
JimmahDean

❔ P/Invoked DeviceIoControl() works in C++ but does nothing in C#.

Code is attached.

I have scoured this for hours upon hours and cross checked the pointers with the working C++ version and everything matches. The call doesn't error, checking LastWin32Error, LastSystemError and LastPInvokeError all return "The operation completed successfully." and the return length of the data retrieved is the same in C# as it is in C++, even checked in ProcMon that both apps were making the same system calls and they are. The call happens successfully as it should, but zero data is retrieved in the C# version.

I'm at my wits end here.
Program.cs10.02KB
Was this page helpful?