First - it appears the function name is sufficient to detect that. Despite that, here are a few nit-picking corrections:

Jerry Jenkins wrote:

Martin Tröster wrote:

How do I find out whether a function uses CDECL instead of STDCALL? I found the information (link lost unfortunately) that entries in the def file like [EMAIL PROTECTED] are called via STDCALL, whereas in case of testfunc2 without any @ specifying the space is CDECL. Is this guess right? If not, how else do I find this out?

The most safe one I have known is to disassemble it and look over the output. If the function have no parameters, you can declare it as either CDECL or STDCALL.


Suppose it have some parameters and its type is CDECL, you can find:
1. "lret" in the function
2. it will be called in a way like
pushl something1
pushl something2
call address of [EMAIL PROTECTED]
addl $8, %%esp

Not necessarily, not by a long shot.
The above is correct if the program was not optimized. Optimizations change EVERYTHING. It is very common to see the "addl" (that pops the arguments from the stack) agregated for several function calls (making it both of the wrong number, and not immediately after the return). The same goes for the "push" - they may be further up. In fact, I have seen cases where an argument was pushed for one function, and then used for another without pop and repush (I suppose this required deeper understanding of the function, as it was it's right to change it on stack).


In other words - you cannot teach assembly pattern recognition in three lines on a mailing list, I'm afraid.

While wer'e nitpicking - function name won't have the "@0".


and for a STDCALL, there are: 1. something that is similar to "lret $8" in the function 2. it will be called in a way like pushl something1 pushl something2 call address of [EMAIL PROTECTED]

Same considerations go here.
While nitpicking - in your case function will have "[EMAIL PROTECTED]", as we pushed two arguments.


--
Shachar Shemesh
Open Source integration consultant
Home page & resume - http://www.shemesh.biz/





Reply via email to