I am trying to make a pointer access class of which the goal is to simplifly access to known memory locations.
as for now I have this class:
template<class T = DWORD> struct Pointer
{
private://minimum 2 params
std::vector<T> params;
Pointer()
{}
Pointer(T a)
{params.push_back(a);}
public:
Pointer(T a, T b)
{params.push_back(a);Pointer::Pointer(b);}
Pointer(T a, T b, T c)
{params.push_back(a);Pointer::Pointer(b,c);}
Pointer(T a, T b, T c, T d)
{params.push_back(a);Pointer::Pointer(b,c,d);}
Pointer(T a, T b, T c, T d, T e)
{params.push_back(a);Pointer::Pointer(b,c,d,e);}
Pointer(T a, T b, T c, T d, T e, T f)
{params.push_back(a);Pointer::Pointer(b,c,d,e,f);}
Pointer(T a, T b, T c, T d, T e, T f, T g)
{params.push_back(a);Pointer::Pointer(b,c,d,e,f,g);}
//all the way to ... z
T* ResolvePointer(/*,bool fallback = false*/)
{
T variable = params[0];
try
{
auto it = params.begin();
++it;
for(; it != params.end(); ++it)
variable = *reinterpret_cast<T*>(variable) + *it;
}
catch(...)
{
/*if(fallback){
static char fallback_location[2048];
variable = reinterpret_cast<T>(&fallback_location[0]);
}else{*/
variable = NULL;
//}
}
return reinterpret_cast<T*>(variable);
}
T* operator()()
{
return ResolvePointer();
}
};
but whenever I call it
(for example:
Player[slot].Money = Pointer<int>(0x00400000+0x008E98EC,0xD8+(0x4*slot),0xE4,0x00,0x4)();
),
the params
vector always has only a
:(
what am I doing wrong? How do I solve this?
P.S: I would like to use variadic templates but I am using MICROSOFT VISUAL C++ 11