Results 1 to 2 of 2
  1. #1
    Remote Access Memory's Avatar
    Join Date
    Oct 2017
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0

    Post What is wrong with my code???

    This is suppose to give ammo when the user reaches less than 3 bullets left, both of my addresses work in cheat engine... so what's wrong... is it just a simple error???

    Code:
    #include <Windows.h>
    #include <iostream>
    
    class LocalPlayer
    {
    public:
    	DWORD                      Pid;
    	DWORD       PAmmo = 0x02370FDC;
    	DWORD       SAmmo = 0x02370FD8;
    	int                      PData;
    	int                      SData;
    	int                     NPData;
    	int                     NSData;
    	void ReadP()
    	{
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		ReadProcessMemory(handle, (LPCVOID)PAmmo, &PData, sizeof(PData), 0);
    	}
    	void WriteP()
    	{
    		NPData = PData += 1000;
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		WriteProcessMemory(handle, (LPVOID)PAmmo, &NPData, sizeof(NPData), 0);
    	}
    	void ReadS()
    	{
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		ReadProcessMemory(handle, (LPCVOID)SAmmo, &SData, sizeof(SData), 0);
    	}
    	void WriteS()
    	{
    		NSData = SData += 1000;
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		WriteProcessMemory(handle, (LPVOID)SAmmo, &NSData, sizeof(NSData), 0);
    	}
    }; LocalPlayer localPlayer;
    int main()
    {
    	while (true)
    	{
    		Sleep(1);
    		localPlayer.ReadP();
    		localPlayer.ReadS();
    		if (localPlayer.PData < 3)
    		{
    			localPlayer.WriteP();
    		} else 
    		if (localPlayer.SData < 3)
    		{
    			localPlayer.WriteS();
    		}
    	}
    	return 0;
    }
    I'm using Windows 10 if that matters.

  2. #2
    CrypticMods's Avatar
    Join Date
    Apr 2016
    Gender
    male
    Posts
    415
    Reputation
    10
    Thanks
    502
    My Mood
    Sad
    Quote Originally Posted by Remote Access Memory View Post
    This is suppose to give ammo when the user reaches less than 3 bullets left, both of my addresses work in cheat engine... so what's wrong... is it just a simple error???

    Code:
    #include <Windows.h>
    #include <iostream>
    
    class LocalPlayer
    {
    public:
    	DWORD                      Pid;
    	DWORD       PAmmo = 0x02370FDC;
    	DWORD       SAmmo = 0x02370FD8;
    	int                      PData;
    	int                      SData;
    	int                     NPData;
    	int                     NSData;
    	void ReadP()
    	{
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		ReadProcessMemory(handle, (LPCVOID)PAmmo, &PData, sizeof(PData), 0);
    	}
    	void WriteP()
    	{
    		NPData = PData += 1000;
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		WriteProcessMemory(handle, (LPVOID)PAmmo, &NPData, sizeof(NPData), 0);
    	}
    	void ReadS()
    	{
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		ReadProcessMemory(handle, (LPCVOID)SAmmo, &SData, sizeof(SData), 0);
    	}
    	void WriteS()
    	{
    		NSData = SData += 1000;
    		HWND HWnd = FindWindowA(0, ("Call of DutyŽ: Black Ops II"));
    		GetWindowThreadProcessId(HWnd, &Pid);
    		HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
    		WriteProcessMemory(handle, (LPVOID)SAmmo, &NSData, sizeof(NSData), 0);
    	}
    }; LocalPlayer localPlayer;
    int main()
    {
    	while (true)
    	{
    		Sleep(1);
    		localPlayer.ReadP();
    		localPlayer.ReadS();
    		if (localPlayer.PData < 3)
    		{
    			localPlayer.WriteP();
    		} else 
    		if (localPlayer.SData < 3)
    		{
    			localPlayer.WriteS();
    		}
    	}
    	return 0;
    }
    I'm using Windows 10 if that matters.
    You don't have to declare HWnd, GetWindowThreadProcessId, and handle each time. lmao. Just declare it once at the top of the class.

Similar Threads

  1. [Help] What is wrong with this code!
    By killer660 in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 14
    Last Post: 08-01-2011, 09:55 AM
  2. [Help] What is wrong with this code?
    By IGNITE09178 in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 15
    Last Post: 07-01-2011, 03:59 AM
  3. Bad Syntax - What is wrong with this code?
    By HACKINGPIE in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 5
    Last Post: 01-19-2011, 12:12 AM
  4. What's wrong with ths code?
    By killashoota1 in forum C++/C Programming
    Replies: 13
    Last Post: 04-13-2010, 04:47 PM
  5. What is wrong with this code?
    By t7ancients in forum C++/C Programming
    Replies: 10
    Last Post: 10-19-2009, 01:58 PM