-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlibhid.cpp
More file actions
45 lines (40 loc) · 1.08 KB
/
libhid.cpp
File metadata and controls
45 lines (40 loc) · 1.08 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
#include "libhid.h"
#if defined(OS_WINDOWS)
#include "imp/windows_manager.hpp"
#elif defined(OS_LINUX)
#include "imp/linux_manager.hpp"
#elif defined(OS_MAC)
#include "imp/mac_manager.hpp"
#endif
#include "imp/md5.hpp"
#include "imp/util.hpp"
#include <cstring>
#include <iostream>
using namespace system_info;
LibHid::LibHid()
{
}
std::string LibHid::GetHardwareId()
{
std::string hardwareIdResult = "";
try {
// Getting HID
std::string hid = NativeOSManager::GetHardwareProperties();
if (hid.empty()) {
#ifdef LIB_DEBUG
std::cerr << "Couldn't get any of all hardware IDs! " << std::endl;
#endif
return hid;
}
// Getting MD5 hash of data about hardware - there is our UUID
MD5 md5(hid);
std::string md5hash = md5.HexDigest();
std::string uuid = Util::HashToUUID(md5hash);
hardwareIdResult = uuid;
} catch (...) {
#ifdef LIB_DEBUG
std::cerr << "Unpredictable error in GetHardwareId! " << std::endl;
#endif
}
return hardwareIdResult;
}