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/
|
logs/
|
||||||
bass.lib
|
bass.lib
|
||||||
|
|
||||||
|
.vs/
|
||||||
bin/
|
bin/
|
||||||
bins/
|
bins/
|
||||||
build/
|
build/
|
||||||
|
@ -42,6 +42,8 @@ LIBS += -lbassmidi
|
|||||||
|
|
||||||
macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices
|
macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices
|
||||||
|
|
||||||
|
win32:LIBS += -ladvapi32
|
||||||
|
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
RESOURCES += resources.qrc
|
RESOURCES += resources.qrc
|
||||||
|
@ -3,28 +3,43 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
|
||||||
|
|
||||||
#if (defined(_WIN32) || defined(_WIN64))
|
#if (defined(_WIN32) || defined(_WIN64))
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <sddl.h>
|
||||||
static DWORD dwVolSerial;
|
|
||||||
static BOOL bIsRetrieved;
|
|
||||||
|
|
||||||
QString get_hdid()
|
QString get_hdid()
|
||||||
{
|
{
|
||||||
bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial,
|
HANDLE hToken;
|
||||||
nullptr, nullptr, nullptr, 0);
|
HANDLE pHandle;
|
||||||
|
PTOKEN_USER pToken;
|
||||||
|
DWORD uSize = 0;
|
||||||
|
LPWSTR HDIDParam;
|
||||||
|
|
||||||
if (bIsRetrieved)
|
pHandle = GetCurrentProcess();
|
||||||
return QString::number(dwVolSerial, 16);
|
OpenProcessToken(pHandle, TOKEN_QUERY, &hToken);
|
||||||
else
|
if (!GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)1, NULL, 0, &uSize))
|
||||||
// a totally random string
|
{
|
||||||
// what could possibly go wrong
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||||
return "gxsps32sa9fnwic92mfbs0";
|
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 <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@ -33,7 +48,7 @@ QString get_hdid()
|
|||||||
{
|
{
|
||||||
QFile fstab_file("/etc/fstab");
|
QFile fstab_file("/etc/fstab");
|
||||||
if (!fstab_file.open(QIODevice::ReadOnly))
|
if (!fstab_file.open(QIODevice::ReadOnly))
|
||||||
return "gxcps32sa9fnwic92mfbs0";
|
return "uxcps32sa9fnwic92mfbs0";
|
||||||
|
|
||||||
QTextStream in(&fstab_file);
|
QTextStream in(&fstab_file);
|
||||||
|
|
||||||
@ -48,7 +63,7 @@ QString get_hdid()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "gxcpz32sa9fnwic92mfbs0";
|
return "uxcpz32sa9fnwic92mfbs1";
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
|
Loading…
Reference in New Issue
Block a user