#include <windows.h>
#include <iostream>
#include <Tlhelp32.h>
using namespace std;
void EnableDebugPriv()
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken);
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue);
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &tkp, sizeof(tkp), NULL, NULL);
CloseHandle(hToken);
}
int main(int argc, char *argv[])
{
SetConsoleTitle("account.exe");
EnableDebugPriv();
TCHAR War3Name[32] = TEXT("Warcraft III");
HWND hWar3 = FindWindow(War3Name, NULL);
if(!hWar3)
{
cout << "Warcraft 3 was not found." << endl;
system( "pause" );
return 1;
}
DWORD pid;
GetWindowThreadProcessId( hWar3, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open Warcraft III." << endl;system( "pause" );
return 1;
}
// Static address of saved account names in DWORD.
DWORD Address = 15413504;
DWORD Buffer = 0;
DWORD WINAPI GetLastError(void);
SIZE_T BytesRead = 0;
for(;;)
{
char Name[16];
Name[15] = 0;
for( unsigned int i = 0; i < 15; i++ )
{
ReadProcessMemory( hOpen, (LPVOID)( Address + i ), &Buffer, 1, &BytesRead );
Name[i] = Buffer;
}
cout << "Your current account name is: " << Name << endl << endl << "Please type in a new account name and press enter." << endl << endl;
SIZE_T BytesWritten = 0;
char NewName[16];
memset(NewName, 0, 16 );
cin.getline (NewName,16);
for( unsigned int j = 0; j < 15; j++ )
{
WriteProcessMemory( hOpen, (LPVOID)(Address + j), (LPCVOID)(NewName+ j), 1, &BytesWritten );
}
cout << "\n";
cout << "Your new account name is: " << NewName << endl << endl;
}
}