myown How do I cheat?
Reputation: 0
Joined: 11 Mar 2014 Posts: 9
|
Posted: Wed Mar 12, 2014 12:48 am Post subject: [C++]FindWindow |
|
|
why always when i try this code get error
HWND hWnd = FindWindow(0, "Call of Duty")
full code
| Code: | #include <windows.h>
#include <iostream>
int main()
{
using namespace std;
int compteur_un = 0;
int compteur_deux = 0;
bool boucle = true;
cout << "Hello" << endl;
HWND hWnd = FindWindow(0, "Call of Duty")
if(hWnd == 0)
{
MessageBox(0, "Can't find window.", "Erreur", MB_OK|MB_ICONERROR);
}
else
{
DWORD proccess_ID;
GetWindowThreadProcessId(hWnd, &proccess_ID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccess_ID);
if(!hProcess)
{
MessageBox(0, "Can't open the process", "Erreur!", MB_OK|MB_ICONERROR);
}
return 0;
} |
other code
| Code: | #include <iostream>
#include <windows.h>
// FindWindow();
// GetWindowThreadProcessId();
// OpenProcess();
// WriteProcessMemory();
// CloseHandle();
using namespace std;
int main()
{
int newValue = 700;
HWND hWnd = FindWindow(0, "Call of Duty");
if (hWnd == 0) {
cerr << "Cannot find window." << endl;
} else {
DWORD pId;
GetWindowThreadProcessId(hWnd, &pId);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
if (!hProc) {
cerr << "Cannot open process." << endl;
} else {
int isSuccessful = WriteProcessMemory(hProc, (LPVOID)0x000AFCC4, &newValue, (DWORD)sizeof(newValue), NULL);
if (isSuccessful > 0) {
clog << "Process memory written." << endl;
} else {
cerr << "Cannot write process memory." << endl;
}
CloseHandle(hProc);
}
}
return 0;
} |
|
|