Skip to content

Commit

Permalink
Remove DX9 Support and update IsLaneMinion offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
R3nzTheCodeGOD committed Apr 3, 2024
1 parent f383356 commit 5059583
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 484 deletions.
88 changes: 18 additions & 70 deletions R3nzSkin/Hooks.cpp
Expand Up @@ -9,7 +9,6 @@
#include "fnv_hash.hpp"
#include "imgui/imgui.h"
#include "imgui/imgui_impl_dx11.h"
#include "imgui/imgui_impl_dx9.h"
#include "imgui/imgui_impl_win32.h"
#include "vmt_smart_hook.hpp"

Expand Down Expand Up @@ -97,7 +96,6 @@ static LRESULT WINAPI wndProc(const HWND window, const UINT msg, const WPARAM wP
}

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 tahomaRanges[] = {
Expand Down Expand Up @@ -131,7 +129,7 @@ namespace d3d_vtable {
}
}

static void init_imgui(void* device, bool is_d3d11 = false) noexcept
static void init_imgui(IDXGISwapChain* device) noexcept
{
cheatManager.database->load();
cheatManager.logger->addLog("All skins loaded from memory!\n");
Expand Down Expand Up @@ -232,59 +230,40 @@ namespace d3d_vtable {

ImGui_ImplWin32_Init(cheatManager.memory->window);

if (is_d3d11) {
p_swap_chain = static_cast<IDXGISwapChain*>(device);
p_swap_chain->GetDevice(__uuidof(d3d11_device), reinterpret_cast<void**>(&(d3d11_device)));
d3d11_device->GetImmediateContext(&d3d11_device_context);
create_render_target();
::ImGui_ImplDX11_Init(d3d11_device, d3d11_device_context);
::ImGui_ImplDX11_CreateDeviceObjects();
} else
::ImGui_ImplDX9_Init(static_cast<IDirect3DDevice9*>(device));
p_swap_chain = device;
p_swap_chain->GetDevice(__uuidof(d3d11_device), reinterpret_cast<void**>(&(d3d11_device)));
d3d11_device->GetImmediateContext(&d3d11_device_context);
create_render_target();
::ImGui_ImplDX11_Init(d3d11_device, d3d11_device_context);
::ImGui_ImplDX11_CreateDeviceObjects();

originalWndProc = WNDPROC(::SetWindowLongPtr(cheatManager.memory->window, GWLP_WNDPROC, reinterpret_cast<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
static void render() noexcept
{
const auto client{ cheatManager.memory->client };
if (client && client->game_state == GGameState_s::Running) {
cheatManager.hooks->init();
if (cheatManager.gui->is_open) {
if (is_d3d11)
::ImGui_ImplDX11_NewFrame();
else
::ImGui_ImplDX9_NewFrame();
::ImGui_ImplDX11_NewFrame();
::ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
cheatManager.gui->render();
ImGui::EndFrame();
ImGui::Render();

if (is_d3d11) {
d3d11_device_context->OMSetRenderTargets(1, &main_render_target_view, nullptr);
::ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
} else {
unsigned long colorwrite, srgbwrite;
const auto dvc{ static_cast<IDirect3DDevice9*>(device) };
dvc->GetRenderState(D3DRS_COLORWRITEENABLE, &colorwrite);
dvc->GetRenderState(D3DRS_SRGBWRITEENABLE, &srgbwrite);
dvc->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
dvc->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
::ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
dvc->SetRenderState(D3DRS_COLORWRITEENABLE, colorwrite);
dvc->SetRenderState(D3DRS_SRGBWRITEENABLE, srgbwrite);
}
d3d11_device_context->OMSetRenderTargets(1, &main_render_target_view, nullptr);
::ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}
}
}

struct dxgi_present {
static long WINAPI hooked(IDXGISwapChain* p_swap_chain, UINT sync_interval, UINT flags) noexcept
{
std::call_once(init_device, [&]() { init_imgui(p_swap_chain, true); });
render(p_swap_chain, true);
std::call_once(init_device, [&]() { init_imgui(p_swap_chain); });
render();
return m_original(p_swap_chain, sync_interval, flags);
}
static decltype(&hooked) m_original;
Expand All @@ -302,30 +281,6 @@ namespace d3d_vtable {
static decltype(&hooked) m_original;
};
decltype(dxgi_resize_buffers::m_original) dxgi_resize_buffers::m_original;

struct end_scene {
static long WINAPI hooked(IDirect3DDevice9* p_device) noexcept
{
std::call_once(init_device, [&]() { init_imgui(p_device); });
render(p_device);
return m_original(p_device);
}
static decltype(&hooked) m_original;
};
decltype(end_scene::m_original) end_scene::m_original;

struct reset {
static long WINAPI hooked(IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* parametrs) noexcept
{
::ImGui_ImplDX9_InvalidateDeviceObjects();
const auto hr{ m_original(device, parametrs) };
if (hr >= 0)
::ImGui_ImplDX9_CreateDeviceObjects();
return hr;
}
static decltype(&hooked) m_original;
};
decltype(reset::m_original) reset::m_original;
};

static void changeModelForObject(const AIBaseCommon* obj, const char* model, const std::int32_t skin) noexcept
Expand Down Expand Up @@ -443,27 +398,20 @@ void Hooks::init() 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) {
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");
} else {
::MessageBoxA(nullptr, "Uncheck legacy dx9 in the client settings cuz it is no longer supported.", "R3nzSkin", MB_OK | MB_ICONWARNING);
::ExitProcess(EXIT_SUCCESS);
}
}

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

if (d3d_device_vmt)
d3d_device_vmt->unhook();
if (swap_chain_vmt)
swap_chain_vmt->unhook();

swap_chain_vmt->unhook();
cheatManager.cheatState = false;
}
2 changes: 1 addition & 1 deletion R3nzSkin/R3nzSkin.cpp
Expand Up @@ -53,7 +53,7 @@ __declspec(safebuffers) static void WINAPI DllAttach([[maybe_unused]] LPVOID lp)
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");
Expand Down
2 changes: 0 additions & 2 deletions R3nzSkin/R3nzSkin.vcxproj
Expand Up @@ -214,7 +214,6 @@
<ClCompile Include="imgui\imgui_demo.cpp" />
<ClCompile Include="imgui\imgui_draw.cpp" />
<ClCompile Include="imgui\imgui_impl_dx11.cpp" />
<ClCompile Include="imgui\imgui_impl_dx9.cpp" />
<ClCompile Include="imgui\imgui_impl_win32.cpp" />
<ClCompile Include="imgui\imgui_tables.cpp" />
<ClCompile Include="imgui\imgui_widgets.cpp" />
Expand All @@ -234,7 +233,6 @@
<ClInclude Include="imgui\imconfig.h" />
<ClInclude Include="imgui\imgui.h" />
<ClInclude Include="imgui\imgui_impl_dx11.h" />
<ClInclude Include="imgui\imgui_impl_dx9.h" />
<ClInclude Include="imgui\imgui_impl_win32.h" />
<ClInclude Include="imgui\imgui_internal.h" />
<ClInclude Include="imgui\imstb_rectpack.h" />
Expand Down
6 changes: 0 additions & 6 deletions R3nzSkin/R3nzSkin.vcxproj.filters
Expand Up @@ -59,9 +59,6 @@
<ClCompile Include="imgui\imgui_draw.cpp">
<Filter>Imgui</Filter>
</ClCompile>
<ClCompile Include="imgui\imgui_impl_dx9.cpp">
<Filter>Imgui</Filter>
</ClCompile>
<ClCompile Include="imgui\imgui_impl_dx11.cpp">
<Filter>Imgui</Filter>
</ClCompile>
Expand Down Expand Up @@ -119,9 +116,6 @@
<ClInclude Include="imgui\imgui.h">
<Filter>Imgui</Filter>
</ClInclude>
<ClInclude Include="imgui\imgui_impl_dx9.h">
<Filter>Imgui</Filter>
</ClInclude>
<ClInclude Include="imgui\imgui_impl_dx11.h">
<Filter>Imgui</Filter>
</ClInclude>
Expand Down

8 comments on commit 5059583

@liucyin
Copy link

@liucyin liucyin commented on 5059583 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx a lot!

@Kura5555
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can u help me i cant install R3nzSkin and have erorr

@Kura5555
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx a lot!
how u make it

@liliyucai123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you give me .hid file?

@zgw-1998
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢

@ceryyyy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, the game has been updated to 14.8. Is the software still updated

@zykath93
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey yo, is still usable with the vanguard update?

@NoLifeBRYAN
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro its not working anymore ..
now patch 14.9 ...
please update ...

Please sign in to comment.