Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


(C++) What's wrong?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Sat Dec 17, 2016 11:54 am    Post subject: (C++) What's wrong? Reply with quote

I can not connect to the process. Because?

Code:

#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

using namespace std;

int newscore;


int main()
{
   HWND windowProgram = FindWindow(0, L"Step 2");
   cout<<"Coloque o novo escore: ";
   cin>>::newscore;
   if(windowProgram==0)
      cerr<<"abra o programa"<<endl;
   else{
      DWORD processID;
      GetWindowThreadProcessId(windowProgram, &processID);
      HANDLE handleProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
      if(!handleProcess)
         cerr<<"Nao foi possivel abrir o processo"<<endl;
      else{
         int memoryHack = WriteProcessMemory(handleProcess, (LPVOID)0x011B8C80, &newscore, (DWORD)sizeof(newscore), NULL);
         if(memoryHack > 0)
            clog<<"FOi escrito"<<endl;
         else
            cerr<<"Não foi escrito"<<endl;

         CloseHandle(handleProcess);
         }
      }

system("PAUSE");

return 0;
}

_________________
...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Sat Dec 17, 2016 2:56 pm    Post subject: Reply with quote

Are you running it as administrator?

and you may first have to obtain SeDebugPrivilege

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Kavvman
Master Cheater
Reputation: 2

Joined: 17 Apr 2004
Posts: 316

PostPosted: Sat Dec 17, 2016 6:43 pm    Post subject: Reply with quote

Where does it error out(which function)?
_________________
...
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Sun Dec 18, 2016 5:44 am    Post subject: Reply with quote

Incredibly, I did manage to sort it out. Replaces where "FALSE" is written with "0".
Notice the beginning of the main.
Code:

HWND windowProgram = FindWindow(0, L"Step 2");

Without this "L" does not work, I wanted to store the window name in a variable. But I can not put the name of the variable and this "L" together.

_________________
...
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Sun Dec 18, 2016 6:36 am    Post subject: Reply with quote

on your project properties change unicode to multibyte character and you should then be able to take the L off.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites