This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: dll question


Tim Newsham wrote:
> This much seems to work properly.  I am having problems, however, when
> I try to actually call one of the procedures.  The stack pointer (esp)
> seems to be incorrect after a call to the procedure.  In particular
> I am passing in 3 4-byte arguments (12 bytes).  The emitted code
> looks like:
> 
>     <push args>
>     call *%ebx
>     addl %0xc, %esp
> 

You have to declare called functions as __stdcall. For example:

int __stdcall (*fptr)(int a, int b, int c);

...
fptr = GetProcAddress(dllhandle, "functionname");
(*fptr)(par1, par2, par3);

This case the emitted code will look like:
<push args>
call *%ebx

Stdcall function removes from stack pushed arguments itself.

-- 
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]