c++ changing memory offset help

Posts 1–15 of 22 · Page 1 of 2
c++ changing memory offset help
I have the address for no recoil for a game



Code:
004807B5
and the default value is

Code:
116
and i know this because i have tested this in cheat engine

and i know that the value that enables no recoil is

Code:
117
so how would i go about putting this into a c++ project?

can any help me please, or leave some links, or code, it would be so great full thanmks
Hi I suggest you starting with this memory library made by a person which is very good library. Mainly functions is
Code:
mem.Read<variabletype> (address);
and mem.Write (address, value);
this both functions are the best for you want, for example to change the recoil in your game is:
Code:
mem.Write(0x4807B5, 117);
But I never used write func, I used only read because is more undetectable, I'm checking everyday my hack in casual of CSGO for 2 weeks and is still undetectable plus I made an algorithm to avoid VAC detection. I hope that library helps you

PS: "mem" is declared as ProcMem (class)
Code:
ProcMem mem;
i dont know what you mean by its a good library, you didnt tell me what the libary is so i cant include it?, ive tried
Code:
WriteProcessMemory
i dont know
I thought I pasted it. Sorry. Search on google "Memory Class by Nether".
Quote Originally Posted by Tonyx97 View Post
I thought I pasted it. Sorry. Search on google "Memory Class by Nether".
Thank you I'll get back to you and let you know if I get it working
Here is the code im using to try and test this:
Code:
#include <iostream>
#include <string>
#include <windows.h>
#include "ProcMem.h"
using namespace std;

ProcMem mem;
int i = 0;
int main(){
	ProcMem mem; //Declare Class Object
	mem.GetProcess("CoDWaWmp.exe");
	DWORD dwBase = mem.Module("CoDWaWmp.exe"); //Define Process Base (watch for upper/lower case, the module process.exe is different from the process name Process.exe
	DWORD dwServer = mem.Module("server.dll");
	/*cout << "Press [F1]" << endl;

	if (dwBase)
	{
		cout << "Info: " << dwServer << " " << dwBase << endl;

	}
	*/

	while (i < 1) //infinite loop!
	{

		if (GetAsyncKeyState(VK_F1))
		{

			mem.Write(0x4807B5, 117);

		}
	}



}
I have tried this with a DLL, and injected it, but nothing happens even when i press the key
i have tried this an a console application but when i press F1 the game crashes, i don't know what is wrong, i have posted a screen shot below, maybe that might help you to help me, i really want this to work, thanks for helping me btw means alot


1º: Remove the first line of main because you already declared mem.
2º: The modules are useless in that code and you should remove "int i = 0;" and just use "true" or "1" instead of " i < 0" it's a waste if memory and it helps you to improve
And the game crashes because you are repeating the write 0.0001 times per second so... Just use after mem.Write "Sleep (1000)" or something like that
The image you posted (of CE) says the data type in the game is just 1 byte. (?)

But mem.Write(0x******,117); is probably (do you know?) writing an INT (ie. 4 bytes)

Check if the library explicitly has a .WriteByte() function, or if it's using generics, try
Code:
mem.Write(0x********,(BYTE)117);  //BYTE is defined in Windows.h?...I forget
mem.Write(0x********,(char)117);  //

mem.Write<BYTE>(0x********,117); //?
mem.Write<char>(0x********,117); //?
by default the value '117', even though it would fit into a byte, is treated as int32.

 
(important) rant
you really should write your own memory library....if it's "too hard", then you don't understand "this stuff" well enough to be doing it. imo.

edit: what Tony* said is true -- you're going to end up writing to it hundreds of times in a single key press, which shouldn't cause a problem (?), but might, depending on your memory library I guess - either way, it's not 'good'.

Code:
bool wasKeyDown = false;

while (1)
{
  if (GetAsyncKeyState(VK_F1)) // see msdn for return value :|
  { // key is currently down
    wasKeyDown = true;
  }
  else
  {//key isn't currently down, but was it down a  moment ago?! 
    if (wasKeyDown)
    {
      //do the thing
      wasKeyDown = false; // have to reset it..
    }
  }
}
^^this will cause the function to be called only after the key has been pressed and also *released*, which works for your needs, and avoids the call the Sleep. -->As opposed to doing something constantly while the key is pressed down.
Omg it worked thank you so so much i appreciate everyones help i really do
I can share my KeyCode.h for you guys, I made it 2 months ago and it works perfectly for me:
Code:
#include <windows.h>

#define LEFT_MOUSE_BUTTON 0x01
#define RIGHT_MOUSE_BUTTON 0x02
#define MIDDLE_MOUSE_BUTTON 0x04
#define A 0x41
#define B 0x42
#define C 0x43
#define D 0x44
#define E 0x45
#define F 0x46
#define G 0x47
#define H 0x48
#define I 0x49
#define J 0x4A
#define K 0x4B
#define L 0x4C
#define M 0x4D
#define N 0x4E
#define O 0x4F
#define P 0x50
#define Q 0x51
#define R 0x52
#define S 0x53
#define T 0x54
#define U 0x55
#define V 0x56
#define W 0x57
#define X 0x58
#define Y 0x59
#define Z 0x5A
#define K_0 0x30
#define K_1 0x31
#define K_2 0x32
#define K_3 0x33
#define K_4 0x34
#define K_5 0x35
#define K_6 0x36
#define K_7 0x37
#define K_8 0x38
#define K_9 0x39
#define BACKSPACE 0x08
#define TAB 0x09
#define ENTER 0x0D
#define CONTROL 0x11
#define ALT 0x12
#define CAPSLOCK 0x14
#define ESCAPE 0x1B
#define SPACE 0x20
#define ARROW_LEFT 0x25
#define ARROW_UP 0x26
#define ARROW_RIGHT 0x27
#define ARROW_DOWN 0x28
#define KDELETE 0x2E
#define LWIN 0x5B
#define RWIN 0x5C
#define NUM_0 0x60
#define NUM_1 0x61
#define NUM_2 0x62
#define NUM_3 0x63
#define NUM_4 0x64
#define NUM_5 0x65
#define NUM_6 0x66
#define NUM_7 0x67
#define NUM_8 0x68
#define NUM_9 0x69
#define NUM_ADD 0x6B
#define NUM_SEPARATOR 0x6C
#define NUM_SUBTRACT 0x6D
#define NUM_DECIMAL 0x11
#define NUM_DIVIDE 0x6F
#define F1 0x70
#define F2 0x71
#define F3 0x72
#define F4 0x73
#define F5 0x74
#define F6 0x75
#define F7 0x76
#define F8 0x77
#define F9 0x78
#define F10 0x79
#define F11 0x7A
#define F12 0x7B
#define LSHIFT 0xA0
#define RSHIFT 0xA1
#define LCONTROL 0xA2
#define RCONTROL 0xA3

bool keyPressed[] =
{
    false
};

bool keyUnpressed[][2] =
{
    {true, false}
};

bool GetKeyDown (int _key)
{
    if (GetAsyncKeyState(_key) && !keyPressed[_key])
    {
        keyPressed[_key] = true;
        return keyPressed[_key];
    }
    else if (!GetAsyncKeyState(_key) && keyPressed[_key])
    {
        keyPressed[_key] = false;
        return keyPressed[_key];
    }
    return false;
}

bool GetKeyUp (int _key)
{
    if (GetAsyncKeyState(_key) && !keyPressed[_key])
    {
        if (!keyUnpressed[_key][1])
        {
            keyUnpressed[_key][1] = true;
        }
    }
    if (keyUnpressed[_key][1])
    {
        if (GetAsyncKeyState(_key) && keyUnpressed[_key][0])
        {
            keyUnpressed[_key][0] = false;
            return keyUnpressed[_key][0];
        }
        else if (!GetAsyncKeyState(_key) && !keyUnpressed[_key][0])
        {
            keyUnpressed[_key][0] = true;
            return keyUnpressed[_key][0];
        }
    }
    return false;
}

int GetKey (int _key)
{
    if (GetAsyncKeyState(_key))
    {
        return GetAsyncKeyState(_key);
    }
    return 0;
}
Use GetKeyDown(Key) when you only need to call it 1 time like as want hiimachicken1.
Use GetKeyUp (Key) when you want to call some function when a key is unpressed.
Use GetKey (Key) is almost the same as GetAsyncKeyState.
This library is very useful if you're going to work with a lot of keys
PS: in the file you can find some useless stuff as the second array because you don't need another dimension for the array. But I don't touch it for now haha.
Quote Originally Posted by Tonyx97 View Post
I can share my KeyCode.h for you guys, I made it 2 months ago and it works perfectly for me:
Code:
#include <windows.h>

#define LEFT_MOUSE_BUTTON 0x01
#define RIGHT_MOUSE_BUTTON 0x02
#define MIDDLE_MOUSE_BUTTON 0x04
#define A 0x41
#define B 0x42
#define C 0x43
#define D 0x44
#define E 0x45
#define F 0x46
#define G 0x47
#define H 0x48
#define I 0x49
#define J 0x4A
#define K 0x4B
#define L 0x4C
#define M 0x4D
#define N 0x4E
#define O 0x4F
#define P 0x50
#define Q 0x51
#define R 0x52
#define S 0x53
#define T 0x54
#define U 0x55
#define V 0x56
#define W 0x57
#define X 0x58
#define Y 0x59
#define Z 0x5A
#define K_0 0x30
#define K_1 0x31
#define K_2 0x32
#define K_3 0x33
#define K_4 0x34
#define K_5 0x35
#define K_6 0x36
#define K_7 0x37
#define K_8 0x38
#define K_9 0x39
#define BACKSPACE 0x08
#define TAB 0x09
#define ENTER 0x0D
#define CONTROL 0x11
#define ALT 0x12
#define CAPSLOCK 0x14
#define ESCAPE 0x1B
#define SPACE 0x20
#define ARROW_LEFT 0x25
#define ARROW_UP 0x26
#define ARROW_RIGHT 0x27
#define ARROW_DOWN 0x28
#define KDELETE 0x2E
#define LWIN 0x5B
#define RWIN 0x5C
#define NUM_0 0x60
#define NUM_1 0x61
#define NUM_2 0x62
#define NUM_3 0x63
#define NUM_4 0x64
#define NUM_5 0x65
#define NUM_6 0x66
#define NUM_7 0x67
#define NUM_8 0x68
#define NUM_9 0x69
#define NUM_ADD 0x6B
#define NUM_SEPARATOR 0x6C
#define NUM_SUBTRACT 0x6D
#define NUM_DECIMAL 0x11
#define NUM_DIVIDE 0x6F
#define F1 0x70
#define F2 0x71
#define F3 0x72
#define F4 0x73
#define F5 0x74
#define F6 0x75
#define F7 0x76
#define F8 0x77
#define F9 0x78
#define F10 0x79
#define F11 0x7A
#define F12 0x7B
#define LSHIFT 0xA0
#define RSHIFT 0xA1
#define LCONTROL 0xA2
#define RCONTROL 0xA3

bool keyPressed[] =
{
    false
};

bool keyUnpressed[][2] =
{
    {true, false}
};

bool GetKeyDown (int _key)
{
    if (GetAsyncKeyState(_key) && !keyPressed[_key])
    {
        keyPressed[_key] = true;
        return keyPressed[_key];
    }
    else if (!GetAsyncKeyState(_key) && keyPressed[_key])
    {
        keyPressed[_key] = false;
        return keyPressed[_key];
    }
    return false;
}

bool GetKeyUp (int _key)
{
    if (GetAsyncKeyState(_key) && !keyPressed[_key])
    {
        if (!keyUnpressed[_key][1])
        {
            keyUnpressed[_key][1] = true;
        }
    }
    if (keyUnpressed[_key][1])
    {
        if (GetAsyncKeyState(_key) && keyUnpressed[_key][0])
        {
            keyUnpressed[_key][0] = false;
            return keyUnpressed[_key][0];
        }
        else if (!GetAsyncKeyState(_key) && !keyUnpressed[_key][0])
        {
            keyUnpressed[_key][0] = true;
            return keyUnpressed[_key][0];
        }
    }
    return false;
}

int GetKey (int _key)
{
    if (GetAsyncKeyState(_key))
    {
        return GetAsyncKeyState(_key);
    }
    return 0;
}
Use GetKeyDown(Key) when you only need to call it 1 time like as want hiimachicken1.
Use GetKeyUp (Key) when you want to call some function when a key is unpressed.
Use GetKey (Key) is almost the same as GetAsyncKeyState.
This library is very useful if you're going to work with a lot of keys
PS: in the file you can find some useless stuff as the second array because you don't need another dimension for the array. But I don't touch it for now haha.
Why not GetAsyncKeyState( 'A' ) etc? Works with every A-Z, a-z, 0-9 chars.
Every other one ( TAB etc ) are defined as virtual key in WinUser.h

https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
@Tonyx97
Code:
int GetKey (int _key)
{
    if (GetAsyncKeyState(_key))
    {
        return GetAsyncKeyState(_key);
    }
    return 0;
}

should be

Code:
int GetKey (int _key)
{
         return GetAsyncKeyState(_key);
}
: |

it's exactly equivalent - if the first call to getasynckeystate returns 0, you return 0....else you call getasynckeystate again and pass its return value along --> so you're simply returning the return-value of getasynckeystate! Except your version could read a non-zero on the first call, but then get a 0 on the second call to getasynckeystate. Unlikely, but there is no reason for it.


@hiimachicken1 You should say what exactly the problem was, and what the solution was..not just 'nvm, it works now'.
Quote Originally Posted by abuckau907 View Post
@Tonyx97
Code:
int GetKey (int _key)
{
    if (GetAsyncKeyState(_key))
    {
        return GetAsyncKeyState(_key);
    }
    return 0;
}

should be

Code:
int GetKey (int _key)
{
         return GetAsyncKeyState(_key);
}
: |

it's exactly equivalent - if the first call to getasynckeystate returns 0, you return 0....else you call getasynckeystate again and pass its return value along --> so you're simply returning the return-value of getasynckeystate! Except your version could read a non-zero on the first call, but then get a 0 on the second call to getasynckeystate. Unlikely, but there is no reason for it.


@hiimachicken1 You should say what exactly the problem was, and what the solution was..not just 'nvm, it works now'.
Yes, you're right, I did it long time ago and when I finished the library I didn't spend time on optimizing it but I could. Thanks for the tip anyways
@abuckau907

To anyone wanting to know the code, and you can compare it to see how i made it work
Code:
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <windows.h>
#include "ProcMem.h"
using namespace std;
int main(){
	ProcMem mem; //Declare Class Object
	mem.GetProcess("CoDWaWmp.exe");
	DWORD dwBase = mem.Module("CoDWaWmp.exe"); //Define Process Base (watch for upper/lower case, the module process.exe is different from the process name Process.exe
	DWORD dwServer = mem.Module("server.dll");


	bool wasKeyDown = false;
	if (dwBase){

		cout << "[F1] no-recoil" << endl;
	}
	while (1)
	{
		Sleep(1000);
		if (GetAsyncKeyState(VK_F1)) // see msdn for return value :|
		{ // key is currently down
			wasKeyDown = true;
		}
		else
		{//key isn't currently down, but was it down a  moment ago?! 
			if (wasKeyDown)
			{
				//do the thing
				mem.Write(0x4807B5, (BYTE)117);
				wasKeyDown = false; // have to reset it..
			}
		}
	}
}
Posts 1–15 of 22 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us