- Katılım
- 22 May 2021
- Mesajlar
- 1,473
- Beğeniler
- 333
C++ Boş Proje Açın
Verdiğim Ayarları Yapın
3 Adet Dosya Oluşturun vector.h memory.h ve main.cpp isimli dosyalar oluşturun
İşte Bu Kadar İyi Oyunlar...
ayarlar:
main.cpp:
vector.h:
memory.h:
Verdiğim Ayarları Yapın
3 Adet Dosya Oluşturun vector.h memory.h ve main.cpp isimli dosyalar oluşturun
İşte Bu Kadar İyi Oyunlar...
ayarlar:
C++:
multicode karakter
20 level
Release x86
main.cpp:
C++:
#include "memory.h"
#include "vector.h"
#include <thread>
namespace offset
{
// client
constexpr ::std::ptrdiff_t dwLocalPlayer = 0xDB25DC;
constexpr ::std::ptrdiff_t dwEntityList = 0x4DCDE7C;
// engine
constexpr ::std::ptrdiff_t dwClientState = 0x58CFC4;
constexpr ::std::ptrdiff_t dwClientState_ViewAngles = 0x4D90;
constexpr ::std::ptrdiff_t dwClientState_GetLocalPlayer = 0x180;
// entity
constexpr ::std::ptrdiff_t m_dwBoneMatrix = 0x26A8;
constexpr ::std::ptrdiff_t m_bDormant = 0xED;
constexpr ::std::ptrdiff_t m_iTeamNum = 0xF4;
constexpr ::std::ptrdiff_t m_lifeState = 0x25F;
constexpr ::std::ptrdiff_t m_vecOrigin = 0x138;
constexpr ::std::ptrdiff_t m_vecViewOffset = 0x108;
constexpr ::std::ptrdiff_t m_aimPunchAngle = 0x303C;
constexpr ::std::ptrdiff_t m_bSpottedByMask = 0x980;
}
constexpr Vector3 CalculateAngle(
const Vector3& localPosition,
const Vector3& enemyPosition,
const Vector3& viewAngles) noexcept
{
return ((enemyPosition - localPosition).ToAngle() - viewAngles);
}
int main()
{
// initialize memory class
const auto memory = Memory{ "csgo.exe" };
// module addresses
const auto client = memory.GetModuleAddress("client.dll");
const auto engine = memory.GetModuleAddress("engine.dll");
// infinite hack loop
while (true)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// aimbot key
if (!GetAsyncKeyState(VK_RBUTTON))
continue;
// get local player
const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::dwLocalPlayer);
const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);
// eye position = origin + viewOffset
const auto localEyePosition = memory.Read<Vector3>(localPlayer + offset::m_vecOrigin) +
memory.Read<Vector3>(localPlayer + offset::m_vecViewOffset);
const auto clientState = memory.Read<std::uintptr_t>(engine + offset::dwClientState);
const auto localPlayerId =
memory.Read<std::int32_t>(clientState + offset::dwClientState_GetLocalPlayer);
const auto viewAngles = memory.Read<Vector3>(clientState + offset::dwClientState_ViewAngles);
const auto aimPunch = memory.Read<Vector3>(localPlayer + offset::m_aimPunchAngle) * 2;
// aimbot fov
auto bestFov = 5.f;
auto bestAngle = Vector3{ };
for (auto i = 1; i <= 32; ++i)
{
const auto player = memory.Read<std::uintptr_t>(client + offset::dwEntityList + i * 0x10);
if (memory.Read<std::int32_t>(player + offset::m_iTeamNum) == localTeam)
continue;
if (memory.Read<bool>(player + offset::m_bDormant))
continue;
if (memory.Read<std::int32_t>(player + offset::m_lifeState))
continue;
if (memory.Read<std::int32_t>(player + offset::m_bSpottedByMask) & (1 << localPlayerId))
{
const auto boneMatrix = memory.Read<std::uintptr_t>(player + offset::m_dwBoneMatrix);
// pos of player head in 3d space
// 8 is the head bone index :)
const auto playerHeadPosition = Vector3{
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x0C),
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x1C),
memory.Read<float>(boneMatrix + 0x30 * 8 + 0x2C)
};
const auto angle = CalculateAngle(
localEyePosition,
playerHeadPosition,
viewAngles + aimPunch
);
const auto fov = std::hypot(angle.x, angle.y);
if (fov < bestFov)
{
bestFov = fov;
bestAngle = angle;
}
}
}
// if we have a best angle, do aimbot
if (!bestAngle.IsZero())
memory.Write<Vector3>(clientState + offset::dwClientState_ViewAngles, viewAngles + bestAngle / 3.f); // smoothing
}
return 0;
}
vector.h:
C:
#pragma once
#include <numbers>
#include <cmath>
struct Vector3
{
// constructor
constexpr Vector3(
const float x = 0.f,
const float y = 0.f,
const float z = 0.f) noexcept :
x(x), y(y), z(z) { }
// operator overloads
constexpr const Vector3& operator-(const Vector3& other) const noexcept
{
return Vector3{ x - other.x, y - other.y, z - other.z };
}
constexpr const Vector3& operator+(const Vector3& other) const noexcept
{
return Vector3{ x + other.x, y + other.y, z + other.z };
}
constexpr const Vector3& operator/(const float factor) const noexcept
{
return Vector3{ x / factor, y / factor, z / factor };
}
constexpr const Vector3& operator*(const float factor) const noexcept
{
return Vector3{ x * factor, y * factor, z * factor };
}
// utils
constexpr const Vector3& ToAngle() const noexcept
{
return Vector3{
std::atan2(-z, std::hypot(x, y)) * (180.0f / std::numbers::pi_v<float>),
std::atan2(y, x) * (180.0f / std::numbers::pi_v<float>),
0.0f };
}
constexpr const bool IsZero() const noexcept
{
return x == 0.f && y == 0.f && z == 0.f;
}
// struct data
float x, y, z;
};
memory.h:
C:
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <TlHelp32.h>
#include <cstdint>
#include <string_view>
class Memory
{
private:
std::uintptr_t processId = 0;
void* processHandle = nullptr;
public:
// Constructor that finds the process id
// and opens a handle
Memory(const std::string_view processName) noexcept
{
::PROCESSENTRY32 entry = { };
entry.dwSize = sizeof(::PROCESSENTRY32);
const auto snapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
while (::Process32Next(snapShot, &entry))
{
if (!processName.compare(entry.szExeFile))
{
processId = entry.th32ProcessID;
processHandle = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
break;
}
}
// Free handle
if (snapShot)
::CloseHandle(snapShot);
}
// Destructor that frees the opened handle
~Memory()
{
if (processHandle)
::CloseHandle(processHandle);
}
// Returns the base address of a module by name
const std::uintptr_t GetModuleAddress(const std::string_view moduleName) const noexcept
{
::MODULEENTRY32 entry = { };
entry.dwSize = sizeof(::MODULEENTRY32);
const auto snapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processId);
std::uintptr_t result = 0;
while (::Module32Next(snapShot, &entry))
{
if (!moduleName.compare(entry.szModule))
{
result = reinterpret_cast<std::uintptr_t>(entry.modBaseAddr);
break;
}
}
if (snapShot)
::CloseHandle(snapShot);
return result;
}
// Read process memory
template <typename T>
constexpr const T Read(const std::uintptr_t& address) const noexcept
{
T value = { };
::ReadProcessMemory(processHandle, reinterpret_cast<const void*>(address), &value, sizeof(T), NULL);
return value;
}
// Write process memory
template <typename T>
constexpr void Write(const std::uintptr_t& address, const T& value) const noexcept
{
::WriteProcessMemory(processHandle, reinterpret_cast<void*>(address), &value, sizeof(T), NULL);
}
};