I wrote it up in c++, and I am getting the correct length output, but the client says invalid patcher key, any ideas?
Code:
#include "stdafx.h"
#include <ctime>
#include "Common.h"
#include <Windows.h>
#include <mmsystem.h>
#include <iostream>
#include <shellapi.h>
#pragma comment (lib, "winmm.lib")
#include "md5wrapper.h"
void encrypt (uint64* v, uint64* k);
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "-tCalculating ClientHash: ";
//Calculate md5sum of AgeOfConan.exe
md5wrapper md5;
string hash = md5.getHashFromFile("AgeOfConan.exe");
cout << hash.c_str() << "n-tCalculating Key: ";
//Calculate Key
uint32 keys[] = {0x5BCE568E, 0x0FB2E8CBC, 0x0A324E6D8, 0x0F22BF865};
__time64_t cur_time = _time64(0);
encrypt((uint64*)(&cur_time), (uint64*)keys);
char hexString1[16];
char hexString2[16];
sprintf_s(hexString1, "%x", (long long)cur_time);
sprintf_s(hexString2, "%x", (((long long)cur_time) >> 32));
cout << hexString2 << hexString1 << endl;
//Call timebeginperiod
cout << "-tCalling timeBeginPeriod(1)" << endl;;
timeBeginPeriod(1);
//Launch the client
cout << "-tLaunching Age of Conan" << endl;
string args = "-novideo -clienthash ";
args.append(hash);
args.append(" -key ");
args.append(hexString2);
args.append(hexString1);
ShellExecuteA(NULL, "open", "AgeOfConan.exe", args.c_str(), NULL, SW_SHOW);
cin.get();
//Finished
cout << "-tCalling timeEndPeriod";
timeEndPeriod(1);
return 0;
}
void encrypt (uint64* v, uint64* k) {
uint64 v0=v[0], v1=v[1], sum=0, i; /* set up */
uint64 delta=0x61C886470; /* a key schedule constant */
uint64 k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
for (i=0; i < 32; i++) { /* basic cycle start */
sum += delta;
v0 += ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
v1 += ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3); /* end cycle */
}
v[0]=v0; v[1]=v1;
}