how to speed up your gunz client
step 1
step 2:
profit
step 1
Code:
#pragma once
#include "MMath.h"
#include <unordered_map>
class MHashContainer
{
std::unordered_map<void*, DWORD> m_mapHash;
public:
inline void Add(void* key, DWORD hash)
{
m_mapHash[key] = hash;
}
inline void Remove(void* key)
{
m_mapHash.erase(key);
}
inline DWORD Get(void* key)
{
auto it = m_mapHash.find(key);
if (it != m_mapHash.end())
return it->second;
return 0;
}
void Reserve(size_t capacity)
{
m_mapHash.reserve(capacity);
}
};
extern void (*g_fpOnCrcFail)();
inline MHashContainer* GetHashContainer() noexcept
{
static MHashContainer* s_instance = []() -> MHashContainer*
{
return new MHashContainer();
}();
return s_instance;
}
#define PTR_OFFSET 0x66D6
namespace FNV
{
inline DWORD FNV1a(const BYTE* data, size_t len)
{
DWORD hash = 2166136261u;
for (size_t i = 0; i < len; ++i)
{
hash ^= data[i];
hash *= 16777619u;
}
return hash;
}
}
template <typename T>
class MProtectValue
{
T m_value;
DWORD m_cachedHash;
private:
inline DWORD BuildHash() const
{
return FNV::FNV1a((const BYTE*)&m_value, sizeof(T));
}
public:
MProtectValue() : m_value(), m_cachedHash(0) {}
~MProtectValue()
{
MHashContainer* hc = ::GetHashContainer();
if (hc) {
hc->Remove(this);
}
}
inline T& Ref() { return m_value; }
inline const T& Ref() const { return m_value; }
inline void Set(const T& newVal)
{
m_value = newVal;
}
bool Set_CheckCrc(const T& newVal)
{
CheckCrc();
m_value = newVal;
MakeCrc();
return true;
}
inline void Set_MakeCrc(const T& newVal)
{
m_value = newVal;
MakeCrc();
}
inline void ShiftHeapPos()
{
MakeCrc();
}
inline void ShiftHeapPos_CheckCrc()
{
CheckCrc();
MakeCrc();
}
inline void MakeCrc()
{
m_cachedHash = BuildHash();
::GetHashContainer()->Add(this, m_cachedHash);
}
inline void CheckCrc()
{
if (BuildHash() != m_cachedHash)
g_fpOnCrcFail();
}
private:
MProtectValue(T val) : m_value(val), m_cachedHash(0) {}
MProtectValue<T>& operator=(int) { return *this; }
};
#define MEMBER_SET_CHECKCRC(PROTECTVALUE, MEMBER, NEWVAL) { \
PROTECTVALUE.CheckCrc(); \
PROTECTVALUE.Ref().MEMBER = (NEWVAL); \
PROTECTVALUE.MakeCrc(); \
}
Code:
#include "stdafx.h"
#include "MMemoryProxy.h"
void (*g_fpOnCrcFail)() = 0;
MHashContainer g_hashContainer;
step 2:
profit

