- Joined
- Apr 7, 2009
- Messages
- 647
- Reaction score
- 26
Apparently, I keep getting P/Invoke problems with this code...I'm gonna guess that it's cuz my imported parameter type is incorrect.
Could anyone help me?
C++
C#
Could anyone help me?
C++
Code:
#ifdef __cplusplus
extern "C"
{
#endif
byte tDESKey[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
const int blockSize = 8;
__declspec(dllexport) void getNextIV(byte * iv)
{
byte newIV[blockSize];
if(iv == NULL)
{
printf("Hello, World!");//Testing
}
}
#ifdef __cplusplus
}
#endif
C#
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;
namespace CPPCryptoTest
{
class Program
{
[DllImport("Stuff.dll")]
static extern void getNextIV(ref byte[] b);
static void Main(string[] args)
{
byte[] b = new byte[8];
//The line below causes a P/Invoke exception
getNextIV(ref b);//This should output "Hello, World!"
Console.ReadLine();
}
}
}
Last edited:

