Skip to content

Commit

Permalink
added auto hide crosshair in drawcrosshair hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Jan 12, 2021
1 parent 017d367 commit 13ed05c
Show file tree
Hide file tree
Showing 77 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions AssaultCube-Multihack.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<ClCompile Include="src\hacks\Crosshair.cpp" />
<ClCompile Include="src\hacks\Teleport.cpp" />
<ClCompile Include="src\hooks\c2sinfo.cpp" />
<ClCompile Include="src\hooks\drawcrosshair.cpp" />
<ClCompile Include="src\hooks\hooks.cpp" />
<ClCompile Include="src\hooks\movelocalplayer.cpp" />
<ClCompile Include="src\hooks\servertoclient.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions AssaultCube-Multihack.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<ClCompile Include="src\hacks\Crosshair.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\hooks\drawcrosshair.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\pch.h">
Expand Down
Binary file added build/Win32/Debug/AssaultCube-Multihack.dll
Binary file not shown.
Binary file added build/Win32/Debug/AssaultCube-Multihack.ilk
Binary file not shown.
Binary file added build/Win32/Debug/AssaultCube-Multihack.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Debug|Win32|C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions build/Win32/Debug/bin/AssaultCube-Multihack.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
 base.cpp
Crosshair.cpp
Teleport.cpp
c2sinfo.cpp
drawcrosshair.cpp
hooks.cpp
movelocalplayer.cpp
servertoclient.cpp
ShowCursor.cpp
SwapBuffers.cpp
C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\src\hooks\SwapBuffers.cpp(25): warning C4189: 'io': local variable is initialized but not referenced
WndProc.cpp
main.cpp
Generating Code...
AssaultCube-Multihack.vcxproj -> C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\build\Win32\Debug\AssaultCube-Multihack.dll
Binary file added build/Win32/Debug/bin/AssaultCube-Multihack.pch
Binary file not shown.
Binary file added build/Win32/Debug/bin/Crosshair.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/ShowCursor.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/SwapBuffers.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/Teleport.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/WndProc.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/base.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/c2sinfo.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/drawcrosshair.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/hooks.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_demo.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_draw.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_impl_opengl2.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_impl_win32.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_tables.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/imgui_widgets.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/libmem.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/main.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/movelocalplayer.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/pch.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/servertoclient.obj
Binary file not shown.
Binary file added build/Win32/Debug/bin/vc142.idb
Binary file not shown.
Binary file added build/Win32/Debug/bin/vc142.pdb
Binary file not shown.
Binary file added build/Win32/Release/AssaultCube-Multihack.dll
Binary file not shown.
Binary file added build/Win32/Release/AssaultCube-Multihack.iobj
Binary file not shown.
Binary file added build/Win32/Release/AssaultCube-Multihack.ipdb
Binary file not shown.
Binary file added build/Win32/Release/AssaultCube-Multihack.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Release|Win32|C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions build/Win32/Release/bin/AssaultCube-Multihack.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
 SwapBuffers.cpp
C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\src\hooks\SwapBuffers.cpp(25): warning C4189: 'io': local variable is initialized but not referenced
Generating code
0 of 1454 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
0 functions had inline decision re-evaluated but remain unchanged
Finished generating code
AssaultCube-Multihack.vcxproj -> C:\Users\rdbo\Documents\Repo\AssaultCube-Multihack\AssaultCube-Multihack-main\build\Win32\Release\AssaultCube-Multihack.dll
Binary file added build/Win32/Release/bin/AssaultCube-Multihack.pch
Binary file not shown.
Binary file added build/Win32/Release/bin/Crosshair.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/ShowCursor.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/SwapBuffers.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/Teleport.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/WndProc.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/base.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/c2sinfo.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/hooks.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_demo.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_draw.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_impl_opengl2.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_impl_win32.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_tables.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/imgui_widgets.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/libmem.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/main.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/movelocalplayer.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/pch.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/servertoclient.obj
Binary file not shown.
Binary file added build/Win32/Release/bin/vc142.pdb
Binary file not shown.
4 changes: 4 additions & 0 deletions src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ mem::voidptr_t Base::Data::pShowCursor = nullptr;
mem::voidptr_t Base::Data::p_c2sinfo = nullptr;
mem::voidptr_t Base::Data::p_servertoclient = nullptr;
mem::voidptr_t Base::Data::p_movelocalplayer = nullptr;
mem::voidptr_t Base::Data::p_drawcrosshair = nullptr;
SwapBuffers_t Base::Data::oSwapBuffers = nullptr;
WndProc_t Base::Data::oWndProc = nullptr;
ShowCursor_t Base::Data::oShowCursor = nullptr;
c2sinfo_t Base::Data::o_c2sinfo = nullptr;
servertoclient_t Base::Data::o_servertoclient = nullptr;
movelocalplayer_t Base::Data::o_movelocalplayer = nullptr;
drawcrosshair_t Base::Data::o_drawcrosshair = nullptr;
mem::size_t Base::Data::szSwapBuffers = 5;
mem::size_t Base::Data::szShowCursor = 5;
mem::size_t Base::Data::sz_c2sinfo = 5;
mem::size_t Base::Data::sz_servertoclient = 6;
mem::size_t Base::Data::sz_movelocalplayer = 8;
mem::size_t Base::Data::sz_drawcrosshair = 5;
UINT Base::Data::WMKeys[0xFE];
bool Base::Data::InitSwapBuffers = false;
bool Base::Data::IsUnloaded = false;
Expand Down Expand Up @@ -66,6 +69,7 @@ void Base::Init(HMODULE hMod)
Data::p_c2sinfo = (mem::voidptr_t)Data::game.c2sinfo;
Data::p_servertoclient = (mem::voidptr_t)Data::game.servertoclient;
Data::p_movelocalplayer = (mem::voidptr_t)Data::game.movelocalplayer;
Data::p_drawcrosshair = (mem::voidptr_t)Data::game.drawcrosshair;
Hooks::Init();
}

Expand Down
4 changes: 4 additions & 0 deletions src/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ namespace Base
extern mem::voidptr_t p_c2sinfo;
extern mem::voidptr_t p_servertoclient;
extern mem::voidptr_t p_movelocalplayer;
extern mem::voidptr_t p_drawcrosshair;
extern SwapBuffers_t oSwapBuffers;
extern ShowCursor_t oShowCursor;
extern WndProc_t oWndProc;
extern c2sinfo_t o_c2sinfo;
extern servertoclient_t o_servertoclient;
extern movelocalplayer_t o_movelocalplayer;
extern drawcrosshair_t o_drawcrosshair;
extern mem::size_t szSwapBuffers;
extern mem::size_t szShowCursor;
extern mem::size_t sz_c2sinfo;
extern mem::size_t sz_servertoclient;
extern mem::size_t sz_movelocalplayer;
extern mem::size_t sz_drawcrosshair;
extern UINT WMKeys[0xFE];
extern bool InitSwapBuffers;
extern bool IsUnloaded;
Expand Down Expand Up @@ -95,5 +98,6 @@ namespace Base
void c2sinfo(playerent* d);
void servertoclient(int chan, uchar* buf, int len, bool demo);
void movelocalplayer();
void drawcrosshair(playerent* p, int n, struct color* c, float size);
}
}
3 changes: 3 additions & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typedef void(* servertoclient_t)(int chan, uchar* buf, int len, bool demo);
typedef void(* updateworld_t)(int curtime, int lastmillis);
typedef void(* c2sinfo_t)(playerent* d);
typedef void(* movelocalplayer_t)(void);
typedef void(* drawcrosshair_t)(playerent* p, int n, struct color* c, float size);

class AC_Client
{
Expand All @@ -22,6 +23,7 @@ class AC_Client
updateworld_t updateworld = nullptr;
c2sinfo_t c2sinfo = nullptr;
movelocalplayer_t movelocalplayer = nullptr;
drawcrosshair_t drawcrosshair = nullptr;
public:
inline AC_Client()
{
Expand Down Expand Up @@ -49,6 +51,7 @@ class AC_Client
this->updateworld = (updateworld_t) GAME_OFFSET(0x25EB0);
this->c2sinfo = (c2sinfo_t) GAME_OFFSET(0x20720);
this->movelocalplayer = (movelocalplayer_t) GAME_OFFSET(0x25770);
this->drawcrosshair = (drawcrosshair_t) GAME_OFFSET(0x8660);
this->Updated = true;
}
};
Expand Down
8 changes: 8 additions & 0 deletions src/hooks/drawcrosshair.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <pch.h>
#include <base.h>

void Base::Hooks::drawcrosshair(playerent* p, int n, struct color* c, float size)
{
if(!Data::Settings::EnableCrosshair)
return Data::o_drawcrosshair(p, n, c, size);
}
2 changes: 2 additions & 0 deletions src/hooks/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ void Base::Hooks::Init()
Data::o_c2sinfo = (c2sinfo_t)mem::in::detour_trampoline(Data::p_c2sinfo, (mem::voidptr_t)Hooks::c2sinfo, Data::sz_c2sinfo, mem::MEM_DT_M1);
Data::o_servertoclient = (servertoclient_t)mem::in::detour_trampoline(Data::p_servertoclient, (mem::voidptr_t)Hooks::servertoclient, Data::sz_servertoclient, mem::MEM_DT_M1);
Data::o_movelocalplayer = (movelocalplayer_t)mem::in::detour_trampoline(Data::p_movelocalplayer, (mem::voidptr_t)Hooks::movelocalplayer, Data::sz_movelocalplayer);
Data::o_drawcrosshair = (drawcrosshair_t)mem::in::detour_trampoline(Data::p_drawcrosshair, (mem::voidptr_t)Hooks::drawcrosshair, Data::sz_drawcrosshair, mem::MEM_DT_M1);
}

void Base::Hooks::Shutdown()
{
SetWindowLongPtr(Data::hWindow, GWL_WNDPROC, (LONG_PTR)Data::oWndProc);
mem::in::detour_restore(Data::p_drawcrosshair, (mem::byte_t*)Data::o_drawcrosshair, Data::sz_drawcrosshair);
mem::in::detour_restore(Data::p_movelocalplayer, (mem::byte_t*)Data::o_movelocalplayer, Data::sz_movelocalplayer);
mem::in::detour_restore(Data::p_servertoclient, (mem::byte_t*)Data::o_servertoclient, Data::sz_servertoclient);
mem::in::detour_restore(Data::p_c2sinfo, (mem::byte_t*)Data::o_c2sinfo, Data::sz_c2sinfo);
Expand Down

0 comments on commit 13ed05c

Please sign in to comment.