-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (65 loc) · 2.31 KB
/
main.cpp
File metadata and controls
80 lines (65 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* main.cpp
* -------------------------
* proof of conecpt of the library
* -------------------------
* Stavros Avramidis 2/5/2019
*/
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <conio.h>
#include "library.h"
//#pragma comment(lib, "wmi.lib")
int main() {
Wmi wmi;
wmi.init();
std::vector<QueryObj> q_res;
// Get Motherboard name
wmi.query("SELECT * FROM Win32_BaseBoard", q_res);
std::cout << "------------------ MotherBoard -------------------" << std::endl;
if (!q_res.empty()) {
auto res = q_res[0];
std::cout << "Manufacturer\t:\t" << res["Manufacturer"] << '\n';
std::cout << "Product\t\t:\t" << res["Product"] << '\n';
std::cout << "Version\t\t:\t" << res["Version"] << '\n';
}
// Get BIOS info
q_res.clear();
wmi.query("SELECT * FROM Win32_BIOS ", q_res);
std::cout << "---------------------- BIOS ----------------------" << std::endl;
if (!q_res.empty()) {
auto res = q_res[0];
std::cout << "Manufacturer\t:\t" << res["Manufacturer"] << '\n';
std::cout << "Bios Version\t:\t" << res["Name"] << '\n';
std::cout << "Description\t:\t" << res["Description"] << '\n';
}
// Get SMBUS info
q_res.clear();
std::string devID;
wmi.query("SELECT * FROM Win32_PnPSignedDriver WHERE description LIKE '\%SMBUS\%'", q_res);
std::cout << "---------------------- SMBUS ---------------------" << std::endl;
if (!q_res.empty()) {
auto res = q_res[0];
std::cout << "Manufacturer\t:\t" << res["Manufacturer"] << '\n';
std::cout << "DeviceID\t:\t" << res["DeviceID"] << '\n';
std::cout << "Description\t:\t" << res["Description"] << '\n';
std::cout << "Location\t:\t" << res["Location"] << '\n';
devID = res["DeviceID"];
}
std::string rgx = ".+" + devID.substr(4, 33) + ".+";
q_res.clear();
AdditionalFilters filters;
filters.emplace("Dependent", (std::regex) rgx);
filters.emplace("Antecedent", (std::regex) ".*Port.*");
wmi.query("SELECT * FROM Win32_PnPAllocatedResource", q_res, &filters);
if (!q_res.empty()) {
auto res = q_res[0];
std::regex rgx(".*StartingAddress=\"(\\d+)\".*");
std::smatch matches;
if (std::regex_search(res["Antecedent"], matches, rgx)) {
std::cout << "Starting Address:\t" << "0x" << std::hex << std::stoi(matches[1].str()) << "\n";
}
}
}