Dateien nach "/" hochladen

This commit is contained in:
2026-11-07 20:24:24 +00:00
parent e227a9db4f
commit d66c4da19b
3 changed files with 329 additions and 0 deletions
+298
View File
@@ -0,0 +1,298 @@
#include "inc/include.h"
extern "C"
{
extern u64 some_stuff();
__attribute__((naked)) void nopstub()
{
__asm
{
jmp some_stuff
}
}
void init(Context* pctx)
{
auto& state = pctx->state;
state.in_forward.construct( pctx->game_base + OFF_IN_FORWARD );
state.in_duck.construct( pctx->game_base + OFF_IN_DUCK );
state.in_jump.construct( pctx->game_base + OFF_IN_JUMP );
state.fp_cache[0] = xf(0x3F000000);
state.fp_cache[1] = xf(0x3F800000);
state.fp_cache[2] = xf(0);
}
const char *get_player_name(Context *ctx, u64 player)
{
return ctx->pfn_get_player_name(player);
}
GameModes get_game_mode(Context* pctx)
{
u64 mp_gamemode_base = pctx->game_base + OFF_GAMEMODE;
if(mp_gamemode_base != 0ull)
{
auto gamemode_addr = *(u64*)(mp_gamemode_base + 0x50);
auto gamemode = *(u64*)gamemode_addr;
pctx->state.game_mode_raw = gamemode;
if(gamemode == 0x6c61766976727573)
return GameModes::SURVIVAL;
else if(gamemode == 0x6c006d6465657266)
{
auto squad_id = *(int*)(pctx->me + OFF_ENTITY_SQUAD_ID);
if(squad_id == -1)
{
return GameModes::TEAM_DEATHMATCH;
} else
{
return GameModes::GUN_RUN;
}
} else if(gamemode == 0x6c6f72746e6f63)
{
return GameModes::CONTROL;
}
}
return GameModes::INVALID;
}
bool process_entity(Context* pctx, Entity& me, size_t eidx, Entity& ent, CachedEntity* prec)
{
if(ent.is_alive())
{
auto type = ent.type();
if(type != EEntityType::INVALID)
{
if(type == EEntityType::DUMMIE || type == EEntityType::PLAYER)
{
prec->is_valid = true;
prec->signifier = ent.signifier_id();
if(type == EEntityType::PLAYER)
{
prec->is_ally = ent.is_ally_of(pctx, me);
prec->name = get_player_name(pctx, ent.base()); // TODO
prec->level = ent.get_level(pctx);
} else
{
prec->name = nullptr;
}
auto vec_origin = ent.vec_origin();
auto my_origin = me.vec_origin();
auto vec_delta = (vec_origin - my_origin);
float dist = vec_delta.length_sqr();
prec->dist_to_local = fabsf( pctx, dist );
prec->health = ent.health();
prec->vec_origin = ent.vec_origin();
auto coll = ent.collision();
auto coord_frame = ent.coord_frame();
if (coll == nullptr)
{
prec->rpts_avail = false;
} else
{
auto vec_mins = coll->vec_mins();
auto vec_maxs = coll->vec_maxs();
prec->rpts_avail = math::setup_render_points(pctx, coord_frame, vec_mins, vec_maxs, prec->rpts);
if(prec->rpts_avail == true)
{
prec->draw_pos_top[0] = prec->rpts.x;
prec->draw_pos_top[1] = prec->rpts.y - xf(0x41B80000);
}
}
auto curr_health = prec->health;
if(curr_health == 100)
{
prec->color[0] = 65;
prec->color[1] = 255;
prec->color[2] = 65;
} else if(curr_health > 65)
{
prec->color[0] = 255;
prec->color[1] = 255;
prec->color[2] = 65;
} else{
prec->color[0] = 255;
prec->color[1] = 65;
prec->color[2] = 65;
}
return true;
} else
{
prec->is_valid = false;
}
} else
{
prec->is_valid = false;
}
} else
{
prec->is_valid = false;
}
return false;
}
void cache_entities(Context* pctx, Entity& me)
{
auto entlist = reinterpret_cast<EntityRecord*>(pctx->game_base + OFF_ENTITY_LIST);
size_t highest_eidx = 0ull;
for(size_t i = 0ull; i < 0x10000; i++)
{
auto prec = &pctx->state.entity_cache[ i ];
auto rec = &entlist[i];
if(rec->ptr != 0ull && rec->ptr != me.base())
{
auto ent = Entity(rec->ptr);
if(process_entity( pctx, me, i, ent, prec ) && i > highest_eidx)
{
highest_eidx = i;
}
} else
{
prec->is_valid = false;
}
}
pctx->state.highest_eidx = highest_eidx;
}
void think(Context* pctx)
{
auto me = r5::local_player(pctx);
if(me.is_valid() && me.is_alive())
{
pctx->state.game_mode = get_game_mode(pctx);
pctx->me = me.base();
features::glow( pctx );
features::movement( pctx );
features::esp_tick( pctx );
}
}
__declspec(dllexport) bool __fastcall hkIsGamepadDisabled(u64 inst)
{
u64 retaddr = BASE_OF(_ReturnAddress()) & 0xFFFF;
u64 context_base = 0xFAFBFCFDFEFAFDFE;
Context* pctx = (Context*)context_base;
bool result = pctx->state.is_controller;
if(retaddr != 0xB6A0)
return result;
if(r5::is_valid_context(pctx) && pctx->state.is_controller == false)
{
float mouse_x = xf(0x0), mouse_y = xf(0x0);
float orig_mouse_x = xf(0x0), orig_mouse_y = xf(0x0);
read_xmm6(&mouse_x);
read_xmm7(&mouse_y);
orig_mouse_x = mouse_x;
orig_mouse_y = mouse_y;
features::rcs(pctx, mouse_x, mouse_y);
if (orig_mouse_x != mouse_x)
write_xmm6(mouse_x);
if(orig_mouse_y != mouse_y)
write_xmm7(mouse_y);
}
return result;
}
extern void MkrCtxHook();
__declspec(dllexport) __attribute__((naked)) void __fastcall hkMkrCtxRenderPre()
{
__asm
{
mov rbx, qword ptr [rsp+0x98]
call MkrCtxHook
movaps xmm6, xmmword ptr [rsp+0x70]
add rsp, 0x88
pop rdi
pop rbx
ret
}
}
void __fastcall MkrCtxHook()
{
u64 retaddr = 0ull;
__asm mov retaddr, rbx;
if( (retaddr & 0xFFFF) != 0x6701 )
return; // prevent rendering multiple times.
u64 context_base = 0xFAFBFCFDFEFAFEEE;
Context *pctx = (Context *)context_base;
if (r5::is_valid_context(pctx))
{
u64 apex_base = pctx->game_base;
u32 signon_state = *(u32*)(apex_base + OFF_SIGNON_STATE);
if(signon_state == 8)
{
auto me = r5::local_player(pctx);
if(me.is_valid())
{
cache_entities(pctx, me);
}
render::tick( pctx );
}
} else
{
pctx->pfn_draw_colored_text( *pctx->mss_ptr, 2, 14, 450, 450, 255, 255, 255, 255, 0, "DrauseHook [DEBUG]");
}
}
u64 some_stuff()
{
u64 retaddr = BASE_OF(_ReturnAddress()) & 0xFFFF;
if(retaddr == 0x7024)
{
u64 context_base = 0xFAFBFCFDFEFAFDFC;
Context* pctx = (Context*)context_base;
if(!r5::is_valid_context(pctx))
{
return 0ull;
}
if(pctx->inited != 1u)
{
init(pctx);
pctx->inited = 1u;
}
u64 apex_base = pctx->game_base;
u32 signon_state = *(u32*)(apex_base + OFF_SIGNON_STATE);
if(signon_state == 8)
{
pctx->state.is_controller = *(u8*)( apex_base + 0x1C64440 + 0x1084 ) == 1u;
think(pctx);
}
}
return 0ull;
}
}