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 


Can change in CheatEngine but not in C++?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Ravskie
How do I cheat?
Reputation: 0

Joined: 05 Oct 2010
Posts: 2

PostPosted: Tue Oct 05, 2010 5:00 am    Post subject: Can change in CheatEngine but not in C++? Reply with quote

Hey,

Code:

DWORD dw, dw2;

      HANDLE hProcessSnap;
        HANDLE hProcess = NULL;
      VirtualProtectEx(hProcess, (void *)0x1C9B57B3, sizeof(0x1C9B57B3), PAGE_EXECUTE_READWRITE, &dw);
        PROCESSENTRY32 pe32;   
        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
        pe32.dwSize = sizeof(PROCESSENTRY32);
        Process32First(hProcessSnap, &pe32);
        do
        {         
            if(!strcmp(pe32.szExeFile, "deadrising2.exe"))
            {
                 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
                 break;
            }
        }
        while(Process32Next(hProcessSnap, &pe32));
        CloseHandle( hProcessSnap );
        if(hProcess != NULL)
        {
            WriteProcessMemory(hProcess, (void *)0x1C9B57B3, "DR2MP", sizeof(0x1C9B57B3), NULL);       
            CloseHandle(hProcess);   
            return true;
        }


And I've also tried:

Code:

DWORD dw, dw2;
VirtualProtect((void *)0x1C9B57B3, sizeof(0x1C9B57B3), PAGE_EXECUTE_READWRITE, &dw);
strcpy((void *)0X1C9B57B3, "DR2MP", sizeof(0x1C9B57B3));
VirtualProtect((void *)0x1C9B57B3, sizeof(0x1C9B57B3), dw, &dw2);


Problem is, i can change that address in cheat engine and the button text changes to DR2MP, but when i try it in C++ it just refuses to change?

Any ideas why this wont work?

Please help if you can, thanks! Razz
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Tue Oct 05, 2010 5:24 pm    Post subject: Re: Can change in CheatEngine but not in C++? Reply with quote

Virtually every one of those functions has the possibility of failing, yet you aren't doing any error-checking whatsoever. You're calling virtual protect on an uninitialized process handle, you're probably passing the wrong value for the size parameter of writeprocessmem, and you're possibly failing by asking for process_all_access instead of more granular permissions. There might be more, dunno. I'd scrap what you have and google for some better examples.

Cheers,
adude

Ravskie wrote:
Hey,

Code:

DWORD dw, dw2;

      HANDLE hProcessSnap;
        HANDLE hProcess = NULL;
      VirtualProtectEx(hProcess, (void *)0x1C9B57B3, sizeof(0x1C9B57B3), PAGE_EXECUTE_READWRITE, &dw);
        PROCESSENTRY32 pe32;   
        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
        pe32.dwSize = sizeof(PROCESSENTRY32);
        Process32First(hProcessSnap, &pe32);
        do
        {         
            if(!strcmp(pe32.szExeFile, "deadrising2.exe"))
            {
                 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
                 break;
            }
        }
        while(Process32Next(hProcessSnap, &pe32));
        CloseHandle( hProcessSnap );
        if(hProcess != NULL)
        {
            WriteProcessMemory(hProcess, (void *)0x1C9B57B3, "DR2MP", sizeof(0x1C9B57B3), NULL);       
            CloseHandle(hProcess);   
            return true;
        }


And I've also tried:

Code:

DWORD dw, dw2;
VirtualProtect((void *)0x1C9B57B3, sizeof(0x1C9B57B3), PAGE_EXECUTE_READWRITE, &dw);
strcpy((void *)0X1C9B57B3, "DR2MP", sizeof(0x1C9B57B3));
VirtualProtect((void *)0x1C9B57B3, sizeof(0x1C9B57B3), dw, &dw2);


Problem is, i can change that address in cheat engine and the button text changes to DR2MP, but when i try it in C++ it just refuses to change?

Any ideas why this wont work?

Please help if you can, thanks! :P
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Oct 05, 2010 6:18 pm    Post subject: Reply with quote

What the heck does 'sizeof(0x1C9B57B3)' even resolve to ?
Back to top
View user's profile Send private message
Ravskie
How do I cheat?
Reputation: 0

Joined: 05 Oct 2010
Posts: 2

PostPosted: Tue Oct 05, 2010 10:06 pm    Post subject: Reply with quote

Alright,

I fixed up my code, but yet she still doesnt work Confused

Here's what i have atm:

Code:

bool CMemory::InstallStringPatch(DWORD address, const char * string, int size)
{
   DWORD dw;
   HANDLE hProcessSnap;
    HANDLE hProcess = NULL;
   PROCESSENTRY32 pe32;
   
    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    pe32.dwSize = sizeof(PROCESSENTRY32);
    Process32First(hProcessSnap, &pe32);
    do
    {         
        if(!strcmp(pe32.szExeFile, "deadrising2.exe"))
        {
             hProcess = OpenProcess(PROCESS_VM_WRITE, FALSE, pe32.th32ProcessID);
             break;
        }
    }

    while(Process32Next(hProcessSnap, &pe32));
    CloseHandle(hProcessSnap);

    if(hProcess != NULL)
    {
      VirtualProtectEx(hProcess, (void *)address, size, PAGE_READWRITE, &dw);
        WriteProcessMemory(hProcess, (void *)address, string, size, NULL);       
        CloseHandle(hProcess);
      MessageBox(0, "WROTE TO THE ADDRESS", "it wrote", NULL);
        return true;
    }
   return true;
}


Now when i call it, i do get the message box, but there has got to be something wrong as it does not change the value, but i cannot pinpoint what?

Code:

m_pCMemory->InstallStringPatch(BUTTON_MENU_START,          "DR2MP",                5);


Is how i call it.

Anyone know why still? Smile
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Tue Oct 05, 2010 11:25 pm    Post subject: Reply with quote

Dude, check your return values for errors. Writeprocessmem is probably failing because you still don't have the correct permissions.
Back to top
View user's profile Send private message
Ravskie
How do I cheat?
Reputation: 0

Joined: 05 Oct 2010
Posts: 2

PostPosted: Wed Oct 06, 2010 1:11 am    Post subject: Reply with quote

OMG i got it! Very Happy
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