Files

82 lines
2.6 KiB
C++

/*
* Copyright 2020 Andrey Semashev
*
* Distributed under the Boost Software License, Version 1.0.
* See http://www.boost.org/LICENSE_1_0.txt
*/
#ifndef ACTIV_BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_
#define ACTIV_BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_
#include <ActivBoost/winapi/basic_types.hpp>
#ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM
#include <ActivBoost/winapi/detail/header.hpp>
#if !defined(ACTIV_BOOST_USE_WINDOWS_H)
namespace Boost { namespace winapi {
#ifdef _WIN64
typedef INT_PTR_ (ACTIV_BOOST_WINAPI_WINAPI_CC *FARPROC_)();
typedef INT_PTR_ (ACTIV_BOOST_WINAPI_WINAPI_CC *NEARPROC_)();
typedef INT_PTR_ (ACTIV_BOOST_WINAPI_WINAPI_CC *PROC_)();
#else
typedef int (ACTIV_BOOST_WINAPI_WINAPI_CC *FARPROC_)();
typedef int (ACTIV_BOOST_WINAPI_WINAPI_CC *NEARPROC_)();
typedef int (ACTIV_BOOST_WINAPI_WINAPI_CC *PROC_)();
#endif // _WIN64
}} // namespace Boost::winapi
extern "C" {
#if !defined(UNDER_CE)
ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::FARPROC_ ACTIV_BOOST_WINAPI_WINAPI_CC
GetProcAddress(Boost::winapi::HMODULE_ hModule, Boost::winapi::LPCSTR_ lpProcName);
#else
// On Windows CE there are two functions: GetProcAddressA (since Windows CE 3.0) and GetProcAddressW.
// GetProcAddress is a macro that is _always_ defined to GetProcAddressW.
ACTIV_BOOST_WINAPI_IMPORT_EXCEPT_WM Boost::winapi::FARPROC_ ACTIV_BOOST_WINAPI_WINAPI_CC
GetProcAddressA(Boost::winapi::HMODULE_ hModule, Boost::winapi::LPCSTR_ lpProcName);
ACTIV_BOOST_WINAPI_IMPORT_EXCEPT_WM Boost::winapi::FARPROC_ ACTIV_BOOST_WINAPI_WINAPI_CC
GetProcAddressW(Boost::winapi::HMODULE_ hModule, Boost::winapi::LPCWSTR_ lpProcName);
#endif
} // extern "C"
#endif // !defined(ACTIV_BOOST_USE_WINDOWS_H)
namespace Boost {
namespace winapi {
#if defined(ACTIV_BOOST_USE_WINDOWS_H)
typedef ::FARPROC FARPROC_;
typedef ::NEARPROC NEARPROC_;
typedef ::PROC PROC_;
#endif // defined(ACTIV_BOOST_USE_WINDOWS_H)
#if !defined(UNDER_CE)
// For backward compatibility, don't use directly. Use get_proc_address instead.
using ::GetProcAddress;
#else
using ::GetProcAddressA;
using ::GetProcAddressW;
#endif
ACTIV_BOOST_FORCEINLINE FARPROC_ get_proc_address(HMODULE_ hModule, LPCSTR_ lpProcName)
{
#if !defined(UNDER_CE)
return ::GetProcAddress(hModule, lpProcName);
#else
return ::GetProcAddressA(hModule, lpProcName);
#endif
}
} // namespace winapi
} // namespace Boost
#include <ActivBoost/winapi/detail/footer.hpp>
#endif // ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM
#endif // ACTIV_BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_