Win32 callbacks

new topic     » topic index » view thread      » older message » newer message

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

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu