0.4.00.4.10.4.2
|
Last change
on this file since d7e265d was
fe75eff,
checked in by Michael Medin <michael@…>, 21 months ago
|
|
2011-08-16 MickeM
- Added support for remote WMI checking using target/username/password options like so:
CheckWMI target=192.168.0.123 user= foobar password=foobar namespace=root cimv2 MaxCrit=3 MinWarn=1 "Query:load=Select * from win32_Processor"
- Added support for looking up targets to CheckWMI
CheckWMI target=my_test_xp MaxCrit=3 MinWarn=1 "Query:load=Select * from win32_Processor"
Where <target> is defined under /settings/targets as well as /settings/targets/my_test_xp
2011-08-15 MickeM
- Added support for target in default plugin helpers
- Added remote WMI commands
- Added target section under /settings/targets
|
-
Property mode set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #define _WIN32_DCOM
|
|---|
| 4 | #define _WIN32_WINNT 0x0400
|
|---|
| 5 |
|
|---|
| 6 | #include <error.hpp>
|
|---|
| 7 | #include <windows.h>
|
|---|
| 8 | #include <objbase.h>
|
|---|
| 9 | #include <atlbase.h>
|
|---|
| 10 | #include <atlsafe.h>
|
|---|
| 11 |
|
|---|
| 12 | namespace com_helper {
|
|---|
| 13 |
|
|---|
| 14 | class com_exception {
|
|---|
| 15 | std::wstring error_;
|
|---|
| 16 | HRESULT result_;
|
|---|
| 17 | public:
|
|---|
| 18 | com_exception(std::wstring error) : error_(error) {}
|
|---|
| 19 | com_exception(std::wstring error, HRESULT result) : error_(error), result_(result) {
|
|---|
| 20 | error_ += error::format::from_system(result);
|
|---|
| 21 | }
|
|---|
| 22 | std::wstring getMessage() {
|
|---|
| 23 | return error_;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | class initialize_com {
|
|---|
| 29 | bool isInitialized_;
|
|---|
| 30 | public:
|
|---|
| 31 | initialize_com() : isInitialized_(false) {}
|
|---|
| 32 | ~initialize_com() {
|
|---|
| 33 | unInitialize();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void initialize() {
|
|---|
| 37 | HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|---|
| 38 | if (FAILED(hRes))
|
|---|
| 39 | throw com_exception(_T("CoInitialize failed: "), hRes);
|
|---|
| 40 | isInitialized_ = true;
|
|---|
| 41 | //hRes = CoInitializeSecurity(NULL,-1,NULL,NULL,RPC_C_AUTHN_LEVEL_PKT,RPC_C_IMP_LEVEL_IMPERSONATE,NULL,EOAC_NONE,NULL);
|
|---|
| 42 | hRes = CoInitializeSecurity(NULL,-1,NULL,NULL,RPC_C_AUTHN_LEVEL_DEFAULT,RPC_C_IMP_LEVEL_IDENTIFY,NULL,EOAC_NONE,NULL);
|
|---|
| 43 | if (FAILED(hRes))
|
|---|
| 44 | throw com_exception(_T("CoInitializeSecurity failed: "), hRes);
|
|---|
| 45 | }
|
|---|
| 46 | void unInitialize() {
|
|---|
| 47 | if (!isInitialized_)
|
|---|
| 48 | return;
|
|---|
| 49 | CoUninitialize();
|
|---|
| 50 | isInitialized_ = false;
|
|---|
| 51 | }
|
|---|
| 52 | bool isInitialized() const {
|
|---|
| 53 | return isInitialized_;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | }; |
|---|
Note: See
TracBrowser
for help on using the repository browser.