R
Richard A. Lowe
Hi all (sorry I haven't been around lately for those who know me, life
happens
I have to call a native DLL (written > 5 years ago, not by me, and all
source lost) that is currently being called from a Java application also
written about 5 years ago (I think Borland JBuilder 4 was the IDE - Java 1.2
perhaps?). The Java declaration looks like this:
public static native int EncryptStuff(String publicKeyFile, String data,
int dataLength, String encryptedFilePath) throws Exception; {
try { }
catch (Exception excp) {
System.out.println(excp.toString());
}
}
It encrypts a string when passed the public key and the length of the string
and writes it to the encryptedFilePath. I found a signature that can be
successfully called (returns code 0), but it does not produce the same
output file when given the *exact same input data*:
[DllImport("Crypt.dll")]
public static extern int EncryptStuff(
[MarshalAs(UnmanagedType.AnsiBStr)] string publicKeyFile,
[MarshalAs(UnmanagedType.AnsiBStr)] string data,
int dataLength,
[MarshalAs(UnmanagedType.AnsiBStr)] string encryptedFilePath);
I think all other UnmanagedType options on the string parameters cause an
error return code. I do not know how Java marshals its parameters by
default - how can I declare my external function to match the Java one, so I
can produce the same output? What other directions could I take in
approaching this problem? I do not have a debuggable version of the Java
app, but I do have the source files of the public key, data and the output
encrypted file I am trying to create. You help is humbly requested and
greatly needed!
Thanks,
Richard
happens
I have to call a native DLL (written > 5 years ago, not by me, and all
source lost) that is currently being called from a Java application also
written about 5 years ago (I think Borland JBuilder 4 was the IDE - Java 1.2
perhaps?). The Java declaration looks like this:
public static native int EncryptStuff(String publicKeyFile, String data,
int dataLength, String encryptedFilePath) throws Exception; {
try { }
catch (Exception excp) {
System.out.println(excp.toString());
}
}
It encrypts a string when passed the public key and the length of the string
and writes it to the encryptedFilePath. I found a signature that can be
successfully called (returns code 0), but it does not produce the same
output file when given the *exact same input data*:
[DllImport("Crypt.dll")]
public static extern int EncryptStuff(
[MarshalAs(UnmanagedType.AnsiBStr)] string publicKeyFile,
[MarshalAs(UnmanagedType.AnsiBStr)] string data,
int dataLength,
[MarshalAs(UnmanagedType.AnsiBStr)] string encryptedFilePath);
I think all other UnmanagedType options on the string parameters cause an
error return code. I do not know how Java marshals its parameters by
default - how can I declare my external function to match the Java one, so I
can produce the same output? What other directions could I take in
approaching this problem? I do not have a debuggable version of the Java
app, but I do have the source files of the public key, data and the output
encrypted file I am trying to create. You help is humbly requested and
greatly needed!
Thanks,
Richard