|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "usvfsparameters.h" |
| 4 | +#include "dllimport.h" |
| 5 | +#include <shared_memory.h> |
| 6 | + |
| 7 | +#include <string> |
| 8 | +#include <boost/interprocess/containers/string.hpp> |
| 9 | +#include <boost/interprocess/containers/flat_set.hpp> |
| 10 | +#include <boost/interprocess/containers/slist.hpp> |
| 11 | + |
| 12 | +namespace usvfs |
| 13 | +{ |
| 14 | + |
| 15 | +class ForcedLibrary |
| 16 | +{ |
| 17 | +public: |
| 18 | + ForcedLibrary( |
| 19 | + const std::string& processName, const std::string& libraryPath, |
| 20 | + const shared::VoidAllocatorT &allocator); |
| 21 | + |
| 22 | + std::string processName() const; |
| 23 | + std::string libraryPath() const; |
| 24 | + |
| 25 | +private: |
| 26 | + shared::StringT m_processName; |
| 27 | + shared::StringT m_libraryPath; |
| 28 | +}; |
| 29 | + |
| 30 | + |
| 31 | +class DLLEXPORT SharedParameters |
| 32 | +{ |
| 33 | +public: |
| 34 | + SharedParameters() = delete; |
| 35 | + SharedParameters(const SharedParameters &reference) = delete; |
| 36 | + SharedParameters &operator=(const SharedParameters &reference) = delete; |
| 37 | + |
| 38 | + SharedParameters(const usvfsParameters& reference, |
| 39 | + const shared::VoidAllocatorT &allocator); |
| 40 | + |
| 41 | + usvfsParameters makeLocal() const; |
| 42 | + |
| 43 | + std::string instanceName() const; |
| 44 | + std::string currentSHMName() const; |
| 45 | + std::string currentInverseSHMName() const; |
| 46 | + void setSHMNames(const std::string& current, const std::string& inverse); |
| 47 | + |
| 48 | + void setDebugParameters( |
| 49 | + LogLevel level, CrashDumpsType dumpType, const std::string& dumpPath, |
| 50 | + std::chrono::milliseconds delayProcess); |
| 51 | + |
| 52 | + std::size_t userConnected(); |
| 53 | + std::size_t userDisconnected(); |
| 54 | + std::size_t userCount(); |
| 55 | + |
| 56 | + std::size_t registeredProcessCount() const; |
| 57 | + std::vector<DWORD> registeredProcesses() const; |
| 58 | + void registerProcess(DWORD pid); |
| 59 | + void unregisterProcess(DWORD pid); |
| 60 | + |
| 61 | + void blacklistExecutable(const std::string& name); |
| 62 | + void clearExecutableBlacklist(); |
| 63 | + bool executableBlacklisted(const std::string& app, const std::string& cmd) const; |
| 64 | + |
| 65 | + void addForcedLibrary(const std::string& process, const std::string& path); |
| 66 | + std::vector<std::string> forcedLibraries(const std::string& processName); |
| 67 | + void clearForcedLibraries(); |
| 68 | + |
| 69 | +private: |
| 70 | + using StringAllocatorT = |
| 71 | + shared::VoidAllocatorT::rebind<shared::StringT>::other; |
| 72 | + |
| 73 | + using DWORDAllocatorT = shared::VoidAllocatorT::rebind<DWORD>::other; |
| 74 | + |
| 75 | + using ForcedLibraryAllocatorT = |
| 76 | + shared::VoidAllocatorT::rebind<ForcedLibrary>::other; |
| 77 | + |
| 78 | + |
| 79 | + using ProcessBlacklist = boost::container::flat_set< |
| 80 | + shared::StringT, std::less<shared::StringT>, StringAllocatorT>; |
| 81 | + |
| 82 | + using ProcessList = boost::container::flat_set< |
| 83 | + DWORD, std::less<DWORD>, DWORDAllocatorT>; |
| 84 | + |
| 85 | + using ForcedLibraries = boost::container::slist< |
| 86 | + ForcedLibrary, ForcedLibraryAllocatorT>; |
| 87 | + |
| 88 | + |
| 89 | + mutable bi::interprocess_mutex m_mutex; |
| 90 | + shared::StringT m_instanceName; |
| 91 | + shared::StringT m_currentSHMName; |
| 92 | + shared::StringT m_currentInverseSHMName; |
| 93 | + bool m_debugMode; |
| 94 | + LogLevel m_logLevel; |
| 95 | + CrashDumpsType m_crashDumpsType; |
| 96 | + shared::StringT m_crashDumpsPath; |
| 97 | + std::chrono::milliseconds m_delayProcess; |
| 98 | + uint32_t m_userCount; |
| 99 | + ProcessBlacklist m_processBlacklist; |
| 100 | + ProcessList m_processList; |
| 101 | + ForcedLibraries m_forcedLibraries; |
| 102 | +}; |
| 103 | + |
| 104 | +} // namespace |
0 commit comments