![]() |
calling ...
when I have a function like this
f1(const char *szFmt,...); from which I want to call another function like f2(const char *szFmt,...); from inside f1, writing f2(szFmt) obviously doesnt work ... anybody know how to do it ? |
Re: calling ...
It's a pretty big hack and I'm not sure if it will work on anything but windows...
Code:
#include <stdio.h> |
Re: calling ...
Uhh why do you use the "__declspec( naked )" stuff?
I don't think you need this?(and what the heck is it anyway) |
Re: calling ...
thx
naked tells the compiler that the function should be compiled without any initializing or exiting code, e.g. stack ops etc. |
Re: calling ...
i miss the point of calling a function in a function? :S
|
Re: calling ...
sometimes you wanna do something do some data and then pass the original parameters further to another function, don't you ? the problem here is that you cannot just pass the parameters to the next function, this simply doesnt work, somehow the stack seems to be fucked up then. Therefore a solution would be such a naked function. but since this isnt the most beautiful way to go, gotta think about some other solution.
|
Re: calling ...
Else you can use varargs and concatenate all your szFmt into one single string, that you'll feed to f2 this way. I had the same problem once and that's how I did it.
*edit* code always help Code:
int function1 (const char *fmt, ...) |
Re: calling ...
If you pass say 5 parameters to a function using variable parameters...
main: -------- push 9 push 7 push 3 push 5 push "a string" call Function1 Function1: ------------- push "a string" ( Same one as was passed to us ) call Function2 Function2: ------------- Hopes that the variable arguments are still in the correct order on the stack! Ofcourse that is inaccurate but hopefully it shows that when anything wants to access those variable arguments they may get the address of a string instead since things are popped off the stack in reverse order. Hopefully I'm not too wrong on that so correct me if thats the case. |
All times are GMT +2. The time now is 16:16. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.