1 Replies - 264 Views - Last Post: 02 August 2014 - 06:26 AM Rate Topic: -----

#1 NullBy7e  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 30-July 14

[readprocessmemory] access violation / bad ptr

Posted 02 August 2014 - 06:17 AM

I am getting an access violation when debugging my application.
Trying to get the value of a memory addr in a game.

What am I doing wrong?
I figure that its not reading from the base address?
Base address returns 400000, and even if I manually enter the base address it still throws a memory violation.
Cause its reading at 0x000000 which is reserved for null ptrs (so I have read).

bool CCharacter::is_loaded() 
{
	byte* buffer = new byte[24];
	ReadProcessMemory(CSettings::phandle, (void*)(CSettings::base + 0x00FD1D9C + 0x60 + 0xA4), &buffer, sizeof(buffer), 0);
	cout << buffer;

	delete buffer;
	return true;
}


Main:


int main()
{
	HANDLE hProcess, hCommandEventLocal, hAllocationEventLocal;
	 
	BOOL isOK;
	HANDLE hToken;
	HANDLE hCurrentProcess;
	hCurrentProcess = GetCurrentProcess();
	isOK = OpenProcessToken( hCurrentProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken );
	if( !isOK )
	{
		return E_FAIL;
	}
	 
	SetPrivilege( hToken, SE_DEBUG_NAME, TRUE );
	 
	//////////////////////////////////////////////////////////////////////
	 
	DWORD pid;
	HWND hwnd;
	HANDLE phandle;

	hwnd = FindWindow(NULL, L"DARK SOULS II");
	if (hwnd) {
		GetWindowThreadProcessId(hwnd, &pid);
		phandle = OpenProcess(PROCESS_VM_READ, 0, pid);
		if (!phandle) {
			cout << "Could not locate the game, please start it first" << endl;
			system("pause");
			exit(1);
		}
		CSettings::phandle = phandle;
		CSettings::base = dwGetModuleBaseAddress(pid, _T("DarkSoulsII.exe")); 
	}

	//////////////////////////////////////////////////////////////////////

	CSettings::parse();
	CDatabase* db = new CDatabase();
	
	CGame* game = new CGame();

	if(game->character->is_loaded()) {

	}

	system("pause");
}


Is This A Good Question/Topic? 0
  • +

Replies To: [readprocessmemory] access violation / bad ptr

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3650
  • View blog
  • Posts: 11,419
  • Joined: 05-May 12

Re: [readprocessmemory] access violation / bad ptr

Posted 02 August 2014 - 06:26 AM

We do not help with game cheats, trainers, and bots. Please do not pursue this line of questioning. If you have further questions, feel free to PM me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1