I have a c++ function to be exported as a .dll to use:
static __declspec(dllexport) void DiagEncrypt(
UCHAR * ptrDataByte,
size_t numBytes,
ACCESS_LEVEL accLevel);
void DiagnosticCrypto::DiagEncrypt(UCHAR * ptrDataByte, size_t numBytes, ACCESS_LEVEL accLevel)
And I import it in my C# program:
[DllImport("DiagnosticCryptoDll.dll", EntryPoint = "?DiagEncrypt@DiagnosticCrypto@DiagnosticCryptoDll@@SAXPAEIW4ACCESS_LEVEL@12@@Z", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
static extern void DiagEncrypt(
//[MarshalAs(UnmanagedType.LPArray)] byte[] data,
IntPtr data,
uint numBytes, //UintPtr numBytes,
ACCESS_LEVEL accLevel);
when I execute it, there's an error of unbalanced stack.
Can somebody help me to figure out where the error is?
The marked part is what I have tried but it failed.