In Microsoft C++ and C, on 32 and 64-bit builds a long is only 32 bits.
However, in C# a long is always 64 bits.
So what I think is happening is that some of the bytes of the two 64 bit longs that are pushed onto the stack by the C# call are being popped off as the Data*
in the C++.
Because the second parameter you're pushing is 0, it so happens that bytes with value 0 are being used for the pointer, hence it is null.
Change the declaration to int
instead of long
to solve your problem.