| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <functional> |
| 7 |
#include <list> |
| 8 |
#include <string> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
struct LdrDllLoadEvent |
| 12 |
{ |
| 13 |
const std::wstring& name; |
| 14 |
uintptr_t base_address; |
| 15 |
}; |
| 16 |
|
| 17 |
class LdrObserver |
| 18 |
{ |
| 19 |
public: |
| 20 |
std::vector<std::wstring> module_names; |
| 21 |
|
| 22 |
|
| 23 |
std::function<void(const LdrDllLoadEvent&)> action; |
| 24 |
void* cookie{}; |
| 25 |
}; |
| 26 |
|
| 27 |
class LdrWatcher |
| 28 |
{ |
| 29 |
public: |
| 30 |
void Install(const LdrObserver& observer); |
| 31 |
~LdrWatcher(); |
| 32 |
|
| 33 |
private: |
| 34 |
bool InjectCurrentModules(const LdrObserver& observer); |
| 35 |
void UninstallAll(); |
| 36 |
std::list<LdrObserver> observers; |
| 37 |
}; |