View Single Post
Old 09-09-2005, 08:41 AM   #1 (permalink)
TheSheep
Registered User
 
TheSheep's Avatar
 
Join Date: Mar 2005
Location: UK
Posts: 11
TheSheep is on a distinguished road
Send a message via ICQ to TheSheep Send a message via AIM to TheSheep Send a message via MSN to TheSheep Send a message via Yahoo to TheSheep
[Win32] Stack basics?

I'd like to know whether each thread in an application gets its own stack space that isn't modified by other applications. I'd also like to confirm that parameters to functions are sent to the functions by being pushed onto the stack in reverse order and popped off in the correct order. To illustrate my point, are these two statements essentially the same?
Code:
ExecuteMyFunction(param1,param2,param3);

and

__asm
   {
   push param3
   push param2
   push param1
   call ExecuteMyFunction
   }
The reason is that I'm trying to make a printf-style function that outputs in a different way. It's defined (very simplified) as follows:
Code:
//ignore amtldlm :D
void Message(void *amtldlm,char *stri,...)
{
printf("Message: ");
printf(stri); //other parameters still sitting on stack
printf("\n");
}
The idea is that the user passes a printf-format string (stri) and any additional parameters. The additional params are never retrieved so should be one the stack, right?
Looking at stdarg.h, it looks instead like each parameter is just copied side-by-side into memory; in which case is there some way (easier than parsing the string and using va_arg) that I can transfer the extra parameters from one function to the other?

Rgds.
TheSheep is offline   Reply With Quote