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 


Need help with simple trainer source C++

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

Joined: 04 Jan 2011
Posts: 7

PostPosted: Fri Jan 14, 2011 7:40 pm    Post subject: Need help with simple trainer source C++ Reply with quote

In learning I am using Torchlight for this, I found the base pointer using CE. So when I restart my comp or game I can use this same address to change the value anytime since it doesn't change. Here is what CE gives me:

Example.png has the image to save time typing it all.
NOTE** The last pointer is "Torchlight.exe+009885E8"

I now have this code:

Code:

#include <windows.h>
#include <iostream>

int ReadMemory();
void WriteMemory(const int& newValue);

DWORD Dynamic_Address   = 0x11D484D4; //Dynamic address      **Changes
DWORD Dynamic_Pointer1   = 0x07AF1214; //Dynamic pointer 1   **Changes
DWORD Dynamic_Pointer2   = 0x07AF1180; //Dynamic pointer 2   **Changes
DWORD Static_Pointer   = 0x009885E8; //Static address      **Same

DWORD New_Address = 0x00;

DWORD Offset1 = 0x3c4; //3C4
DWORD Offset2 = 0x14;  //14
DWORD Offset3 = 0x08;  //8

////////////////////////////////////////////////////////////////
/// Static_Pointer and offset 3      = Dynamic_Pointer2
/// Dynamic_Pointer2 and offset 2   = Dynmaic_Pointer1
/// Dynamic_Pointer1 and offset 1   = Dynamic_Address
///
/// NOTE** Static_Pointer actuall "Torchlight.exe+0099885E8"
////////////////////////////////////////////////////////////////

HANDLE GameHandle;
DWORD Pid = 0;

int main()
{
   bool isRunning = true;
   int choice = 0;
   int currentValue = 0;
   int amount = 0;

   //Open the process and check if specific game is open
   GetWindowThreadProcessId(FindWindow(0, "Torchlight"), &Pid);
   if(!Pid)
   {
      std::cout << "Failed to find Torchlight window\n\n";
      isRunning = false;
   }
   else
   {
      GameHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, Pid);
   }

   while(isRunning)
   {
      std::cout << "Torchlight trainer\n\n";
      std::cout << "1 = Get gold\n";
      std::cout << "2 = Add gold\n";
      std::cout << "0 = Exit\n";
      std::cout << "Enter choice: ";
      std::cin >> choice;
      switch(choice)
      {
      case 1:
         //Read current xp
         currentValue = ReadMemory();
         std::cout << "\nCurrent value: " << currentValue << "\n\n";
         break;
      case 2:
         //Add xp
         std::cout << "Enter amount: ";
         std::cin >> amount;
         WriteMemory(amount);
         currentValue = ReadMemory();
         std::cout << "\nNew value: " << currentValue << "\n\n";
         break;
      case 0:
         isRunning = false;
         break;
      default:
         std::cout << "Invalid option, try again...\n\n";
         break;
      }
   }

   return 0;
}

int ReadMemory()
{
   int inValue= 0;

   ReadProcessMemory(GameHandle, (void*)New_Address, &inValue, 4, NULL);

   return inValue;
}

void WriteMemory(const int& newValue)
{
   int outValue = newValue;

   WriteProcessMemory(GameHandle, (void*)New_Address, &outValue, 4, NULL);
}


I am confused since if I enter the dynamic_address no problems reading or writing, if I try and use any of the others doesn't work. I figure I have to do something with the offset, but I have tried so many different things to get no solution, so now I am coming here for someone to show me what I am doing wrong. Thank you in advance for your help.



Example.png
 Description:
CE Shows me about this pointer.
 Filesize:  22.54 KB
 Viewed:  9405 Time(s)

Example.png


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

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

PostPosted: Fri Jan 14, 2011 9:18 pm    Post subject: Reply with quote

You'll need to find the module address of Torchlight.exe and add 0x009885E8 to get to the static address

easiest is using toolhelp32snapshot and then module32first/module32next to find it (module32first will most likely already contain what you need)

_________________
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
wicked357
How do I cheat?
Reputation: 0

Joined: 04 Jan 2011
Posts: 7

PostPosted: Fri Jan 14, 2011 9:27 pm    Post subject: Reply with quote

I am not familiar with your recommendations, could you provide an example or a link to something I can read a little more about it exactly?

I found some information about this method you mention only thing is I don't see how it is different than what I have for finding the process. I am not seeing how I turn this into an address and use it like my other address to add to each other.

Here is the link I found,

deathsoft[dot]com/forum/index.php?showtopic=20

EDIT** I tried something like,

DWORD Mod_Add = Process32First(snapshot, &pe32);

but that didn't work, so right now I am shooting with a blindfold on, but ill keep searching while I wait for a response. I did some research and found that Process32First returns a boolean so that makes sense why it dodn't work...
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jan 14, 2011 10:59 pm    Post subject: Reply with quote

you're right, randomly guessing and putting things in isn't going to work.

http://msdn.microsoft.com/en-us/library/ms684218(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms684225(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms684221(v=vs.85).aspx

there is an example for looping through it, pretty simple.
Back to top
View user's profile Send private message
wicked357
How do I cheat?
Reputation: 0

Joined: 04 Jan 2011
Posts: 7

PostPosted: Fri Jan 14, 2011 11:35 pm    Post subject: Reply with quote

I noticed while messing around using Module32 only shows my DLL's when it is listing. My address shows this "Torchlight.exe+0098...." wouldn't I use processentry? if so, I see there are many variables to it, the only one that catches my eye is szExeFile, because it appears to be HEX. My only issue here is before I go along and rebuild this proram I have a mess right now, wouldn't that not be the address but the name in HEX? If so I am obviously at a deadend unless one of those weird numbers is the process address. I see moduleentry has an address member, but again this isn't a dll.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 204

Joined: 25 Jan 2006
Posts: 8580
Location: 127.0.0.1

PostPosted: Sat Jan 15, 2011 12:15 am    Post subject: Reply with quote

Torchlight.exe is just a symbol. CE just displays it as the name for convenience to you to understand what the offsets are based from. Module32First / Module32Next will return each of the module names and their base address.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
wicked357
How do I cheat?
Reputation: 0

Joined: 04 Jan 2011
Posts: 7

PostPosted: Sat Jan 15, 2011 12:26 am    Post subject: Reply with quote

EDIT** My problem was my actual base pointer, I found choose another pointer out of pointer scanner that was a DLL and it had 5 offsets and I got it all to work good. I had to tweak the crap out of my code still it was a mess as it was. But I will be doing more test with it tomorrow to make sure it is working ok. Thank you for your assistance.
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