mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-01-14 23:57:57 +03:00
Some cosmetic fixes
This commit is contained in:
parent
2cf145e2a0
commit
87548b9af9
@ -1,9 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types_meta.h"
|
enum
|
||||||
|
{
|
||||||
#define P_PRE 0 // plugin function called before gamedll
|
P_PRE, // plugin function called before gamedll
|
||||||
#define P_POST 1 // plugin function called after gamedll
|
P_POST, // plugin function called after gamedll
|
||||||
|
};
|
||||||
|
|
||||||
struct api_info_t
|
struct api_info_t
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ class CForwardCallbackJIT : public jitasm::function<int, CForwardCallbackJIT, in
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CForwardCallbackJIT(jitdata_t *jitdata);
|
CForwardCallbackJIT(jitdata_t *jitdata);
|
||||||
void naked_main();
|
void naked_main() override;
|
||||||
void call_func(jitasm::Frontend::Reg32 addr);
|
void call_func(jitasm::Frontend::Reg32 addr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -59,19 +59,21 @@ void CForwardCallbackJIT::naked_main()
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto globals = ebx;
|
auto globals = ebx;
|
||||||
auto mg_backup = m_jitdata->has_ret ? 8 : 0;
|
auto mg_backup = m_jitdata->has_ret ? 8 /* orig + over */ : 0;
|
||||||
auto framesize = mg_backup + sizeof(meta_globals_t);
|
auto framesize = mg_backup + sizeof(meta_globals_t);
|
||||||
|
|
||||||
if (m_jitdata->has_varargs) {
|
if (m_jitdata->has_varargs) {
|
||||||
|
size_t buf_offset = framesize;
|
||||||
|
|
||||||
sub(esp, framesize += MAX_STRBUF_LEN);
|
sub(esp, framesize += MAX_STRBUF_LEN);
|
||||||
|
|
||||||
// format varargs
|
// format varargs
|
||||||
lea(edx, dword_ptr[ebp + 8 + m_jitdata->args_count * 4]); // varargs ptr
|
lea(edx, dword_ptr[ebp + 8 + m_jitdata->args_count * 4]); // varargs ptr
|
||||||
lea(eax, dword_ptr[esp + mg_backup + sizeof(meta_globals_t)]); // buf ptr
|
lea(eax, dword_ptr[esp + buf_offset]); // buf ptr
|
||||||
mov(ecx, size_t(vsnprintf));
|
mov(ecx, size_t(vsnprintf));
|
||||||
|
|
||||||
push(edx);
|
push(edx);
|
||||||
push(dword_ptr[ebp + 8 + (m_jitdata->args_count - 1) * 4]); // last arg of pfn (format)
|
push(dword_ptr[ebp + 8 + (m_jitdata->args_count - 1) * 4]); // last arg of pfn (format string)
|
||||||
push(MAX_STRBUF_LEN);
|
push(MAX_STRBUF_LEN);
|
||||||
push(eax);
|
push(eax);
|
||||||
call(ecx);
|
call(ecx);
|
||||||
@ -80,7 +82,7 @@ void CForwardCallbackJIT::naked_main()
|
|||||||
else
|
else
|
||||||
sub(esp, framesize);
|
sub(esp, framesize);
|
||||||
|
|
||||||
// setup globals ptr
|
// setup globals ptr and backup old data
|
||||||
mov(globals, size_t(&g_metaGlobals));
|
mov(globals, size_t(&g_metaGlobals));
|
||||||
movups(xmm0, xmmword_ptr[globals]);
|
movups(xmm0, xmmword_ptr[globals]);
|
||||||
mov(eax, dword_ptr[globals + 16]);
|
mov(eax, dword_ptr[globals + 16]);
|
||||||
@ -256,25 +258,25 @@ void CForwardCallbackJIT::naked_main()
|
|||||||
|
|
||||||
void CForwardCallbackJIT::call_func(jitasm::Frontend::Reg32 addr)
|
void CForwardCallbackJIT::call_func(jitasm::Frontend::Reg32 addr)
|
||||||
{
|
{
|
||||||
const size_t normal_args_count = m_jitdata->args_count - (m_jitdata->has_varargs ? 1u : 0u);
|
const size_t fixed_args_count = m_jitdata->args_count - (m_jitdata->has_varargs ? 1u /* excluding format string */ : 0u);
|
||||||
const size_t strbuf_stack_offset = (m_jitdata->has_ret ? 8u : 0u) + sizeof(meta_globals_t);
|
const size_t strbuf_offset = (m_jitdata->has_ret ? 8u : 0u) + sizeof(meta_globals_t);
|
||||||
|
|
||||||
// push formatted buf
|
// push formatted buf instead of format string
|
||||||
if (m_jitdata->has_varargs) {
|
if (m_jitdata->has_varargs) {
|
||||||
lea(eax, dword_ptr[esp + strbuf_stack_offset]);
|
lea(eax, dword_ptr[esp + strbuf_offset]);
|
||||||
push(eax);
|
push(eax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// push normal args
|
// push normal args
|
||||||
for (size_t j = normal_args_count; j > 0; j--)
|
for (size_t j = fixed_args_count; j > 0; j--)
|
||||||
push(dword_ptr[ebp + 8 + (j - 1) * 4]);
|
push(dword_ptr[ebp + 8 + (j - 1) * sizeof(int)]);
|
||||||
|
|
||||||
// call
|
// call
|
||||||
call(addr);
|
call(addr);
|
||||||
|
|
||||||
// pop stack
|
// pop stack
|
||||||
if (m_jitdata->args_count)
|
if (m_jitdata->args_count)
|
||||||
add(esp, m_jitdata->args_count * 4);
|
add(esp, m_jitdata->args_count * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
class CSimpleJmp : public jitasm::function<void, CSimpleJmp>
|
class CSimpleJmp : public jitasm::function<void, CSimpleJmp>
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
struct jitdata_t
|
struct jitdata_t
|
||||||
{
|
{
|
||||||
size_t pfn_original;
|
size_t pfn_original;
|
||||||
|
size_t pfn_offset; // from fn table
|
||||||
uint8 args_count;
|
uint8 args_count;
|
||||||
bool has_ret;
|
bool has_ret;
|
||||||
bool has_varargs;
|
bool has_varargs;
|
||||||
uint8 mm_hook_time;
|
uint8 mm_hook_time;
|
||||||
size_t pfn_offset; // from fn table
|
|
||||||
size_t mm_hook;
|
size_t mm_hook;
|
||||||
|
|
||||||
MPlugin* plugins;
|
MPlugin* plugins;
|
||||||
|
@ -8,7 +8,7 @@ void meta_new_dll_functions_t::set_from(NEW_DLL_FUNCTIONS* _pFuncs)
|
|||||||
void meta_new_dll_functions_t::copy_to(NEW_DLL_FUNCTIONS *_pFuncs) const
|
void meta_new_dll_functions_t::copy_to(NEW_DLL_FUNCTIONS *_pFuncs) const
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// TODO: Implemented check regamedll
|
// TODO: Implement regamedll check
|
||||||
// exit
|
// exit
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,7 +44,7 @@ void metamod_startup()
|
|||||||
const char *cp;
|
const char *cp;
|
||||||
|
|
||||||
META_CONS(" ");
|
META_CONS(" ");
|
||||||
META_CONS(" Metamod version %s Copyright (c) 2001-2016 Will Day (modification ReHLDS Team)", APP_VERSION_STRD);
|
META_CONS(" Metamod version %s Copyright (c) 2001-2016 Will Day (modification by ReHLDS Team)", APP_VERSION_STRD);
|
||||||
META_CONS(" Metamod comes with ABSOLUTELY NO WARRANTY; for details type `meta gpl'.");
|
META_CONS(" Metamod comes with ABSOLUTELY NO WARRANTY; for details type `meta gpl'.");
|
||||||
META_CONS(" This is free software, and you are welcome to redistribute it");
|
META_CONS(" This is free software, and you are welcome to redistribute it");
|
||||||
META_CONS(" under certain conditions; type `meta gpl' for details.");
|
META_CONS(" under certain conditions; type `meta gpl' for details.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user