mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-27 22:17:55 +03:00
Trying inline getHook
Using visibility=default instead of symbols
This commit is contained in:
parent
0dd99aaf6d
commit
feeca13f08
@ -61,7 +61,7 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
'_snprintf': 'snprintf'
|
||||
])
|
||||
|
||||
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-msse2', '-fp-model fast=2', '-fomit-frame-pointer', '-inline-forceinline', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s'
|
||||
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-msse2', '-fp-model fast=2', '-fomit-frame-pointer', '-inline-forceinline', '-fvisibility=default', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s'
|
||||
}
|
||||
|
||||
ToolchainConfigUtils.apply(project, cfg, b)
|
||||
|
@ -123,7 +123,7 @@ void callVoidForward(size_t func, original_t original, f_args... args)
|
||||
hookctx_t hookCtx(sizeof...(args), args...);
|
||||
|
||||
g_hookCtx = &hookCtx;
|
||||
_callVoidForward(g_hookManager.getHook(func), original, args...);
|
||||
_callVoidForward(g_hookManager.getHookFast(func), original, args...);
|
||||
g_hookCtx = nullptr;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ R callForward(size_t func, original_t original, f_args... args)
|
||||
hookctx_t hookCtx(sizeof...(args), args...);
|
||||
|
||||
g_hookCtx = &hookCtx;
|
||||
auto ret = _callForward<R>(g_hookManager.getHook(func), original, args...);
|
||||
auto ret = _callForward<R>(g_hookManager.getHookFast(func), original, args...);
|
||||
g_hookCtx = nullptr;
|
||||
|
||||
return ret;
|
||||
|
@ -41,6 +41,18 @@ hook_t hooklist_player[] = {
|
||||
DLL(CBasePlayer_Observer_IsValidTarget),
|
||||
};
|
||||
|
||||
const size_t hooklist_engine_size = arraysize(hooklist_engine);
|
||||
const size_t hooklist_gamedll_size = arraysize(hooklist_gamedll);
|
||||
const size_t hooklist_player_size = arraysize(hooklist_player);
|
||||
hook_t* hooklist_t::getHookSafe(size_t hook)
|
||||
{
|
||||
#define CASE(h) case ht_##h: if (index < arraysize(hooklist_##h)) return &hooklist_##h[index]; else break;
|
||||
|
||||
const auto table = hooks_tables_e(hook / MAX_REGION_RANGE);
|
||||
const auto index = hook & (MAX_REGION_RANGE - 1);
|
||||
|
||||
switch (table) {
|
||||
CASE(engine)
|
||||
CASE(gamedll)
|
||||
CASE(player)
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -104,15 +104,12 @@ struct hook_t
|
||||
extern hook_t hooklist_engine[];
|
||||
extern hook_t hooklist_gamedll[];
|
||||
extern hook_t hooklist_player[];
|
||||
extern const size_t hooklist_engine_size;
|
||||
extern const size_t hooklist_gamedll_size;
|
||||
extern const size_t hooklist_player_size;
|
||||
|
||||
struct hooklist_t
|
||||
{
|
||||
hook_t *operator[](size_t hook) const
|
||||
{
|
||||
#define CASE(h) case ht_##h: if (index < hooklist_##h##_size) return &hooklist_##h[index]; else break;
|
||||
#define CASE(h) case ht_##h: return &hooklist_##h[index];
|
||||
|
||||
const auto table = hooks_tables_e(hook / MAX_REGION_RANGE);
|
||||
const auto index = hook & (MAX_REGION_RANGE - 1);
|
||||
@ -126,6 +123,8 @@ struct hooklist_t
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static hook_t *getHookSafe(size_t hook);
|
||||
|
||||
enum hooks_tables_e
|
||||
{
|
||||
ht_engine,
|
||||
|
@ -39,7 +39,7 @@ void CHookManager::clearHandlers() const
|
||||
|
||||
hook_t* CHookManager::getHook(size_t func) const
|
||||
{
|
||||
return m_hooklist[func];
|
||||
return m_hooklist.getHookSafe(func);
|
||||
}
|
||||
|
||||
CAmxxHook* CHookManager::getAmxxHook(cell handle) const
|
||||
|
@ -34,6 +34,10 @@ public:
|
||||
hook_t* getHook(size_t func) const;
|
||||
CAmxxHook* getAmxxHook(cell hook) const;
|
||||
|
||||
hook_t* getHookFast(size_t func) const {
|
||||
return m_hooklist[func];
|
||||
}
|
||||
|
||||
private:
|
||||
hooklist_t m_hooklist;
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
|
||||
|
||||
linkerOptions: new GccToolchainConfig.LinkerOptions(
|
||||
interProceduralOptimizations: true,
|
||||
stripSymbolTable: false,
|
||||
stripSymbolTable: true,
|
||||
staticLibGcc: true,
|
||||
staticIntel: true,
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user