Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackImbalance MDA exception using stdcall calling conversion on both sides

I got pInvokeStackImbalance MDA for some unclear reason

Native code:

extern "C" __declspec(dllexport) __declspec(noinline)  void __stdcall 
Ex(__int64 mask, unsigned long *index)
{
    *index = mask;
}

Managed:

[DllImport("Libr.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int Ex(long mask, out uint index);

...

        uint val;
        long mask = 12;
        NativeWrapper.Ex(mask, out val); // pInvokeStackImbalance MDA here

So as you can see CallingConvention StdCall is using.. what is the reason of that warning here?

like image 869
Brans Ds Avatar asked Feb 20 '26 08:02

Brans Ds


1 Answers

The native function return type is void but your C# code returns int.

like image 94
David Heffernan Avatar answered Feb 21 '26 20:02

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!