Source-Python-Dev-Team / Source.Python

This plugin aims to use boost::python and create an easily accessible wrapper around the Source Engine API for scripter use.
http://forums.sourcepython.com
GNU General Public License v3.0
164 stars 32 forks source link

Conflict with SourceMod (Windows) #108

Closed Nomy closed 6 years ago

Nomy commented 8 years ago

Hello, I had submitted a bug report over at SourceMod bug tracker and found the bug to be somehow present when SP is ran with other server plugins.

SourceMod Bug report Link: https://bugs.alliedmods.net/show_bug.cgi?id=6460

More info: version Protocol version 13518 [258/258] Exe version 1.35.1.8 (csgo) Exe build: 15:47:47 Jan 6 2016 (6240) (730)

sp version Current Source.Python version: 232

sm version SourceMod Version Information: SourceMod Version: 1.7.3-dev+5290 SourcePawn Engine: SourcePawn 1.7, jit-x86 (build 1.7.3-dev+5290) SourcePawn API: v1 = 4, v2 = 6 Compiled on: Jan 9 2016 09:02:48 Built from: https://github.com/alliedmodders/sourcemod/commit/1e71bd1 Build ID: 5290:1e71bd1 http://www.sourcemod.net/

meta version Metamod:Source version 1.10.7-dev Built from: https://github.com/alliedmodders/metamod-source/commit/019a388 Build ID: 948:019a388 Loaded As: Valve Server Plugin Compiled on: Sep 10 2015 Plugin interface version: 15:14 SourceHook version: 5:5 http://www.metamodsource.net/

Ayuto commented 8 years ago

Thanks for reporting! You can try loading SP after MM and SM, because our signature scanner also searches for hooked signatures. This isn't a perfect solution, but should suffice for now.

I guess we need to find a shared solution with AlliedModders.

Nomy commented 8 years ago

I tried loading SP using plugin_load command after the server loaded with SM and MM. SP failed to load with this error:

VAC secure mode is activated. GC Connection established for server version 258, instance idx 1 plugin_load addons/source-python [Source.Python] Loading... [Source.Python] Failed to load the main module. [Source.Python] Could not initialize python. [Source.Python] Unloading... [Source.Python] Failed to unload the main module. [Source.Python] Unloaded successfully.

[SP] Caught an Exception: Traceback (most recent call last): File '..\addons\source-python\packages\source-pythoninit.py', line 38, in load setup_sp_command() File '..\addons\source-python\packages\source-pythoninit.py', line 122, in setup_sp_command from core.command import _core_command File '..\addons\source-python\packages\source-python\core\command.py', line 14, in from auth.commands import _auth_commands File '..\addons\source-python\packages\source-python\auth\commands.py', line 16, in from auth.manager import auth_manager File '..\addons\source-python\packages\source-python\auth\manager.py', line 19, in from players.helpers import uniqueid_from_playerinfo File '..\addons\source-python\packages\source-python\players\helpers.py', line 13, in from players.games import get_client_language File '..\addons\source-python\packages\source-python\players\gamesinit.py', line 27, in _game_module = import_module('players.games.{0}'.format(GAME_NAME)) File '..\addons\source-python\packages\source-python\players\games\csgo.py', line 10, in from players._language.cache import get_client_language File '..\addons\source-python\packages\source-python\players_language\cache.py', line 13, in from listeners import on_client_disconnect_listener_manager File '..\addons\source-python\packages\source-python\listenersinit.py', line 54, in from listeners._entity_output import on_entity_output_listener_manager File '..\addons\source-python\packages\source-python\listeners_entity_output. py', line 40, in @PreHook(BaseEntityOutput.fire_output) File '..\addons\source-python\packages\source-python\memory\manager.py', line 611, in get func = binary[identifier].make_function(

ValueError: Could not find signature.

[SP] Caught an Exception: Traceback (most recent call last): File '..\addons\source-python\packages\source-pythoninit.py', line 47, in unload unload_plugins() File '..\addons\source-python\packages\source-pythoninit.py', line 205, in unload_plugins from core.command import _core_command File '..\addons\source-python\packages\source-python\core\command.py', line 14, in from auth.commands import _auth_commands File '..\addons\source-python\packages\source-python\auth\commands.py', line 16, in from auth.manager import auth_manager File '..\addons\source-python\packages\source-python\auth\manager.py', line 19, in from players.helpers import uniqueid_from_playerinfo File '..\addons\source-python\packages\source-python\players\helpers.py', line 13, in from players.games import get_client_language File '..\addons\source-python\packages\source-python\players\gamesinit.py', line 21, in from players.games import base as _base_module

ImportError: cannot import name 'base'

sp Unknown command "sp"

Ayuto commented 8 years ago

Oh, it seems like Sourcemod's CDetour is using absolute jumps for hooking, which generates different OP codes (FF 25 + 4 bytes for the absolute address). https://github.com/alliedmodders/sourcemod/blob/6fe4175fd2fd2b223cb509a24c5544bb54f34ef4/public/CDetour/detourhelpers.h#L75

Currently, SP only searches for hooks, which use relative jumps (E9 + 4 bytes for the relative address), because SPE was using relative jumps as well. https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/modules/memory/memory_scanner.cpp#L144

I will update our signature scanner to search for hooks with absolute jumps as well.

Ayuto commented 8 years ago

Please try the new version if the buildbot has finished it. You should make sure that you have always at least one entity output hook registered at SM, because they restore their hook if no entity output hook is registered anymore! If you want to unload SM, you need to unload SP at first.

Nomy commented 8 years ago

Thanks! It now loads without errors after SM has loaded.