Changing Windows DLL load order? (load order, not search order)

前端 未结 4 1434
半阙折子戏
半阙折子戏 2021-02-07 11:15

Say I have one executable: app.exe

I use 2 different 3rd party DLLs in this executable: foo.dll bar.dll and the Application must l

4条回答
  •  孤城傲影
    2021-02-07 12:02

    Here's an idea: How about marking them as "Delay Loaded dlls" in the linker options of app.exe?

    Delay-loading will allow you to link "statically" (i.e. without LoadLibrary() et.al) but will not load the DLL and do the linking until it's actually needed.

    If that is an option, then (assuming you can wait so long, i.e. do not access foo/bar dll functions before main()), you could, in main(), access a function (just fetch a function ptr or something) in foo.dll first, which would load it and bind all "statically" linked functions?

    (Maybe LoadLibrary() triggers the same link-when-needed procedure. Not sure. It would look cleaner in your code though.)

提交回复
热议问题