diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-18 23:13:57 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-22 07:33:38 -0400 |
| commit | b2a1e1391fdd6bdee1c5e8d337b273447c70a506 (patch) | |
| tree | bbcee13a329fd9276a43a2d524f48ff83c32517b /src/env.h | |
| parent | f95479b981b41f51a3ecf055c73f42440766e5d7 (diff) | |
split env
Diffstat (limited to 'src/env.h')
| -rw-r--r-- | src/env.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/env.h b/src/env.h new file mode 100644 index 00000000..1e913a40 --- /dev/null +++ b/src/env.h @@ -0,0 +1,117 @@ +namespace env +{ + +class Module; +class SecurityProduct; +class WindowsInfo; +class Metrics; + +struct HandleCloser +{ + using pointer = HANDLE; + + void operator()(HANDLE h) + { + if (h != INVALID_HANDLE_VALUE) { + ::CloseHandle(h); + } + } +}; + +using HandlePtr = std::unique_ptr<HANDLE, HandleCloser>; + + +struct LibraryFreer +{ + using pointer = HINSTANCE; + + void operator()(HINSTANCE h) + { + if (h != 0) { + ::FreeLibrary(h); + } + } +}; + +struct COMReleaser +{ + void operator()(IUnknown* p) + { + if (p) { + p->Release(); + } + } +}; + + +template <class T> +using COMPtr = std::unique_ptr<T, COMReleaser>; + + +class Console +{ +public: + Console(); + ~Console(); + +private: + bool m_hasConsole; + FILE* m_in; + FILE* m_out; + FILE* m_err; +}; + + +// represents the process's environment +// +class Environment +{ +public: + Environment(); + ~Environment(); + + // list of loaded modules in the current process + // + const std::vector<Module>& loadedModules() const; + + // information about the operating system + // + const WindowsInfo& windowsInfo() const; + + // information about the installed security products + // + const std::vector<SecurityProduct>& securityProducts() const; + + // information about displays + // + const Metrics& metrics() const; + + // logs the environment + // + void dump() const; + +private: + std::vector<Module> m_modules; + std::unique_ptr<WindowsInfo> m_windows; + std::vector<SecurityProduct> m_security; + std::unique_ptr<Metrics> m_metrics; +}; + + +enum class CoreDumpTypes +{ + Mini = 1, + Data, + Full +}; + +// creates a minidump file for the given process +// +bool coredump(CoreDumpTypes type); + +// finds another process with the same name as this one and creates a minidump +// file for it +// +bool coredumpOther(CoreDumpTypes type); + +} // namespace env |
