add new hdid algo (#694)
* add new hdid algo * forgot the w for unicode * add advapi32 to windows * get rid of visual studio 2022 shit * Update src/hardware_functions.cpp Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> * close handle when it fails Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
This commit is contained in:
parent
69f49f7fee
commit
7e9ad9946b
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@ base-full/
|
||||
logs/
|
||||
bass.lib
|
||||
|
||||
.vs/
|
||||
bin/
|
||||
bins/
|
||||
build/
|
||||
|
@ -42,6 +42,8 @@ LIBS += -lbassmidi
|
||||
|
||||
macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices
|
||||
|
||||
win32:LIBS += -ladvapi32
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
RESOURCES += resources.qrc
|
||||
|
@ -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);
|
||||
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 <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__
|
||||
|
Loading…
Reference in New Issue
Block a user