Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Use logger
Browse files Browse the repository at this point in the history
  • Loading branch information
R3nzTheCodeGOD committed Nov 18, 2022
1 parent 22398be commit 3a49202
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
4 changes: 3 additions & 1 deletion R3nzSkin/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ void GUI::render() noexcept
ImGui::EndTabItem();
}

if (ImGui::BeginTabItem("Logger"))
if (ImGui::BeginTabItem("Logger")) {
cheatManager.logger->draw();
ImGui::EndTabItem();
}

if (ImGui::BeginTabItem("Extras")) {
ImGui::hotkey("Menu Key", cheatManager.config->menuKey);
Expand Down
11 changes: 8 additions & 3 deletions R3nzSkin/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace d3d_vtable {
static void init_imgui(void* device, bool is_d3d11 = false) noexcept
{
cheatManager.database->load();
cheatManager.logger->addLog("All skins loaded from memory!\n");
ImGui::CreateContext();
auto& style{ ImGui::GetStyle() };

Expand Down Expand Up @@ -205,6 +206,7 @@ namespace d3d_vtable {
io.Fonts->AddFontFromFileTTF((path / "malgun.ttf").string().c_str(), cfg.SizePixels, &cfg, io.Fonts->GetGlyphRangesKorean());
io.Fonts->AddFontFromFileTTF((path / "msyh.ttc").string().c_str(), cfg.SizePixels, &cfg, io.Fonts->GetGlyphRangesChineseFull());
cfg.MergeMode = false;
cheatManager.logger->addLog("Fonts loaded!\n");
}

ImGui_ImplWin32_Init(cheatManager.memory->window);
Expand All @@ -220,6 +222,7 @@ namespace d3d_vtable {
::ImGui_ImplDX9_Init(reinterpret_cast<IDirect3DDevice9*>(device));

originalWndProc = WNDPROC(::SetWindowLongW(cheatManager.memory->window, GWLP_WNDPROC, LONG_PTR(&wndProc)));
cheatManager.logger->addLog("WndProc hooked!\n\tOriginal: 0x%X\n\tNew: 0x%X\n", &originalWndProc, &wndProc);
}

static void render(void* device, bool is_d3d11 = false) noexcept
Expand Down Expand Up @@ -327,7 +330,7 @@ static void changeSkinForObject(const AIBaseCommon* obj, const std::int32_t skin
}
}

void Hooks::init() const noexcept
void Hooks::init() noexcept
{
const auto player{ cheatManager.memory->localPlayer };
const auto heroes{ cheatManager.memory->heroList };
Expand Down Expand Up @@ -419,20 +422,22 @@ void Hooks::init() const noexcept
}
}

void Hooks::install() const noexcept
void Hooks::install() noexcept
{
if (cheatManager.memory->d3dDevice) {
d3d_device_vmt = std::make_unique<::vmt_smart_hook>(cheatManager.memory->d3dDevice);
d3d_device_vmt->apply_hook<d3d_vtable::end_scene>(42);
d3d_device_vmt->apply_hook<d3d_vtable::reset>(16);
cheatManager.logger->addLog("DX9 Hooked!\n");
} else if (cheatManager.memory->swapChain) {
swap_chain_vmt = std::make_unique<::vmt_smart_hook>(cheatManager.memory->swapChain);
swap_chain_vmt->apply_hook<d3d_vtable::dxgi_present>(8);
swap_chain_vmt->apply_hook<d3d_vtable::dxgi_resize_buffers>(13);
cheatManager.logger->addLog("DX11 Hooked!\n");
}
}

void Hooks::uninstall() const noexcept
void Hooks::uninstall() noexcept
{
::SetWindowLongW(cheatManager.memory->window, GWLP_WNDPROC, LONG_PTR(originalWndProc));

Expand Down
6 changes: 3 additions & 3 deletions R3nzSkin/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inline WNDPROC originalWndProc;

class Hooks {
public:
void init() const noexcept;
void install() const noexcept;
void uninstall() const noexcept;
void init() noexcept;
void install() noexcept;
void uninstall() noexcept;
};
23 changes: 18 additions & 5 deletions R3nzSkin/R3nzSkin.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma warning(disable : 6387)
#pragma warning(disable : 4715)
#pragma warning(disable : 6387 4715)

#include <Windows.h>
#include <array>
#include <clocale>
#include <chrono>
#include <cstdint>
Expand Down Expand Up @@ -37,24 +37,37 @@ __declspec(safebuffers) static void WINAPI DllAttach([[maybe_unused]] LPVOID lp)
{
using namespace std::chrono_literals;

HideThread(::GetCurrentThread());
cheatManager.start();
if (HideThread(::GetCurrentThread()))
cheatManager.logger->addLog("Thread Hided!\n");

cheatManager.memory->Search(true);
while (true) {
std::this_thread::sleep_for(1s);

if (!cheatManager.memory->client)
cheatManager.memory->Search(true);
if (cheatManager.memory->client->game_state == GGameState_s::Running)
break;
else if (cheatManager.memory->client->game_state == GGameState_s::Running)
break;
}

cheatManager.logger->addLog("GameClient found!\n");

const auto gadget{ *reinterpret_cast<std::array<std::uint8_t, 2>*>(cheatManager.memory->base + offsets::global::retSpoofGadget) };
cheatManager.logger->addLog("Gadget: 0x%X 0x%X\n", gadget.at(0), gadget.at(1));

invoker.init(cheatManager.memory->base + offsets::global::retSpoofGadget);
cheatManager.logger->addLog("Invoker initialized!\n");

std::this_thread::sleep_for(500ms);
cheatManager.memory->Search(false);
cheatManager.logger->addLog("All offsets found!\n");
std::this_thread::sleep_for(500ms);

cheatManager.config->init();
cheatManager.config->load();
cheatManager.logger->addLog("CFG loaded!\n");

cheatManager.hooks->install();

while (cheatManager.cheatState)
Expand Down
9 changes: 6 additions & 3 deletions R3nzSkin/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <thread>
#include <vector>

#include "CheatManager.hpp"
#include "Memory.hpp"
#include "Offsets.hpp"

Expand Down Expand Up @@ -122,20 +123,22 @@ void Memory::Search(bool gameClient)

if (!address) {
::MessageBoxA(nullptr, ("Failed to find pattern: " + pattern).c_str(), "R3nzSkin", MB_OK | MB_ICONWARNING);
// cheatManager.logger->addLog("Not found: %s\n", pattern.c_str());
continue;
}

if (sig.read)
address = *reinterpret_cast<uint8_t**>(address + (pattern.find_first_of("?") / 3));
address = *reinterpret_cast<std::uint8_t**>(address + (pattern.find_first_of("?") / 3));
else if (address[0] == 0xE8)
address = address + *reinterpret_cast<uint32_t*>(address + 1) + 5;
address = address + *reinterpret_cast<std::uint32_t*>(address + 1) + 5;

if (sig.sub_base)
address -= this->base;

address += sig.additional;

*sig.offset = reinterpret_cast<uint32_t>(address);
*sig.offset = reinterpret_cast<std::uint32_t>(address);
// cheatManager.logger->addLog("Found: %s\n\tAddress: 0x%X\n", pattern.c_str(), *sig.offset);
break;
}

Expand Down

0 comments on commit 3a49202

Please sign in to comment.