Win32 callbacks
- Posted by Daniel Berstein <daber at PAIR.COM> Oct 25, 1998
- 444 views
This might be a question to Rob but maybe someone else has the answer or is interested on the subject. I'm trying to do some DLL's to extend (greatly) Euphoria functionality. I'm coding this stuff on Delphi (version 3). Everything is fine when my Eu program calls the DLL. I need the DLL to callback one function on the Eu program (event handlers). I use something like: [on exw program] <link dll ... etc> integer cb procedure callback -- Our callback procedure <do something> return --(*) end procedure SomeDllProcedure(cb) -- Call dll procedure to test our -- callback [on dll code (delphi)] type CallBackProcedure : procedure; stdcall; <other declarations...> var MyCallBack : CallBackProcedure; SomeDllProcedure (cb: pointer); sdtcall; begin MyCallBack := cb; {Asign callback address} MyCallBack; {Call callback procedure} end; The DLL does call and execute the Euphoria code, but when we reach the return statement (*) I get a Windows error like: Application error: test.exe (or exw.exe if unbouded) The instruction at 00580354 referenced memory at bffffffff The memory could not be written. Click Ok.... blah, blah, blah. I tracked the bug in between Euphoria returns the control to the DLL and the DLL getting the control from Euphoria. I supposed it had something to do with calling conventions, but tried all (register, pascal, cdecl, stdcall, safecall) with the same result. So the question is: Is this an Euphoria limitation or a Delphi one? Has anyone got this problem with other laguages (C/C++?)? Regards, Daniel Berstein daber at pair.com