aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Attorney_Online.pro2
-rw-r--r--src/hardware_functions.cpp51
3 files changed, 36 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index ca7eb582..11710e94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ base-full/
logs/
bass.lib
+.vs/
bin/
bins/
build/
diff --git a/Attorney_Online.pro b/Attorney_Online.pro
index 3b4a0ee4..c1340fb3 100644
--- a/Attorney_Online.pro
+++ b/Attorney_Online.pro
@@ -42,6 +42,8 @@ LIBS += -lbassmidi
macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices
+win32:LIBS += -ladvapi32
+
CONFIG += c++17
RESOURCES += resources.qrc
diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp
index 2f3c44d3..4bd23997 100644
--- a/src/hardware_functions.cpp
+++ b/src/hardware_functions.cpp
@@ -3,28 +3,43 @@
#include <QDebug>
#include <QtGlobal>
-#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
-
#if (defined(_WIN32) || defined(_WIN64))
#include <windows.h>
-
-static DWORD dwVolSerial;
-static BOOL bIsRetrieved;
+#include <sddl.h>
QString get_hdid()
{
- bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial,
- nullptr, nullptr, nullptr, 0);
-
- if (bIsRetrieved)
- return QString::number(dwVolSerial, 16);
- else
- // a totally random string
- // what could possibly go wrong
- return "gxsps32sa9fnwic92mfbs0";
-}
+ HANDLE hToken;
+ HANDLE pHandle;
+ PTOKEN_USER pToken;
+ DWORD uSize = 0;
+ LPWSTR HDIDParam;
+
+ pHandle = GetCurrentProcess();
+ OpenProcessToken(pHandle, TOKEN_QUERY, &hToken);
+ if (!GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)1, NULL, 0, &uSize))
+ {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ CloseHandle(hToken);
+ return "gxsps32sa9fnwic92mfbs1";
+ }
+ }
-#elif (defined(LINUX) || defined(__linux__))
+ pToken = (PTOKEN_USER)GlobalAlloc(GPTR, uSize);
+
+ if (!GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)1, pToken, uSize, &uSize))
+ {
+ CloseHandle(hToken);
+ return "gxsps32sa9fnwic92mfbs2";
+ }
+
+ ConvertSidToStringSidW(pToken->User.Sid, &HDIDParam);
+ QString returnHDID = QString::fromWCharArray(HDIDParam);
+ CloseHandle(hToken);
+ return returnHDID;
+}
+#elif QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+#if (defined(LINUX) || defined(__linux__))
#include <QFile>
#include <QTextStream>
@@ -33,7 +48,7 @@ QString get_hdid()
{
QFile fstab_file("/etc/fstab");
if (!fstab_file.open(QIODevice::ReadOnly))
- return "gxcps32sa9fnwic92mfbs0";
+ return "uxcps32sa9fnwic92mfbs0";
QTextStream in(&fstab_file);
@@ -48,7 +63,7 @@ QString get_hdid()
}
}
- return "gxcpz32sa9fnwic92mfbs0";
+ return "uxcpz32sa9fnwic92mfbs1";
}
#elif defined __APPLE__