• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Results 1 to 5 of 5
    1. #1
      The Angel Of Verdun
      Always More To Code!
       
      Lurking
       
      Nether's Avatar
      Join Date
      Dec 2013
      Location
      England, SW
      Posts
      299
      Thanks (-->)
      54
      Thanks (<--)
      186

      Post C++ Memory Class - Progress (Looking To Improve)

      John Kittz
      Hey Guys,

      I used to watch Fleeps tutorials and made a few things based of the sources he released, and I havent coded in awhile till recently.

      I have been studying basics of C++ just so I can understand the language abit better (Have Previously coded in VB ALOT),
      and well Ive made a simple read memory function for a console.

      I know there is the ReadProcessMemory Function but I tried to make it shorter to use but would like some tips/hints on what I could improove on,
      I do plan to make it so you can read/write all data types and hex/string addresses (game.exe+1234) < like that .

      mem.cpp
      #include "stdafx.h"

      using namespace std;

      #pragma region Storage

      DWORD Game_ID;
      HANDLE hProcess;
      HWND Game;

      #pragma endregion Storage For Varibles


      mem::mem()// GetProc
      {
      //wchar_t Pname[20];//Window Name Varible (wide character - LPCSTR [.c_str] / LPCWSTR [wchar_t]
      //cout << "Enter Process Window Name: ";
      //wcin >> Pname;

      Game = FindWindow(NULL, L"Solitaire");//find the Process Via Its Window Name

      if(Game)// If The Process Is Running
      {
      GetWindowThreadProcessId(Game, &Game_ID);//Gets The Process ID From The Process Window
      hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Game_ID);//Declare hProcess As The Process/Handle And Give It Full Access
      cout << "\nProcess Running!" << endl;
      }
      else
      {
      cout << "\nProcess Is Not Running!" << endl;
      }
      }

      void mem::MemRead(string Address, int nBytes){

      DWORD _Address = strtol(Address.c_str(), 0, 0);

      switch(nBytes){

      case 4:
      int DataTypeI;
      ReadProcessMemory(hProcess, (LPVOID)_Address, &DataTypeI, sizeof(DataTypeI), NULL);
      cout << "The Address " << Address << " Stores An Integer Value ( " << DataTypeI << " )" << endl;
      break;

      case 16:
      float DataTypeF;
      ReadProcessMemory(hProcess, (LPVOID)_Address, &DataTypeF, sizeof(DataTypeF), NULL);
      cout << "The Address " << Address << " Stores A Float Value ( " << DataTypeF << " )" << endl;
      break;

      case 32:
      double DataTypeD;
      ReadProcessMemory(hProcess, (LPVOID)_Address, &DataTypeD, sizeof(DataTypeD), NULL);
      cout << "The Address " << Address << " Stores A Double Value ( " << DataTypeD << " )" << endl;
      break;

      default:
      cout << "Invalid Selection, [Integer = 4 | Float = 16 | Double = 32]" << endl;
      break;

      }
      }

      void mem::Read(string Address, string Data){

      if(Data == "Integer"){
      MemRead(Address, 4);
      }

      if(Data == "Float"){
      MemRead(Address, 16);
      }

      if(Data == "Double"){
      MemRead(Address, 32);
      }
      }


      main.cpp

      #include "stdafx.h"
      using namespace std;


      int main()
      {

      mem OB;
      OB.MemRead("0x6B02808", 32);
      OB.Read("0x6B02808", "Double");
      system("pause");
      return 0;
      }


      So you can read memory by either:

      Read("Address As String", "Data Type")
      MemRead("Address As String", Data In Bytes) < its just a switch

      What I want to do is make one function with only one ReadProcessMemory, and you dont need all that code and have something like this mem.read("addy", Type(float))

      I will continue reading books and online tutorials for general C++ programming as i want to understand more about programming with C++ not just focused around hacks, so when
      I get into situations like this ill know exactly what to do or atleast have an idea of where im going and what is possible .

      The Idea for this came to me when i saw other sources on here and it had tons of read/write process memory in peoples code, i just wanted to make a class for it so it can be called in
      a small line of code and in the end bring the overall ammount of code down, although this may be pointless its helping me play around with classes and learn more about the language
      Last edited by Nether; 12-11-2013 at 10:42 PM.

    2. #2
      Hacker
      Learning to hack games!
       
      Pawning
       
      Fleep's Avatar
      Join Date
      May 2012
      Posts
      626
      Thanks (-->)
      208
      Thanks (<--)
      727
      This is very cool, if you happen to complete it and decide to share that class many of us would appreciate it

      Good work

      Fleep

    3. Thanks Nether thanked for this post
    4. #3
      Coder
      Creating UE3 x86/x64 tut
       
      Coding
       
      TastyHorror's Avatar
      Join Date
      Oct 2012
      Location
      Canada
      Posts
      184
      Thanks (-->)
      54
      Thanks (<--)
      81
      You should use the switch statement in your read function to increase performance and efficiency. Also, don't use global variables.
      Last edited by TastyHorror; 12-12-2013 at 03:47 AM.
      Quote Originally Posted by squeenie View Post
      And just like Jesus did on easter Monday, he returns!

    5. #4
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      Declare those global vars in the class instead.

      If you have 2 objects of the vlass, the first one will probably lead to unexpected behaviour.

      Rather than outputing the result, return it, and use templates to reduce the size of the class.
      C++ Memory Class - Progress (Looking To Improve)

    6. Thanks Nether thanked for this post
    7. #5
      The Angel Of Verdun
      Always More To Code!
       
      Lurking
       
      Nether's Avatar
      Join Date
      Dec 2013
      Location
      England, SW
      Posts
      299
      Thanks (-->)
      54
      Thanks (<--)
      186
      Cheats'n'Trainers
      Thank you for the information / tips you have provided I will continue to work on this , thank you for the support

    8. Thanks NTvalk thanked for this post

    Similar Game Hacker Threads

    1. [Source Code] Nether's C++ Memory Class V1.6
      By Nether in forum Tutorials and Snippets
      Replies: 65
      Last Post: 03-13-2017, 08:12 PM
    2. [Source Code] Nether's V1.5 C++ Memory Class
      By Nether in forum Tutorials and Snippets
      Replies: 6
      Last Post: 03-05-2014, 12:21 PM
    3. [Source Code] Nether's V1.4 C++ Memory Class
      By Nether in forum Tutorials and Snippets
      Replies: 11
      Last Post: 01-31-2014, 08:27 AM
    4. [Source Code] Nether's VB Memory Class
      By Nether in forum Visual Basic
      Replies: 0
      Last Post: 01-25-2014, 07:24 PM
    5. [Source Code] ProcMem.h C++ Memory Class
      By Nether in forum Tutorials and Snippets
      Replies: 3
      Last Post: 01-12-2014, 05:03 AM

    Tags for this Thread