Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Nvidia.h"
- #include <cstdint>
- #include <comdef.h>
- #include <thread>
- namespace memory
- {
- static DWORD process_id = 14004;
- static uint64_t process_base = 0x7ff609700000;
- static HANDLE process_handle = NULL;
- static uint64_t world = 0;
- static uint64_t camera = 0;
- static uint64_t near_ent_size = 0;
- static uint64_t near_ent = 0;
- template <typename T>
- T read(uintptr_t address)
- {
- T value;
- ReadProcessMemory(process_handle, (LPCVOID)address, &value, sizeof(T), NULL);
- return value;
- }
- template <typename T>
- bool write(uintptr_t address, T value)
- {
- return WriteProcessMemory(process_handle, (LPVOID)address, &value, sizeof(T), NULL);
- }
- }
- using namespace memory;
- class Vector3
- {
- public:
- Vector3() : x(0.f), y(0.f), z(0.f)
- {
- }
- Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z)
- {
- }
- ~Vector3()
- {
- }
- float x;
- float y;
- float z;
- inline float Dot(Vector3 v)
- {
- return x * v.x + y * v.y + z * v.z;
- }
- inline float Distance(Vector3 v)
- {
- return float(sqrtf(powf(v.x - x, 2.0) + powf(v.y - y, 2.0) + powf(v.z - z, 2.0)));
- }
- inline float Length()
- {
- float ls = x * x + y * y + z * z;
- return sqrt(ls);
- }
- float DistTo(const Vector3& vOther) const
- {
- Vector3 delta;
- delta.x = x - vOther.x;
- delta.y = y - vOther.y;
- delta.z = z - vOther.z;
- return delta.Length();
- }
- bool operator==(const Vector3& in) const {
- return (this->x == in.x && this->y == in.y && this->z == in.z);
- }
- Vector3 operator+(Vector3 v)
- {
- return Vector3(x + v.x, y + v.y, z + v.z);
- }
- Vector3 operator-(Vector3 v)
- {
- return Vector3(x - v.x, y - v.y, z - v.z);
- }
- Vector3 operator*(float number) const {
- return Vector3(x * number, y * number, z * number);
- }
- Vector3& operator/=(float fl) {
- x /= fl;
- y /= fl;
- z /= fl;
- return *this;
- }
- Vector3& operator-=(const Vector3& v)
- {
- x -= v.x;
- y -= v.y;
- z -= v.z;
- return *this;
- }
- };
- Vector3 get_inverted_view_right()
- {
- return Vector3(read<Vector3>(camera + 0x8));
- }
- Vector3 get_inverted_view_up()
- {
- return Vector3(read<Vector3>(camera + 0x14));
- }
- Vector3 get_inverted_view_forward()
- {
- return Vector3(read<Vector3>(camera + 0x20));
- }
- Vector3 get_viewport_size()
- {
- return Vector3(read<Vector3>(camera + 0x58));
- }
- Vector3 get_inverted_view_translation()
- {
- return Vector3(read<Vector3>(camera + 0x2C));
- }
- Vector3 get_projection_d1()
- {
- return Vector3(read<Vector3>(camera + 0xD0));
- }
- Vector3 get_projection_d2()
- {
- return Vector3(read<Vector3>(camera + 0xDC));
- }
- Vector3 world_to_screen(Vector3 position)
- {
- Vector3 temp = position - get_inverted_view_translation();
- float x = temp.Dot(get_inverted_view_right());
- float y = temp.Dot(get_inverted_view_up());
- float z = temp.Dot(get_inverted_view_forward());
- if (z > 0)
- {
- return Vector3(get_viewport_size().x * (1 + (x / get_projection_d1().x / z)), get_viewport_size().y * (1 - (y / get_projection_d2().y / z)), z);
- }
- return { 0, 0, 0 };
- }
- Vector3 get_head_position(uint64_t entity)
- {
- return Vector3(read<Vector3>(read<uint64_t>(entity + 0xD0) + 0x168));
- }
- Vector3 get_feet_position(uint64_t entity)
- {
- return Vector3(read<Vector3>(read<uint64_t>(entity + 0xD0) + 0x2C));
- }
- void create_all()
- {
- process_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);
- world = read<uint64_t>(process_base + 0x26166D8);
- camera = read<uint64_t>(world + 0xB50);
- near_ent_size = read<uint64_t>(world + 0x1A48);
- near_ent = read<uint64_t>(world + 0x1A40);
- }
- int main()
- {
- CreateThread(0, 0, (LPTHREAD_START_ROUTINE)create_all, 0, 0, 0);
- Nvidia* overlay = { 0 };
- // Initialize the window
- if (!overlay->window_init())
- exit(-1);
- // D2D Failed to initialize?
- if (!overlay->init_d2d())
- exit(-1);
- while (true)
- {
- overlay->begin_scene();
- overlay->clear_scene();
- for (uint64_t i = 0; i < near_ent_size; i++)
- {
- uint64_t entity = read<uint64_t>(near_ent + (i * 0x8));
- Vector3 sh = world_to_screen(get_head_position(entity));
- overlay->draw_text_red(sh.x, sh.y, "test");
- }
- overlay->end_scene();
- }
- overlay->d2d_shutdown();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement