|
-
Sep 1st, 2007, 10:05 PM
#1
Thread Starter
Frenzied Member
Get Function Size?
How do you get a functions size? I know you get its location by doing &func but what about the size?
-
Sep 2nd, 2007, 09:17 AM
#2
Re: Get Function 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?
-
Sep 3rd, 2007, 08:52 AM
#3
Thread Starter
Frenzied Member
Re: Get Function Size?
 Originally Posted by twanvl
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.
-
Sep 3rd, 2007, 09:14 AM
#4
Re: Get Function Size?
Instead of injecting a dll I would rather inject a function from my program.
This is simply not possible. Just use a dll.
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|