Newbie HvHer
- User ID
- 40389
- Messages
- 1
- Reactions
- 0
- Level
- 4
Hello everyone, after some tutorials on Youtube I was able to snip a code together, but unfortunately it doesn't work ingame, so opposing players are not displayed in the radar. Maybe someone can take a look at it, I would be very grateful!
Offsets are already updated.
Thanks!
Offsets are already updated.
main.cpp:
#include "memory.h"
#include <thread>
using namespace std;
namespace offsets {
// offsets nach jedem csgo update unbedingt updaten
constexpr auto localPlayer = 0xDC14CC;
constexpr auto entityList = 0x4DDD91C;
constexpr auto teamNum = 0xF4;
constexpr auto spotted = 0x93D;
}
int main() {
const auto memory = Memory{ "csgo.exe" };
const auto client = memory.GetModuleAddress("client.dll");
// loop
while (true) {
const auto localPlayer = memory.Read<std::uintptr_t>(client + offsets::localPlayer);
const auto localTeam = memory.Read<std::uintptr_t>(client + offsets::teamNum);
for (auto i = 1; i <= 64; ++i) {
const auto entity = memory.Read<std::uintptr_t>(client + offsets::entityList + i * 0x10);
if (memory.Read<std::uintptr_t>(entity + offsets::teamNum) == localTeam)
continue;
memory.Write<bool>(entity + offsets::spotted, true);
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
return 0;
}
memory.h:
#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);
}
};
Thanks!