tags:

views:

47

answers:

1

Given the size of the code of the main function in bytes passed as a parameter to a function, what is the best way to get to the base address for the main code and retrieve the first char * in the argv array?

+3  A: 

There is no portable way to accomplish this. It depends entirely on what platform you are using and what calling convention is used.

That said, the size of the code in main() shouldn't ordinarily have any impact on the layout of the stack because the code is not located on the stack.

The best way to get argv from a function called from main() is to have that function take a const char** as a parameter and pass the argv into it.

James McNellis