-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathhwid.cpp
More file actions
110 lines (71 loc) · 2.02 KB
/
Copy pathhwid.cpp
File metadata and controls
110 lines (71 loc) · 2.02 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <windows.h>
#include <string>
#include <windows.h>
#include <string>
#include <intrin.h>
#include <string.h>
#include "hwid.h"
#include "xor.h"
#include "print.h"
#include <filesystem>
#include <iostream>
char m_szHardwareId[33];
char szRawHardwareId[512];
char Serial::GetSystemDriveLetter(void)
{
char szSystemDir[MAX_PATH];
if (!GetSystemDirectoryA(szSystemDir, sizeof(szSystemDir)))
return '\0';
//report_info("L: %c", szSystemDir[0]);
return szSystemDir[0];
}
PCHAR Serial::GetCPUVendorId(char* pszCPUVendorId)
{
int iCPUInfo[4];
__cpuid(iCPUInfo, 0);
*((int*)(pszCPUVendorId)) = iCPUInfo[1];
*((int*)(pszCPUVendorId + 4)) = iCPUInfo[3];
*((int*)(pszCPUVendorId + 8)) = iCPUInfo[2];
return pszCPUVendorId;
}
PCHAR Serial::GetHwProfileGuid(char* pszHwProfileGuid)
{
HW_PROFILE_INFOA HwProfileInfo;
if (!GetCurrentHwProfileA(&HwProfileInfo))
return NULL;
strcpy_s(pszHwProfileGuid, 39, HwProfileInfo.szHwProfileGuid);
return pszHwProfileGuid;
}
PCHAR Serial::GetHardwareId(std::string id)
{
// check if hwid already generated
if (m_szHardwareId[0] && (strlen(m_szHardwareId) == 32))
return m_szHardwareId;
char value[255];
DWORD BufferSize = sizeof(value);
LONG res = RegGetValueA(HKEY_LOCAL_MACHINE, "SYSTEM\\HardwareConfig", "LastConfig", RRF_RT_REG_SZ, NULL, value, &BufferSize);
if (res == 0)
{
}
else
{
std::cerr << "[ldr_c] HI pt. 1 failed! " << res << std::endl;
}
// char szHwProfileGuid[40];
//ZeroMemory(szHwProfileGuid, sizeof(szHwProfileGuid));
// if (!GetHwProfileGuid(szHwProfileGuid))
// {
// print::set_error("[ldr_c] HI pt. 2 failed!");
// return NULL;
// }
char szCPUVendorId[13];
ZeroMemory(szCPUVendorId, sizeof(szCPUVendorId));
if (!GetCPUVendorId(szCPUVendorId))
{
print::set_error("[ldr_c] HI pt. 3 failed!");
return NULL;
}
// part 4
sprintf_s(szRawHardwareId, "%s@%s%s@", id.c_str(), value, szCPUVendorId);
return szRawHardwareId;
}