├── .gitignore ├── diaa_sami_comsupp ├── Makefile └── diaa_sami_comsupp.cpp ├── include ├── wmiexception.hpp ├── unistd.h ├── wmiresult.hpp ├── wmi.hpp └── wmiclasses.hpp ├── CMakeSettings.json ├── CMakeLists.txt ├── Makefile ├── src ├── test.cpp ├── wmiresult.cpp └── wmi.cpp ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.dll 4 | *.exe. 5 | bin 6 | build 7 | .vscode/ 8 | /.vs 9 | -------------------------------------------------------------------------------- /diaa_sami_comsupp/Makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | CPPFLAGS=-c -O3 3 | CPP_SOURCES= diaa_sami_comsupp.cpp 4 | LDFLAGS=-loleaut32 5 | 6 | OBJECTS=$(CPP_SOURCES:%.cpp=bin/%.o) 7 | DEPS=$(OBJECTS:bin/%.o=bin/%.d) 8 | 9 | all: bin diaa_sami_comsupp.dll 10 | 11 | -include $(DEPS) 12 | 13 | diaa_sami_comsupp.dll: $(OBJECTS) 14 | @echo "Linking" $@ 15 | @$(CXX) -shared -o $@ $(OBJECTS) $(LDFLAGS) 16 | 17 | bin/%.o: %.cpp 18 | @echo "Compiling" $< 19 | @$(CXX) -MD $(CFLAGS) $(CPPFLAGS) -o $@ $< 20 | 21 | bin: 22 | mkdir bin 23 | 24 | clean: 25 | @echo "Cleaning" 26 | @rm -rf bin/*.o bin/*.d diaa_sami_comsupp.dll 27 | -------------------------------------------------------------------------------- /include/wmiexception.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #ifndef WMIEXCEPTION_HPP 9 | #define WMIEXCEPTION_HPP 10 | 11 | #include 12 | #include 13 | 14 | namespace Wmi 15 | { 16 | 17 | struct WmiException 18 | { 19 | 20 | WmiException(const std::string &str_errorMessage, long l_errorCode) : 21 | errorMessage(str_errorMessage), 22 | errorCode(l_errorCode) 23 | {} 24 | 25 | std::string hexErrorCode() const 26 | { 27 | std::stringstream ss; 28 | ss<<"0x"< 4 | #include 5 | #include 6 | 7 | void __stdcall _com_issue_error(HRESULT hr) 8 | { 9 | #define MESSAGE_LENGTH_MAX 128 10 | char message[MESSAGE_LENGTH_MAX]; 11 | StringCbPrintfA(message, MESSAGE_LENGTH_MAX, "_com_issue_error() called with parameter HRESULT = %lu", hr); 12 | MessageBox(NULL, message, "Error", MB_OK | MB_ICONERROR); 13 | } 14 | 15 | namespace _com_util 16 | { 17 | char * __stdcall ConvertBSTRToString(BSTR bstr) 18 | { 19 | const unsigned int stringLength = lstrlenW(bstr); 20 | char *const ascii = new char [stringLength + 1]; 21 | 22 | wcstombs(ascii, bstr, stringLength + 1); 23 | 24 | return ascii; 25 | } 26 | 27 | BSTR __stdcall ConvertStringToBSTR(const char *const ascii) 28 | { 29 | const unsigned int stringLength = lstrlenA(ascii); 30 | BSTR bstr = SysAllocStringLen(NULL, stringLength); 31 | 32 | mbstowcs(bstr, ascii, stringLength + 1); 33 | 34 | return bstr; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6...3.20) 2 | project (Wmi) 3 | set (CMAKE_CXX_STANDARD 11) 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -c -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64") 5 | 6 | set(WMISOURCES ${PROJECT_SOURCE_DIR}/src/wmi.cpp ${PROJECT_SOURCE_DIR}/src/wmiresult.cpp) 7 | include_directories(${TOTAL_INCLUDES} ${PROJECT_SOURCE_DIR}/include) 8 | 9 | 10 | add_library(wmi STATIC ${WMISOURCES}) 11 | add_library(diaa_sami_comsupp STATIC ${PROJECT_SOURCE_DIR}/diaa_sami_comsupp/diaa_sami_comsupp.cpp) 12 | add_executable(test_wmi ${PROJECT_SOURCE_DIR}/src/test.cpp) 13 | 14 | if(${CMAKE_VERSION} VERSION_GREATER "3.0.0") 15 | target_include_directories(wmi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) 16 | endif() 17 | target_link_libraries(wmi ole32 oleaut32 wbemuuid ) 18 | target_link_libraries(test_wmi wmi ole32 oleaut32 wbemuuid) 19 | 20 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) 21 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) 22 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) 23 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) 24 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | CPPFLAGS=-c -O3 -std=c++11 -Wall -Wextra -Weffc++ -I../kernel_module/include -I./include -I./utils -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wdouble-promotion -Wuninitialized -fipa-pure-const -Wtrampolines -Wfloat-equal -Wcast-qual -Wcast-align -Wconversion -Wlogical-op -Wredundant-decls -Wshadow -Wint-to-pointer-cast 3 | CPP_SOURCES= \ 4 | src/wmi.cpp \ 5 | src/wmiresult.cpp 6 | 7 | TEST_SOURCE= src/test.cpp 8 | 9 | LDFLAGS=-lole32 -loleaut32 -lwbemuuid -L. -ldiaa_sami_comsupp 10 | 11 | OBJECTS=$(CPP_SOURCES:src/%.cpp=bin/%.o) 12 | TEST_OBJECT=$(TEST_SOURCE:src/%.cpp=bin/%.o) 13 | DEPS=$(OBJECTS:bin/%.o=bin/%.d) $(TEST_OBJECT:bin/%.o=bin/%.d) 14 | 15 | all: bin wmi.dll test.exe 16 | 17 | -include $(DEPS) 18 | 19 | wmi.dll: $(OBJECTS) diaa_sami_comsupp.dll 20 | @echo "Linking" $@ 21 | @$(CXX) -shared -o $@ $(OBJECTS) $(LDFLAGS) 22 | 23 | test.exe: wmi.dll $(TEST_OBJECT) 24 | @echo "Linking" $@ 25 | @$(CXX) -o $@ $(TEST_OBJECT) -L. -lwmi 26 | 27 | bin/%.o: src/%.cpp 28 | @echo "Compiling" $< 29 | @$(CXX) -MD $(CFLAGS) $(CPPFLAGS) -o $@ $< 30 | 31 | bin: 32 | mkdir bin 33 | 34 | diaa_sami_comsupp.dll: 35 | @make -C diaa_sami_comsupp 36 | @ln -s diaa_sami_comsupp/$@ . 37 | 38 | clean: 39 | @echo "Cleaning" 40 | @make -C diaa_sami_comsupp clean 41 | @rm -rf bin/*.o bin/*.d wmi.dll diaa_sami_comsupp.dll test.exe 42 | -------------------------------------------------------------------------------- /include/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNISTD_H 2 | #define _UNISTD_H 1 3 | 4 | /* This is intended as a drop-in replacement for unistd.h on Windows. 5 | * Please add functionality as neeeded. 6 | * https://stackoverflow.com/a/826027/1202830 7 | */ 8 | 9 | #include 10 | #include 11 | #include /* for getpid() and the exec..() family */ 12 | #include /* for _getcwd() and _chdir() */ 13 | 14 | #define srandom srand 15 | #define random rand 16 | 17 | /* Values for the second argument to access. 18 | These may be OR'd together. */ 19 | #define R_OK 4 /* Test for read permission. */ 20 | #define W_OK 2 /* Test for write permission. */ 21 | //#define X_OK 1 /* execute permission - unsupported in windows*/ 22 | #define F_OK 0 /* Test for existence. */ 23 | 24 | #define access _access 25 | #define dup2 _dup2 26 | #define execve _execve 27 | #define ftruncate _chsize 28 | #define unlink _unlink 29 | #define fileno _fileno 30 | #define getcwd _getcwd 31 | #define chdir _chdir 32 | #define isatty _isatty 33 | #define lseek _lseek 34 | /* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ 35 | 36 | #ifdef _WIN64 37 | #define ssize_t __int64 38 | #else 39 | #define ssize_t long 40 | #endif 41 | 42 | #define STDIN_FILENO 0 43 | #define STDOUT_FILENO 1 44 | #define STDERR_FILENO 2 45 | /* 46 | //should be in some equivalent to 47 | typedef __int8 int8_t; 48 | typedef __int16 int16_t; 49 | typedef __int32 int32_t; 50 | typedef __int64 int64_t; 51 | typedef unsigned __int8 uint8_t; 52 | typedef unsigned __int16 uint16_t; 53 | typedef unsigned __int32 uint32_t; 54 | typedef unsigned __int64 uint64_t; 55 | */ 56 | #endif /* unistd.h */ -------------------------------------------------------------------------------- /src/test.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | using std::cerr; 15 | using std::cout; 16 | using std::endl; 17 | using std::string; 18 | using std::wcout; 19 | 20 | using namespace Wmi; 21 | 22 | int main(int /*argc*/, char */*args*/[]) 23 | { 24 | try { 25 | Win32_ComputerSystem computer = retrieveWmi(); 26 | Win32_ComputerSystemProduct product = retrieveWmi(); 27 | SoftwareLicensingService liscense = retrieveWmi(); 28 | Win32_OperatingSystem os_info = retrieveWmi(); 29 | 30 | cout<<"Computername: "<()) 44 | { 45 | cout<("Caption,Started,State")) 50 | { 51 | cout<()) 58 | { 59 | cout << antivirus.DisplayName << " | path:" << antivirus.PathToSignedProductExe << " state:" << antivirus.ProductState << " time: " << antivirus.Timestamp << endl; 60 | } 61 | 62 | // Example for Windows Embedded 63 | //UWF_Filter filter = retrieveWmi(); 64 | //cout << "UWF Filter enabled:" << filter.CurrentEnabled << std::endl; 65 | } catch (const WmiException &ex) { 66 | cerr<<"Wmi error: "< 12 | #include 13 | #include 14 | 15 | namespace Wmi 16 | { 17 | 18 | class WmiResult 19 | { 20 | 21 | public: 22 | WmiResult() : 23 | result() 24 | {} 25 | 26 | void set(std::size_t index, std::wstring name, const std::wstring &value); 27 | 28 | std::vector >::iterator begin() 29 | { 30 | return result.begin(); 31 | } 32 | 33 | std::vector >::iterator end() 34 | { 35 | return result.end(); 36 | } 37 | 38 | std::vector >::const_iterator cbegin() const 39 | { 40 | return result.cbegin(); 41 | } 42 | 43 | std::vector >::const_iterator cend() const 44 | { 45 | return result.cend(); 46 | } 47 | 48 | std::size_t size() const 49 | { 50 | return result.size(); 51 | } 52 | 53 | bool extract(std::size_t index, const std::string &name, std::wstring &out) const; 54 | bool extract(std::size_t index, const std::string &name, std::string &out) const; 55 | bool extract(std::size_t index, const std::string &name, int &out) const; 56 | bool extract(std::size_t index, const std::string &name, bool &out) const; 57 | bool extract(std::size_t index, const std::string &name, uint64_t &out) const; 58 | bool extract(std::size_t index, const std::string &name, uint32_t &out) const; 59 | bool extract(std::size_t index, const std::string &name, uint16_t &out) const; 60 | bool extract(std::size_t index, const std::string &name, uint8_t &out) const; 61 | 62 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 63 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 64 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 65 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 66 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 67 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 68 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 69 | bool extract(std::size_t index, const std::string &name, std::vector &out) const; 70 | 71 | private: 72 | std::vector > result; 73 | 74 | }; //end class WmiResult 75 | 76 | }; //end namespace Wmi 77 | 78 | #endif //WMIRESULT_HPP -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WMI 2 | === 3 | 4 | Created by Thomas Sparber 2016 5 | 6 | GOAL 7 | ---- 8 | This is a very simple library written in C++ to execute WMI queries. 9 | The aim is to make it as simple as possible and stick as much as 10 | possible to the C++ standard (avoid Microsoft specific things) so that 11 | it even compiles smoothly on MinGW. 12 | 13 | Usage 14 | ----- 15 | I think it is so simple that a small program explains the usage without 16 | any further comments: 17 | ```cpp 18 | int main(int /*argc*/, char */*args*/[]) 19 | { 20 | try { 21 | Win32_ComputerSystem computer = retrieveWmi(); 22 | Win32_ComputerSystemProduct product = retrieveWmi(); 23 | SoftwareLicensingService liscense = retrieveWmi(); 24 | Win32_OperatingSystem os_info = retrieveWmi(); 25 | 26 | cout<<"Computername: "<()) 37 | { 38 | cout< contains all interfaces to execute WMI queries. 49 | The include file contains some predefined WMI classes 50 | (e.g. Win32_ComputerSystem or Win32_Service...) 51 | 52 | Create WMI classes 53 | ------------------ 54 | As already mentioned, the include file provides some standard 55 | WMI classes, but it is also very easy to add more of them. All you need to do is: 56 | ```cpp 57 | struct Win32_MyCustomClass 58 | { 59 | 60 | /** 61 | * This function is called by requestWmi and requestAllWmi 62 | * with the actual WmiResult 63 | **/ 64 | void setProperties(const WmiResult &result, std::size_t index) 65 | { 66 | //EXAMPLE EXTRACTING PROPERTY TO CLASS 67 | result.extract(index, "name", (*this).name); 68 | } 69 | 70 | /** 71 | * This function is used to determine the actual WMI class name 72 | **/ 73 | static std::string getWmiClassName() 74 | { 75 | return "Win32_MyCustomClass"; 76 | } 77 | 78 | /** 79 | * This function can be optionally implemented if the wmi class 80 | * is not member of cimv2. In such a case, this function needs 81 | * to return the root for this WMI class 82 | **/ 83 | /*static std::string getWmiClassName() 84 | { 85 | return "not cimv2"; 86 | }*/ 87 | 88 | string name; 89 | //All the other properties you wish to read from WMI 90 | 91 | }; //end struct Win32_ComputerSystem 92 | ``` 93 | These two functions are the only requirements your class needs to have. -------------------------------------------------------------------------------- /include/wmi.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #ifndef WMI_HPP 9 | #define WMI_HPP 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Wmi 18 | { 19 | 20 | //SFINAE test 21 | //default wmi path if wmi class does not implement getWmiPath 22 | template 23 | std::string CallGetWmiPath(...) 24 | { 25 | return "cimv2"; 26 | } 27 | 28 | template 29 | typename std::enable_if::value, std::string>::type 30 | CallGetWmiPath(int /* required, otherwise we get an ambiguitiy error... */) 31 | { 32 | return WmiClass::getWmiPath(); 33 | } 34 | 35 | void query(const std::string& q, const std::string& p, WmiResult &out); 36 | 37 | inline WmiResult query(const std::string& q, const std::string& p) 38 | { 39 | WmiResult result; 40 | query(q, p, result); 41 | return result; 42 | } 43 | 44 | template 45 | inline void retrieveWmi(WmiClass &out) 46 | { 47 | WmiResult result; 48 | const std::string q = std::string("Select * From ") + WmiClass::getWmiClassName(); 49 | query(q, CallGetWmiPath(0), result); 50 | out.setProperties(result, 0); 51 | } 52 | 53 | template 54 | inline void retrieveWmi(WmiClass &out, std::string columns) 55 | { 56 | WmiResult result; 57 | const std::string q = std::string("Select ") + columns + std::string(" From ") + WmiClass::getWmiClassName(); 58 | query(q, CallGetWmiPath(0), result); 59 | out.setProperties(result, 0); 60 | } 61 | 62 | template 63 | inline WmiClass retrieveWmi() 64 | { 65 | WmiClass temp; 66 | retrieveWmi(temp); 67 | return temp; 68 | } 69 | 70 | template 71 | inline WmiClass retrieveWmi(std::string columns) 72 | { 73 | WmiClass temp; 74 | retrieveWmi(temp, columns); 75 | return temp; 76 | } 77 | 78 | template 79 | inline void retrieveAllWmi(std::vector &out) 80 | { 81 | WmiResult result; 82 | const std::string q = std::string("Select * From ") + WmiClass::getWmiClassName(); 83 | query(q, CallGetWmiPath(0), result); 84 | 85 | out.clear(); 86 | for(std::size_t index = 0; index < result.size(); ++index) 87 | { 88 | WmiClass temp; 89 | temp.setProperties(result, index); 90 | out.push_back(std::move(temp)); 91 | } 92 | } 93 | 94 | template 95 | inline void retrieveAllWmi(std::vector &out, std::string columns) 96 | { 97 | WmiResult result; 98 | const std::string q = std::string("Select ") + columns + std::string(" From ") + WmiClass::getWmiClassName(); 99 | query(q, CallGetWmiPath(0), result); 100 | 101 | out.clear(); 102 | for(std::size_t index = 0; index < result.size(); ++index) 103 | { 104 | WmiClass temp; 105 | temp.setProperties(result, index); 106 | out.push_back(std::move(temp)); 107 | } 108 | } 109 | 110 | template 111 | inline std::vector retrieveAllWmi() 112 | { 113 | std::vector ret; 114 | retrieveAllWmi(ret); 115 | 116 | return ret; 117 | } 118 | 119 | template 120 | inline std::vector retrieveAllWmi(std::string columns) 121 | { 122 | std::vector ret; 123 | retrieveAllWmi(ret, columns); 124 | 125 | return ret; 126 | } 127 | 128 | }; //end namespace Wmi 129 | 130 | #endif //WMI_HPP -------------------------------------------------------------------------------- /src/wmiresult.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | using std::codecvt_utf8; 15 | using std::string; 16 | using std::transform; 17 | using std::vector; 18 | using std::wstring; 19 | using std::wstring_convert; 20 | 21 | using namespace Wmi; 22 | 23 | wstring unescape(wstring str) 24 | { 25 | size_t start_pos = 0; 26 | const wstring from = L"\\\""; 27 | const wstring to = L"\""; 28 | 29 | while((start_pos = str.find(from, start_pos)) != string::npos) 30 | { 31 | str.replace(start_pos, from.length(), to); 32 | start_pos += to.length(); 33 | } 34 | 35 | return str; 36 | } 37 | 38 | bool tokenize(const wstring &str, vector &out) 39 | { 40 | size_t start_pos = str.find(L"["); 41 | 42 | if(start_pos == string::npos)return false; 43 | 44 | do 45 | { 46 | start_pos++; 47 | size_t end_pos = start_pos; 48 | size_t temp_pos = start_pos; 49 | 50 | while(end_pos != start_pos && temp_pos != string::npos && temp_pos == end_pos) 51 | { 52 | end_pos = str.find(L"\"", temp_pos+2); 53 | temp_pos = str.find(L"\\\"", temp_pos); 54 | } 55 | 56 | temp_pos = str.find(L",", end_pos); 57 | if(temp_pos == string::npos)temp_pos = str.find(L"]", end_pos); 58 | end_pos = temp_pos; 59 | 60 | wstring token = str.substr(str[start_pos] == L'\"' ? start_pos+1 : start_pos, str[start_pos] == L'\"' ? (end_pos - start_pos - 2) : (end_pos - start_pos)); 61 | out.push_back(unescape(token)); 62 | 63 | start_pos = end_pos; 64 | end_pos = start_pos; 65 | temp_pos = start_pos; 66 | } 67 | while(start_pos != string::npos && start_pos+1 != str.length()); 68 | 69 | return true; 70 | } 71 | 72 | void WmiResult::set(std::size_t index, wstring name, const wstring &value) 73 | { 74 | while(index >= result.size())result.emplace_back(); 75 | 76 | transform(name.begin(), name.end(), name.begin(), ::tolower); 77 | result[index][name] = value; 78 | } 79 | 80 | bool WmiResult::extract(std::size_t index, const string &name, wstring &out) const 81 | { 82 | if(index >= result.size())return false; 83 | 84 | wstring key(name.cbegin(), name.cend()); 85 | transform(key.begin(), key.end(), key.begin(), ::tolower); 86 | 87 | auto found = result[index].find(key); 88 | if(found == result[index].cend())return false; 89 | 90 | out = found->second; 91 | return true; 92 | } 93 | 94 | bool WmiResult::extract(std::size_t index, const string &name, string &out) const 95 | { 96 | wstring temp; 97 | if(!extract(index, name, temp))return false; 98 | 99 | wstring_convert> myconv; 100 | out = myconv.to_bytes(temp); 101 | return true; 102 | } 103 | 104 | bool WmiResult::extract(std::size_t index, const string &name, int &out) const 105 | { 106 | string temp; 107 | if(!extract(index, name, temp))return false; 108 | 109 | char *test; 110 | out = strtol(temp.c_str(), &test, 0); 111 | return (test == temp.c_str() + temp.length()); 112 | } 113 | 114 | bool WmiResult::extract(std::size_t index, const string &name, bool &out) const 115 | { 116 | string temp; 117 | if(!extract(index, name, temp))return false; 118 | 119 | transform(temp.begin(), temp.end(), temp.begin(), ::tolower); 120 | if(temp == "true" || temp == "1")out = true; 121 | else if(temp == "false" || temp == "0")out = false; 122 | else return false; 123 | 124 | return true; 125 | } 126 | 127 | bool WmiResult::extract(std::size_t index, const string &name, uint64_t &out) const 128 | { 129 | string temp; 130 | if(!extract(index, name, temp))return false; 131 | 132 | char *test; 133 | out = strtoull(temp.c_str(), &test, 0); 134 | return (test == temp.c_str() + temp.length()); 135 | } 136 | 137 | bool WmiResult::extract(std::size_t index, const string &name, uint32_t &out) const 138 | { 139 | string temp; 140 | if(!extract(index, name, temp))return false; 141 | 142 | char *test; 143 | out = (uint32_t)std::strtoul(temp.c_str(), &test, 0); 144 | return (test == temp.c_str() + temp.length()); 145 | } 146 | 147 | bool WmiResult::extract(std::size_t index, const string &name, uint16_t &out) const 148 | { 149 | string temp; 150 | if(!extract(index, name, temp))return false; 151 | 152 | char *test; 153 | out = (uint16_t)std::strtoul(temp.c_str(), &test, 0); 154 | return (test == temp.c_str() + temp.length()); 155 | } 156 | 157 | bool WmiResult::extract(std::size_t index, const string &name, uint8_t &out) const 158 | { 159 | string temp; 160 | if(!extract(index, name, temp))return false; 161 | 162 | char *test; 163 | out = (uint8_t)std::strtoul(temp.c_str(), &test, 0); 164 | return (test == temp.c_str() + temp.length()); 165 | } 166 | 167 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 168 | { 169 | wstring temp; 170 | if(!extract(index, name, temp))return false; 171 | 172 | if(!tokenize(temp, out))return false; 173 | 174 | return true; 175 | } 176 | 177 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 178 | { 179 | vector tokens; 180 | if(!extract(index, name, tokens))return false; 181 | 182 | out.resize(tokens.size()); 183 | for(std::size_t i = 0; i < tokens.size(); ++i) 184 | { 185 | wstring_convert> myconv; 186 | const wstring &temp = tokens[i]; 187 | out[i] = myconv.to_bytes(temp); 188 | } 189 | 190 | return true; 191 | } 192 | 193 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 194 | { 195 | vector tokens; 196 | if(!extract(index, name, tokens))return false; 197 | 198 | out.resize(tokens.size()); 199 | for(std::size_t i = 0; i < tokens.size(); ++i) 200 | { 201 | char *test; 202 | out[i] = strtol(tokens[i].c_str(), &test, 0); 203 | return (test == tokens[i].c_str() + tokens[i].length()); 204 | } 205 | 206 | return true; 207 | } 208 | 209 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 210 | { 211 | vector tokens; 212 | if(!extract(index, name, tokens))return false; 213 | 214 | out.resize(tokens.size()); 215 | for(std::size_t i = 0; i < tokens.size(); ++i) 216 | { 217 | string temp = tokens[i]; 218 | transform(temp.begin(), temp.end(), temp.begin(), ::tolower); 219 | if(temp == "true" || temp == "1")out[i] = true; 220 | else if(temp == "false" || temp == "0")out[i] = false; 221 | else return false; 222 | } 223 | 224 | return true; 225 | } 226 | 227 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 228 | { 229 | vector tokens; 230 | if(!extract(index, name, tokens))return false; 231 | 232 | out.resize(tokens.size()); 233 | for(std::size_t i = 0; i < tokens.size(); ++i) 234 | { 235 | char *test; 236 | out[i] = strtoull(tokens[i].c_str(), &test, 0); 237 | if(test != tokens[i].c_str() + tokens[i].length()) return false; 238 | } 239 | 240 | return true; 241 | } 242 | 243 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 244 | { 245 | vector tokens; 246 | if(!extract(index, name, tokens))return false; 247 | 248 | out.resize(tokens.size()); 249 | for(std::size_t i = 0; i < tokens.size(); ++i) 250 | { 251 | char *test; 252 | out[i] = (uint32_t)strtoul(tokens[i].c_str(), &test, 0); 253 | if (test != tokens[i].c_str() + tokens[i].length()) return false; 254 | } 255 | 256 | return true; 257 | } 258 | 259 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 260 | { 261 | vector tokens; 262 | if(!extract(index, name, tokens))return false; 263 | 264 | out.resize(tokens.size()); 265 | for(std::size_t i = 0; i < tokens.size(); ++i) 266 | { 267 | char *test; 268 | out[i] = (uint16_t)strtoul(tokens[i].c_str(), &test, 0); 269 | if (test != tokens[i].c_str() + tokens[i].length()) return false; 270 | } 271 | 272 | return true; 273 | } 274 | 275 | bool WmiResult::extract(std::size_t index, const string &name, vector &out) const 276 | { 277 | vector tokens; 278 | if(!extract(index, name, tokens))return false; 279 | 280 | out.resize(tokens.size()); 281 | for(std::size_t i = 0; i < tokens.size(); ++i) 282 | { 283 | char *test; 284 | out[i] = (uint8_t)strtoul(tokens[i].c_str(), &test, 0); 285 | if (test != tokens[i].c_str() + tokens[i].length()) return false; 286 | } 287 | 288 | return true; 289 | } 290 | -------------------------------------------------------------------------------- /src/wmi.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | using std::function; 17 | using std::string; 18 | using std::wstring; 19 | using std::wstringstream; 20 | 21 | using namespace Wmi; 22 | 23 | wstring escape(wstring str) 24 | { 25 | size_t start_pos = 0; 26 | const wstring from = L"\""; 27 | const wstring to = L"\\\""; 28 | 29 | while((start_pos = str.find(from, start_pos)) != string::npos) 30 | { 31 | str.replace(start_pos, from.length(), to); 32 | start_pos += to.length(); 33 | } 34 | 35 | return str; 36 | } 37 | 38 | IWbemLocator* createWbemLocator() 39 | { 40 | IWbemLocator *pLocator = nullptr; 41 | HRESULT hr = CoCreateInstance(CLSID_WbemLocator, nullptr, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void**)&pLocator); 42 | if(FAILED(hr)) 43 | { 44 | switch(hr) 45 | { 46 | case REGDB_E_CLASSNOTREG: throw WmiException("Error initializing IWbemLocator: REGDB_E_CLASSNOTREG", hr); 47 | case CLASS_E_NOAGGREGATION: throw WmiException("Error initializing IWbemLocator: CLASS_E_NOAGGREGATION", hr); 48 | case E_NOINTERFACE: throw WmiException("Error initializing IWbemLocator: E_NOINTERFACE", hr); 49 | case E_POINTER: throw WmiException("Error initializing IWbemLocator: E_POINTER", hr); 50 | default: throw WmiException("Error initializing IWbemLocator: Unknown Error", hr); 51 | } 52 | } 53 | 54 | return pLocator; 55 | } 56 | 57 | IWbemServices* connect(IWbemLocator *pLocator, const std::string& path) 58 | { 59 | IWbemServices *pServices; 60 | HRESULT hr = pLocator->ConnectServer(_bstr_t("\\\\.\\root\\") + _bstr_t(path.c_str()), nullptr, nullptr, nullptr, 0, nullptr, nullptr, &pServices); 61 | if(FAILED(hr)) 62 | { 63 | switch(hr) 64 | { 65 | case (HRESULT)WBEM_E_ACCESS_DENIED: throw WmiException("Error initializing IWbemServices: WBEM_E_ACCESS_DENIED", hr); 66 | case (HRESULT)WBEM_E_FAILED: throw WmiException("Error initializing IWbemServices: WBEM_E_FAILED", hr); 67 | case (HRESULT)WBEM_E_INVALID_NAMESPACE: throw WmiException("Error initializing IWbemServices: WBEM_E_INVALID_NAMESPACE", hr); 68 | case (HRESULT)WBEM_E_INVALID_PARAMETER: throw WmiException("Error initializing IWbemServices: WBEM_E_INVALID_PARAMETER", hr); 69 | case (HRESULT)WBEM_E_OUT_OF_MEMORY: throw WmiException("Error initializing IWbemServices: WBEM_E_OUT_OF_MEMORY", hr); 70 | case (HRESULT)WBEM_E_TRANSPORT_FAILURE: throw WmiException("Error initializing IWbemServices: WBEM_E_TRANSPORT_FAILURE", hr); 71 | case (HRESULT)WBEM_E_LOCAL_CREDENTIALS: throw WmiException("Error initializing IWbemServices: WBEM_E_LOCAL_CREDENTIALS", hr); 72 | default: throw WmiException("Error initializing IWbemServices: Unknown Error", hr); 73 | } 74 | } 75 | 76 | //Set authentication proxy 77 | hr = CoSetProxyBlanket(pServices, 78 | RPC_C_AUTHN_DEFAULT, 79 | RPC_C_AUTHZ_NONE, 80 | COLE_DEFAULT_PRINCIPAL, 81 | RPC_C_AUTHN_LEVEL_DEFAULT, 82 | RPC_C_IMP_LEVEL_IMPERSONATE, 83 | nullptr, 84 | EOAC_NONE 85 | ); 86 | 87 | if(FAILED(hr)) 88 | { 89 | switch(hr) 90 | { 91 | case E_INVALIDARG: throw WmiException("Coult not set proxy blanket: E_INVALIDARG", hr); 92 | default: throw WmiException("Coult not set proxy blanket: Unknown Error", hr); 93 | } 94 | } 95 | 96 | return pServices; 97 | } 98 | 99 | IEnumWbemClassObject* execute(IWbemServices *pServices, const string &q) 100 | { 101 | IEnumWbemClassObject *pClassObject; 102 | HRESULT hr = pServices->ExecQuery(_bstr_t("WQL"), _bstr_t(q.c_str()), WBEM_FLAG_RETURN_IMMEDIATELY|WBEM_FLAG_FORWARD_ONLY, nullptr, &pClassObject); 103 | if(FAILED(hr)) 104 | { 105 | switch(hr) 106 | { 107 | case (HRESULT)WBEM_E_ACCESS_DENIED: throw WmiException("Error executing query: WBEM_E_ACCESS_DENIED", hr); 108 | case (HRESULT)WBEM_E_FAILED: throw WmiException("Error executing query: WBEM_E_FAILED", hr); 109 | case (HRESULT)WBEM_E_INVALID_CLASS: throw WmiException("Error executing query: WBEM_E_INVALID_CLASS", hr); 110 | case (HRESULT)WBEM_E_INVALID_PARAMETER: throw WmiException("Error executing query: WBEM_E_INVALID_PARAMETER", hr); 111 | case (HRESULT)WBEM_E_OUT_OF_MEMORY: throw WmiException("Error executing query: WBEM_E_OUT_OF_MEMORY", hr); 112 | case (HRESULT)WBEM_E_SHUTTING_DOWN: throw WmiException("Error executing query: WBEM_E_SHUTTING_DOWN", hr); 113 | case (HRESULT)WBEM_E_TRANSPORT_FAILURE: throw WmiException("Error executing query: WBEM_E_TRANSPORT_FAILURE", hr); 114 | default: throw WmiException("Error executing query: Unknown Error", hr); 115 | } 116 | } 117 | 118 | return pClassObject; 119 | } 120 | 121 | void foreachObject(IEnumWbemClassObject *pClassObject, function fn) 122 | { 123 | bool cont = true; 124 | HRESULT hr = WBEM_S_NO_ERROR; 125 | 126 | //The final Next will return WBEM_S_FALSE 127 | while(cont && hr == WBEM_S_NO_ERROR) 128 | { 129 | ULONG uReturned = 0; 130 | IWbemClassObject *apObj; 131 | hr = pClassObject->Next(WBEM_INFINITE, 1, &apObj, &uReturned); 132 | 133 | if(FAILED(hr)) 134 | { 135 | switch(hr) 136 | { 137 | case WBEM_S_FALSE: break; 138 | case (HRESULT)WBEM_E_INVALID_PARAMETER: throw WmiException("Error getting next element: WBEM_E_INVALID_PARAMETER", hr); 139 | case (HRESULT)WBEM_E_OUT_OF_MEMORY: throw WmiException("Error getting next element: WBEM_E_OUT_OF_MEMORY", hr); 140 | case (HRESULT)WBEM_E_UNEXPECTED: throw WmiException("Error getting next element: WBEM_E_UNEXPECTED", hr); 141 | case (HRESULT)WBEM_E_TRANSPORT_FAILURE: throw WmiException("Error getting next element: WBEM_E_TRANSPORT_FAILURE", hr); 142 | case WBEM_S_TIMEDOUT: throw WmiException("Error getting next element: WBEM_S_TIMEDOUT", hr); 143 | default: throw WmiException("Error getting next element: Unknown Error", hr); 144 | } 145 | } 146 | 147 | if(uReturned == 1) 148 | { 149 | cont = (cont && fn(apObj)); 150 | apObj->Release(); 151 | } 152 | } 153 | } 154 | 155 | wstring convertVariant(const VARIANT &value) 156 | { 157 | bool handled = true; 158 | std::wstringstream ss; 159 | 160 | switch(value.vt) 161 | { 162 | case VT_EMPTY: 163 | break; 164 | case VT_NULL: 165 | ss<<"NULL"; 166 | break; 167 | case VT_I2: 168 | ss< fn) 295 | { 296 | SAFEARRAY *psaNames = nullptr; 297 | HRESULT hr = object->GetNames(nullptr, WBEM_FLAG_ALWAYS | WBEM_FLAG_NONSYSTEM_ONLY, nullptr, &psaNames); 298 | 299 | if(FAILED(hr)) 300 | { 301 | switch(hr) 302 | { 303 | case (HRESULT)WBEM_E_FAILED: throw WmiException("Could not get properties: WBEM_E_FAILED", hr); 304 | case (HRESULT)WBEM_E_INVALID_PARAMETER: throw WmiException("Could not get properties: WBEM_E_INVALID_PARAMETER", hr); 305 | case (HRESULT)WBEM_E_OUT_OF_MEMORY: throw WmiException("Could not get properties: WBEM_E_OUT_OF_MEMORY", hr); 306 | default: throw WmiException("Could not get properties: WBEM_E_FAILED", hr); 307 | } 308 | } 309 | 310 | long lLower, lUpper; 311 | BSTR propName = nullptr; 312 | SafeArrayGetLBound(psaNames, 1, &lLower); 313 | SafeArrayGetUBound(psaNames, 1, &lUpper); 314 | 315 | for(long i = lLower; i <= lUpper; ++i) 316 | { 317 | hr = SafeArrayGetElement(psaNames, &i, &propName); 318 | 319 | if(FAILED(hr)) 320 | { 321 | switch(hr) 322 | { 323 | case DISP_E_BADINDEX: throw WmiException("Could not get name from SafeArray: DISP_E_BADINDEX", hr); 324 | case E_INVALIDARG: throw WmiException("Could not get name from SafeArray: E_INVALIDARG", hr); 325 | case E_OUTOFMEMORY: throw WmiException("Could not get name from SafeArray: E_OUTOFMEMORY", hr); 326 | default: throw WmiException("Could not get name from SafeArray: Unknown Error", hr); 327 | } 328 | } 329 | 330 | VARIANT value; 331 | VariantInit(&value); 332 | hr = object->Get(propName, 0, &value, nullptr, nullptr); 333 | 334 | if(FAILED(hr)) 335 | { 336 | switch(hr) 337 | { 338 | case (HRESULT)WBEM_E_FAILED: throw WmiException("Could not get property: WBEM_E_FAILED", hr); 339 | case (HRESULT)WBEM_E_INVALID_PARAMETER: throw WmiException("Could not get property: WBEM_E_INVALID_PARAMETER", hr); 340 | case (HRESULT)WBEM_E_NOT_FOUND: throw WmiException("Could not get property: WBEM_E_NOT_FOUND", hr); 341 | case (HRESULT)WBEM_E_OUT_OF_MEMORY: throw WmiException("Could not get property: WBEM_E_OUT_OF_MEMORY", hr); 342 | default: throw WmiException("Could not get property: Unknown Error", hr); 343 | } 344 | } 345 | 346 | bool cont; 347 | try { 348 | cont = fn(propName, convertVariant(value)); 349 | } catch (const WmiException &e) { 350 | wstring temp(propName); 351 | throw WmiException(string("Can't convert parameter: ") + string(temp.begin(), temp.end()) + ": " + e.errorMessage, e.errorCode); 352 | } 353 | 354 | VariantClear(&value); 355 | SysFreeString(propName); 356 | if(!cont)break; 357 | } 358 | 359 | SafeArrayDestroy(psaNames); 360 | } 361 | 362 | void Wmi::query(const string& q, const string& p, WmiResult &out) 363 | { 364 | HRESULT hr = CoInitialize(nullptr); 365 | if (FAILED(hr)) 366 | { 367 | throw WmiException("The COM library is already initialized on this thread", hr); 368 | } 369 | 370 | IWbemLocator *pLocator; 371 | IWbemServices *pServices; 372 | IEnumWbemClassObject *pClassObject; 373 | 374 | //Create the WBEM locator 375 | try { 376 | pLocator = createWbemLocator(); 377 | } catch (const WmiException &) { 378 | CoUninitialize(); 379 | throw; 380 | } 381 | 382 | //Open connection to computer 383 | try { 384 | pServices = connect(pLocator, p); 385 | } catch (const WmiException &) { 386 | pLocator->Release(); 387 | CoUninitialize(); 388 | throw; 389 | } 390 | 391 | //Execute the query 392 | try { 393 | pClassObject = execute(pServices, q); 394 | } catch (const WmiException &) { 395 | pServices->Release(); 396 | pLocator->Release(); 397 | CoUninitialize(); 398 | throw; 399 | } 400 | 401 | try { 402 | std::size_t index = 0; 403 | 404 | foreachObject(pClassObject, [&out,&index](IWbemClassObject *object) 405 | { 406 | foreachProperty(object, [&out,index](const wstring &name, const std::wstring &value) 407 | { 408 | out.set(index,name, value); 409 | return true; 410 | }); 411 | index++; 412 | return true; 413 | }); 414 | } catch (const WmiException &) { 415 | pServices->Release(); 416 | pLocator->Release(); 417 | CoUninitialize(); 418 | throw; 419 | } 420 | 421 | pClassObject->Release(); 422 | 423 | pServices->Release(); 424 | pLocator->Release(); 425 | CoUninitialize(); 426 | } 427 | -------------------------------------------------------------------------------- /include/wmiclasses.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * WMI 4 | * @author Thomas Sparber (2016) 5 | * 6 | **/ 7 | 8 | #ifndef WMICLASSES_HPP 9 | #define WMICLASSES_HPP 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace Wmi 17 | { 18 | struct Win32_ComputerSystemProduct 19 | { 20 | 21 | Win32_ComputerSystemProduct(): 22 | Caption(), 23 | Description(), 24 | IdentifyingNumber(), 25 | Name(), 26 | UUID(), 27 | Vendor(), 28 | Version() 29 | { } 30 | void setProperties(const WmiResult &result, std::size_t index){ 31 | 32 | result.extract(index,"Caption",(*this).Caption); 33 | result.extract(index,"Description",(*this).Description); 34 | result.extract(index,"IdentifyingNumber",(*this).IdentifyingNumber); 35 | result.extract(index,"Name",(*this).Name); 36 | result.extract(index,"UUID",(*this).UUID); 37 | result.extract(index,"Vendor",(*this).Vendor); 38 | result.extract(index,"Version",(*this).Version); 39 | 40 | } 41 | 42 | static std::string getWmiClassName() 43 | { 44 | return "Win32_ComputerSystemProduct"; 45 | } 46 | 47 | std::string Caption; 48 | std::string Description; 49 | std::string IdentifyingNumber; 50 | std::string Name; 51 | std::string UUID; 52 | std::string Vendor; 53 | std::string Version; 54 | }; 55 | 56 | struct Win32_ComputerSystem 57 | { 58 | 59 | Win32_ComputerSystem() : 60 | AdminPasswordStatus(), AutomaticManagedPagefile(), AutomaticResetBootOption(), AutomaticResetCapability(), 61 | BootOptionOnLimit(), BootOptionOnWatchDog(), BootROMSupported(), BootupState(), Caption(), ChassisBootupState(), 62 | CreationClassName(), CurrentTimeZone(), DaylightInEffect(), Description(), DNSHostName(), Domain(), DomainRole(), 63 | EnableDaylightSavingsTime(), FrontPanelResetStatus(), InfraredSupported(), InitialLoadInfo(), InstallDate(), 64 | KeyboardPasswordStatus(), LastLoadInfo(), Manufacturer(), Model(), Name(), NameFormat(), NetworkServerModeEnabled(), 65 | NumberOfLogicalProcessors(), NumberOfProcessors(), OEMLogoBitmap(), OEMStringArray(), PartOfDomain(), 66 | PauseAfterReset(), PCSystemType(), PowerManagementCapabilities(), PowerManagementSupported(), 67 | PowerOnPasswordStatus(), PowerState(), PowerSupplyState(), PrimaryOwnerContact(), PrimaryOwnerName(), 68 | ResetCapability(), ResetCount(), ResetLimit(), Roles(), Status(), SupportContactDescription(), SystemStartupDelay(), 69 | SystemStartupOptions(), SystemStartupSetting(), SystemType(), ThermalState(), TotalPhysicalMemory(), UserName(), 70 | WakeUpType(), Workgroup() 71 | {} 72 | 73 | void setProperties(const WmiResult &result, std::size_t index) 74 | { 75 | 76 | result.extract(index,"AdminPasswordStatus",(*this).AdminPasswordStatus); 77 | result.extract(index,"AutomaticManagedPagefile",(*this).AutomaticManagedPagefile); 78 | result.extract(index,"AutomaticResetBootOption",(*this).AutomaticResetBootOption); 79 | result.extract(index,"AutomaticResetCapability",(*this).AutomaticResetCapability); 80 | result.extract(index,"BootOptionOnLimit",(*this).BootOptionOnLimit); 81 | result.extract(index,"BootOptionOnWatchDog",(*this).BootOptionOnWatchDog); 82 | result.extract(index,"BootROMSupported",(*this).BootROMSupported); 83 | result.extract(index,"BootupState",(*this).BootupState); 84 | result.extract(index,"Caption",(*this).Caption); 85 | result.extract(index,"ChassisBootupState",(*this).ChassisBootupState); 86 | result.extract(index,"CreationClassName",(*this).CreationClassName); 87 | result.extract(index,"CurrentTimeZone",(*this).CurrentTimeZone); 88 | result.extract(index,"DaylightInEffect",(*this).DaylightInEffect); 89 | result.extract(index,"Description",(*this).Description); 90 | result.extract(index,"DNSHostName",(*this).DNSHostName); 91 | result.extract(index,"Domain",(*this).Domain); 92 | result.extract(index,"DomainRole",(*this).DomainRole); 93 | result.extract(index,"EnableDaylightSavingsTime",(*this).EnableDaylightSavingsTime); 94 | result.extract(index,"FrontPanelResetStatus",(*this).FrontPanelResetStatus); 95 | result.extract(index,"InfraredSupported",(*this).InfraredSupported); 96 | result.extract(index,"InitialLoadInfo",(*this).InitialLoadInfo); 97 | result.extract(index,"InstallDate",(*this).InstallDate); 98 | result.extract(index,"KeyboardPasswordStatus",(*this).KeyboardPasswordStatus); 99 | result.extract(index,"LastLoadInfo",(*this).LastLoadInfo); 100 | result.extract(index,"Manufacturer",(*this).Manufacturer); 101 | result.extract(index,"Model",(*this).Model); 102 | result.extract(index,"Name",(*this).Name); 103 | result.extract(index,"NameFormat",(*this).NameFormat); 104 | result.extract(index,"NetworkServerModeEnabled",(*this).NetworkServerModeEnabled); 105 | result.extract(index,"NumberOfLogicalProcessors",(*this).NumberOfLogicalProcessors); 106 | result.extract(index,"NumberOfProcessors",(*this).NumberOfProcessors); 107 | result.extract(index,"OEMLogoBitmap",(*this).OEMLogoBitmap); 108 | result.extract(index,"OEMStringArray",(*this).OEMStringArray); 109 | result.extract(index,"PartOfDomain",(*this).PartOfDomain); 110 | result.extract(index,"PauseAfterReset",(*this).PauseAfterReset); 111 | result.extract(index,"PCSystemType",(*this).PCSystemType); 112 | result.extract(index,"PowerManagementCapabilities",(*this).PowerManagementCapabilities); 113 | result.extract(index,"PowerManagementSupported",(*this).PowerManagementSupported); 114 | result.extract(index,"PowerOnPasswordStatus",(*this).PowerOnPasswordStatus); 115 | result.extract(index,"PowerState",(*this).PowerState); 116 | result.extract(index,"PowerSupplyState",(*this).PowerSupplyState); 117 | result.extract(index,"PrimaryOwnerContact",(*this).PrimaryOwnerContact); 118 | result.extract(index,"PrimaryOwnerName",(*this).PrimaryOwnerName); 119 | result.extract(index,"ResetCapability",(*this).ResetCapability); 120 | result.extract(index,"ResetCount",(*this).ResetCount); 121 | result.extract(index,"ResetLimit",(*this).ResetLimit); 122 | result.extract(index,"Roles",(*this).Roles); 123 | result.extract(index,"Status",(*this).Status); 124 | result.extract(index,"SupportContactDescription",(*this).SupportContactDescription); 125 | result.extract(index,"SystemStartupDelay",(*this).SystemStartupDelay); 126 | result.extract(index,"SystemStartupOptions",(*this).SystemStartupOptions); 127 | result.extract(index,"SystemStartupSetting",(*this).SystemStartupSetting); 128 | result.extract(index,"SystemType",(*this).SystemType); 129 | result.extract(index,"ThermalState",(*this).ThermalState); 130 | result.extract(index,"TotalPhysicalMemory",(*this).TotalPhysicalMemory); 131 | result.extract(index,"UserName",(*this).UserName); 132 | result.extract(index,"WakeUpType",(*this).WakeUpType); 133 | result.extract(index,"Workgroup",(*this).Workgroup); 134 | } 135 | 136 | static std::string getWmiClassName() 137 | { 138 | return "Win32_ComputerSystem"; 139 | } 140 | 141 | int AdminPasswordStatus; 142 | bool AutomaticManagedPagefile; 143 | bool AutomaticResetBootOption; 144 | bool AutomaticResetCapability; 145 | std::string BootOptionOnLimit; 146 | std::string BootOptionOnWatchDog; 147 | bool BootROMSupported; 148 | std::string BootupState; 149 | std::string Caption; 150 | int ChassisBootupState; 151 | std::string CreationClassName; 152 | int CurrentTimeZone; 153 | bool DaylightInEffect; 154 | std::string Description; 155 | std::string DNSHostName; 156 | std::string Domain; 157 | int DomainRole; 158 | bool EnableDaylightSavingsTime; 159 | int FrontPanelResetStatus; 160 | bool InfraredSupported; 161 | std::string InitialLoadInfo; 162 | std::string InstallDate; 163 | int KeyboardPasswordStatus; 164 | std::string LastLoadInfo; 165 | std::string Manufacturer; 166 | std::string Model; 167 | std::string Name; 168 | std::string NameFormat; 169 | bool NetworkServerModeEnabled; 170 | int NumberOfLogicalProcessors; 171 | int NumberOfProcessors; 172 | std::string OEMLogoBitmap; 173 | std::string OEMStringArray; 174 | bool PartOfDomain; 175 | int PauseAfterReset; 176 | int PCSystemType; 177 | std::string PowerManagementCapabilities; 178 | std::string PowerManagementSupported; 179 | int PowerOnPasswordStatus; 180 | int PowerState; 181 | int PowerSupplyState; 182 | std::string PrimaryOwnerContact; 183 | std::string PrimaryOwnerName; 184 | int ResetCapability; 185 | int ResetCount; 186 | int ResetLimit; 187 | std::vector Roles; 188 | std::string Status; 189 | std::string SupportContactDescription; 190 | std::string SystemStartupDelay; 191 | std::string SystemStartupOptions; 192 | std::string SystemStartupSetting; 193 | std::string SystemType; 194 | int ThermalState; 195 | uint64_t TotalPhysicalMemory; 196 | std::string UserName; 197 | int WakeUpType; 198 | std::string Workgroup; 199 | 200 | }; //end struct Win32_ComputerSystem 201 | 202 | struct Win32_ParallelPort 203 | { 204 | 205 | Win32_ParallelPort() : 206 | Availability(), Capabilities(), CapabilityDescriptions(), Caption(), ConfigManagerErrorCode(), 207 | ConfigManagerUserConfig(), CreationClassName(), Description(), DeviceID(), DMASupport(), ErrorCleared(), 208 | ErrorDescription(), InstallDate(), LastErrorCode(), MaxNumberControlled(), Name(), OSAutoDiscovered(), 209 | PNPDeviceID(), PowerManagementCapabilities(), PowerManagementSupported(), ProtocolSupported(), Status(), 210 | StatusInfo(), SystemCreationClassName(), SystemName(), TimeOfLastReset() 211 | {} 212 | 213 | void setProperties(const WmiResult &result, std::size_t index) 214 | { 215 | //vscode was a great help with search(.+?), 216 | //and replace result.extract(index, "$1", (*this).$1); 217 | result.extract(index,"Availability",(*this).Availability); 218 | result.extract(index,"Capabilities",(*this).Capabilities); 219 | result.extract(index,"CapabilityDescriptions",(*this).CapabilityDescriptions); 220 | result.extract(index,"Caption",(*this).Caption); 221 | result.extract(index,"ConfigManagerErrorCode",(*this).ConfigManagerErrorCode); 222 | result.extract(index,"ConfigManagerUserConfig",(*this).ConfigManagerUserConfig); 223 | result.extract(index,"CreationClassName",(*this).CreationClassName); 224 | result.extract(index,"Description",(*this).Description); 225 | result.extract(index,"DeviceID",(*this).DeviceID); 226 | result.extract(index,"DMASupport",(*this).DMASupport); 227 | result.extract(index,"ErrorCleared",(*this).ErrorCleared); 228 | result.extract(index,"ErrorDescription",(*this).ErrorDescription); 229 | result.extract(index,"InstallDate",(*this).InstallDate); 230 | result.extract(index,"LastErrorCode",(*this).LastErrorCode); 231 | result.extract(index,"MaxNumberControlled",(*this).MaxNumberControlled); 232 | result.extract(index,"Name",(*this).Name); 233 | result.extract(index,"OSAutoDiscovered",(*this).OSAutoDiscovered); 234 | result.extract(index,"PNPDeviceID",(*this).PNPDeviceID); 235 | result.extract(index,"PowerManagementCapabilities",(*this).PowerManagementCapabilities); 236 | result.extract(index,"PowerManagementSupported",(*this).PowerManagementSupported); 237 | result.extract(index,"ProtocolSupported",(*this).ProtocolSupported); 238 | result.extract(index,"Status",(*this).Status); 239 | result.extract(index,"StatusInfo",(*this).StatusInfo); 240 | result.extract(index,"SystemCreationClassName",(*this).SystemCreationClassName); 241 | result.extract(index,"SystemName",(*this).SystemName); 242 | result.extract(index,"TimeOfLastReset",(*this).TimeOfLastReset); 243 | 244 | } 245 | 246 | static std::string getWmiClassName() 247 | { 248 | return "Win32_ParallelPort"; 249 | } 250 | 251 | int Availability; 252 | std::string Capabilities; 253 | std::string CapabilityDescriptions; 254 | std::string Caption; 255 | int ConfigManagerErrorCode; 256 | bool ConfigManagerUserConfig; 257 | std::string CreationClassName; 258 | std::string Description; 259 | std::string DeviceID; 260 | bool DMASupport; 261 | std::string ErrorCleared; 262 | std::string ErrorDescription; 263 | std::string InstallDate; 264 | int LastErrorCode; 265 | int MaxNumberControlled; 266 | std::string Name; 267 | bool OSAutoDiscovered; 268 | std::string PNPDeviceID; 269 | std::string PowerManagementCapabilities; 270 | bool PowerManagementSupported; 271 | int ProtocolSupported; 272 | std::string Status; 273 | std::string StatusInfo; 274 | std::string SystemCreationClassName; 275 | std::string SystemName; 276 | std::string TimeOfLastReset; 277 | 278 | }; //end class Win32_ParallelPort 279 | 280 | struct Win32_PhysicalMedia 281 | { 282 | Win32_PhysicalMedia() : 283 | Caption(), Description(), InstallDate(), Name(), Status(), CreationClassName(), 284 | Manufacturer(), Model(), SKU(), SerialNumber(), Tag(), Version(), PartNumber(), 285 | OtherIdentifyingInfo(), PoweredOn(), Removable(), Replaceable(), HotSwappable(), 286 | Capacity(), MediaType(), MediaDescription(), WriteProtectOn(), CleanerMedia() 287 | {} 288 | 289 | void setProperties(const WmiResult& result, std::size_t index) 290 | { 291 | result.extract(index, "Caption", (*this).Caption); 292 | result.extract(index, "Description", (*this).Description); 293 | result.extract(index, "InstallDate", (*this).InstallDate); 294 | result.extract(index, "Name", (*this).Name); 295 | result.extract(index, "Status", (*this).Status); 296 | result.extract(index, "CreationClassName", (*this).CreationClassName); 297 | result.extract(index, "Manufacturer", (*this).Manufacturer); 298 | result.extract(index, "Model", (*this).Model); 299 | result.extract(index, "SKU", (*this).SKU); 300 | result.extract(index, "SerialNumber", (*this).SerialNumber); 301 | result.extract(index, "Tag", (*this).Tag); 302 | result.extract(index, "Version", (*this).Version); 303 | result.extract(index, "PartNumber", (*this).PartNumber); 304 | result.extract(index, "OtherIdentifyingInfo", (*this).OtherIdentifyingInfo); 305 | result.extract(index, "PoweredOn", (*this).Removable); 306 | result.extract(index, "Replaceable", (*this).Replaceable); 307 | result.extract(index, "HotSwappable", (*this).HotSwappable); 308 | result.extract(index, "Capacity", (*this).Capacity); 309 | result.extract(index, "MediaType", (*this).MediaType); 310 | result.extract(index, "MediaDescription", (*this).MediaDescription); 311 | result.extract(index, "WriteProtectOn", (*this).WriteProtectOn); 312 | result.extract(index, "CleanerMedia", (*this).CleanerMedia); 313 | } 314 | 315 | static std::string getWmiClassName() 316 | { 317 | return "Win32_PhysicalMedia"; 318 | } 319 | 320 | std::string Caption; 321 | std::string Description; 322 | std::string InstallDate; 323 | std::string Name; 324 | std::string Status; 325 | std::string CreationClassName; 326 | std::string Manufacturer; 327 | std::string Model; 328 | std::string SKU; 329 | std::string SerialNumber; 330 | std::string Tag; 331 | std::string Version; 332 | std::string PartNumber; 333 | std::string OtherIdentifyingInfo; 334 | bool PoweredOn; 335 | bool Removable; 336 | bool Replaceable; 337 | bool HotSwappable; 338 | std::string Capacity; 339 | int MediaType; 340 | std::string MediaDescription; 341 | bool WriteProtectOn; 342 | bool CleanerMedia; 343 | 344 | }; //end class Win32_PhysicalMedia 345 | 346 | struct Win32_Processor 347 | { 348 | Win32_Processor() : 349 | AddressWidth(), Architecture(), AssetTag(), Availability(), Caption(), Characteristics(), ConfigManagerErrorCode(), 350 | ConfigManagerUserConfig(), CpuStatus(), CreationClassName(), CurrentClockSpeed(), CurrentVoltage(), DataWidth(), 351 | Description(), DeviceID(), ErrorCleared(), ErrorDescription(), ExtClock(), Family(), InstallDate(), 352 | L2CacheSize(), L2CacheSpeed(), L3CacheSize(), L3CacheSpeed(), LastErrorCode(), Level(), LoadPercentage(), 353 | Manufacturer(), MaxClockSpeed(), Name(), NumberOfCores(), NumberOfEnabledCore(), NumberOfLogicalProcessors(), 354 | OtherFamilyDescription(), PartNumber(), PNPDeviceID(), PowerManagementCapabilities(), PowerManagementSupported(), ProcessorId(), 355 | ProcessorType(), Revision(), Role(), SecondLevelAddressTranslationExtensions(), SerialNumber(), SocketDesignation(), 356 | Status(), StatusInfo(), Stepping(), SystemCreationClassName(), SystemName(), ThreadCount(), UniqueId(), 357 | UpgradeMethod(), Version(), VirtualizationFirmwareEnabled(), VMMonitorModeExtensions(), VoltageCaps() 358 | {} 359 | 360 | void setProperties(const WmiResult& result, std::size_t index) 361 | { 362 | //vscode was a great help with search(.+?), 363 | //and replace result.extract(index, "$1", (*this).$1); 364 | result.extract(index, "AddressWidth", (*this).AddressWidth); 365 | result.extract(index, "Architecture", (*this).Architecture); 366 | result.extract(index, "AssetTag", (*this).AssetTag); 367 | result.extract(index, "Availability", (*this).Availability); 368 | result.extract(index, "Caption", (*this).Caption); 369 | result.extract(index, "Characteristics", (*this).Characteristics); 370 | result.extract(index, "ConfigManagerErrorCode", (*this).ConfigManagerErrorCode); 371 | result.extract(index, "ConfigManagerUserConfig", (*this).ConfigManagerUserConfig); 372 | result.extract(index, "CpuStatus", (*this).CpuStatus); 373 | result.extract(index, "CreationClassName", (*this).CreationClassName); 374 | result.extract(index, "CurrentClockSpeed", (*this).CurrentClockSpeed); 375 | result.extract(index, "CurrentVoltage", (*this).CurrentVoltage); 376 | result.extract(index, "DataWidth", (*this).DataWidth); 377 | result.extract(index, "Description", (*this).Description); 378 | result.extract(index, "DeviceID", (*this).DeviceID); 379 | result.extract(index, "ErrorCleared", (*this).ErrorCleared); 380 | result.extract(index, "ErrorDescription", (*this).ErrorDescription); 381 | result.extract(index, "ExtClock", (*this).ExtClock); 382 | result.extract(index, "Family", (*this).Family); 383 | result.extract(index, "InstallDate", (*this).InstallDate); 384 | result.extract(index, "L2CacheSize", (*this).L2CacheSize); 385 | result.extract(index, "L2CacheSpeed", (*this).L2CacheSpeed); 386 | result.extract(index, "L3CacheSize", (*this).L3CacheSize); 387 | result.extract(index, "L3CacheSpeed", (*this).L3CacheSpeed); 388 | result.extract(index, "LastErrorCode", (*this).LastErrorCode); 389 | result.extract(index, "Level", (*this).Level); 390 | result.extract(index, "LoadPercentage", (*this).LoadPercentage); 391 | result.extract(index, "Manufacturer", (*this).Manufacturer); 392 | result.extract(index, "MaxClockSpeed", (*this).MaxClockSpeed); 393 | result.extract(index, "Name", (*this).Name); 394 | result.extract(index, "NumberOfCores", (*this).NumberOfCores); 395 | result.extract(index, "NumberOfEnabledCore", (*this).NumberOfEnabledCore); 396 | result.extract(index, "NumberOfLogicalProcessors", (*this).NumberOfLogicalProcessors); 397 | result.extract(index, "OtherFamilyDescription", (*this).OtherFamilyDescription); 398 | result.extract(index, "PartNumber", (*this).PartNumber); 399 | result.extract(index, "PNPDeviceID", (*this).PNPDeviceID); 400 | result.extract(index, "PowerManagementCapabilities", (*this).PowerManagementCapabilities); 401 | result.extract(index, "PowerManagementSupported", (*this).PowerManagementSupported); 402 | result.extract(index, "ProcessorId", (*this).ProcessorId); 403 | result.extract(index, "ProcessorType", (*this).ProcessorType); 404 | result.extract(index, "Revision", (*this).Revision); 405 | result.extract(index, "SecondLevelAddressTranslationExtensions", (*this).SecondLevelAddressTranslationExtensions); 406 | result.extract(index, "SerialNumber", (*this).SerialNumber); 407 | result.extract(index, "SocketDesignation", (*this).SocketDesignation); 408 | result.extract(index, "Status", (*this).Status); 409 | result.extract(index, "StatusInfo", (*this).StatusInfo); 410 | result.extract(index, "Stepping", (*this).Stepping); 411 | result.extract(index, "SystemCreationClassName", (*this).SystemCreationClassName); 412 | result.extract(index, "SystemName", (*this).SystemName); 413 | result.extract(index, "ThreadCount", (*this).ThreadCount); 414 | result.extract(index, "UniqueId", (*this).UniqueId); 415 | result.extract(index, "UpgradeMethod", (*this).UpgradeMethod); 416 | result.extract(index, "Version", (*this).Version); 417 | result.extract(index, "VirtualizationFirmwareEnabled", (*this).VirtualizationFirmwareEnabled); 418 | result.extract(index, "VMMonitorModeExtensions", (*this).VMMonitorModeExtensions); 419 | result.extract(index, "VoltageCaps", (*this).VoltageCaps); 420 | } 421 | 422 | static std::string getWmiClassName() 423 | { 424 | return "Win32_Processor"; 425 | } 426 | 427 | int AddressWidth; 428 | int Architecture; 429 | std::string AssetTag; 430 | int Availability; 431 | std::string Caption; 432 | std::string Characteristics; 433 | int ConfigManagerErrorCode; 434 | bool ConfigManagerUserConfig; 435 | int CpuStatus; 436 | std::string CreationClassName; 437 | int CurrentClockSpeed; 438 | int CurrentVoltage; 439 | int DataWidth; 440 | std::string Description; 441 | std::string DeviceID; 442 | std::string ErrorCleared; 443 | std::string ErrorDescription; 444 | int ExtClock; 445 | int Family; 446 | std::string InstallDate; 447 | int L2CacheSize; 448 | int L2CacheSpeed; 449 | int L3CacheSize; 450 | int L3CacheSpeed; 451 | int LastErrorCode; 452 | int Level; 453 | int LoadPercentage; 454 | std::string Manufacturer; 455 | int MaxClockSpeed; 456 | std::string Name; 457 | int NumberOfCores; 458 | int NumberOfEnabledCore; 459 | int NumberOfLogicalProcessors; 460 | std::string OtherFamilyDescription; 461 | std::string PartNumber; 462 | std::string PNPDeviceID; 463 | std::string PowerManagementCapabilities; 464 | bool PowerManagementSupported; 465 | std::string ProcessorId; 466 | int ProcessorType; 467 | int Revision; 468 | std::string Role; 469 | bool SecondLevelAddressTranslationExtensions; 470 | std::string SerialNumber; 471 | std::string SocketDesignation; 472 | std::string Status; 473 | std::string StatusInfo; 474 | std::string Stepping; 475 | std::string SystemCreationClassName; 476 | std::string SystemName; 477 | std::string ThreadCount; 478 | std::string UniqueId; 479 | int UpgradeMethod; 480 | std::string Version; 481 | bool VirtualizationFirmwareEnabled; 482 | bool VMMonitorModeExtensions; 483 | int VoltageCaps; 484 | 485 | }; //end class Win32_Processor 486 | 487 | struct Win32_Service 488 | { 489 | 490 | Win32_Service() : 491 | AcceptPause(), AcceptStop(), Caption(), CheckPoint(), CreationClassName(), Description(), 492 | DesktopInteract(), DisplayName(), ErrorControl(), ExitCode(), InstallDate(), Name(), PathName(), 493 | ProcessId(), ServiceSpecificExitCode(), ServiceType(), Started(), StartMode(), StartName(), State(), 494 | Status(), SystemCreationClassName(), SystemName(), TagId(), WaitHint() 495 | {} 496 | 497 | void setProperties(const WmiResult &result, std::size_t index) 498 | { 499 | result.extract(index, "AcceptPause", (*this).AcceptPause); 500 | result.extract(index, "AcceptStop", (*this).AcceptStop); 501 | result.extract(index, "Caption", (*this).Caption); 502 | result.extract(index, "CheckPoint", (*this).CheckPoint); 503 | result.extract(index, "CreationClassName", (*this).CreationClassName); 504 | result.extract(index, "Description", (*this).Description); 505 | result.extract(index, "DesktopInteract", (*this).DesktopInteract); 506 | result.extract(index, "DisplayName", (*this).DisplayName); 507 | result.extract(index, "ErrorControl", (*this).ErrorControl); 508 | result.extract(index, "ExitCode", (*this).ExitCode); 509 | result.extract(index, "InstallDate", (*this).InstallDate); 510 | result.extract(index, "Name", (*this).Name); 511 | result.extract(index, "PathName", (*this).PathName); 512 | result.extract(index, "ProcessId", (*this).ProcessId); 513 | result.extract(index, "ServiceSpecificExitCode", (*this).ServiceSpecificExitCode); 514 | result.extract(index, "ServiceType", (*this).ServiceType); 515 | result.extract(index, "Started", (*this).Started); 516 | result.extract(index, "StartMode", (*this).StartMode); 517 | result.extract(index, "StartName", (*this).StartName); 518 | result.extract(index, "State", (*this).State); 519 | result.extract(index, "Status", (*this).Status); 520 | result.extract(index, "SystemCreationClassName", (*this).SystemCreationClassName); 521 | result.extract(index, "SystemName", (*this).SystemName); 522 | result.extract(index, "TagId", (*this).TagId); 523 | result.extract(index, "WaitHint", (*this).WaitHint); 524 | } 525 | 526 | static std::string getWmiClassName() 527 | { 528 | return "Win32_Service"; 529 | } 530 | 531 | bool AcceptPause; 532 | bool AcceptStop; 533 | std::string Caption; 534 | int CheckPoint; 535 | std::string CreationClassName; 536 | std::string Description; 537 | bool DesktopInteract; 538 | std::string DisplayName; 539 | std::string ErrorControl; 540 | int ExitCode; 541 | std::string InstallDate; 542 | std::string Name; 543 | std::string PathName; 544 | int ProcessId; 545 | int ServiceSpecificExitCode; 546 | std::string ServiceType; 547 | bool Started; 548 | std::string StartMode; 549 | std::string StartName; 550 | std::string State; 551 | std::string Status; 552 | std::string SystemCreationClassName; 553 | std::string SystemName; 554 | int TagId; 555 | int WaitHint; 556 | 557 | }; //end Win32_Service 558 | 559 | struct Win32_SerialPort 560 | { 561 | 562 | Win32_SerialPort() : 563 | Availability(), Binary(), Capabilities(), CapabilityDescriptions(), Caption(), 564 | ConfigManagerErrorCode(), ConfigManagerUserConfig(), CreationClassName(), Description(), 565 | DeviceID(), ErrorCleared(), ErrorDescription(), InstallDate(), LastErrorCode(), MaxBaudRate(), 566 | MaximumInputBufferSize(), MaximumOutputBufferSize(), MaxNumberControlled(), Name(), 567 | OSAutoDiscovered(), PNPDeviceID(), PowerManagementCapabilities(), PowerManagementSupported(), 568 | ProtocolSupported(), ProviderType(), SettableBaudRate(), SettableDataBits(), 569 | SettableFlowControl(), SettableParity(), SettableParityCheck(), SettableRLSD(), 570 | SettableStopBits(), Status(), StatusInfo(), Supports16BitMode(), SupportsDTRDSR(), 571 | SupportsElapsedTimeouts(), SupportsIntTimeouts(), SupportsParityCheck(), SupportsRLSD(), 572 | SupportsRTSCTS(), SupportsSpecialCharacters(), SupportsXOnXOff(), SupportsXOnXOffSet(), 573 | SystemCreationClassName(), SystemName(), TimeOfLastReset() 574 | {} 575 | 576 | void setProperties(const WmiResult &result, std::size_t index) 577 | { 578 | result.extract(index,"Availability",(*this).Availability); 579 | result.extract(index,"Binary",(*this).Binary); 580 | result.extract(index,"Capabilities",(*this).Capabilities); 581 | result.extract(index,"CapabilityDescriptions",(*this).CapabilityDescriptions); 582 | result.extract(index,"Caption",(*this).Caption); 583 | result.extract(index,"ConfigManagerErrorCode",(*this).ConfigManagerErrorCode); 584 | result.extract(index,"ConfigManagerUserConfig",(*this).ConfigManagerUserConfig); 585 | result.extract(index,"CreationClassName",(*this).CreationClassName); 586 | result.extract(index,"Description",(*this).Description); 587 | result.extract(index,"DeviceID",(*this).DeviceID); 588 | result.extract(index,"ErrorCleared",(*this).ErrorCleared); 589 | result.extract(index,"ErrorDescription",(*this).ErrorDescription); 590 | result.extract(index,"InstallDate",(*this).InstallDate); 591 | result.extract(index,"LastErrorCode",(*this).LastErrorCode); 592 | result.extract(index,"MaxBaudRate",(*this).MaxBaudRate); 593 | result.extract(index,"MaximumInputBufferSize",(*this).MaximumInputBufferSize); 594 | result.extract(index,"MaximumOutputBufferSize",(*this).MaximumOutputBufferSize); 595 | result.extract(index,"MaxNumberControlled",(*this).MaxNumberControlled); 596 | result.extract(index,"Name",(*this).Name); 597 | result.extract(index,"OSAutoDiscovered",(*this).OSAutoDiscovered); 598 | result.extract(index,"PNPDeviceID",(*this).PNPDeviceID); 599 | result.extract(index,"PowerManagementCapabilities",(*this).PowerManagementCapabilities); 600 | result.extract(index,"PowerManagementSupported",(*this).PowerManagementSupported); 601 | result.extract(index,"ProtocolSupported",(*this).ProtocolSupported); 602 | result.extract(index,"ProviderType",(*this).ProviderType); 603 | result.extract(index,"SettableBaudRate",(*this).SettableBaudRate); 604 | result.extract(index,"SettableDataBits",(*this).SettableDataBits); 605 | result.extract(index,"SettableFlowControl",(*this).SettableFlowControl); 606 | result.extract(index,"SettableParity",(*this).SettableParity); 607 | result.extract(index,"SettableParityCheck",(*this).SettableParityCheck); 608 | result.extract(index,"SettableRLSD",(*this).SettableRLSD); 609 | result.extract(index,"SettableStopBits",(*this).SettableStopBits); 610 | result.extract(index,"Status",(*this).Status); 611 | result.extract(index,"StatusInfo",(*this).StatusInfo); 612 | result.extract(index,"Supports16BitMode",(*this).Supports16BitMode); 613 | result.extract(index,"SupportsDTRDSR",(*this).SupportsDTRDSR); 614 | result.extract(index,"SupportsElapsedTimeouts",(*this).SupportsElapsedTimeouts); 615 | result.extract(index,"SupportsIntTimeouts",(*this).SupportsIntTimeouts); 616 | result.extract(index,"SupportsParityCheck",(*this).SupportsParityCheck); 617 | result.extract(index,"SupportsRLSD",(*this).SupportsRLSD); 618 | result.extract(index,"SupportsRTSCTS",(*this).SupportsRTSCTS); 619 | result.extract(index,"SupportsSpecialCharacters",(*this).SupportsSpecialCharacters); 620 | result.extract(index,"SupportsXOnXOff",(*this).SupportsXOnXOff); 621 | result.extract(index,"SupportsXOnXOffSet",(*this).SupportsXOnXOffSet); 622 | result.extract(index,"SystemCreationClassName",(*this).SystemCreationClassName); 623 | result.extract(index,"SystemName",(*this).SystemName); 624 | result.extract(index,"TimeOfLastReset",(*this).TimeOfLastReset); 625 | } 626 | 627 | static std::string getWmiClassName() 628 | { 629 | return "Win32_SerialPort"; 630 | } 631 | 632 | int Availability; 633 | bool Binary; 634 | std::string Capabilities; 635 | std::string CapabilityDescriptions; 636 | std::string Caption; 637 | int ConfigManagerErrorCode; 638 | bool ConfigManagerUserConfig; 639 | std::string CreationClassName; 640 | std::string Description; 641 | std::string DeviceID; 642 | std::string ErrorCleared; 643 | std::string ErrorDescription; 644 | std::string InstallDate; 645 | int LastErrorCode; 646 | uint64_t MaxBaudRate; 647 | uint64_t MaximumInputBufferSize; 648 | uint64_t MaximumOutputBufferSize; 649 | int MaxNumberControlled; 650 | std::string Name; 651 | bool OSAutoDiscovered; 652 | std::string PNPDeviceID; 653 | std::string PowerManagementCapabilities; 654 | bool PowerManagementSupported; 655 | int ProtocolSupported; 656 | std::string ProviderType; 657 | std::string SettableBaudRate; 658 | std::string SettableDataBits; 659 | std::string SettableFlowControl; 660 | std::string SettableParity; 661 | std::string SettableParityCheck; 662 | std::string SettableRLSD; 663 | std::string SettableStopBits; 664 | std::string Status; 665 | std::string StatusInfo; 666 | bool Supports16BitMode; 667 | bool SupportsDTRDSR; 668 | bool SupportsElapsedTimeouts; 669 | bool SupportsIntTimeouts; 670 | bool SupportsParityCheck; 671 | bool SupportsRLSD; 672 | bool SupportsRTSCTS; 673 | bool SupportsSpecialCharacters; 674 | bool SupportsXOnXOff; 675 | bool SupportsXOnXOffSet; 676 | std::string SystemCreationClassName; 677 | std::string SystemName; 678 | std::string TimeOfLastReset; 679 | 680 | }; //end Win32_SerialPort 681 | 682 | struct SoftwareLicensingService 683 | { 684 | SoftwareLicensingService(): 685 | ClientMachineID(), 686 | DiscoveredKeyManagementServiceMachineIpAddress(), 687 | DiscoveredKeyManagementServiceMachineName(), 688 | DiscoveredKeyManagementServiceMachinePort(), 689 | IsKeyManagementServiceMachine(), 690 | KeyManagementServiceCurrentCount(), 691 | KeyManagementServiceDnsPublishing(), 692 | KeyManagementServiceFailedRequests(), 693 | KeyManagementServiceHostCaching(), 694 | KeyManagementServiceLicensedRequests(), 695 | KeyManagementServiceListeningPort(), 696 | KeyManagementServiceLookupDomain(), 697 | KeyManagementServiceLowPriority(), 698 | KeyManagementServiceMachine(), 699 | KeyManagementServiceNonGenuineGraceRequests(), 700 | KeyManagementServiceNotificationRequests(), 701 | KeyManagementServiceOOBGraceRequests(), 702 | KeyManagementServiceOOTGraceRequests(), 703 | KeyManagementServicePort(), 704 | KeyManagementServiceProductKeyID(), 705 | KeyManagementServiceTotalRequests(), 706 | KeyManagementServiceUnlicensedRequests(), 707 | OA2xBiosMarkerMinorVersion(), 708 | OA2xBiosMarkerStatus(), 709 | OA3xOriginalProductKey(), 710 | OA3xOriginalProductKeyDescription(), 711 | OA3xOriginalProductKeyPkPn(), 712 | PolicyCacheRefreshRequired(), 713 | RemainingWindowsReArmCount(), 714 | RequiredClientCount(), 715 | TokenActivationAdditionalInfo(), 716 | TokenActivationCertificateThumbprint(), 717 | TokenActivationGrantNumber(), 718 | TokenActivationILID(), 719 | TokenActivationILVID(), 720 | Version(), 721 | VLActivationInterval(), 722 | VLRenewalInterval() 723 | {} 724 | 725 | void setProperties(const WmiResult &result, std::size_t index) 726 | { 727 | result.extract(index, "ClientMachineID", (*this).ClientMachineID); 728 | result.extract(index, "DiscoveredKeyManagementServiceMachineIpAddress", (*this).DiscoveredKeyManagementServiceMachineIpAddress); 729 | result.extract(index, "DiscoveredKeyManagementServiceMachineName", (*this).DiscoveredKeyManagementServiceMachineName); 730 | result.extract(index, "DiscoveredKeyManagementServiceMachinePort", (*this).DiscoveredKeyManagementServiceMachinePort); 731 | result.extract(index, "IsKeyManagementServiceMachine", (*this).IsKeyManagementServiceMachine); 732 | result.extract(index, "KeyManagementServiceCurrentCount", (*this).KeyManagementServiceCurrentCount); 733 | result.extract(index, "KeyManagementServiceDnsPublishing", (*this).KeyManagementServiceDnsPublishing); 734 | result.extract(index, "KeyManagementServiceFailedRequests", (*this).KeyManagementServiceFailedRequests); 735 | result.extract(index, "KeyManagementServiceHostCaching", (*this).KeyManagementServiceHostCaching); 736 | result.extract(index, "KeyManagementServiceLicensedRequests", (*this).KeyManagementServiceLicensedRequests); 737 | result.extract(index, "KeyManagementServiceListeningPort", (*this).KeyManagementServiceListeningPort); 738 | result.extract(index, "KeyManagementServiceLookupDomain", (*this).KeyManagementServiceLookupDomain); 739 | result.extract(index, "KeyManagementServiceLowPriority", (*this).KeyManagementServiceLowPriority); 740 | result.extract(index, "KeyManagementServiceMachine", (*this).KeyManagementServiceMachine); 741 | result.extract(index, "KeyManagementServiceNonGenuineGraceRequests", (*this).KeyManagementServiceNonGenuineGraceRequests); 742 | result.extract(index, "KeyManagementServiceNotificationRequests", (*this).KeyManagementServiceNotificationRequests); 743 | result.extract(index, "KeyManagementServiceOOBGraceRequests", (*this).KeyManagementServiceOOBGraceRequests); 744 | result.extract(index, "KeyManagementServiceOOTGraceRequests", (*this).KeyManagementServiceOOTGraceRequests); 745 | result.extract(index, "KeyManagementServicePort", (*this).KeyManagementServicePort); 746 | result.extract(index, "KeyManagementServiceProductKeyID", (*this).KeyManagementServiceProductKeyID); 747 | result.extract(index, "KeyManagementServiceTotalRequests", (*this).KeyManagementServiceTotalRequests); 748 | result.extract(index, "KeyManagementServiceUnlicensedRequests", (*this).KeyManagementServiceUnlicensedRequests); 749 | result.extract(index, "OA2xBiosMarkerMinorVersion", (*this).OA2xBiosMarkerMinorVersion); 750 | result.extract(index, "OA2xBiosMarkerStatus", (*this).OA2xBiosMarkerStatus); 751 | result.extract(index, "OA3xOriginalProductKey", (*this).OA3xOriginalProductKey); 752 | result.extract(index, "OA3xOriginalProductKeyDescription", (*this).OA3xOriginalProductKeyDescription); 753 | result.extract(index, "OA3xOriginalProductKeyPkPn", (*this).OA3xOriginalProductKeyPkPn); 754 | result.extract(index, "PolicyCacheRefreshRequired", (*this).PolicyCacheRefreshRequired); 755 | result.extract(index, "RemainingWindowsReArmCount", (*this).RemainingWindowsReArmCount); 756 | result.extract(index, "RequiredClientCount", (*this).RequiredClientCount); 757 | result.extract(index, "TokenActivationAdditionalInfo", (*this).TokenActivationAdditionalInfo); 758 | result.extract(index, "TokenActivationCertificateThumbprint", (*this).TokenActivationCertificateThumbprint); 759 | result.extract(index, "TokenActivationGrantNumber", (*this).TokenActivationGrantNumber); 760 | result.extract(index, "TokenActivationILID", (*this).TokenActivationILID); 761 | result.extract(index, "TokenActivationILVID", (*this).TokenActivationILVID); 762 | result.extract(index, "Version", (*this).Version); 763 | result.extract(index, "VLActivationInterval", (*this).VLActivationInterval); 764 | result.extract(index, "VLRenewalInterval", (*this).VLRenewalInterval); 765 | } 766 | static std::string getWmiClassName() 767 | { 768 | return "SoftwareLicensingService"; 769 | } 770 | std::string ClientMachineID; 771 | std::string DiscoveredKeyManagementServiceMachineIpAddress; 772 | std::string DiscoveredKeyManagementServiceMachineName; 773 | int DiscoveredKeyManagementServiceMachinePort; 774 | int IsKeyManagementServiceMachine ; 775 | int KeyManagementServiceCurrentCount ; 776 | bool KeyManagementServiceDnsPublishing ; 777 | int KeyManagementServiceFailedRequests ; 778 | bool KeyManagementServiceHostCaching ; 779 | int KeyManagementServiceLicensedRequests ; 780 | int KeyManagementServiceListeningPort ; 781 | std::string KeyManagementServiceLookupDomain; 782 | bool KeyManagementServiceLowPriority ; 783 | std::string KeyManagementServiceMachine; 784 | int KeyManagementServiceNonGenuineGraceRequests ; 785 | int KeyManagementServiceNotificationRequests ; 786 | int KeyManagementServiceOOBGraceRequests ; 787 | int KeyManagementServiceOOTGraceRequests ; 788 | int KeyManagementServicePort ; 789 | std::string KeyManagementServiceProductKeyID; 790 | int KeyManagementServiceTotalRequests ; 791 | int KeyManagementServiceUnlicensedRequests ; 792 | int OA2xBiosMarkerMinorVersion ; 793 | int OA2xBiosMarkerStatus ; 794 | std::string OA3xOriginalProductKey; 795 | std::string OA3xOriginalProductKeyDescription; 796 | std::string OA3xOriginalProductKeyPkPn; 797 | int PolicyCacheRefreshRequired ; 798 | int RemainingWindowsReArmCount ; 799 | int RequiredClientCount ; 800 | std::string TokenActivationAdditionalInfo; 801 | int TokenActivationCertificateThumbprint; 802 | int TokenActivationGrantNumber ; 803 | std::string TokenActivationILID; 804 | int TokenActivationILVID ; 805 | std::string Version; 806 | int VLActivationInterval ; 807 | int VLRenewalInterval ; 808 | }; 809 | 810 | struct Win32_LogicalDisk 811 | { 812 | Win32_LogicalDisk() : 813 | Access(), Availability(), BlockSize(), Caption(), Compressed(), ConfigManagerErrorCode(), 814 | ConfigManagerUserConfig(), CreationClassName(), Description(), DeviceID(), DriveType(), 815 | ErrorCleared(), ErrorDescription(), ErrorMethodology(), FileSystem(), FreeSpace(), InstallDate(), 816 | LastErrorCode(), MaximumComponentLength(), MediaType(), Name(), NumberOfBlocks(), PNPDeviceID(), 817 | PowerManagementCapabilities(), PowerManagementSupported(), ProviderName(), Purpose(), QuotasDisabled(), 818 | QuotasIncomplete(), QuotasRebuilding(), Size(), Status(), StatusInfo(), SupportsDiskQuotas(), 819 | SupportsFileBasedCompression(), SystemCreationClassName(), SystemName(), VolumeDirty(), 820 | VolumeName(), VolumeSerialNumber() 821 | {} 822 | 823 | void setProperties(const WmiResult& result, std::size_t index) 824 | { 825 | result.extract(index, "Access", (*this).Access); 826 | result.extract(index, "Availability", (*this).Availability); 827 | result.extract(index, "BlockSize", (*this).BlockSize); 828 | result.extract(index, "Caption", (*this).Caption); 829 | result.extract(index, "Compressed", (*this).Compressed); 830 | result.extract(index, "ConfigManagerErrorCode", (*this).ConfigManagerErrorCode); 831 | result.extract(index, "ConfigManagerUserConfig", (*this).ConfigManagerUserConfig); 832 | result.extract(index, "CreationClassName", (*this).CreationClassName); 833 | result.extract(index, "Description", (*this).Description); 834 | result.extract(index, "DeviceID", (*this).DeviceID); 835 | result.extract(index, "DriveType", (*this).DriveType); 836 | result.extract(index, "ErrorCleared", (*this).ErrorCleared); 837 | result.extract(index, "ErrorDescription", (*this).ErrorDescription); 838 | result.extract(index, "ErrorMethodology", (*this).ErrorMethodology); 839 | result.extract(index, "FileSystem", (*this).FileSystem); 840 | result.extract(index, "FreeSpace", (*this).FreeSpace); 841 | result.extract(index, "InstallDate", (*this).InstallDate); 842 | result.extract(index, "LastErrorCode", (*this).LastErrorCode); 843 | result.extract(index, "MaximumComponentLength", (*this).MaximumComponentLength); 844 | result.extract(index, "MediaType", (*this).MediaType); 845 | result.extract(index, "Name", (*this).Name); 846 | result.extract(index, "NumberOfBlocks", (*this).NumberOfBlocks); 847 | result.extract(index, "PNPDeviceID", (*this).PNPDeviceID); 848 | result.extract(index, "PowerManagementCapabilities", (*this).PowerManagementCapabilities); 849 | result.extract(index, "PowerManagementSupported", (*this).PowerManagementSupported); 850 | result.extract(index, "ProviderName", (*this).ProviderName); 851 | result.extract(index, "Purpose", (*this).Purpose); 852 | result.extract(index, "QuotasDisabled", (*this).QuotasDisabled); 853 | result.extract(index, "QuotasIncomplete", (*this).QuotasIncomplete); 854 | result.extract(index, "QuotasRebuilding", (*this).QuotasRebuilding); 855 | result.extract(index, "Size", (*this).Size); 856 | result.extract(index, "StatusInfo", (*this).StatusInfo); 857 | result.extract(index, "SupportsDiskQuotas", (*this).SupportsDiskQuotas); 858 | result.extract(index, "SupportsFileBasedCompression", (*this).SupportsFileBasedCompression); 859 | result.extract(index, "SystemCreationClassName", (*this).SystemCreationClassName); 860 | result.extract(index, "SystemName", (*this).SystemName); 861 | result.extract(index, "VolumeDirty", (*this).VolumeDirty); 862 | result.extract(index, "VolumeName", (*this).VolumeName); 863 | result.extract(index, "VolumeSerialNumber", (*this).VolumeSerialNumber); 864 | } 865 | 866 | static std::string getWmiClassName() 867 | { 868 | return "Win32_LogicalDisk"; 869 | } 870 | 871 | int Access; 872 | int Availability; 873 | std::string BlockSize; 874 | std::string Caption; 875 | bool Compressed; 876 | int ConfigManagerErrorCode; 877 | bool ConfigManagerUserConfig; 878 | std::string CreationClassName; 879 | std::string Description; 880 | std::string DeviceID; 881 | int DriveType; 882 | bool ErrorCleared; 883 | std::string ErrorDescription; 884 | std::string ErrorMethodology; 885 | std::string FileSystem; 886 | std::string FreeSpace; 887 | std::string InstallDate; 888 | int LastErrorCode; 889 | int MaximumComponentLength; 890 | int MediaType; 891 | std::string Name; 892 | std::string NumberOfBlocks; 893 | std::string PNPDeviceID; 894 | std::string PowerManagementCapabilities; 895 | std::string PowerManagementSupported; 896 | std::string ProviderName; 897 | std::string Purpose; 898 | bool QuotasDisabled; 899 | bool QuotasIncomplete; 900 | bool QuotasRebuilding; 901 | std::string Size; 902 | std::string Status; 903 | std::string StatusInfo; 904 | bool SupportsDiskQuotas; 905 | bool SupportsFileBasedCompression; 906 | std::string SystemCreationClassName; 907 | std::string SystemName; 908 | bool VolumeDirty; 909 | std::string VolumeName; 910 | std::string VolumeSerialNumber; 911 | }; //end Win32_LogicalDisk 912 | 913 | struct Win32_OperatingSystem 914 | { 915 | Win32_OperatingSystem(): 916 | BootDevice(), 917 | BuildNumber(), 918 | BuildType(), 919 | Caption(), 920 | CodeSet(), 921 | CountryCode(), 922 | CreationClassName(), 923 | CSCreationClassName(), 924 | CSName(), 925 | CurrentTimeZone(), 926 | DataExecutionPrevention_32BitApplications(), 927 | DataExecutionPrevention_Available(), 928 | DataExecutionPrevention_Drivers(), 929 | DataExecutionPrevention_SupportPolicy(), 930 | Debug(), 931 | Description(), 932 | Distributed(), 933 | EncryptionLevel(), 934 | ForegroundApplicationBoost(), 935 | FreePhysicalMemory(), 936 | FreeSpaceInPagingFiles(), 937 | FreeVirtualMemory(), 938 | InstallDate(), 939 | LastBootUpTime(), 940 | LocalDateTime(), 941 | Locale(), 942 | Manufacturer(), 943 | MaxNumberOfProcesses(), 944 | MaxProcessMemorySize(), 945 | MUILanguages(), 946 | Name(), 947 | NumberOfProcesses(), 948 | NumberOfUsers(), 949 | OperatingSystemSKU(), 950 | Organization(), 951 | OSArchitecture(), 952 | OSLanguage(), 953 | OSProductSuite(), 954 | OSType(), 955 | PortableOperatingSystem(), 956 | Primary(), 957 | ProductType(), 958 | RegisteredUser(), 959 | SerialNumber(), 960 | ServicePackMajorVersion(), 961 | ServicePackMinorVersion(), 962 | SizeStoredInPagingFiles(), 963 | Status(), 964 | SuiteMask(), 965 | SystemDevice(), 966 | SystemDirectory(), 967 | SystemDrive(), 968 | TotalVirtualMemorySize(), 969 | TotalVisibleMemorySize(), 970 | Version(), 971 | WindowsDirectory() 972 | {} 973 | 974 | void setProperties(const WmiResult &result, std::size_t index) 975 | { 976 | result.extract(index, "BootDevice", (*this).BootDevice); 977 | result.extract(index, "BuildNumber", (*this).BuildNumber); 978 | result.extract(index, "BuildType", (*this).BuildType); 979 | result.extract(index, "Caption", (*this).Caption); 980 | result.extract(index, "CodeSet", (*this).CodeSet); 981 | result.extract(index, "CountryCode", (*this).CountryCode); 982 | result.extract(index, "CreationClassName", (*this).CreationClassName); 983 | result.extract(index, "CSCreationClassName", (*this).CSCreationClassName); 984 | result.extract(index, "CSName", (*this).CSName); 985 | result.extract(index, "CurrentTimeZone", (*this).CurrentTimeZone); 986 | result.extract(index, "DataExecutionPrevention_32BitApplications", (*this).DataExecutionPrevention_32BitApplications); 987 | result.extract(index, "DataExecutionPrevention_Available", (*this).DataExecutionPrevention_Available); 988 | result.extract(index, "DataExecutionPrevention_Drivers", (*this).DataExecutionPrevention_Drivers); 989 | result.extract(index, "DataExecutionPrevention_SupportPolicy", (*this).DataExecutionPrevention_SupportPolicy); 990 | result.extract(index, "Debug", (*this).Debug); 991 | result.extract(index, "Description", (*this).Description); 992 | result.extract(index, "Distributed", (*this).Distributed); 993 | result.extract(index, "EncryptionLevel", (*this).EncryptionLevel); 994 | result.extract(index, "ForegroundApplicationBoost", (*this).ForegroundApplicationBoost); 995 | result.extract(index, "FreePhysicalMemory", (*this).FreePhysicalMemory); 996 | result.extract(index, "FreeSpaceInPagingFiles", (*this).FreeSpaceInPagingFiles); 997 | result.extract(index, "FreeVirtualMemory", (*this).FreeVirtualMemory); 998 | result.extract(index, "InstallDate", (*this).InstallDate); 999 | result.extract(index, "LastBootUpTime", (*this).LastBootUpTime); 1000 | result.extract(index, "LocalDateTime", (*this).LocalDateTime); 1001 | result.extract(index, "Locale", (*this).Locale); 1002 | result.extract(index, "Manufacturer", (*this).Manufacturer); 1003 | result.extract(index, "MaxNumberOfProcesses", (*this).MaxNumberOfProcesses); 1004 | result.extract(index, "MaxProcessMemorySize", (*this).MaxProcessMemorySize); 1005 | result.extract(index, "MUILanguages", (*this).MUILanguages); 1006 | result.extract(index, "Name", (*this).Name); 1007 | result.extract(index, "NumberOfProcesses", (*this).NumberOfProcesses); 1008 | result.extract(index, "NumberOfUsers", (*this).NumberOfUsers); 1009 | result.extract(index, "OperatingSystemSKU", (*this).OperatingSystemSKU); 1010 | result.extract(index, "Organization", (*this).Organization); 1011 | result.extract(index, "OSArchitecture", (*this).OSArchitecture); 1012 | result.extract(index, "OSLanguage", (*this).OSLanguage); 1013 | result.extract(index, "OSProductSuite", (*this).OSProductSuite); 1014 | result.extract(index, "OSType", (*this).OSType); 1015 | result.extract(index, "PortableOperatingSystem", (*this).PortableOperatingSystem); 1016 | result.extract(index, "Primary", (*this).Primary); 1017 | result.extract(index, "ProductType", (*this).ProductType); 1018 | result.extract(index, "RegisteredUser", (*this).RegisteredUser); 1019 | result.extract(index, "SerialNumber", (*this).SerialNumber); 1020 | result.extract(index, "ServicePackMajorVersion", (*this).ServicePackMajorVersion); 1021 | result.extract(index, "ServicePackMinorVersion", (*this).ServicePackMinorVersion); 1022 | result.extract(index, "SizeStoredInPagingFiles", (*this).SizeStoredInPagingFiles); 1023 | result.extract(index, "Status", (*this).Status); 1024 | result.extract(index, "SuiteMask", (*this).SuiteMask); 1025 | result.extract(index, "SystemDevice", (*this).SystemDevice); 1026 | result.extract(index, "SystemDirectory", (*this).SystemDirectory); 1027 | result.extract(index, "SystemDrive", (*this).SystemDrive); 1028 | result.extract(index, "TotalVirtualMemorySize", (*this).TotalVirtualMemorySize); 1029 | result.extract(index, "TotalVisibleMemorySize", (*this).TotalVisibleMemorySize); 1030 | result.extract(index, "Version", (*this).Version); 1031 | result.extract(index, "WindowsDirectory", (*this).WindowsDirectory); 1032 | 1033 | } 1034 | static std::string getWmiClassName() 1035 | { 1036 | return "Win32_OperatingSystem"; 1037 | } 1038 | std::string BootDevice ; 1039 | std::string BuildNumber ; 1040 | std::string BuildType ; 1041 | std::string Caption ; 1042 | std::string CodeSet ; 1043 | std::string CountryCode ; 1044 | std::string CreationClassName ; 1045 | std::string CSCreationClassName ; 1046 | std::string CSName ; 1047 | int CurrentTimeZone ; 1048 | bool DataExecutionPrevention_32BitApplications ; 1049 | bool DataExecutionPrevention_Available ; 1050 | bool DataExecutionPrevention_Drivers ; 1051 | int DataExecutionPrevention_SupportPolicy ; 1052 | bool Debug ; 1053 | std::string Description ; 1054 | bool Distributed ; 1055 | int EncryptionLevel ; 1056 | int ForegroundApplicationBoost ; 1057 | uint64_t FreePhysicalMemory ; 1058 | uint64_t FreeSpaceInPagingFiles ; 1059 | uint64_t FreeVirtualMemory ; 1060 | ///////////////////////////////////////////////////// 1061 | std::string InstallDate ; 1062 | std::string LastBootUpTime ;///THIS MAYBE INCORRECT 1063 | std::string LocalDateTime ; 1064 | ///////////////////////////////////////////////////////// 1065 | std::string Locale ; 1066 | std::string Manufacturer ; 1067 | uint64_t MaxNumberOfProcesses ; 1068 | uint64_t MaxProcessMemorySize ; 1069 | std::string MUILanguages ; 1070 | std::string Name ; 1071 | int NumberOfProcesses ; 1072 | int NumberOfUsers ; 1073 | int OperatingSystemSKU ; 1074 | std::string Organization ; 1075 | std::string OSArchitecture ; 1076 | int OSLanguage ; 1077 | int OSProductSuite ; 1078 | int OSType ; 1079 | bool PortableOperatingSystem ; 1080 | bool Primary ; 1081 | int ProductType ; 1082 | std::string RegisteredUser ; 1083 | std::string SerialNumber ; 1084 | int ServicePackMajorVersion ; 1085 | int ServicePackMinorVersion ; 1086 | uint64_t SizeStoredInPagingFiles ; 1087 | std::string Status ; 1088 | int SuiteMask ; 1089 | std::string SystemDevice ; 1090 | std::string SystemDirectory ; 1091 | std::string SystemDrive ; 1092 | uint64_t TotalVirtualMemorySize ; 1093 | uint64_t TotalVisibleMemorySize ; 1094 | std::string Version ; 1095 | std::string WindowsDirectory ; 1096 | }; 1097 | 1098 | struct Win32_VideoController 1099 | { 1100 | Win32_VideoController() : 1101 | AcceleratorCapabilities(),AdapterCompatibility(),AdapterDACType(),AdapterRAM(),Availability(), 1102 | CapabilityDescriptions(),Caption(),ColorTableEntries(),ConfigManagerErrorCode(),ConfigManagerUserConfig(), 1103 | CreationClassName(),CurrentBitsPerPixel(),CurrentHorizontalResolution(),CurrentNumberOfColors(), 1104 | CurrentNumberOfColumns(),CurrentNumberOfRows(),CurrentRefreshRate(),CurrentScanMode(),CurrentVerticalResolution(), 1105 | Description(),DeviceID(),DeviceSpecificPens(),DitherType(),DriverDate(),DriverVersion(),ErrorCleared(), 1106 | ErrorDescription(),ICMIntent(),ICMMethod(),InfFilename(),InfSection(),InstallDate(),InstalledDisplayDrivers(), 1107 | LastErrorCode(),MaxMemorySupported(),MaxNumberControlled(),MaxRefreshRate(),MinRefreshRate(),Monochrome(),Name(), 1108 | NumberOfColorPlanes(),NumberOfVideoPages(),PNPDeviceID(),PowerManagementCapabilities(),PowerManagementSupported(), 1109 | ProtocolSupported(),ReservedSystemPaletteEntries(),SpecificationVersion(),Status(),StatusInfo(), 1110 | SystemCreationClassName(),SystemName(),SystemPaletteEntries(),TimeOfLastReset(),VideoArchitecture(), 1111 | VideoMemoryType(),VideoMode(),VideoModeDescription(),VideoProcessor() 1112 | {} 1113 | 1114 | void setProperties(const WmiResult& result, std::size_t index) 1115 | { 1116 | result.extract(index, "AcceleratorCapabilities", (*this).AcceleratorCapabilities); 1117 | result.extract(index, "AdapterCompatibility", (*this).AdapterCompatibility); 1118 | result.extract(index, "AdapterDACType", (*this).AdapterDACType); 1119 | result.extract(index, "AdapterRAM", (*this).AdapterRAM); 1120 | result.extract(index, "Availability", (*this).Availability); 1121 | result.extract(index, "CapabilityDescriptions", (*this).CapabilityDescriptions); 1122 | result.extract(index, "Caption", (*this).Caption); 1123 | result.extract(index, "ColorTableEntries", (*this).ColorTableEntries); 1124 | result.extract(index, "ConfigManagerErrorCode", (*this).ConfigManagerErrorCode); 1125 | result.extract(index, "ConfigManagerUserConfig", (*this).ConfigManagerUserConfig); 1126 | result.extract(index, "CreationClassName", (*this).CreationClassName); 1127 | result.extract(index, "CurrentBitsPerPixel", (*this).CurrentBitsPerPixel); 1128 | result.extract(index, "CurrentHorizontalResolution", (*this).CurrentHorizontalResolution); 1129 | result.extract(index, "CurrentNumberOfColors", (*this).CurrentNumberOfColors); 1130 | result.extract(index, "CurrentNumberOfColumns", (*this).CurrentNumberOfColumns); 1131 | result.extract(index, "CurrentNumberOfRows", (*this).CurrentNumberOfRows); 1132 | result.extract(index, "CurrentRefreshRate", (*this).CurrentRefreshRate); 1133 | result.extract(index, "CurrentScanMode", (*this).CurrentScanMode); 1134 | result.extract(index, "CurrentVerticalResolution", (*this).CurrentVerticalResolution); 1135 | result.extract(index, "Description", (*this).Description); 1136 | result.extract(index, "DeviceID", (*this).DeviceID); 1137 | result.extract(index, "DeviceSpecificPens", (*this).DeviceSpecificPens); 1138 | result.extract(index, "DitherType", (*this).DitherType); 1139 | result.extract(index, "DriverDate", (*this).DriverDate); 1140 | result.extract(index, "DriverVersion", (*this).DriverVersion); 1141 | result.extract(index, "ErrorCleared", (*this).ErrorCleared); 1142 | result.extract(index, "ErrorDescription", (*this).ErrorDescription); 1143 | result.extract(index, "ICMIntent", (*this).ICMIntent); 1144 | result.extract(index, "ICMMethod", (*this).ICMMethod); 1145 | result.extract(index, "InfFilename", (*this).InfFilename); 1146 | result.extract(index, "InfSection", (*this).InfSection); 1147 | result.extract(index, "InstallDate", (*this).InstallDate); 1148 | result.extract(index, "InstalledDisplayDrivers", (*this).InstalledDisplayDrivers); 1149 | result.extract(index, "LastErrorCode", (*this).LastErrorCode); 1150 | result.extract(index, "MaxMemorySupported", (*this).MaxMemorySupported); 1151 | result.extract(index, "MaxNumberControlled", (*this).MaxNumberControlled); 1152 | result.extract(index, "MaxRefreshRate", (*this).MaxRefreshRate); 1153 | result.extract(index, "MinRefreshRate", (*this).MinRefreshRate); 1154 | result.extract(index, "Monochrome", (*this).Monochrome); 1155 | result.extract(index, "Name", (*this).Name); 1156 | result.extract(index, "NumberOfColorPlanes", (*this).NumberOfColorPlanes); 1157 | result.extract(index, "NumberOfVideoPages", (*this).NumberOfVideoPages); 1158 | result.extract(index, "PNPDeviceID", (*this).PNPDeviceID); 1159 | result.extract(index, "PowerManagementCapabilities", (*this).PowerManagementCapabilities); 1160 | result.extract(index, "PowerManagementSupported", (*this).PowerManagementSupported); 1161 | result.extract(index, "ProtocolSupported", (*this).ProtocolSupported); 1162 | result.extract(index, "ReservedSystemPaletteEntries", (*this).ReservedSystemPaletteEntries); 1163 | result.extract(index, "SpecificationVersion", (*this).SpecificationVersion); 1164 | result.extract(index, "Status", (*this).Status); 1165 | result.extract(index, "StatusInfo", (*this).StatusInfo); 1166 | result.extract(index, "SystemCreationClassName", (*this).SystemCreationClassName); 1167 | result.extract(index, "SystemName", (*this).SystemName); 1168 | result.extract(index, "SystemPaletteEntries", (*this).SystemPaletteEntries); 1169 | result.extract(index, "TimeOfLastReset", (*this).TimeOfLastReset); 1170 | result.extract(index, "VideoArchitecture", (*this).VideoArchitecture); 1171 | result.extract(index, "VideoMemoryType", (*this).VideoMemoryType); 1172 | result.extract(index, "VideoMode", (*this).VideoMode); 1173 | result.extract(index, "VideoModeDescription", (*this).VideoModeDescription); 1174 | result.extract(index, "VideoProcessor", (*this).VideoProcessor); 1175 | } 1176 | 1177 | static std::string getWmiClassName() 1178 | { 1179 | return "Win32_VideoController"; 1180 | } 1181 | 1182 | std::string AcceleratorCapabilities; 1183 | std::string AdapterCompatibility; 1184 | std::string AdapterDACType; 1185 | std::uint32_t AdapterRAM; 1186 | std::uint16_t Availability; 1187 | std::string CapabilityDescriptions; 1188 | std::string Caption; 1189 | std::uint32_t ColorTableEntries; 1190 | std::uint32_t ConfigManagerErrorCode; 1191 | bool ConfigManagerUserConfig; 1192 | std::string CreationClassName; 1193 | std::uint32_t CurrentBitsPerPixel; 1194 | std::uint32_t CurrentHorizontalResolution; 1195 | std::uint64_t CurrentNumberOfColors; 1196 | std::uint32_t CurrentNumberOfColumns; 1197 | std::uint32_t CurrentNumberOfRows; 1198 | std::uint32_t CurrentRefreshRate; 1199 | std::uint16_t CurrentScanMode; 1200 | std::uint32_t CurrentVerticalResolution; 1201 | std::string Description; 1202 | std::string DeviceID; 1203 | std::uint32_t DeviceSpecificPens; 1204 | std::uint32_t DitherType; 1205 | std::string DriverDate; 1206 | std::string DriverVersion; 1207 | bool ErrorCleared; 1208 | std::string ErrorDescription; 1209 | std::uint32_t ICMIntent; 1210 | std::uint32_t ICMMethod; 1211 | std::string InfFilename; 1212 | std::string InfSection; 1213 | std::string InstallDate; 1214 | std::string InstalledDisplayDrivers; 1215 | std::uint32_t LastErrorCode; 1216 | std::uint32_t MaxMemorySupported; 1217 | std::uint32_t MaxNumberControlled; 1218 | std::uint32_t MaxRefreshRate; 1219 | std::uint32_t MinRefreshRate; 1220 | bool Monochrome; 1221 | std::string Name; 1222 | std::uint16_t NumberOfColorPlanes; 1223 | std::uint32_t NumberOfVideoPages; 1224 | std::string PNPDeviceID; 1225 | std::string PowerManagementCapabilities; 1226 | bool PowerManagementSupported; 1227 | std::uint16_t ProtocolSupported; 1228 | std::uint32_t ReservedSystemPaletteEntries; 1229 | std::uint32_t SpecificationVersion; 1230 | std::string Status; 1231 | std::uint16_t StatusInfo; 1232 | std::string SystemCreationClassName; 1233 | std::string SystemName; 1234 | std::uint32_t SystemPaletteEntries; 1235 | std::string TimeOfLastReset; 1236 | std::uint16_t VideoArchitecture; 1237 | std::uint16_t VideoMemoryType; 1238 | std::uint16_t VideoMode; 1239 | std::string VideoModeDescription; 1240 | std::string VideoProcessor; 1241 | }; 1242 | 1243 | struct Win32_BaseBoard 1244 | { 1245 | Win32_BaseBoard() : 1246 | Caption(), ConfigOptions(), CreationClassName(), Depth(), Description(), Height(), HostingBoard(), HotSwappable(), InstallDate(), 1247 | Manufacturer(), Model(), Name(), OtherIdentifyingInfo(), PartNumber(), PoweredOn(), Product(), Removable(), Replaceable(), RequirementsDescription(), 1248 | RequiresDaughterBoard(), SerialNumber(), SKU(), SlotLayout(), SpecialRequirements(), Status(), Tag(), Version(), Weight(), Width() 1249 | {} 1250 | 1251 | void setProperties(const WmiResult& result, std::size_t index) 1252 | { 1253 | //vscode was a great help with search(.+?), 1254 | //and replace result.extract(index, "$1", (*this).$1); 1255 | result.extract(index, "Caption", (*this).Caption); 1256 | result.extract(index, "ConfigOptions", (*this).ConfigOptions); 1257 | result.extract(index, "CreationClassName", (*this).CreationClassName); 1258 | result.extract(index, "Depth", (*this).Depth); 1259 | result.extract(index, "Description", (*this).Description); 1260 | result.extract(index, "Height", (*this).Height); 1261 | result.extract(index, "HostingBoard", (*this).HostingBoard); 1262 | result.extract(index, "HotSwappable", (*this).HotSwappable); 1263 | result.extract(index, "InstallDate", (*this).InstallDate); 1264 | result.extract(index, "Manufacturer", (*this).Manufacturer); 1265 | result.extract(index, "Model", (*this).Model); 1266 | result.extract(index, "Name", (*this).Name); 1267 | result.extract(index, "OtherIdentifyingInfo", (*this).OtherIdentifyingInfo); 1268 | result.extract(index, "PoweredOn", (*this).PoweredOn); 1269 | result.extract(index, "Product", (*this).Product); 1270 | result.extract(index, "Removable", (*this).Removable); 1271 | result.extract(index, "Replaceable", (*this).Replaceable); 1272 | result.extract(index, "RequirementsDescription", (*this).RequirementsDescription); 1273 | result.extract(index, "RequiresDaughterBoard", (*this).RequiresDaughterBoard); 1274 | result.extract(index, "SerialNumber", (*this).SerialNumber); 1275 | result.extract(index, "SKU", (*this).SKU); 1276 | result.extract(index, "SlotLayout", (*this).SlotLayout); 1277 | result.extract(index, "SpecialRequirements", (*this).SpecialRequirements); 1278 | result.extract(index, "Status", (*this).Status); 1279 | result.extract(index, "Tag", (*this).Tag); 1280 | result.extract(index, "Version", (*this).Version); 1281 | result.extract(index, "Weight", (*this).Weight); 1282 | result.extract(index, "Width", (*this).Width); 1283 | } 1284 | 1285 | static std::string getWmiClassName() 1286 | { 1287 | return "Win32_BaseBoard"; 1288 | } 1289 | 1290 | std::string Caption; 1291 | std::string ConfigOptions; 1292 | std::string CreationClassName; 1293 | int Depth; 1294 | std::string Description; 1295 | int Height; 1296 | bool HostingBoard; 1297 | bool HotSwappable; 1298 | std::string InstallDate; 1299 | std::string Manufacturer; 1300 | std::string Model; 1301 | std::string Name; 1302 | std::string OtherIdentifyingInfo; 1303 | std::string PartNumber; 1304 | bool PoweredOn; 1305 | std::string Product; 1306 | bool Removable; 1307 | bool Replaceable; 1308 | std::string RequirementsDescription; 1309 | std::string RequiresDaughterBoard; 1310 | std::string SerialNumber; 1311 | std::string SKU; 1312 | std::string SlotLayout; 1313 | std::string SpecialRequirements; 1314 | std::string Status; 1315 | std::string Tag; 1316 | std::string Version; 1317 | int Weight; 1318 | int Width; 1319 | }; //end class Win32_BaseBoard 1320 | 1321 | struct UWF_Filter 1322 | { 1323 | UWF_Filter() : 1324 | Id(), CurrentEnabled(), NextEnabled(), HORMEnabled(), ShutdownPending() 1325 | {} 1326 | 1327 | void setProperties(const WmiResult& result, std::size_t index) 1328 | { 1329 | //vscode was a great help with search(.+?), 1330 | //and replace result.extract(index, "$1", (*this).$1); 1331 | result.extract(index, "Id", (*this).Id); 1332 | result.extract(index, "CurrentEnabled", (*this).CurrentEnabled); 1333 | result.extract(index, "NextEnabled", (*this).NextEnabled); 1334 | result.extract(index, "HORMEnabled", (*this).HORMEnabled); 1335 | result.extract(index, "ShutdownPending", (*this).ShutdownPending); 1336 | } 1337 | 1338 | static std::string getWmiClassName() 1339 | { 1340 | return "UWF_Filter"; 1341 | } 1342 | static std::string getWmiPath() 1343 | { 1344 | return "standardcimv2\\embedded"; 1345 | } 1346 | 1347 | std::string Id; 1348 | bool CurrentEnabled; 1349 | bool NextEnabled; 1350 | bool HORMEnabled; 1351 | bool ShutdownPending; 1352 | }; //end class UWF_Filter 1353 | 1354 | struct AntiVirusProduct 1355 | { 1356 | AntiVirusProduct() : 1357 | DisplayName(), InstanceGuid(), PathToSignedProductExe(), PathToSignedReportingExe(), ProductState(), Timestamp() 1358 | {} 1359 | 1360 | void setProperties(const WmiResult& result, std::size_t index) 1361 | { 1362 | //vscode was a great help with search(.+?), 1363 | //and replace result.extract(index, "$1", (*this).$1); 1364 | result.extract(index, "DisplayName", (*this).DisplayName); 1365 | result.extract(index, "InstanceGuid", (*this).InstanceGuid); 1366 | result.extract(index, "PathToSignedProductExe", (*this).PathToSignedProductExe); 1367 | result.extract(index, "PathToSignedReportingExe", (*this).PathToSignedReportingExe); 1368 | result.extract(index, "ProductState", (*this).ProductState); 1369 | result.extract(index, "Timestamp", (*this).Timestamp); 1370 | } 1371 | 1372 | static std::string getWmiClassName() 1373 | { 1374 | return "AntiVirusProduct"; 1375 | } 1376 | static std::string getWmiPath() 1377 | { 1378 | return "securitycenter2"; 1379 | } 1380 | 1381 | std::string DisplayName; 1382 | std::string InstanceGuid; 1383 | std::string PathToSignedProductExe; 1384 | std::string PathToSignedReportingExe; 1385 | std::uint32_t ProductState; 1386 | std::string Timestamp; 1387 | }; //end class AntiVirusProduct 1388 | 1389 | } //end namespace wmi 1390 | 1391 | #endif //WMICLASSES_HPP --------------------------------------------------------------------------------