crlib: reworked detours.
This commit is contained in:
parent
e003474cae
commit
419626df0e
13 changed files with 274 additions and 205 deletions
|
|
@ -1144,12 +1144,12 @@ float LightMeasure::getSkyColor () {
|
|||
return static_cast <float> (Color (sv_skycolor_r.int_ (), sv_skycolor_g.int_ (), sv_skycolor_b.int_ ()).avg ());
|
||||
}
|
||||
|
||||
SharedLibrary::Handle EntityLinkage::lookup (SharedLibrary::Handle module, const char *function) {
|
||||
DETOUR_RETURN EntityLinkage::lookup (SharedLibrary::Handle module, const char *function) {
|
||||
static const auto &gamedll = game.lib ().handle ();
|
||||
static const auto &self = m_self.handle ();
|
||||
|
||||
const auto resolve = [&] (SharedLibrary::Handle handle) {
|
||||
return reinterpret_cast <SharedLibrary::Handle> (m_dlsym.call <decltype (HOOK_FUNCTION)> (static_cast <HOOK_CAST> (handle), function));
|
||||
return reinterpret_cast <DETOUR_RETURN> (m_dlsym (static_cast <DETOUR_HANDLE> (handle), function));
|
||||
};
|
||||
|
||||
// if requested module is yapb module, put in cache the looked up symbol
|
||||
|
|
@ -1180,6 +1180,6 @@ void EntityLinkage::initialize () {
|
|||
return;
|
||||
}
|
||||
|
||||
m_dlsym.patch (reinterpret_cast <SharedLibrary::Handle> (&HOOK_FUNCTION), reinterpret_cast <SharedLibrary::Handle> (&EntityLinkage::replacement));
|
||||
m_dlsym.install (reinterpret_cast <void *> (EntityLinkage::replacement), true);
|
||||
m_self.locate (&engfuncs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ void BotSupport::checkWelcome () {
|
|||
.writeShort (MessageWriter::fu16 (2.0f, 8.0f))
|
||||
.writeShort (MessageWriter::fu16 (6.0f, 8.0f))
|
||||
.writeShort (MessageWriter::fu16 (0.1f, 8.0f))
|
||||
.writeString (strings.format ("\nHello! You are playing with %s v%s (Build: %s)\nDevised by %s\n\n%s", product.name, product.version, product.build.count, product.author, graph.getAuthor ()));
|
||||
.writeString (strings.format ("\nHello! You are playing with %s v%s (Revision: %s)\nDevised by %s\n\n%s", product.name, product.version, product.build.count, product.author, graph.getAuthor ()));
|
||||
|
||||
m_welcomeReceiveTime = 0.0f;
|
||||
m_needToSendWelcome = false;
|
||||
|
|
@ -634,7 +634,7 @@ void BotSupport::sendPings (edict_t *to) {
|
|||
void BotSupport::installSendTo () {
|
||||
// if previously requested to disable?
|
||||
if (!cv_enable_query_hook.bool_ ()) {
|
||||
if (m_sendToHook.enabled ()) {
|
||||
if (m_sendToDetour.detoured ()) {
|
||||
disableSendTo ();
|
||||
}
|
||||
return;
|
||||
|
|
@ -646,8 +646,8 @@ void BotSupport::installSendTo () {
|
|||
}
|
||||
|
||||
// enable only on modern games
|
||||
if (game.is (GameFlags::Modern) && (plat.linux || plat.win32) && !plat.arm && !m_sendToHook.enabled ()) {
|
||||
m_sendToHook.patch (reinterpret_cast <void *> (&sendto), reinterpret_cast <void *> (&BotSupport::sendTo));
|
||||
if (game.is (GameFlags::Modern) && (plat.linux || plat.win32) && !plat.arm && !m_sendToDetour.detoured ()) {
|
||||
m_sendToDetour.install (reinterpret_cast <void *> (BotSupport::sendTo), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue