forked from degauden/Elements
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModuleInfo.h
More file actions
87 lines (75 loc) · 2.84 KB
/
Copy pathModuleInfo.h
File metadata and controls
87 lines (75 loc) · 2.84 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @file ElementsKernel/ModuleInfo.h
* @brief OS specific details to access at run-time the module
* configuration of the process.
* @date Dec 1, 2014
* @author hubert
*
* @copyright 2012-2020 Euclid Science Ground Segment
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @addtogroup ElementsKernel ElementsKernel
* @{
*/
#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_MODULEINFO_H_
#define ELEMENTSKERNEL_ELEMENTSKERNEL_MODULEINFO_H_
// STL include files
#include <dlfcn.h>
#include <memory>
#include <string>
#include <vector>
// Framework include files
#include "ElementsKernel/Export.h" // ELEMENTS_API
#include "ElementsKernel/Path.h" // for Path::Item
#include "ElementsKernel/System.h" // LIB_PREFIX, LIB_EXTENSION
namespace Elements::System {
class ELEMENTS_API ModuleInfo {
public:
ModuleInfo();
explicit ModuleInfo(void*);
std::string name() const;
std::string libraryName() const;
const void* addresse() const;
operator const Dl_info&() const;
bool isEmpty() const;
private:
std::unique_ptr<Dl_info> m_dlinfo;
};
enum class ModuleType { UNKNOWN, SHAREDLIB, EXECUTABLE };
/// Get the name of the (executable/DLL) file without file-type
ELEMENTS_API const std::string& moduleName();
/// Get the full name of the (executable/DLL) file
ELEMENTS_API const std::string& moduleNameFull();
/// Get type of the module
ELEMENTS_API ModuleType moduleType();
/// Handle to running process
ELEMENTS_API ProcessHandle processHandle();
/// Handle to currently executed module
ELEMENTS_API ImageHandle moduleHandle();
/// Handle to the executable file running
ELEMENTS_API ImageHandle exeHandle();
/// Name of the executable file running
ELEMENTS_API const std::string& exeName();
/// Vector of names of linked modules
ELEMENTS_API std::vector<std::string> linkedModules();
ELEMENTS_API std::vector<Path::Item> linkedModulePaths();
/// Attach module handle
ELEMENTS_API void setModuleHandle(ImageHandle handle);
/// Get the full executable path
ELEMENTS_API Path::Item getExecutablePath();
/// Get the path to the /proc directory of the process
ELEMENTS_API Path::Item getSelfProc();
} // namespace Elements::System
#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_MODULEINFO_H_
/**@}*/