Botan
3.0.0-alpha0
Crypto and TLS for C&
src
lib
utils
dyn_load
dyn_load.h
Go to the documentation of this file.
1
/*
2
* Dynamically Loaded Object
3
* (C) 2010 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_DYNAMIC_LOADER_H_
9
#define BOTAN_DYNAMIC_LOADER_H_
10
11
#include <botan/types.h>
12
#include <string>
13
14
namespace
Botan
{
15
16
/**
17
* Represents a DLL or shared object
18
*/
19
class
BOTAN_TEST_API
Dynamically_Loaded_Library
final
20
{
21
public
:
22
/**
23
* Load a DLL (or fail with an exception)
24
* @param lib_name name or path to a library
25
*
26
* If you don't use a full path, the search order will be defined
27
* by whatever the system linker does by default. Always using fully
28
* qualified pathnames can help prevent code injection attacks (eg
29
* via manipulation of LD_LIBRARY_PATH on Linux)
30
*/
31
Dynamically_Loaded_Library
(
const
std::string& lib_name);
32
33
/**
34
* Unload the DLL
35
* @warning Any pointers returned by resolve()/resolve_symbol()
36
* should not be used after this destructor runs.
37
*/
38
~Dynamically_Loaded_Library
();
39
40
/**
41
* Load a symbol (or fail with an exception)
42
* @param symbol names the symbol to load
43
* @return address of the loaded symbol
44
*/
45
void
* resolve_symbol(
const
std::string& symbol);
46
47
/**
48
* Convenience function for casting symbol to the right type
49
* @param symbol names the symbol to load
50
* @return address of the loaded symbol
51
*/
52
template
<
typename
T>
53
T
resolve
(
const
std::string& symbol)
54
{
55
return
reinterpret_cast<
T
>
(resolve_symbol(symbol));
56
}
57
58
private
:
59
Dynamically_Loaded_Library
(
const
Dynamically_Loaded_Library
&);
60
Dynamically_Loaded_Library
& operator=(
const
Dynamically_Loaded_Library
&);
61
62
std::string m_lib_name;
63
void
* m_lib;
64
};
65
66
}
67
68
#endif
Botan::Dynamically_Loaded_Library
Definition:
dyn_load.h:20
Botan::Dynamically_Loaded_Library::resolve
T resolve(const std::string &symbol)
Definition:
dyn_load.h:53
final
int(* final)(unsigned char *, CTX *)
Definition:
commoncrypto_hash.cpp:29
BOTAN_TEST_API
#define BOTAN_TEST_API
Definition:
compiler.h:51
T
fe T
Definition:
ge.cpp:36
Botan
Definition:
alg_id.cpp:13
Generated by
1.9.3