Existing user? Sign in
Sign up
Games
Servers
Useful
User
Pass
2FA
[C++] Read Windows CD-Key
Freakz Forum Index
->
Trash Bin
->
Trash
->
Programming / Scripting / Database
Author
Message
1036
slacker
[Mentally Stable]
Status: Offline
(since 08-07-2011 08:29)
Joined: 05 Jul 2011
Posts: 48
,
Topics: 7
Location:
Romania
Reputation:
49.1
Votes
: 3
Posted: 06-07-2011, 19:25:08
| Translate post to:
... (
Click for more languages
)
Works on 32/64bit
USAGE:
Code:
int main() {
printf("Blah, blah\nYour cd-key is: ");
GetWindowsKey();
}
Teh Code
Code:
void GetWindowsKey(BOOL is64 = false)
{
if (is64) {
#define WIN64KEY
}
char* wsResult; //Return a Window Product Key
HKEY hRegistryKey; //Registry Handler
BYTE *DigitalProductID = 0; //Digital Product Key Value
DWORD DataLength; //Digital Product Key Length
BYTE ProductKeyExtract[15]; //Extract Key
char sCDKey[30]; //Temp, adding a Window Product Key
int ByteCounter; //Counter
int k; //Convert
int nCur; //XOR calculate
bool bOk = false;
const char *KeyChars[] = {
"B","C","D","F","G","H","J","K","M",
"P","Q","R","T","V","W","X","Y",
"2","3","4","6","7","8","9",NULL
};
const char NT_CURRENT[] = "SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion";
#ifdef WIN64KEY
#ifdef KEY_WOW64_64KEY
#else
#define KEY_WOW64_64KEY 0x0100
#endif
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, NT_CURRENT,
REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_WOW64_64KEY,
&hRegistryKey) == ERROR_SUCCESS )
#else
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, NT_CURRENT,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
&hRegistryKey) == ERROR_SUCCESS )
#endif
{
DataLength = 164;
//Allocate Memory
DigitalProductID = new byte[DataLength];
//Memory Initialization
memset(DigitalProductID, 0, DataLength);
//Digital Product
if( RegQueryValueEx(hRegistryKey, "DigitalProductId",
NULL, NULL, DigitalProductID, &DataLength) == ERROR_SUCCESS )
{
//reading a value start position 52, by 66
memcpy(ProductKeyExtract, DigitalProductID+52, 15);
bOk = true;
}
//Release Memory
if(DigitalProductID) delete []DigitalProductID;
//Close Registry
RegCloseKey(hRegistryKey);
}
if( !bOk )
printf(wsResult);
//Start Converting job, Next Step
memset(sCDKey, 0, sizeof(sCDKey));
for(ByteCounter=24; ByteCounter >= 0; --ByteCounter)
{
nCur = 0;
for(k=14; k >= 0; --k)
{
nCur = (nCur * 256) ^ ProductKeyExtract[k];
ProductKeyExtract[k] = nCur / 24;
nCur %= 24;
}
strcat(sCDKey, KeyChars[nCur]);
//Insert "-"
if( !(ByteCounter % 5) && ByteCounter )
strcat(sCDKey, "-");
}
_strrev(sCDKey);
wsResult = sCDKey;
char *pch;
pch = strstr(wsResult, "-");
if (pch != NULL) {
printf(wsResult);
} else {
GetWindowsKey(true);
}
#ifdef WIN64KEY
#undef WIN64KEY
#endif
}
Sursa:www.info-hack.com
0
0
Back to top
Freakz Forum Index
->
Trash Bin
->
Trash
->
Programming / Scripting / Database
The time now is 03-12-2024, 07:07:56
Copyright info
Based on phpBB
ro
/
com
B
Login
I forgot my password
World of Warcraft
Login for more...
Download WoW 7.3.5
Misc
eSports
Achievements
Buy reputation with votes
Reputation trades
Forum rules
Ban list
Members list
User guide (FAQ)
World of Warcraft
View details