Senior Member
|
01-13-2011
, 06:43
undefined symbol from my own plugin
|
#1
|
All files got included and my class have no dependency on .so or .a, under windows works but under linux it sucks:
Code:
plugin_load addons/plugintemplate_ep2v
failed to dlopen /home/tiago/srcds_l/orangebox/cstrike/addons/plugintemplate_ep2v.so error=/home/tiago/srcds_l/orangebox/cstrike/addons/plugintemplate_ep2v.so: undefined symbol: _ZN11CSigScanLib4LoadEP9KeyValues
Unable to load plugin "addons/plugintemplate_ep2v"
Unable to load plugin "addons/plugintemplate_ep2v"
sigscan.h
PHP Code:
#ifndef LIB_SIGSCAN_H #define LIB_SIGSCAN_H //================================================================================= // Defines //================================================================================= #define LIB_SIGSCAN_VERSION "1.0" #define LIB_SIGSCAN_CLASS CSigScanLib
#define SIGSCAN_ASSERT_FUNCTION(_address, _return) \ if(!pBase) return _return; \ if(!addressName) \ addressName = _address; \ void *pAddr = GetFunction(addressName, GamePlayer); \ if (!pAddr) return _return;
#ifdef WIN32 /* GCC's member function pointers all contain a this pointer adjustor. You'd probably set it to 0 */ #define SIGSCAN_END(o) \ void *addr; } u; u.addr = o; #else #define SIGSCAN_END(o) \ struct {void *addr; intptr_t adjustor;} s; } u; u.s.addr = o; u.s.adjustor = 0; #endif
#define SIGSCAN_0(p, o, r1, r2) \ union { r2(CPlugin_EmptyClass::*mfpnew)(void); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)();
#define SIGSCAN_1(p, o, r1, r2, t1, v1) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1);
#define SIGSCAN_2(p, o, r1, r2, t1, v1, t2, v2) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2);
#define SIGSCAN_3(p, o, r1, r2, t1, v1, t2, v2, t3, v3) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3);
#define SIGSCAN_4(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4);
#define SIGSCAN_5(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5);
#define SIGSCAN_6(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5, t6); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5, v6);
#define SIGSCAN_7(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5, t6, t7); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5, v6, v7);
#define SIGSCAN_8(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5, t6, t7, t8); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5, v6, v7, v8);
#define SIGSCAN_9(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5, t6, t7, t8, t9); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5, v6, v7, v8, v9);
#define SIGSCAN_10(p, o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9, t10, v10) \ union { r2(CPlugin_EmptyClass::*mfpnew)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); \ SIGSCAN_END(o) \ r1 (r2) (reinterpret_cast<CPlugin_EmptyClass*>(p)->*u.mfpnew)(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10);
#define SIGSCAN_STATIC_0(o, r1, r2) \ typedef r2 (*func)(); \ func thisfunc = (func)o; \ r1 (r2) thisfunc();
#define SIGSCAN_STATIC_1(o, r1, r2, t1, v1) \ typedef r2 (*func)(t1); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1);
#define SIGSCAN_STATIC_2(o, r1, r2, t1, v1, t2, v2) \ typedef r2 (*func)(t1, t2); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2);
#define SIGSCAN_STATIC_3(o, r1, r2, t1, v1, t2, v2, t3, v3) \ typedef r2 (*func)(t1, t2, t3); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3);
#define SIGSCAN_STATIC_4(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4) \ typedef r2 (*func)(t1, t2, t3, t4); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4);
#define SIGSCAN_STATIC_5(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) \ typedef r2 (*func)(t1, t2, t3, t4, t5); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5);
#define SIGSCAN_STATIC_6(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) \ typedef r2 (*func)(t1, t2, t3, t4, t5, t6); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5, v6);
#define SIGSCAN_STATIC_7(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) \ typedef r2 (*func)(t1, t2, t3, t4, t5, t6, t7); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5, v6, v7);
#define SIGSCAN_STATIC_8(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8) \ typedef r2 (*func)(t1, t2, t3, t4, t5, t6, t7, t8); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5, v6, v7, v8);
#define SIGSCAN_STATIC_9(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9) \ typedef r2 (*func)(t1, t2, t3, t4, t5, t6, t7, t8, t9); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5, v6, v7, v8, v9);
#define SIGSCAN_STATIC_10(o, r1, r2, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9, t10, v10) \ typedef r2 (*func)(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); \ func thisfunc = (func)o; \ r1 (r2) thisfunc(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10);
//================================================================================= // Class //================================================================================= class LIB_SIGSCAN_CLASS { public: // SigsScan Function struct SigScan_t { const char *Name; const char *Signature; // Windows const char *Symbol; // Linux void *pFunction; // Address to function };
// Load signature configs from a KeyValues file bool Load(KeyValues *kvSigscan);
// Add signature to list, but never write to file bool Add(const char *name, const char *signature, const char *symbol, void *pFunction);
// Add or Replace a signature to list, but never write to file bool AddOrReplace(const char *name, const char *signature, const char *symbol, void *pFunction);
// Replace a signature from list, but never write to file bool Replace(const char *name, const char *signature, const char *symbol, void *pFunction);
// Remove a signature from list, but never write to file bool Remove(const char *name);
// Get the index from list of a sigscan stored on the game configs ie. common.txt and cstrike.txt int GetIndex(const char *name, ...);
// Get the sigscan function address void *GetFunction(const char *name, ...);
/************************************************************************************ SigScan Functions *************************************************************************************/
// Get Advanced Effects ITempEntsSystem *GetTempEnts(const char *addressName /*= "te"*/);
// Switch a player to other team (CSS) // void SwitchTeam(int team_index); bool CSSPlayer_SwitchTeam(edict_t *pEntity, int team_index, const char *addressName /*= "CSSPlayer::SwitchTeam"*/);
// Switch a player to other team (CSS) // void SwitchTeam(int team_index); bool CSSPlayer_SwitchTeam(CBaseEntity *pBase, int team_index, const char *addressName /*= "CSSPlayer::SwitchTeam"*/);
// Respawn a player (CSS) // void RoundRespawn(void); bool CSSPlayer_RoundRespawn(edict_t *pEntity, const char *addressName /*= "CSSPlayer::RoundRespawn"*/);
// Respawn a player (CSS) // void RoundRespawn(void); bool CSSPlayer_RoundRespawn(CBaseEntity *pBase, const char *addressName /*= "CSSPlayer::RoundRespawn"*/);
/************************************************************************************ Static Methods *************************************************************************************/
#ifdef WIN32 static bool GetDllMemInfo(void *pAddr, unsigned char **base_addr, size_t *base_len); static void *FindSignature(unsigned char *pBaseAddress, size_t baseLength, unsigned char *pSignature); #endif
// Holds all signatures // Use only to loop CUtlVector<SigScan_t> vec_sigscan;
// Current game player const char *GamePlayer; };
#endif
sigscan.cpp
PHP Code:
//================================================================================= // Includes //================================================================================= #define NO_INCLUDE_LIBRARIES #include "includes/default.h" #include "serverplugin/serverplugin_engine.h" #include "libs/lib_string.h" #include "libs/lib_entity.h" #include "libs/lib_sigscan.h"
//================================================================================= // Utilities //================================================================================= #ifdef WIN32 static unsigned char HexToBin(char hex_char) { char upper_char = toupper(hex_char); return ((upper_char >= '0' && upper_char <= '9') ? upper_char - 48:upper_char - 55); }
static bool ValidHexChar(char hex_char) { char upper_char = toupper(hex_char); return ((upper_char >= '0' && upper_char <= '9') || (upper_char >= 'A' && upper_char <= 'F')); }
//================================================================================= // Functions //================================================================================= // Load signature configs from a KeyValues file bool LIB_SIGSCAN_CLASS::Load(KeyValues *kvSigscan) { if(!kvSigscan) return false; if(kvSigscan->IsEmpty()) { //kvSigscan->deleteThis(); return true; } KeyValues *kvLoop; #ifdef WIN32 unsigned char *base = 0; size_t len = 0; bool success = GetDllMemInfo(VAR_IFACE_GAMESERVERDLL, &base, &len); if(!success) return false; #else
#endif for(kvLoop = kvSigscan->GetFirstSubKey(); kvLoop; kvLoop = kvLoop->GetNextKey()) { if(kvLoop->GetInt("enable", 1) <= 0) continue; // Not enabled const char *name = kvLoop->GetName(); if(!name) continue; const char *signature = kvLoop->GetString("signature", NULL); const char *symbol = kvLoop->GetString("symbol", NULL); void *pFunction = NULL; #ifdef WIN32 if(!signature) { DevMsg("[WARNING] SigScan: %s got no signature, skip this\n", name); continue; } pFunction = FindSignature(base, len, (unsigned char *)signature); if(!pFunction) continue; AddOrReplace(name, signature, symbol, pFunction); #else if(!symbol) { DevMsg("[WARNING] SigScan: %s got no symbol, skip this\n", name); continue; } #endif if(!pFunction) continue; DevMsg("SigScan: %s got address @ %p\n", name, pFunction); AddOrReplace(name, signature, symbol, pFunction); //kvLoop->deleteThis(); } //kvSigscan->deleteThis(); return true; } /// ... /// ...
dont know why is happening, object is compiled ...
Last edited by sn4k3; 01-13-2011 at 06:48.
|
|