8000 x64 linux sourcehook hookmangen by rtldg · Pull Request #212 · alliedmodders/metamod-source · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

x64 linux sourcehook hookmangen #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ build/
build-*/
obj-*/
.gdb_history

.vs/*
.vscode/*
2 changes: 1 addition & 1 deletion core/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ for sdk_target in MMS.sdk_targets:

if cxx.target.arch == 'x86':
binary.sources += ['sourcehook/sourcehook_hookmangen_x86.cpp']
elif binary.compiler.target.arch == 'x86_64' and binary.compiler.target.platform != 'linux':
elif binary.compiler.target.arch == 'x86_64':
binary.sources += ['sourcehook/sourcehook_hookmangen_x86_64.cpp']
nodes = builder.Add(binary)
MMS.binaries += [nodes]
5 changes: 1 addition & 4 deletions core/metamod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ static MetamodSourceConVar *mm_basedir = NULL;
static CreateInterfaceFn engine_factory = NULL;
static CreateInterfaceFn physics_factory = NULL;
static CreateInterfaceFn filesystem_factory = NULL;
#if !defined( __amd64__ )
static CHookManagerAutoGen g_SH_HookManagerAutoGen(&g_SourceHook);
#endif
static META_RES last_meta_res;
static IServerPluginCallbacks *vsp_callbacks = NULL;
static bool were_plugins_loaded = false;
Expand Down Expand Up @@ -846,7 +844,6 @@ void *MetamodSource::MetaFactory(const char *iface, int *ret, PluginId *id)
}
return static_cast<void *>(static_cast<ISmmPluginManager *>(&g_PluginMngr));
}
#if !defined( __amd64__ )
else if (strcmp(iface, MMIFACE_SH_HOOKMANAUTOGEN) == 0)
{
if (ret)
Expand All @@ -855,7 +852,7 @@ void *MetamodSource::MetaFactory(const char *iface, int *ret, PluginId *id)
}
return static_cast<void *>(static_cast<SourceHook::IHookManagerAutoGen *>(&g_SH_HookManagerAutoGen));
}
#endif

CPluginManager::CPlugin *pl;
List<IMetamodListener *>::iterator event;
IMetamodListener *api;
Expand Down
2 changes: 1 addition & 1 deletion core/sourcehook/generate/sourcehook.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace SourceHook
// SH tries to auto-detect these
// If you want to override SH's auto-detection, pass them in yourself
PassFlag_RetMem = (1<<6), /**< Object is returned in memory (through hidden first param */
PassFlag_RetReg = (1<<7) /**< Object is returned in EAX(:EDX)/RAX(x86_64) */
PassFlag_RetReg = (1<<7) /**< Object is returned in EAX(:EDX) (x86) / RAX(:RDX)/XMM0(:XMM1) (x86_64) */
};

size_t size; //!< Size of the data being passed
Expand Down
7 changes: 6 additions & 1 deletion core/sourcehook/sh_asm_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ namespace SourceHook
this->write_int32(imm);
}

void xor(x86_64_Reg dst, x86_64_Reg src) {
// can't name it `xor` because that's a C++ keyword (it works in VS tho but not clang)
void xor_reg(x86_64_Reg dst, x86_64_Reg src) {
this->write_ubyte(w_rex(src, dst));
this->write_ubyte(0x31);
this->write_ubyte(modrm(src, dst));
Expand Down Expand Up @@ -581,6 +582,10 @@ namespace SourceHook
void retn() {
this->write_ubyte(0xC3);
}

void leave() {
this->write_ubyte(0xC9);
}
};
}
}
4 changes: 2 additions & 2 deletions core/sourcehook/sourcehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ namespace SourceHook
// The following two flags are only relevant for byval return types.
// SH tries to auto-detect these
// If you want to override SH's auto-detection, pass them in yourself
PassFlag_RetMem = (1<<6), /**< Object is returned in memory (through hidden first param */
PassFlag_RetReg = (1<<7) /**< Object is returned in EAX(:EDX)/RAX(x86_64) */
PassFlag_RetMem = (1<<6), /**< Object is returned in memory (through hidden first param) */
PassFlag_RetReg = (1<<7) /**< Object is returned in EAX(:EDX) (x86) / RAX(:RDX)/XMM0(:XMM1) (x86_64) */
};

size_t size; //!< Size of the data being passed
Expand Down
6 changes: 1 addition & 5 deletions core/sourcehook/sourcehook_hookmangen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdio.h>
#include "sourcehook_impl.h"
#include "sourcehook_hookmangen.h"
#if defined( PLATFORM_64BITS ) && !defined( _LINUX )
#if defined( PLATFORM_64BITS )
#include "sourcehook_hookmangen_x86_64.h"
typedef SourceHook::Impl::x64GenContext SHGenContext;
#else
Expand Down Expand Up @@ -61,9 +61,6 @@ namespace SourceHook

HookManagerPubFunc CHookManagerAutoGen::MakeHookMan(const ProtoInfo *proto, int vtbl_offs, int vtbl_idx)
{
#if defined( PLATFORM_64BITS ) && defined( _LINUX )
return nullptr;
#else
CProto mproto(proto);
for (auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter)
{
Expand All @@ -85,7 +82,6 @@ namespace SourceHook
m_Contexts.emplace_back(std::move(sctx));
}
return pubFunc;
#endif
}

void CHookManagerAutoGen::ReleaseHookMan(HookManagerPubFunc pubFunc)
Expand Down
Loading
Loading
0