pInvokeStackImbalance MDA Warning how to fix it
i'm trying to invoke this in my c# application
[DllImport("UOEncryption.dll")]
public static extern void Decompress([In, Out] byte[] dest, byte[] src, out int dest_size, ref int src_size, ref HuffmanObj obj);
[DllImport("UOEncryption.dll")]
public static extern void开发者_如何学JAVA DecompressClean(ref HuffmanObj obj);
the signatures in c are
void Decompress(char *dest, const char *src, int *dest_size, int *src_size, HuffmanObj *obj);
void DecompressClean(HuffmanObj *obj);
I don't know how it's wrong.
Thank you
You forgot the CallingConvention property in the [DllImport] declaration, it is Cdecl in your case. The default is StdCall, that will indeed trigger the MDA warning.
The ref keyword on the HuffmanObj looks wrong too, assuming you declared it as a class instead of a struct. Do try to debug the native code so you can look at the passed argument values and quickly see a problem like this. Project + Properties, Debug tab, Enable unmanaged code debugging checkbox. Set a breakpoint on the first line in the native function body.
精彩评论