C++ Pointer + Offset?
Hey, i'm trying to learn myself some c++ and so forth. Not going into detail, anyways, i might need some help. I tried search here and came up with not much about what i was looking for.
I wrote a test code so i could modify the game 'Solitaire' in windows 7. Dude stop looking at me like that. it's a test
Anyways, i found the Pointer in cheat engine which points to the address know as the 'score' so i also know how to find the correct address using the pointer + offset in cheat engine.
So what's the problem? Well i don't exactly know how to find the correct memory address in c++. I know the pointer and i know the offset.
But how do i calculate the new address that the game appoints it to.
If i know this calculation alone it's already a big help
This is the code that i currently have.
I un-commented the action to patch the game so that it doesn't mess up anything while i was trying to figure out how to calculate the new address.
Thanks 
I wrote a test code so i could modify the game 'Solitaire' in windows 7. Dude stop looking at me like that. it's a test

Anyways, i found the Pointer in cheat engine which points to the address know as the 'score' so i also know how to find the correct address using the pointer + offset in cheat engine.
So what's the problem? Well i don't exactly know how to find the correct memory address in c++. I know the pointer and i know the offset.
But how do i calculate the new address that the game appoints it to.
If i know this calculation alone it's already a big help

This is the code that i currently have.
I un-commented the action to patch the game so that it doesn't mess up anything while i was trying to figure out how to calculate the new address.
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
// This will find you the proper adress in the memory
LONG pointer = 0x0020C020;
LONG offset = 14; // 14
LONG address;
if(pointer)
{
// If pointer is exists, calculate the proper adress and use that
address = (pointer + offset);
}
else
{
// If pointer is empty then use this adress
address = 0x005DA534;
}
cout << "The pointer points to the addres ";
cout << address;
cin.get();
//value to send to game
int newvalue = 99;
// Handles
/*
HWND hwnd = FindWindow(NULL, "Solitaire"); //what window to find
HANDLE phandle;
DWORD pid;
if (hwnd != 0)
{
//just a option
cout << "Game is running. Press enter to hack it.";
//name of program window
SetWindowText(NULL,"Far Cry 2 Hack");
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
cin.get();
}
else
{
//shows if game is not running
cout << "Open the game";
cin.get();
return 0;
}
if (phandle != 0)
{
WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);
//says done if it worked
cout << "Done";
cin.get();
}
else
{
//if it didn't work it says failed
cout << "Failed";
cin.get();
}
*/
}

