// Copyright (C) 2014 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include #include #include #include NzDynLibImpl::NzDynLibImpl(NzDynLib* parent) { NazaraUnused(parent); } NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol, NzString* errorMessage) const { NzDynLibFunc sym = reinterpret_cast(GetProcAddress(m_handle, symbol.GetConstBuffer())); if (!sym) *errorMessage = NzError::GetLastSystemError(); return sym; } bool NzDynLibImpl::Load(const NzString& libraryPath, NzString* errorMessage) { NzString path = libraryPath; if (!path.EndsWith(".dll")) path += ".dll"; std::unique_ptr wPath(path.GetWideBuffer()); m_handle = LoadLibraryExW(wPath.get(), nullptr, (NzFile::IsAbsolute(path)) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0); if (m_handle) return true; else { *errorMessage = NzError::GetLastSystemError(); return false; } } void NzDynLibImpl::Unload() { FreeLibrary(m_handle); }