Log in

View Full Version : parameters


death
March 20th, 2002, 18:20
if it was written in C++ most likely it uses classes..
when you call a class member function (that is not static), the first parameter pushed is the pointer to the class object (this).. if you notice this somewhere in the executable, it's C++..

[er. this was supposed to be a reply to foxthree's solaris executable question, wrong button pressed]

notbob
March 20th, 2002, 19:12
Quote:
Originally posted by death
if it was written in C++ most likely it uses classes..
when you call a class member function (that is not static), the first parameter pushed is the pointer to the class object (this).. if you notice this somewhere in the executable, it's C++..


This isn't entirely true. Generally speaking, non-static class member functions have their this pointer passed as an implicit argument 0, but it isn't necessarily passed on the stack.

MSVC6 for example passes this in the ECX register. It's a pretty solid hint that that's what is happening when a function uses ECX extensively without first preserving it somewhere.

I know the original post was in reference to Solaris (and presumably a SPARC processor), but my point is to be aware of parameter-passing in registers.

cheers,
-notbob