Results 1 to 4 of 4

Thread: Get Function Size?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Get Function Size?

    How do you get a functions size? I know you get its location by doing &func but what about the size?

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    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?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: Get Function Size?

    Quote 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.

  4. #4
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    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
  •  



Click Here to Expand Forum to Full Width