Skip to content

Commit

Permalink
13.1 patch update.
Browse files Browse the repository at this point in the history
- new little legends added. - x86RetSpoof added. - Localization done for little legend names.
  • Loading branch information
R3nzTheCodeGOD committed Jan 16, 2023
1 parent ef90524 commit 2015562
Show file tree
Hide file tree
Showing 17 changed files with 497 additions and 116 deletions.
2 changes: 1 addition & 1 deletion R3nzSkinTFT/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Config::load() noexcept
this->currentComboSkinIndex = config_json.value("currentComboSkinIndex", 0);
this->curretSkinId = config_json.value("curretSkinId", 1);

if (this->curretSkinId <= 0)
if (this->curretSkinId < 1)
this->curretSkinId = 1;

in.close();
Expand Down
39 changes: 30 additions & 9 deletions R3nzSkinTFT/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <string>
#include <mutex>
#include <vector>
#include <variant>
#include <tuple>

#include "imgui/imgui.h"
#include "imgui/imgui_stdlib.h"
Expand All @@ -16,7 +18,7 @@ inline void footer() noexcept
{
ImGui::Separator();
ImGui::textUnformattedCentered((std::string("Last Build: ") + __DATE__ + " - " + __TIME__).c_str());
ImGui::textUnformattedCentered("Copyright (C) 2022 R3nzTheCodeGOD");
ImGui::textUnformattedCentered("Copyright (C) 2022-2023 R3nzTheCodeGOD");
}

void GUI::render() noexcept
Expand All @@ -32,7 +34,14 @@ void GUI::render() noexcept
};

std::call_once(this->changeSkin, [&]() noexcept -> void {
if (cheatManager.config->currentComboSkinIndex > 0 && cheatManager.config->curretSkinId > cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1].skinCount)
const auto& pet{ cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1] };
std::int32_t count{ 0 };
if (std::holds_alternative<std::int32_t>(pet.skinIds))
count = std::get<std::int32_t>(pet.skinIds);
else if (std::holds_alternative<std::pair<std::int32_t, std::int32_t>>(pet.skinIds))
count = std::get<std::pair<std::int32_t, std::int32_t>>(pet.skinIds).second;

if (cheatManager.config->currentComboSkinIndex > 0 && cheatManager.config->curretSkinId > count)
cheatManager.config->curretSkinId = 1;

if (cheatManager.config->currentComboSkinIndex > 0)
Expand All @@ -42,10 +51,22 @@ void GUI::render() noexcept
ImGui::Begin("R3nzSkin TFT", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_AlwaysAutoResize);
if (ImGui::BeginTabBar("TabBar", ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyScroll | ImGuiTabBarFlags_NoTooltip)) {
if (ImGui::BeginTabItem("Skin Changer")) {
if (ImGui::Combo("Current Pet", &cheatManager.config->currentComboSkinIndex, vectorGetter, static_cast<void*>(&cheatManager.database->pets), cheatManager.database->pets.size() + 1))
cheatManager.config->curretSkinId = 1;

ImGui::SliderInt("Current Pet SkinId", &cheatManager.config->curretSkinId, 1, cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1].skinCount);
if (ImGui::Combo("Current Pet", &cheatManager.config->currentComboSkinIndex, vectorGetter, static_cast<void*>(&cheatManager.database->pets), cheatManager.database->pets.size() + 1)) {
const auto& pet{ cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1] };
if (std::holds_alternative<std::int32_t>(pet.skinIds))
cheatManager.config->curretSkinId = 1;
else if (std::holds_alternative<std::pair<std::int32_t, std::int32_t>>(pet.skinIds))
cheatManager.config->curretSkinId = std::get<std::pair<std::int32_t, std::int32_t>>(pet.skinIds).first;
}

const auto& pet{ cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1] };
if (std::holds_alternative<std::int32_t>(pet.skinIds)) {
ImGui::SliderInt("Current Pet SkinId", &cheatManager.config->curretSkinId, 1, std::get<std::int32_t>(pet.skinIds));
} else if (std::holds_alternative<std::pair<std::int32_t, std::int32_t>>(pet.skinIds)) {
const auto pair{ std::get<std::pair<std::int32_t, std::int32_t>>(pet.skinIds) };
ImGui::SliderInt("Current Pet SkinId", &cheatManager.config->curretSkinId, pair.first, pair.second);
}

if (ImGui::Button("Change Pet Skin"))
player->changeSkin(cheatManager.database->pets[cheatManager.config->currentComboSkinIndex - 1].modelName, cheatManager.config->curretSkinId);
footer();
Expand All @@ -58,10 +79,10 @@ void GUI::render() noexcept
}

if (ImGui::BeginTabItem("Extra")) {
ImGui::InputText("##pushmanualmodel", &this->manualModel);
ImGui::InputText("##push_model", &this->model);
ImGui::SameLine();
if (ImGui::Button("Push Manual Model"))
player->changeSkin(this->manualModel.c_str(), 1);
if (ImGui::Button("Push Model"))
player->changeSkin(this->model.c_str(), 1);
ImGui::Separator();
ImGui::InputText("Change Nick", player->getNamePtr());
ImGui::Separator();
Expand Down
2 changes: 1 addition & 1 deletion R3nzSkinTFT/GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class GUI {
void render() noexcept;
private:
std::once_flag changeSkin;
std::string manualModel{ "TFTDebug_DummyMelee" };
std::string model{ "TFTDebug_DummyMelee" };
};
33 changes: 11 additions & 22 deletions R3nzSkinTFT/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,20 @@ std::once_flag init_device;
std::unique_ptr<::vmt_smart_hook> d3d_device_vmt{ nullptr };
std::unique_ptr<::vmt_smart_hook> swap_chain_vmt{ nullptr };

static const ImWchar ranges[] = {
static const ImWchar tahomaRanges[] = {
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x0100, 0x024F, // Latin Extended-A + Latin Extended-B
0x0250, 0x02FF, // IPA Extensions + Spacing Modifier Letters
0x0300, 0x03FF, // Combining Diacritical Marks + Greek/Coptic
0x0400, 0x044F, // Cyrillic
0x0600, 0x06FF, // Arabic
0x0400, 0x052F, // Cyrillic + Cyrillic Supplement
0x0530, 0x06FF, // Armenian + Hebrew + Arabic
0x0E00, 0x0E7F, // Thai
0x1E00, 0x1FFF, // Latin Extended Additional + Greek Extended
0x2000, 0x20CF, // General Punctuation + Superscripts and Subscripts + Currency Symbols
0x2100, 0x218F, // Letterlike Symbols + Number Forms
0,
};

static ImWchar* getFontGlyphRangesKr() noexcept
{
static ImVector<ImWchar> rangesKR;
if (rangesKR.empty()) {
ImFontGlyphRangesBuilder builder;
auto& io{ ImGui::GetIO() };
builder.AddRanges(io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
builder.AddRanges(io.Fonts->GetGlyphRangesChineseFull());
builder.AddRanges(io.Fonts->GetGlyphRangesKorean());
builder.AddRanges(io.Fonts->GetGlyphRangesJapanese());
builder.BuildRanges(&rangesKR);
}
return rangesKR.Data;
}

namespace d3d_vtable {
ID3D11Device* d3d11_device{ nullptr };
ID3D11DeviceContext* d3d11_device_context{ nullptr };
Expand Down Expand Up @@ -166,10 +155,10 @@ namespace d3d_vtable {
::CoTaskMemFree(pathToFonts);
ImFontConfig cfg;
cfg.SizePixels = 15.0f;
io.Fonts->AddFontFromFileTTF((path / "tahoma.ttf").string().c_str(), 15.0f, &cfg, ranges);
io.Fonts->AddFontFromFileTTF((path / "tahoma.ttf").string().c_str(), 15.0f, &cfg, tahomaRanges);
}

ImGui_ImplWin32_Init(cheatManager.memory->getRiotWindow());
ImGui_ImplWin32_Init(cheatManager.memory->riotWindow);

if (is_d3d11) {
p_swap_chain = reinterpret_cast<IDXGISwapChain*>(device);
Expand All @@ -181,7 +170,7 @@ namespace d3d_vtable {
} else
::ImGui_ImplDX9_Init(reinterpret_cast<IDirect3DDevice9*>(device));

originalWndProc = WNDPROC(::SetWindowLongW(cheatManager.memory->getRiotWindow(), GWLP_WNDPROC, LONG_PTR(&wndProc)));
originalWndProc = WNDPROC(::SetWindowLongW(cheatManager.memory->riotWindow, GWLP_WNDPROC, LONG_PTR(&wndProc)));
}

static void render(void* device, bool is_d3d11 = false) noexcept
Expand Down Expand Up @@ -278,7 +267,7 @@ void Hooks::install() const noexcept

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

if (d3d_device_vmt)
d3d_device_vmt->unhook();
Expand Down
8 changes: 7 additions & 1 deletion R3nzSkinTFT/R3nzSkinTFT.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma warning(disable : 6387 4715)

#include <Windows.h>
#include <array>
#include <clocale>
#include <chrono>
#include <cstdint>
Expand All @@ -12,6 +13,7 @@
#include "GUI.hpp"
#include "Hooks.hpp"
#include "Memory.hpp"
#include "RetSpoofInvoker.hpp"

#include "SDK/GameState.hpp"

Expand Down Expand Up @@ -47,6 +49,10 @@ static void WINAPI DllAttach([[maybe_unused]] LPVOID lp) noexcept
break;
}

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

std::this_thread::sleep_for(500ms);
cheatManager.memory->Search(false);
std::this_thread::sleep_for(500ms);
Expand All @@ -62,7 +68,7 @@ static void WINAPI DllAttach([[maybe_unused]] LPVOID lp) noexcept
::ExitProcess(0u);
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID reserved)
__declspec(safebuffers) BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID reserved)
{
if (reason == DLL_PROCESS_ATTACH) {
HideThread(hModule);
Expand Down
2 changes: 2 additions & 0 deletions R3nzSkinTFT/R3nzSkinTFT.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<ClInclude Include="GUI.hpp" />
<ClInclude Include="Offsets.hpp" />
<ClInclude Include="resource.h" />
<ClInclude Include="RetSpoofInvoker.hpp" />
<ClInclude Include="SDK\AIBaseCommon.hpp" />
<ClInclude Include="SDK\AString.hpp" />
<ClInclude Include="SDK\CharacterDataStack.hpp" />
Expand All @@ -114,6 +115,7 @@
<ClInclude Include="SkinDatabase.hpp" />
<ClInclude Include="Utils.hpp" />
<ClInclude Include="vmt_smart_hook.hpp" />
<ClInclude Include="x86RetSpoof.hpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="R3nzSkinTFT.rc" />
Expand Down
6 changes: 6 additions & 0 deletions R3nzSkinTFT/R3nzSkinTFT.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
<ClInclude Include="Logger.hpp">
<Filter>Source Files\Logger</Filter>
</ClInclude>
<ClInclude Include="x86RetSpoof.hpp">
<Filter>Source Files\Utils</Filter>
</ClInclude>
<ClInclude Include="RetSpoofInvoker.hpp">
<Filter>Source Files\Utils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="R3nzSkinTFT.rc" />
Expand Down
47 changes: 47 additions & 0 deletions R3nzSkinTFT/RetSpoofInvoker.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <cstdint>

#include "x86RetSpoof.hpp"

class RetSpoofInvoker {
private:
std::uintptr_t gadgetAddress{ 0 };
public:
void init(std::uintptr_t gadgetAddress) noexcept
{
this->gadgetAddress = gadgetAddress;
}

template <typename ReturnType, typename... Args>
ReturnType invokeFastcall(std::uintptr_t ecx, std::uintptr_t edx, std::uintptr_t functionAddress, Args... args) const noexcept
{
return x86RetSpoof::invokeFastcall<ReturnType, Args...>(ecx, edx, functionAddress, this->gadgetAddress, args...);
}

template <typename ReturnType, typename... Args>
ReturnType invokeThiscall(std::uintptr_t ecx, std::uintptr_t functionAddress, Args... args) const noexcept
{
return x86RetSpoof::invokeThiscall<ReturnType, Args...>(ecx, functionAddress, this->gadgetAddress, args...);
}

template <typename ReturnType, std::size_t index, typename... Args>
ReturnType invokeThiscall(std::uintptr_t ecx, Args... args) const noexcept
{
return x86RetSpoof::invokeThiscall<ReturnType, Args...>(ecx, (*reinterpret_cast<std::uintptr_t**>(ecx))[index], this->gadgetAddress, args...);
}

template <typename ReturnType, typename... Args>
ReturnType invokeStdcall(std::uintptr_t functionAddress, Args... args) const noexcept
{
return x86RetSpoof::invokeStdcall<ReturnType, Args...>(functionAddress, this->gadgetAddress, args...);
}

template <typename ReturnType, typename... Args>
ReturnType invokeCdecl(std::uintptr_t functionAddress, Args... args) const noexcept
{
return x86RetSpoof::invokeCdecl<ReturnType, Args...>(functionAddress, this->gadgetAddress, args...);
}
};

inline RetSpoofInvoker invoker;
11 changes: 6 additions & 5 deletions R3nzSkinTFT/SDK/CharacterDataStack.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <Windows.h>
#include <cstdint>

#include "CharacterDataStack.hpp"
#include "../CheatManager.hpp"
#include "../RetSpoofInvoker.hpp"
#include "../offsets.hpp"

#include "CharacterDataStack.hpp"

void CharacterDataStack::push(const char* model, const std::int32_t skin) noexcept
{
using FnPush = int(__thiscall*)(void*, const char* model, std::int32_t skinid, std::int32_t, bool update_spells, bool dont_update_hud, bool, bool, bool change_particle, bool, char, const char*, std::int32_t, const char*, std::int32_t, bool, std::int32_t);
static const auto Push{ reinterpret_cast<FnPush>(std::uintptr_t(::GetModuleHandle(nullptr)) + offsets::functions::FnCharacterDataStack__Push) };
Push(this, model, skin, 0, false, false, false, false, true, false, -1, "\x00", 0, "\x00", 0, false, 1);
{
invoker.invokeThiscall<int>(std::uintptr_t(this), cheatManager.memory->moduleBase + offsets::functions::FnCharacterDataStack__Push, model, skin, 0, false, false, false, false, true, false, std::int8_t(-1), "\x00", 0, "\x00", 0, false, 1);
}
24 changes: 15 additions & 9 deletions R3nzSkinTFT/SkinDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
#include "SkinDatabase.hpp"
#include "offsets.hpp"

std::uint32_t SkinDatabase::getSkinsLenForModel(std::string model) noexcept
std::int32_t SkinDatabase::getSkinsLenForModel(std::string model, const std::int32_t startIdx) const noexcept
{
static const auto getCharacterPackage{ reinterpret_cast<std::uintptr_t(__cdecl*)(std::string&,std::uint32_t)>(cheatManager.memory->getLeagueModule() + offsets::functions::FnCharacterData__GetCharacterPackage) };
const auto defaultSkinData{ *reinterpret_cast<std::uintptr_t*>(getCharacterPackage(model, 0u) + 0x34) };
for (auto skinsLen{ 1u };; ++skinsLen)
if (*reinterpret_cast<std::uintptr_t*>(getCharacterPackage(model, skinsLen) + 0x34) == defaultSkinData)
return skinsLen - 1u;
const auto defaultSkinData{ cheatManager.memory->getCharacterPackage(model, 0) };
for (std::int32_t skinsLen{ startIdx };; ++skinsLen)
if (cheatManager.memory->getCharacterPackage(model, skinsLen) == defaultSkinData)
return skinsLen - 1;
}

void SkinDatabase::update() noexcept
{
// automatically update number of skins
for (auto& pet : this->pets)
pet.skinCount = this->getSkinsLenForModel(pet.modelName);
for (auto& pet : this->pets) {
if (std::holds_alternative<std::int32_t>(pet.skinIds)) {
pet.skinIds = this->getSkinsLenForModel(pet.modelName, std::get<std::int32_t>(pet.skinIds));
} else if (std::holds_alternative<std::pair<std::int32_t, std::int32_t>>(pet.skinIds)) {
const auto pair{ std::get<std::pair<std::int32_t, std::int32_t>>(pet.skinIds) };
pet.skinIds = std::make_pair(pair.first, this->getSkinsLenForModel(pet.modelName, pair.first));
}

pet.skinName = cheatManager.memory->translateString(pet.skinName);
}
}
Loading

0 comments on commit 2015562

Please sign in to comment.