mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
feat(NativeHooks): Added basics for native hooking
This commit is contained in:
parent
17f7e22c47
commit
3b840f62e9
@ -8,6 +8,7 @@
|
|||||||
#include "hooking.hpp"
|
#include "hooking.hpp"
|
||||||
#include "memory/module.hpp"
|
#include "memory/module.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
|
#include "native_hooks/native_hooks.hpp"
|
||||||
#include "pointers.hpp"
|
#include "pointers.hpp"
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
#include "script_mgr.hpp"
|
#include "script_mgr.hpp"
|
||||||
|
@ -63,6 +63,8 @@ namespace big
|
|||||||
void enable();
|
void enable();
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
|
std::list<script_hook*> m_native_hooks;
|
||||||
|
std::unordered_map<rage::scrNativeHash, rage::scrNativeHandler> m_natives;
|
||||||
private:
|
private:
|
||||||
bool m_enabled{};
|
bool m_enabled{};
|
||||||
minhook_keepalive m_minhook_keepalive;
|
minhook_keepalive m_minhook_keepalive;
|
||||||
|
16
BigBaseV2/src/native_hooks/native_hooks.hpp
Normal file
16
BigBaseV2/src/native_hooks/native_hooks.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "natives.hpp"
|
||||||
|
|
||||||
|
namespace big::native_hook
|
||||||
|
{
|
||||||
|
inline void NETWORK_CAN_BAIL(rage::scrNativeCallContext* src);
|
||||||
|
inline void STAT_SET_INT(rage::scrNativeCallContext* src);
|
||||||
|
inline void TRIGGER_SCRIPT_EVENT(rage::scrNativeCallContext* src);
|
||||||
|
|
||||||
|
static std::unordered_map<rage::scrNativeHash, rage::scrNativeHandler> natives_replace =
|
||||||
|
{
|
||||||
|
{ 0x580CE4438479CC61, &NETWORK_CAN_BAIL },
|
||||||
|
{ 0xB3271D7AB655B441, &STAT_SET_INT },
|
||||||
|
{ 0x5AE99C571D5BBE5D, &TRIGGER_SCRIPT_EVENT }
|
||||||
|
};
|
||||||
|
}
|
11
BigBaseV2/src/native_hooks/network_can_bail.cpp
Normal file
11
BigBaseV2/src/native_hooks/network_can_bail.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "native_hooks.hpp"
|
||||||
|
|
||||||
|
namespace big::native_hook
|
||||||
|
{
|
||||||
|
void NETWORK_CAN_BAIL(rage::scrNativeCallContext* src)
|
||||||
|
{
|
||||||
|
LOG(INFO) << "NATIVE_HOOK => NETWORK_CAN_BAIL : TRIGGERED";
|
||||||
|
|
||||||
|
src->set_return_value<BOOL>(false);
|
||||||
|
}
|
||||||
|
}
|
28
BigBaseV2/src/native_hooks/stat_set_int.cpp
Normal file
28
BigBaseV2/src/native_hooks/stat_set_int.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "native_hooks.hpp"
|
||||||
|
#include "gta/joaat.hpp"
|
||||||
|
|
||||||
|
namespace big::native_hook
|
||||||
|
{
|
||||||
|
void STAT_SET_INT(rage::scrNativeCallContext* src)
|
||||||
|
{
|
||||||
|
Hash stat_hash = src->get_arg<Hash>(0);
|
||||||
|
int value = src->get_arg<int>(1);
|
||||||
|
BOOL save = src->get_arg<BOOL>(2);
|
||||||
|
|
||||||
|
switch (stat_hash)
|
||||||
|
{
|
||||||
|
case RAGE_JOAAT("MPPLY_GAME_EXPLOITS"):
|
||||||
|
case RAGE_JOAAT("MPPLY_VC_HATE"):
|
||||||
|
case RAGE_JOAAT("MPPLY_EXPLOITS"):
|
||||||
|
case RAGE_JOAAT("MPPLY_TC_ANNOYINGME"):
|
||||||
|
case RAGE_JOAAT("MPPLY_TC_HATE"):
|
||||||
|
src->set_return_value<BOOL>(true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
src->set_return_value<BOOL>(STATS::STAT_SET_INT(stat_hash, value, save));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
BigBaseV2/src/native_hooks/trigger_script_event.cpp
Normal file
24
BigBaseV2/src/native_hooks/trigger_script_event.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "native_hooks.hpp"
|
||||||
|
#include "pointers.hpp"
|
||||||
|
|
||||||
|
namespace big::native_hook
|
||||||
|
{
|
||||||
|
void TRIGGER_SCRIPT_EVENT(rage::scrNativeCallContext* src)
|
||||||
|
{
|
||||||
|
int event_group = src->get_arg<int>(0);
|
||||||
|
Any* event_data = src->get_arg<Any*>(1);
|
||||||
|
int event_size = src->get_arg<int>(3);
|
||||||
|
int player_bits = src->get_arg<int>(4);
|
||||||
|
|
||||||
|
if (event_group)
|
||||||
|
{
|
||||||
|
Hash event_hash = event_data[0];
|
||||||
|
|
||||||
|
LOG(INFO) << "Event hash: " << event_hash;
|
||||||
|
for (size_t i = 1; i < std::min(event_size, 200); i++)
|
||||||
|
LOG(INFO) << "Arg[#" << i << "] : " << event_data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPT::TRIGGER_SCRIPT_EVENT(event_group, event_data, event_size, player_bits);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
#include "gta/fwddec.hpp"
|
#include "gta/fwddec.hpp"
|
||||||
#include "gta/enums.hpp"
|
#include "gta/enums.hpp"
|
||||||
#include "gta/replay.hpp"
|
#include "gta/replay.hpp"
|
||||||
|
#include "gta/script_program.hpp"
|
||||||
#include "function_types.hpp"
|
#include "function_types.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
|
@ -35,8 +35,8 @@ namespace big::toxic
|
|||||||
inline void bounty_player(Player target, Player origin, int amount)
|
inline void bounty_player(Player target, Player origin, int amount)
|
||||||
{
|
{
|
||||||
const size_t arg_count = 22;
|
const size_t arg_count = 22;
|
||||||
int64_t args[22] = {
|
int args[22] = {
|
||||||
2388821078, // 0
|
(int)eRemoteEvent::Bounty, // 0
|
||||||
origin, // 1 Player in script self
|
origin, // 1 Player in script self
|
||||||
target, // 2 Player in script self
|
target, // 2 Player in script self
|
||||||
0, // 3 unk
|
0, // 3 unk
|
||||||
|
Loading…
Reference in New Issue
Block a user