-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDynamicLibraryModule.h
More file actions
executable file
·70 lines (55 loc) · 1.87 KB
/
Copy pathDynamicLibraryModule.h
File metadata and controls
executable file
·70 lines (55 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//==============================================================================
// Copyright (c) 2011-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools
/// \file
/// \brief Interface for loading/unloading shared images and retrieving symbol addresses.
//==============================================================================
#ifndef _DYNAMIC_LIBRARY_MODULE_H_
#define _DYNAMIC_LIBRARY_MODULE_H_
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif
#include <string>
#include <vector>
/// Interface for loading/unloading shared images and retrieving symbol addresses.
class DynamicLibraryModule
{
public:
/// ctor
DynamicLibraryModule(void);
/// ctor
/// \param name name of .so/.dll file which ctor will load.
DynamicLibraryModule(const std::string& name);
/// dtor
~DynamicLibraryModule(void);
/// Free/close the .dll/.so image.
void UnloadModule();
/// Load the module.
/// \param name of .so/.dll file.
/// \returns success.
bool LoadModule(const std::string& name);
/// Attempt to load the module, based upon the vector of names.
/// Iterate over them and quit after the first success
/// \param name of .so/.dll file.
/// \returns success.
bool LoadModule(const std::vector<std::string>& names);
/// Look up a symbol.
/// \param name of symbol to lookup
/// \returns pointer to the symbol.
void* GetProcAddress(const std::string& name);
/// Do we have a shared object sucessfully loaded?
/// \returns an image is loaded.
bool IsLoaded() const { return m_Module != NULL; };
private:
/// typedef for our OS connection to a shared image.
#ifdef _WIN32
typedef HMODULE ImageHandle_t;
#else
typedef void* ImageHandle_t;
#endif
/// Handle/pointer to .so/.dll.
ImageHandle_t m_Module;
};
#endif