Skip to content

Commit

Permalink
Remove unused LoopModeGame hook
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Oct 22, 2024
1 parent 4a395ab commit 4ce1540
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 84 deletions.
5 changes: 0 additions & 5 deletions Source/Endpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ sdl3::SDL_PeepEvents* SDLHook_PeepEvents_cpp() noexcept
return original;
}

cs2::CLoopModeGame::getWorldSession LoopModeGameHook_getWorldSession_cpp(const void* returnAddress) noexcept
{
return GlobalContext::instance().fullContext().getWorldSessionHook(ReturnAddress{returnAddress});
}

void ViewRenderHook_onRenderStart_cpp(cs2::CViewRender* thisptr) noexcept
{
auto& fullContext = GlobalContext::instance().fullContext();
Expand Down
6 changes: 0 additions & 6 deletions Source/GlobalContext/FullGlobalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@ struct FullGlobalContext {
Tier0Dll{}}
, hooks{
peepEventsHook,
gameDependencies.loopModeGame,
gameDependencies.viewRender,
VmtLengthCalculator{clientDLL.getCodeSection(), clientDLL.getVmtSection()}}
, entityClassifier{gameDependencies.entitiesVMTs}
{
}

[[nodiscard]] cs2::CLoopModeGame::getWorldSession getWorldSessionHook(ReturnAddress) noexcept
{
return hooks.loopModeGameHook.originalGetWorldSession;
}

[[nodiscard]] auto features(auto& dependencies) noexcept
{
Expand Down
7 changes: 1 addition & 6 deletions Source/Hooks/Hooks.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
#pragma once

#include "LoopModeGameHook.h"
#include "PeepEventsHook.h"
#include "ViewRenderHook.h"

#include <Vmt/VmtLengthCalculator.h>

struct Hooks {
Hooks(PeepEventsHook peepEventsHook, cs2::CLoopModeGame** loopModeGame, cs2::CViewRender** viewRender, const VmtLengthCalculator& clientVmtLengthCalculator) noexcept
Hooks(PeepEventsHook peepEventsHook, cs2::CViewRender** viewRender, const VmtLengthCalculator& clientVmtLengthCalculator) noexcept
: peepEventsHook{peepEventsHook}
, loopModeGameHook{loopModeGame, clientVmtLengthCalculator}
, viewRenderHook{viewRender, clientVmtLengthCalculator}
{
}

void update() noexcept
{
loopModeGameHook.update();
viewRenderHook.update();
}

void forceUninstall() noexcept
{
peepEventsHook.disable();
loopModeGameHook.forceUninstall();
viewRenderHook.forceUninstall();
}

PeepEventsHook peepEventsHook;
LoopModeGameHook loopModeGameHook;
ViewRenderHook viewRenderHook;
};
43 changes: 0 additions & 43 deletions Source/Hooks/LoopModeGameHook.h

This file was deleted.

8 changes: 0 additions & 8 deletions Source/LinuxEndpoints.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.globl SDLHook_PeepEvents_asm
.globl LoopModeGameHook_getWorldSession_asm
.globl ViewRenderHook_onRenderStart_asm

SDLHook_PeepEvents_asm:
Expand All @@ -16,12 +15,5 @@ SDLHook_PeepEvents_asm:
pop %rdi
jmp *%rax # jump to the original function

LoopModeGameHook_getWorldSession_asm:
push %rdi # backup volatile rdi used in the original function
mov 8(%rsp), %rdi # load return address into rdi
call LoopModeGameHook_getWorldSession_cpp
pop %rdi
jmp *%rax # jump to the original function

ViewRenderHook_onRenderStart_asm:
jmp ViewRenderHook_onRenderStart_cpp
1 change: 0 additions & 1 deletion Source/Osiris.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@
<ClInclude Include="HookDependencies\HookDependenciesBuilder.h" />
<ClInclude Include="HookDependencies\HookDependenciesMask.h" />
<ClInclude Include="Hooks\Hooks.h" />
<ClInclude Include="Hooks\LoopModeGameHook.h" />
<ClInclude Include="Hooks\PeepEventsHook.h" />
<ClInclude Include="Hooks\ViewRenderHook.h" />
<ClInclude Include="Hud\BombStatus\BombStatusPanel.h" />
Expand Down
15 changes: 0 additions & 15 deletions Source/WindowsEndpoints.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
EXTERN DllMain_cpp:PROC
EXTERN SDLHook_PeepEvents_cpp:PROC
EXTERN LoopModeGameHook_getWorldSession_cpp:PROC
EXTERN ViewRenderHook_onRenderStart_cpp:PROC

EXTERNDEF textSectionStartMarker:DWORD
Expand Down Expand Up @@ -106,20 +105,6 @@ SDLHook_PeepEvents_asm PROC
jmp rax ; jump to the original function
SDLHook_PeepEvents_asm ENDP

LoopModeGameHook_getWorldSession_asm PROC
push rcx ; backup volatile rcx used in the original function
sub rsp, 48 ; align stack pointer and allocate shadow space for function call
call makeTextSectionExecutable
mov rcx, [rsp + 56] ; load return address into rcx
call LoopModeGameHook_getWorldSession_cpp
mov [rsp + 40], rax ; backup rax as the next call will destroy it
call makeTextSectionNotExecutable
add rsp, 40
pop rax
pop rcx
jmp rax ; jump to the original function
LoopModeGameHook_getWorldSession_asm ENDP

ViewRenderHook_onRenderStart_asm PROC
push rcx ; backup volatile rcx
sub rsp, 32 ; allocate shadow space for function call
Expand Down

0 comments on commit 4ce1540

Please sign in to comment.