• Getting the address of static function in C

    From Rachit Shah@21:1/5 to All on Fri Apr 20 10:10:43 2018
    Hi,


    Is there any way that I can get the address of a function which is declared static in another file?

    File1.c
    static int func1()
    {

    }


    File2.c
    {
    void *addr;
    addr = getAddressOf("func1");
    }


    void *getAddressOf(char *fn_name)
    {
    /* Magic here */
    }

    My intent is to replace the address of the func1 with the func2, so that whenever the func1 is called from file1, func2 will be invoked.
    Once I get the address.
    I also tried --wrap but it is not working for the static function.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gusti6@gmail.com@21:1/5 to All on Wed May 2 14:09:57 2018
    The intention of static is to keep the function local to File1.c, as far as I know what you want is not possible.

    On Friday, April 20, 2018 at 1:10:46 PM UTC-4, 123sfsdac wrote:
    Hi,


    Is there any way that I can get the address of a function which is declared static in another file?

    File1.c
    static int func1()
    {

    }


    File2.c
    {
    void *addr;
    addr = getAddressOf("func1");
    }


    void *getAddressOf(char *fn_name)
    {
    /* Magic here */
    }

    My intent is to replace the address of the func1 with the func2, so that whenever the func1 is called from file1, func2 will be invoked.
    Once I get the address.
    I also tried --wrap but it is not working for the static function.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)