mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
9921dd6c77
- Replaces RAII handling of DLLs with global function pointers. (We don't unload the dll this way, but that seems unnecessary anyway). - Simplifies code by just needing to call an init function, but not needing to pass around an object holding the function pointers. - Adds a templated dll loader that takes the dll and a list of name/pointer pairs to load the dll and set the pointers in one shot.
25 lines
552 B
C++
25 lines
552 B
C++
#include "dll.hpp"
|
|
#include <llarp/util/logging.hpp>
|
|
#include <llarp/util/str.hpp>
|
|
|
|
namespace llarp::win32
|
|
{
|
|
namespace
|
|
{
|
|
auto cat = log::Cat("win32-dll");
|
|
}
|
|
|
|
namespace detail
|
|
{
|
|
HMODULE
|
|
load_dll(const std::string& dll)
|
|
{
|
|
auto handle = LoadLibraryExA(dll.c_str(), NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
|
|
if (not handle)
|
|
throw win32::error{fmt::format("failed to load '{}'", dll)};
|
|
log::info(cat, "loaded '{}'", dll);
|
|
return handle;
|
|
}
|
|
} // namespace detail
|
|
} // namespace llarp::win32
|