diff --git a/.gitignore b/.gitignore index ca7eb58..11710e9 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 3b4a0ee..c1340fb 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 2f3c44d..4bd2399 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -3,28 +3,43 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - #if (defined(_WIN32) || defined(_WIN64)) #include - -static DWORD dwVolSerial; -static BOOL bIsRetrieved; +#include QString get_hdid() { - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, - nullptr, nullptr, nullptr, 0); + HANDLE hToken; + HANDLE pHandle; + PTOKEN_USER pToken; + DWORD uSize = 0; + LPWSTR HDIDParam; - if (bIsRetrieved) - return QString::number(dwVolSerial, 16); - else - // a totally random string - // what could possibly go wrong - return "gxsps32sa9fnwic92mfbs0"; + 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"; + } + } + + 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 (defined(LINUX) || defined(__linux__)) +#elif QT_VERSION < QT_VERSION_CHECK(5, 11, 0) +#if (defined(LINUX) || defined(__linux__)) #include #include @@ -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__