forked from danielkrupinski/Osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientHooks.h
47 lines (38 loc) · 1.59 KB
/
ClientHooks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <HookType.h>
#include <Platform/Macros/CallingConventions.h>
#include <Platform/Macros/PlatformSpecific.h>
#include <RetSpoof/FunctionInvoker.h>
namespace csgo
{
struct ClientPOD;
enum class FrameStage;
enum class UserMessageType;
}
class ClientHooks {
public:
void install(csgo::ClientPOD* client)
{
hookImpl.init(client);
originalFrameStageNotify = reinterpret_cast<decltype(originalFrameStageNotify)>(hookImpl.hookAt(37, &frameStageNotify));
originalDispatchUserMessage = reinterpret_cast<decltype(originalDispatchUserMessage)>(hookImpl.hookAt(38, &dispatchUserMessage));
}
void uninstall()
{
hookImpl.restore();
}
[[nodiscard]] auto getOriginalFrameStageNotify() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalFrameStageNotify };
}
[[nodiscard]] auto getOriginalDispatchUserMessage() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalDispatchUserMessage };
}
static void FASTCALL_CONV frameStageNotify(FASTCALL_THIS(csgo::ClientPOD* thisptr), csgo::FrameStage stage) noexcept;
static bool FASTCALL_CONV dispatchUserMessage(FASTCALL_THIS(csgo::ClientPOD* thisptr), csgo::UserMessageType type, int passthroughFlags, int size, const void* data) noexcept;
private:
HookType hookImpl;
void (THISCALL_CONV* originalFrameStageNotify)(csgo::ClientPOD* thisptr, csgo::FrameStage stage);
bool (THISCALL_CONV* originalDispatchUserMessage)(csgo::ClientPOD* thisptr, csgo::UserMessageType type, int passthroughFlags, int size, const void* data);
};