How do you get a functions size? I know you get its location by doing &func but what about the size?
Printable View
How do you get a functions size? I know you get its location by doing &func but what about the size?
What do you mean by function size? The number of bytes the assembly code takes up? What about internal calls to other functions, data used, etc. ?
There is no guarantee that &func gets you the location of the function in memory. It could just be a handle, a hash to look up in a table or whatever. Your program could be for instance running in an interpreter, the function you are making a pointer to may not even exist in memory. That most (all?) implementations choose to give you a memory location doesn't mean it is a requirement.
The only guarantees you get from &func is that you can call it, and (therefore) that it is different from &other_func.
Now the question is: Why do you want to know the size of a function? What are you trying to do?
Instead of injecting a dll I would rather inject a function from my program.Quote:
Originally Posted by twanvl
This is simply not possible. Just use a dll.Quote:
Instead of injecting a dll I would rather inject a function from my program.
Would there by any advantage of injecting a single function (aside from not having two separate files)? The function would be injected into another process' address space, so you can no longer refer to variables in your program. The functional would also need to be relocated, because any internal pointers it has may no longer be valid. And what about any functions called by your function? Library functions? Function calls inserted by the compiler? Exception handling?