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
main.cpp
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
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
C++:
#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);
}
}
C++:
#include "stdafx.h"
using namespace std;
int main()
{
mem OB;
OB.MemRead("0x6B02808", 32);
OB.Read("0x6B02808", "Double");
system("pause");
return 0;
}
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: