Hi,
i've a "C" dll which has 5 input parameters and 4 output parameters
i.e.
WARRANTS_API int ValidateUserCertificate(char *UserIP, char *PrimaryOCSP, char *SecondaryOCSP, char *PrimaryRegistry, char *SecondaryRegistry,
char *CertHash, char *CertData, char *EDIPI, char *ErrMsg);
last 4 are the output parameters and
i) CertHash should be at least 72 bytes in size.
ii) CertData should be 4000 bytes in size
iii) EDIPI must be 1024 bytes or bigger
iv) ErrMsg should be at least 4000 bytes in size.
now i've written the C# CODE AS FOLLOWS
[DllImport(@"warrants.dll", EntryPoint = "ValidateUserCertificate",
ExactSpelling = true,CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int ValidateUserCertificate(String S1, String S2, String S3, String S4, String S5,
[MarshalAs(UnmanagedType.LPTStr)] String S6, [MarshalAs(UnmanagedType.LPTStr)] String S7,
[MarshalAs(UnmanagedType.LPTStr)] String S8, [MarshalAs(UnmanagedType.LPTStr)] String S9);
-----------------------------------------
i've C# like this:
byte[] byteHash = new byte[75];
byte[] byteData = new byte[4000];
byte[] byteMsg = new byte[2048];
byte[] byteDId = new byte[1024];
string CertHash;
string CertData;
string ErrMsg;
string DodId;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
CertHash = enc.GetString(byteHash);
CertData = enc.GetString(byteData);
ErrMsg = enc.GetString(byteMsg);
DodId = enc.GetString(byteDId);
int HostValue = ValidCertificate.ValidateUserCertificate(str1, str2, str3, str4, str5 , CertHash, CertData, DodId, ErrMsg);
When i call this it gives me error saying
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
please help
how do i solve it