forked from danielkrupinski/Osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PanoramaMarshallHelperHooks.h
58 lines (47 loc) · 2.54 KB
/
PanoramaMarshallHelperHooks.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
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <HookType.h>
#include <Platform/Macros/CallingConventions.h>
#include <Platform/Macros/PlatformSpecific.h>
#include <RetSpoof/FunctionInvoker.h>
namespace csgo { struct PanoramaMarshallHelperPOD; }
class PanoramaMarshallHelperHooks {
public:
void install(csgo::PanoramaMarshallHelperPOD* panoramaMarshallHelper)
{
hookImpl.init(panoramaMarshallHelper);
originalGetNumArgs = reinterpret_cast<decltype(originalGetNumArgs)>(hookImpl.hookAt(1, &getNumArgs));
originalGetArgAsNumber = reinterpret_cast<decltype(originalGetArgAsNumber)>(hookImpl.hookAt(5, &getArgAsNumber));
originalGetArgAsString = reinterpret_cast<decltype(originalGetArgAsString)>(hookImpl.hookAt(7, &getArgAsString));
originalSetResultInt = reinterpret_cast<decltype(originalSetResultInt)>(hookImpl.hookAt(WIN32_LINUX(14, 11), &setResultInt));
}
void uninstall()
{
hookImpl.restore();
}
[[nodiscard]] auto getOriginalGetNumArgs() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalGetNumArgs };
}
[[nodiscard]] auto getOriginalGetArgAsNumber() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalGetArgAsNumber };
}
[[nodiscard]] auto getOriginalGetArgAsString() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalGetArgAsString };
}
[[nodiscard]] auto getOriginalSetResultInt() const
{
return FunctionInvoker{ retSpoofGadgets->client, originalSetResultInt };
}
static unsigned FASTCALL_CONV getNumArgs(FASTCALL_THIS(csgo::PanoramaMarshallHelperPOD* thisptr), void* params) noexcept;
static double FASTCALL_CONV getArgAsNumber(FASTCALL_THIS(csgo::PanoramaMarshallHelperPOD* thisptr), void* params, int index) noexcept;
static const char* FASTCALL_CONV getArgAsString(FASTCALL_THIS(csgo::PanoramaMarshallHelperPOD* thisptr), void* params, int index) noexcept;
static void FASTCALL_CONV setResultInt(FASTCALL_THIS(csgo::PanoramaMarshallHelperPOD* thisptr), void* params, int result) noexcept;
private:
HookType hookImpl;
unsigned (THISCALL_CONV* originalGetNumArgs)(csgo::PanoramaMarshallHelperPOD* thisptr, void* params);
double (THISCALL_CONV* originalGetArgAsNumber)(csgo::PanoramaMarshallHelperPOD* thisptr, void* params, int index);
const char* (THISCALL_CONV* originalGetArgAsString)(csgo::PanoramaMarshallHelperPOD* thisptr, void* params, int index);
void (THISCALL_CONV* originalSetResultInt)(csgo::PanoramaMarshallHelperPOD* thisptr, void* params, int result);
};