Are you tracing through the disassembled code with the debugger?  It's been
a long time since I did this but I'll give you what I remember.

In your example, first the the options variable is pushed on the stack, then
the address of db_handle.  Then the function is called.  In the function
itself, ESP is saved in EBP and ESP is adjusted to make room for the
function's local variables.  At this point parameters passed to the function
are above EBP and are referenced as EBP+x, local variables are below EBP and
referenced as EBP-x.  The first parameter (db_handle) is probably at EBP+8.

The returned value is passed back in the EAX register.

This all comes from my dos/windows experience - I don't know how well it
translates to Linux.

Patrick McCabe

----- Original Message -----
From: Joshua b. Jore <josh at greentechnologist.org>
To: <tclug-list at mn-linux.org>
Sent: Thursday, October 11, 2001 7:14 AM
Subject: [TCLUG] [OT] C argument passing?


> So this isn't really a Linux question but I haven't turned up much that's
> useful from stuff like google. (there are just too many things that aren't
> the right answer). I'm trying to figure out how to use some parts of the
> Lotus Notes' undocumented API and while I can get down with a debugger to
> exactly where the code goes through I'm not sure where exactly to look for
> the various parts of a call like:
>
> int my_func(unsigned int* db_handle, unsigned int options);
>
> I assume I should be looking at everything from ESP to ESI? Or maybe ESP
> to EBP? I dunno. And where does that return int get put? Arg. Ideas?
>
> (and yes, I'm only intel right now)
>
> Joshua Jore
> Minneapolis Ward 3, precinct 10
>
> _______________________________________________
> Twin Cities Linux Users Group Mailing List - Minneapolis/St. Paul,
Minnesota
> http://www.mn-linux.org
> tclug-list at mn-linux.org
> https://mailman.mn-linux.org/mailman/listinfo/tclug-list
>