Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 105,403 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,791 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



C++ MS Pinball trainer.

 
Reply to this topicStart new topic

C++ MS Pinball trainer.

DanerC++
post 3 Jul, 2008 - 08:54 AM
Post #1


New D.I.C Head

*
Joined: 3 Jul, 2008
Posts: 2

Okay, i know how to change the values of my score in Pinball for Microsoft using Cheat Engine 5.4, but i would like to know why this code doesnt work. Well basicly its ment to create a C++ app to manipulate this value and then come back and tell me.

CODE
  #include <windows.h>
#include <tlhelp32.h>
#include <conio.h>
#include <stdlib.h>

bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size);

void main()
{
     printf("=== Pinball Trainer Example. Made by <your name here> ===\n\n");
     if(ChangeMemVal("PINBALL.EXE", (void*) 0xA90C62, 100000000, 4))
          printf("The score has been edited successfully.\n");
     else
          printf("An error occured while attempting edit the score.\n");
     system("PAUSE");
     return 0;
}


/* This function modifys a memory address according to its arguments.
   Arguments :
             ProcessName - the process we want to modify
             MemAddress - the memory address we want to modify
             NewVal - the value we want to change the memory address to
             size - the size of the memory address
   Returns :
           the success of the edit.
   */


bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size)
{
     HANDLE hProcessSnap;
     HANDLE hProcess = NULL;
     PROCESSENTRY32 pe32;    
     hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
     pe32.dwSize = sizeof( PROCESSENTRY32 );
     Process32First(hProcessSnap, &pe32);
     do
     {          
          if(!strcmp(pe32.szExeFile, ProcessName))
          {
               hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
               break;
          }
     }
     while(Process32Next(hProcessSnap, &pe32));
     CloseHandle( hProcessSnap );
     if(hProcess != NULL)
     {
          WriteProcessMemory(hProcess, MemAddress, &NewVal, size, NULL);     // write the value          
          CloseHandle(hProcess);    
          return true;
     }    
     return false;
}


CODE
9 C:\Documents and Settings\Same\My Documents\Untitled2.cpp `main' must return `int'

C:\Documents and Settings\Sam\My Documents\Untitled2.cpp In function `int main(...)':


CODE
10 C:\Documents and Settings\Sam\My Documents\Untitled2.cpp `printf' undeclared (first use this function)

  (Each undeclared identifier is reported only once for each function it appears in.)

Theres my errors i get.

Thanks in advance.

This post has been edited by DanerC++: 3 Jul, 2008 - 08:56 AM
User is offlineProfile CardPM

Go to the top of the page


tortillaboy05
post 3 Jul, 2008 - 09:22 AM
Post #2


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 20


My Contributions


I don't know exactly how to fix the first error, maybe:

CODE

#include <stdio.h>

using namespace std;

int main()
{
...
return 0;
}



Yeah just change the return type of main to int that should fix it.

To fix the second error you need to include <stdio.h> library for printf();

This post has been edited by tortillaboy05: 3 Jul, 2008 - 09:24 AM
User is offlineProfile CardPM

Go to the top of the page

DanerC++
post 3 Jul, 2008 - 09:49 AM
Post #3


New D.I.C Head

*
Joined: 3 Jul, 2008
Posts: 2

Thanks alot. Thats sorted the problem now.. biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 8/20/08 05:02AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month