Hello all coders,
I'm trying to add a way to read wmic or GUID and then use it as a string like that http://prntscr.com/nhk98b
The goal is to identify players using multiple accounts.
I found a sample but i can't compile it, i need some lib :(
FILE* CommandResult = _popen("wmic csproduct get uuid", "rt"); //send the command to the cmd and return a pointer to the command result
char line[256]; //a buffer to read from the file
while(fgets(line, 256, CommandResult)) printf(line); //read and print all lines one by one
_pclose(CommandResult);
Can someone help me with a working CB sample? Please
Although this is not related to C::B, I`ll try directing you to an answer.
If I get your problem right, you need to ensure only one instance of your app is running on the target machine. This is how (https://www.google.com/search?q=prevent+multiple+application+instances+site:stackoverflow.com) it`s done.
Bear in mind though that this is not in any way a panacea, for sophicticated players may use additional PCs, virtual machines, diassemblers, and lots of other cool things to overcome the restriction you are trying to impose.
Thank you for the reply!
QuoteIf I get your problem right, you need to ensure only one instance of your app is running on the target machine. This is how it`s done.
No, its only about a UUID , nothing to do with multiple instances. About "virtual machines, diassemblers, and lots of other cool things" is fine, i don't have hackers players.
A sample will really help.
Okay, digging a little bit further into your code snippet I realized that your task is to uniquely identify a Windows PC.
You could`ve stated that earlier =)
Well, getting a unique Windows installation GUID can be done as follows:
HKEY hKey;
WCHAR *MachineGUID[128];
DWORD dwBufferSize = sizeof(MachineGUID);
ULONG nError;
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey);
nError = RegQueryValueExW(hKey, L"MachineGuid", 0, NULL, (LPBYTE)MachineGUID, &dwBufferSize);
RegCloseKey(hkey);
if (nError == ERROR_SUCCESS) {
/// do something with MachineGUID...
}
thanks again, compiled!
now, how could i have a string with uuid?
somthing like that:
string GetUUID()
{
HKEY hKey;
WCHAR *MachineGUID[128];
DWORD dwBufferSize = sizeof(MachineGUID);
ULONG nError;
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey);
nError = RegQueryValueExW(hKey, L"MachineGuid", 0, NULL, (LPBYTE)MachineGUID, &dwBufferSize);
RegCloseKey(hKey);
if (nError == ERROR_SUCCESS) {
//do something with MachineGUID...
//return hKey;
}
}
// here i will use the uuid
m_RemoteSocket->PutBytes( m_GPSProtocol->SEND_GPSC_INIT3( 2, GetUUID() ) ); // verify the uuid
ULONG GetUUID(WCHAR *MachineGUID, DWORD *dwBufferSize) {
HKEY hKey;
ULONG nError;
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey);
nError = RegQueryValueExW(hKey, L"MachineGuid", 0, NULL, (LPBYTE)MachineGUID, dwBufferSize);
RegCloseKey(hKey);
return nError;
}
WCHAR MachineGUID[512];
DWORD dwBufferSize = sizeof(MachineGUID);
if (GetUUID(MachineGUID, &dwBufferSize) == ERROR_SUCCESS) {
// convert MachineGUID from WCHAR* to string
...
m_RemoteSocket->PutBytes( m_GPSProtocol->SEND_GPSC_INIT3( 2, stringMachineGUID ) );
}
added your code: http://prntscr.com/nhxvs9
and i got this error: http://prntscr.com/nhxvgi
Please read this FAQ and this website rules.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)
http://forums.next.codeblocks.org/index.php/topic,9996.0.html (http://forums.next.codeblocks.org/index.php/topic,9996.0.html)
Tim S.
Quote from: patrocle on April 28, 2019, 06:06:25 PM
and i got this error: http://prntscr.com/nhxvgi
Of course, that`s because I don`t know which data type that SEND_GPSC_INIT3() function accepts, so I considered it to be up to you to convert...
but the stringMachineGUID is not declarated and i dont think is a string, look to be a char.
It`s undeclared for one simple reason: I do not know what data type SEND_GPSC_INIT3() accepts.
It is up to you to declare stringMachineGUID and give it a value converted from MachineGUID`s *WCHAR.
accept string, that't i ask for string output. *WCHAR is not accepted and the guid result is empty :( I give up
Thanks for your help mate.
Damn it. That was the first google result (https://stackoverflow.com/a/6623809).
std::wstring wtmp(MachineGUID);
std::string stringMachineGUID(wtmp.begin(), wtmp.end());
now a real problem, guid is empty :o
Quote from: stahta01 on April 28, 2019, 06:10:21 PM
Please read this FAQ and this website rules.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F)
http://forums.next.codeblocks.org/index.php/topic,9996.0.html (http://forums.next.codeblocks.org/index.php/topic,9996.0.html)
Tim S.
my apologies, I thought it is 'General' and I have any chances to solve this 'issue'
Sorry again