Initial commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
namespace r5
|
||||
{
|
||||
struct context_t
|
||||
{
|
||||
uintptr_t my_base;
|
||||
uintptr_t my_length;
|
||||
|
||||
bool m_initialized;
|
||||
|
||||
struct
|
||||
{
|
||||
uintptr_t base;
|
||||
size_t length;
|
||||
} m_process_info;
|
||||
} inline _ctx;
|
||||
|
||||
__forceinline auto en_decrypt(void* data_ptr, size_t length, uint64_t key)
|
||||
{
|
||||
for (size_t i = 0; i < length; i++)
|
||||
reinterpret_cast<uint8_t*>(data_ptr)[i] ^= key;
|
||||
}
|
||||
|
||||
extern bool setup_context();
|
||||
extern bool setup_dyn_addrs();
|
||||
extern bool setup_interfaces_early();
|
||||
extern bool setup_interfaces();
|
||||
extern bool setup_convars();
|
||||
|
||||
extern void initialize();
|
||||
extern void initialize_full();
|
||||
extern void shutdown();
|
||||
|
||||
extern bool setup_context_encrypted(uintptr_t base);
|
||||
extern bool setup_context_internal(uintptr_t base, _pimage_dos_header dh, _pimage_nt_header nh);
|
||||
extern bool setup_context();
|
||||
|
||||
extern bool is_within_eac(void* address);
|
||||
|
||||
extern void think();
|
||||
|
||||
extern void maintain_screen_size();
|
||||
|
||||
//
|
||||
// hook handlers.
|
||||
//
|
||||
extern void on_game_state_change(bool current, bool previous);
|
||||
extern void on_createmove(respawn::user_cmd_t* user_cmd);
|
||||
extern void on_clmove();
|
||||
extern void on_paint();
|
||||
extern void on_render();
|
||||
extern void on_fsn(int stage);
|
||||
extern void on_window_proc(UINT msg, WPARAM w_param, LPARAM l_param);
|
||||
|
||||
__forceinline auto on_failure(ulong line, const char* file)
|
||||
{
|
||||
log_info("a failure inside game_r5 was reported (file='%s', line=%i).", file, line);
|
||||
log_info("the return address which might contain more info is %p", _ReturnAddress());
|
||||
|
||||
//
|
||||
// this will throw an access violation and automatically generate a crash dump.
|
||||
// but only if this was configured for windows error reporting (WER).
|
||||
//
|
||||
*reinterpret_cast<int*>(0) = NULL;
|
||||
}
|
||||
|
||||
__forceinline auto is_within_self(void* va)
|
||||
{
|
||||
auto address = mem::addr(va).Base();
|
||||
|
||||
if (address == 0)
|
||||
return false;
|
||||
|
||||
return (address >= _ctx.my_base &&
|
||||
address <= (_ctx.my_base + _ctx.my_length));
|
||||
}
|
||||
}
|
||||
|
||||
#define report_failure() r5::on_failure(__LINE__, _XS(__FILE__))
|
||||
Reference in New Issue
Block a user