• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 Andrey Semashev
3  *
4  * Distributed under the Boost Software License, Version 1.0.
5  * See http://www.boost.org/LICENSE_1_0.txt
6  */
7 
8 #ifndef BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_
9 #define BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_
10 
11 #include <boost/winapi/basic_types.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
18 
19 #include <boost/winapi/detail/header.hpp>
20 
21 #if !defined(BOOST_USE_WINDOWS_H)
22 namespace boost { namespace winapi {
23 #ifdef _WIN64
24 typedef INT_PTR_ (BOOST_WINAPI_WINAPI_CC *FARPROC_)();
25 typedef INT_PTR_ (BOOST_WINAPI_WINAPI_CC *NEARPROC_)();
26 typedef INT_PTR_ (BOOST_WINAPI_WINAPI_CC *PROC_)();
27 #else
28 typedef int (BOOST_WINAPI_WINAPI_CC *FARPROC_)();
29 typedef int (BOOST_WINAPI_WINAPI_CC *NEARPROC_)();
30 typedef int (BOOST_WINAPI_WINAPI_CC *PROC_)();
31 #endif // _WIN64
32 }} // namespace boost::winapi
33 
34 extern "C" {
35 #if !defined(UNDER_CE)
36 BOOST_WINAPI_IMPORT boost::winapi::FARPROC_ BOOST_WINAPI_WINAPI_CC
37 GetProcAddress(boost::winapi::HMODULE_ hModule, boost::winapi::LPCSTR_ lpProcName);
38 #else
39 // On Windows CE there are two functions: GetProcAddressA (since Windows CE 3.0) and GetProcAddressW.
40 // GetProcAddress is a macro that is _always_ defined to GetProcAddressW.
41 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::FARPROC_ BOOST_WINAPI_WINAPI_CC
42 GetProcAddressA(boost::winapi::HMODULE_ hModule, boost::winapi::LPCSTR_ lpProcName);
43 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::FARPROC_ BOOST_WINAPI_WINAPI_CC
44 GetProcAddressW(boost::winapi::HMODULE_ hModule, boost::winapi::LPCWSTR_ lpProcName);
45 #endif
46 } // extern "C"
47 #endif // !defined(BOOST_USE_WINDOWS_H)
48 
49 namespace boost {
50 namespace winapi {
51 
52 #if defined(BOOST_USE_WINDOWS_H)
53 typedef ::FARPROC FARPROC_;
54 typedef ::NEARPROC NEARPROC_;
55 typedef ::PROC PROC_;
56 #endif // defined(BOOST_USE_WINDOWS_H)
57 
58 #if !defined(UNDER_CE)
59 // For backward compatibility, don't use directly. Use get_proc_address instead.
60 using ::GetProcAddress;
61 #else
62 using ::GetProcAddressA;
63 using ::GetProcAddressW;
64 #endif
65 
get_proc_address(HMODULE_ hModule,LPCSTR_ lpProcName)66 BOOST_FORCEINLINE FARPROC_ get_proc_address(HMODULE_ hModule, LPCSTR_ lpProcName)
67 {
68 #if !defined(UNDER_CE)
69     return ::GetProcAddress(hModule, lpProcName);
70 #else
71     return ::GetProcAddressA(hModule, lpProcName);
72 #endif
73 }
74 
75 } // namespace winapi
76 } // namespace boost
77 
78 #include <boost/winapi/detail/footer.hpp>
79 
80 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
81 #endif // BOOST_WINAPI_GET_PROC_ADDRESS_HPP_INCLUDED_
82