2015-08-10 15:45:56 +10:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2015-08-10 15:45:56 +10:00
|
|
|
*
|
|
|
|
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "library_win32.hpp"
|
|
|
|
|
2017-12-18 15:46:52 +11:00
|
|
|
#include "win32/except.hpp"
|
2015-08-10 15:45:56 +10:00
|
|
|
|
|
|
|
using util::detail::win32::library;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2016-11-17 18:07:57 +11:00
|
|
|
library::library (const std::experimental::filesystem::path &path):
|
2016-10-08 17:18:04 +11:00
|
|
|
m_handle (LoadLibraryA (path.c_str ()))
|
2015-08-10 15:45:56 +10:00
|
|
|
{
|
|
|
|
if (!m_handle)
|
2017-12-18 15:46:52 +11:00
|
|
|
win32::error::throw_code ();
|
2015-08-10 15:45:56 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
library::~library ()
|
|
|
|
{
|
|
|
|
FreeLibrary (m_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void*
|
|
|
|
library::symbol (const char *name)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<void*> (GetProcAddress (m_handle, name));
|
|
|
|
}
|