Update to spice2x-25-04-25 (pre-apply)
> broken commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <random>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -76,3 +77,50 @@ std::string ws2s(const std::wstring &wstr) {
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool acquire_shutdown_privs() {
|
||||
|
||||
// check if already acquired
|
||||
static bool acquired = false;
|
||||
if (acquired)
|
||||
return true;
|
||||
|
||||
// get process token
|
||||
HANDLE hToken;
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
||||
return false;
|
||||
|
||||
// get the LUID for the shutdown privilege
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
|
||||
tkp.PrivilegeCount = 1;
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
// get the shutdown privilege for this process
|
||||
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
|
||||
|
||||
// check for error
|
||||
bool success = GetLastError() == ERROR_SUCCESS;
|
||||
if (success)
|
||||
acquired = true;
|
||||
return success;
|
||||
}
|
||||
|
||||
void generate_ea_card(char card[17]) {
|
||||
// don't ask why the existing codebase uses 18 char array when there are only 16+1 chars
|
||||
|
||||
// create random
|
||||
std::random_device rd;
|
||||
std::mt19937 generator(rd());
|
||||
std::uniform_int_distribution<> uniform(0, 15);
|
||||
|
||||
// randomize card
|
||||
strcpy(card, "E00401");
|
||||
char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
for (int i = 6; i < 16; i++) {
|
||||
card[i] = hex[uniform(generator)];
|
||||
}
|
||||
|
||||
// terminate and flush
|
||||
card[16] = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user