Conversion from unmanaged data to managed.

  • Thread starter Thread starter Eduardo Pavinato Klein
  • Start date Start date
E

Eduardo Pavinato Klein

Hi.

I have a Embedded C++ DLL that exports byte arrays. My export function
header is:

BOOL RSATest_GetKeyPair (BYTE **pubKey, BYTE **privKey, DWORD & dwPubKSize,
DWORD & dwPrivKSize)

How do I do it on the .NET CF?
I don't know how to retrieve byte arrays from unmanaged code.

Thanks,
Eduardo
 
You will need to modify your C++ dll to fill supplied buffers instead of
allocating memory internally and returning pointer:

BOOL RSATest_GetKeyPair (BYTE *pubKey, BYTE *privKey, DWORD & dwPubKSize,
DWORD & dwPrivKSize)
On invoke dwPubKSize and dwPrivKSize should be set to the size of the
supplied buffers and upon return you will set them to the actual data size.
Make sure you check for that the buffers are sufficient

[DllImport("yourdll")]
extern public static bool RSATest_GetKeyPair (byte[] pubKey, byte[] privKey,
ref int dwPubKSize, ref int dwPrivKSize);
 
Back
Top