problem calling Delphi dll

caelum

New Member
:confused: Hello Peggers,
I have a problem calling a Delphi ddl (AESign.dll) made by a 3-rd party.
De function in the dll:
function AESign(PEM, PassWord, XML, MsgTxt: PChar; var XMLSize, MsgSize: word): word; external 'AESign.dll';

If i use the code below, i'll get error (6069) : 'C' call Stack has been compromised after calling AESign in AESign.dll.
I don't think it is the callingconvention, because i already use CDECL.
i'm afraid that i dont use the right datatypes for the Delphi equivalents PChar and word, but i'm not sure.
Can anyone help me?
Best regards,
Jeronimo

My Progress code:
define var c_cert as char initial 'test key'.

define var c_xml as char initial 'test xml string' no-undo.

define var c_wachtw as char initial 'whoami' no-undo.

&SCOPED-DEFINE XMLDATA_LENGTH 500
&SCOPED-DEFINE MSGDATA_LENGTH 100

define variable msgsize as integer no-undo.
define variable xmlsize as integer no-undo.

define variable w-Return as integer no-undo.
define variable ptr-xmlData as memptr no-undo.
define variable ptr-password as memptr no-undo.
define variable ptr-msg as memptr no-undo.
define variable ptr-cert as memptr no-undo.


/* Alloceren variabelen */
set-size(ptr-xmlData) = length(c_xml) + {&XMLDATA_LENGTH} + 1.
set-size(ptr-password) = length(c_wachtw) + 1.
set-size(ptr-msg) = {&MSGDATA_LENGTH} + 1.
set-size(ptr-cert) = length(c_cert) + 1.

put-string(ptr-xmlData, 1) = c_xml.
put-string(ptr-password, 1) = c_wachtw.
put-string(ptr-cert, 1) = c_cert.
/* Set up variables */
ASSIGN msgsize = {&MSGDATA_LENGTH}
xmlsize = length(c_xml) + {&XMLDATA_LENGTH}.

run AEsign(ptr-cert,
ptr-password,
input-output ptr-xmldata,
input-output ptr-msg,
xmlsize,
msgsize,
output w-Return) .

/* Release allocated memory */
set-size(ptr-xmlData) = 0.
set-size(ptr-password) = 0.
set-size(ptr-msg) = 0.
set-size(ptr-cert) = 0.

/* Check for errors */
IF w-Return NE 0 THEN DO:
message "FOUT " get-string(ptr-msg, 1) view-as alert-box.
RETURN.
END.

PROCEDURE AESign EXTERNAL "AESign.dll" CDECL:
define input parameter PEM as memptr. /* private Key from .cer */
define input parameter Pass as memptr. /* password .cer */
define input-output parameter XML as memptr. /* input xml string. output xml string + header made in dll */
define input-output parameter MSG as memptr. /* input empty. output error message */
define input parameter sizexml as short. /* lengte xml */
define input parameter sizemsg as short. /* lengte xml */
define return parameter iResult as short. /* 2 = less memory, 0 = Ok */
 
Back
Top