added hdid function(for win32)

This commit is contained in:
Skoland 2017-01-22 01:19:59 +01:00
parent 623d67999a
commit 7b73150053
5 changed files with 47 additions and 12 deletions

View File

@ -29,7 +29,8 @@ SOURCES += main.cpp\
hex_functions.cpp \ hex_functions.cpp \
encryption_functions.cpp \ encryption_functions.cpp \
courtroom.cpp \ courtroom.cpp \
aocharbutton.cpp aocharbutton.cpp \
win32_functions.cpp
HEADERS += lobby.h \ HEADERS += lobby.h \
text_file_functions.h \ text_file_functions.h \
@ -46,4 +47,5 @@ HEADERS += lobby.h \
hex_functions.h \ hex_functions.h \
encryption_functions.h \ encryption_functions.h \
courtroom.h \ courtroom.h \
aocharbutton.h aocharbutton.h \
win32_functions.h

View File

@ -9,13 +9,13 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
AOApplication main_app(argc, argv); AOApplication main_app(argc, argv);
main_app.construct_lobby(); main_app.construct_lobby();
main_app.net_manager->connect_to_master(); main_app.net_manager->connect_to_master();
AOPacket *f_packet = new AOPacket("ALL#%"); AOPacket *f_packet = new AOPacket("ALL#%");
main_app.send_ms_packet(f_packet); main_app.send_ms_packet(f_packet);
main_app.w_lobby->show(); main_app.w_lobby->show();
return main_app.exec(); return main_app.exec();
} }

View File

@ -3,6 +3,7 @@
#include "lobby.h" #include "lobby.h"
#include "networkmanager.h" #include "networkmanager.h"
#include "encryption_functions.h" #include "encryption_functions.h"
#include "win32_functions.h"
#include <QDebug> #include <QDebug>
@ -85,9 +86,14 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
//you may ask where 322 comes from. that would be a good question. //you may ask where 322 comes from. that would be a good question.
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
//T0D0 add an actual HDID here QString f_hdid;
AOPacket *hi_packet = new AOPacket("HI#ao2testinginprogressdontmindme#%"); #ifdef Q_OS_WIN32
f_hdid = get_hdid();
#else
f_hdid = "ao2testinginprogress";
#endif
AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
send_server_packet(hi_packet); send_server_packet(hi_packet);
delete hi_packet; delete hi_packet;
@ -97,6 +103,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (f_contents.size() < 1) if (f_contents.size() < 1)
return; return;
//T0D0: save server version here, somehow
} }
else if (header == "CT") else if (header == "CT")
{ {

15
win32_functions.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "win32_functions.h"
DWORD dwVolSerial;
BOOL bIsRetrieved;
QString get_hdid()
{
bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL);
if (bIsRetrieved)
return QString::number(dwVolSerial, 16);
else
return "invalidhd"; //what could possibly go wrong
}

11
win32_functions.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef WIN32_FUNCTIONS_H
#define WIN32_FUNCTIONS_H
#include <QString>
#include <windows.h>
#include <stdio.h>
QString get_hdid();
#endif // WIN32_FUNCTIONS_H