Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

DLL calling its own functions?

Can a Windows DLL exported function call another exported function of the same DLL? For example:

__declspec(dllexport) int __cdecl Function1();

__declspec(dllexport) int __cdecl Function2();

....

__declspec(dllexport) int __cdecl Function1() { return Function2(); }

__declspec(dllexport) int __cdecl Function2() { return 102; }

Most importantly, if this IS allowed. Is the call made by Function1 to Function2 done directly, or would it be called via the current process's JMP table for the DLL.

1 Answer

Relevance
  • 10 years ago
    Favorite Answer

    The answer to the first question is yes, no problem for a DLL to call it's exported functions.

    There is no guarantee that the call will be made through the jump table (aka the IAT).

    One scenario where it definitely won't call through the jump table is if the compiler decides to inline the call, which it is free to do.

    If you compile the above code in release mode with VS2010, the generated code for Function1 is:

    mov eax,102

    ret

    So, no call through the jump table there.

Still have questions? Get your answers by asking now.