Updated gdc-psyfork with current (NPOTB).
- Added support for custom symbols.txt path (-s <path>). - Added support for dlsym symbol lookup in linux bins (-n). - Updated gdc_core.sh example script to account for new options above. - Updated symbols.txt.
This commit is contained in:
parent
a66adcbc88
commit
f757d5f09b
@ -8,6 +8,9 @@ ENGINE_BIN=${ENGINE_PATH}/bin/engine
|
|||||||
GAME_BIN=${ENGINE_PATH}/${GAME_DIR}/bin/server
|
GAME_BIN=${ENGINE_PATH}/${GAME_DIR}/bin/server
|
||||||
STEAMINF=${ENGINE_PATH}/${GAME_DIR}/steam.inf
|
STEAMINF=${ENGINE_PATH}/${GAME_DIR}/steam.inf
|
||||||
|
|
||||||
|
GDC_PATH=${SM_PATH}/tools/gdc-psyfork
|
||||||
|
GDC_BIN=${GDC_PATH}/Release/gdc
|
||||||
|
|
||||||
if [ "${GAMEDATA_DIR}" == "" ] ; then
|
if [ "${GAMEDATA_DIR}" == "" ] ; then
|
||||||
GAMEDATA_DIR=${GAME_DIR}
|
GAMEDATA_DIR=${GAME_DIR}
|
||||||
fi
|
fi
|
||||||
@ -107,16 +110,34 @@ cd ${SM_PATH}/tools/gdc-psyfork
|
|||||||
hg pull -u
|
hg pull -u
|
||||||
|
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
|
|
||||||
|
cd ${ENGINE_PATH}
|
||||||
|
|
||||||
for i in "${gamedata_files[@]}"
|
for i in "${gamedata_files[@]}"
|
||||||
do
|
do
|
||||||
./Release/gdc \
|
NO_SYMTABLE=
|
||||||
-g ${GAME_DIR} \
|
|
||||||
|
readelf --sections ${GAME_BIN}${BIN_EXT}.so | grep --quiet .symtab
|
||||||
|
if [ "${PIPESTATUS[1]}" != "0" ] ; then
|
||||||
|
NO_SYMTABLE=" -n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
readelf --sections ${GAME_BIN}${BIN_EXT}.so | grep --quiet .strtab
|
||||||
|
if [ "${PIPESTATUS[1]}" != "0" ] ; then
|
||||||
|
NO_SYMTABLE=" -n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# having an issue upon exit after loading some source2007 server bins, invalid free in sendtable dtor, idk. suppress.
|
||||||
|
MALLOC_CHECK_=0 ${GDC_BIN} \
|
||||||
|
-g ${GAMEDATA_DIR} \
|
||||||
-e ${ENGINE_NAME} \
|
-e ${ENGINE_NAME} \
|
||||||
-f ${SM_PATH}/gamedata/$i \
|
-f ${SM_PATH}/gamedata/$i \
|
||||||
-b ${GAME_BIN}${BIN_EXT}.so \
|
-b ${GAME_BIN}${BIN_EXT}.so \
|
||||||
-x ${ENGINE_BIN}${BIN_EXT}.so \
|
-x ${ENGINE_BIN}${BIN_EXT}.so \
|
||||||
-w ${GAME_BIN}.dll \
|
-w ${GAME_BIN}.dll \
|
||||||
-y ${ENGINE_BIN}.dll
|
-y ${ENGINE_BIN}.dll \
|
||||||
|
-s ${GDC_PATH}/symbols.txt \
|
||||||
|
${NO_SYMTABLE}
|
||||||
echo -e "------------------------------------------------------\n"
|
echo -e "------------------------------------------------------\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -16,12 +16,23 @@ char *game_binary = NULL;
|
|||||||
char *engine_binary = NULL;
|
char *engine_binary = NULL;
|
||||||
char *wgame_binary = NULL;
|
char *wgame_binary = NULL;
|
||||||
char *wengine_binary = NULL;
|
char *wengine_binary = NULL;
|
||||||
|
char *symbols_file = NULL;
|
||||||
|
|
||||||
|
bool use_symtab = true;
|
||||||
|
|
||||||
inline bool IsDigit( char c )
|
inline bool IsDigit( char c )
|
||||||
{
|
{
|
||||||
return c < 58 && c > 47;
|
return c < 58 && c > 47;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintUsage()
|
||||||
|
{
|
||||||
|
printf("Usage: ./gdc -g <game> -e <engine name> -f <gamedata file> -b <game binary> -x <engine binary> -w <win game binary> -y <win engine binary> [-s <symbols.txt file>]\n");
|
||||||
|
printf("Other options:\n");
|
||||||
|
printf(" -d\tAdd debug output\n");
|
||||||
|
printf(" -n\tDon't use symbol table for lookups (falls back to dlsym)\n");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *gamedata = NULL;
|
char *gamedata = NULL;
|
||||||
@ -29,12 +40,18 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "b:de:f:g:x:w:y:")) != -1)
|
while ((opt = getopt(argc, argv, "b:nde:f:g:x:w:y:s:")) != -1)
|
||||||
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
debug = true;
|
debug = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
use_symtab = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
game = optarg;
|
game = optarg;
|
||||||
break;
|
break;
|
||||||
@ -63,18 +80,23 @@ int main(int argc, char **argv)
|
|||||||
wengine_binary = optarg;
|
wengine_binary = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
symbols_file = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
printf("Usage: ./gdc -g <game> -e <engine name> -f <gamedata file> -b <game binary> -x <engine binary> -w <win game binary> -y <win engine binary>\n");
|
PrintUsage();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("WHAT\n");
|
printf("WHAT\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!game || !engine || !gamedata || !game_binary || !engine_binary || !wgame_binary || !wengine_binary)
|
if (!game || !engine || !gamedata || !game_binary || !engine_binary || !wgame_binary || !wengine_binary)
|
||||||
{
|
{
|
||||||
printf("Usage: ./gdc -g <game> -e <engine name> -f <gamedata file> -b <game binary> -x <engine binary> -w <win game binary> -y <win engine binary>\n");
|
PrintUsage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +147,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CGameConfig symbols;
|
CGameConfig symbols;
|
||||||
if (!symbols.EnterFile("symbols.txt", err, sizeof(err)))
|
if (!symbols.EnterFile(symbols_file ? symbols_file : "symbols.txt", err, sizeof(err)))
|
||||||
{
|
{
|
||||||
printf("symbols.txt: %s\n", err);
|
printf("symbols.txt: %s\n", err);
|
||||||
return 0;
|
return 0;
|
||||||
@ -178,7 +200,16 @@ int main(int argc, char **argv)
|
|||||||
int newOffset;
|
int newOffset;
|
||||||
if (symvt[0])
|
if (symvt[0])
|
||||||
{
|
{
|
||||||
void **newvt = (void**) mu.ResolveSymbol(ghandle, symvt);
|
void **newvt = NULL;
|
||||||
|
if( use_symtab )
|
||||||
|
{
|
||||||
|
newvt = (void**)mu.ResolveSymbol(ghandle, symvt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newvt = (void **)dlsym(ghandle, symvt);
|
||||||
|
}
|
||||||
|
|
||||||
if (!newvt)
|
if (!newvt)
|
||||||
{
|
{
|
||||||
printf("? O: %-22s - can't find, skipping\n", symvt);
|
printf("? O: %-22s - can't find, skipping\n", symvt);
|
||||||
@ -362,13 +393,15 @@ int checkSigStringW(int file, const char* symbol)
|
|||||||
|
|
||||||
int checkSigStringL(void *handle, const char* symbol)
|
int checkSigStringL(void *handle, const char* symbol)
|
||||||
{
|
{
|
||||||
bool isAt = (symbol[0] == '@');
|
bool isAt = (symbol[0] == '@' && symbol[1] != '\0');
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
bool dummy;
|
bool dummy;
|
||||||
|
|
||||||
if (isAt)
|
if (isAt)
|
||||||
{
|
{
|
||||||
if( mu.ResolveSymbol(handle, symbol + 1) )
|
if( use_symtab && mu.ResolveSymbol(handle, &symbol[1]) )
|
||||||
|
matches = 1;
|
||||||
|
else if( !use_symtab && dlsym(handle, &symbol[1]) )
|
||||||
matches = 1;
|
matches = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -403,15 +436,30 @@ void findFuncPos(const char *sym, int &func, int ¶ms)
|
|||||||
|
|
||||||
int findVFunc(void *handle, void **vt, const char *symbol)
|
int findVFunc(void *handle, void **vt, const char *symbol)
|
||||||
{
|
{
|
||||||
int offset = 1;
|
if( !use_symtab )
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 1000; i++ )
|
||||||
|
{
|
||||||
|
void *pFunc = vt[i];
|
||||||
|
if( !pFunc )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( pFunc == dlsym(handle, symbol ) )
|
||||||
|
return i - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int funcPos, paramPos;
|
int funcPos, paramPos;
|
||||||
findFuncPos(symbol, funcPos, paramPos);
|
findFuncPos(symbol, funcPos, paramPos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
void *pFunc = vt[i];
|
void *pFunc = vt[i];
|
||||||
|
if( !pFunc )
|
||||||
|
continue;
|
||||||
|
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
if (!(s = mu.ResolveAddr(handle, pFunc)))
|
if (!(s = mu.ResolveAddr(handle, pFunc)))
|
||||||
@ -426,12 +474,11 @@ int findVFunc(void *handle, void **vt, const char *symbol)
|
|||||||
|
|
||||||
if (strcmp(s + tempFuncPos, symbol + funcPos) == 0)
|
if (strcmp(s + tempFuncPos, symbol + funcPos) == 0)
|
||||||
{
|
{
|
||||||
offset = i;
|
return i - 2;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset - 2;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int strncopy(char *dest, const char *src, size_t count)
|
unsigned int strncopy(char *dest, const char *src, size_t count)
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
"ShouldGib" "_ZN9CTFPlayer9ShouldGibERK15CTakeDamageInfob"
|
"ShouldGib" "_ZN9CTFPlayer9ShouldGibERK15CTakeDamageInfob"
|
||||||
"GetRadius" "_ZN13CTFBaseRocket9GetRadiusEv"
|
"GetRadius" "_ZN13CTFBaseRocket9GetRadiusEv"
|
||||||
"DeflectPlayer" "_ZN13CTFWeaponBase13DeflectPlayerEP9CTFPlayerS1_R6VectorS3_S3_"
|
"DeflectPlayer" "_ZN13CTFWeaponBase13DeflectPlayerEP9CTFPlayerS1_R6VectorS3_S3_"
|
||||||
|
"GetDataDescMap" "_ZN11CBaseEntity14GetDataDescMapEv"
|
||||||
|
|
||||||
// CSSDM
|
// CSSDM
|
||||||
"IPointsForKill" "_ZN14CTeamplayRules14IPointsForKillEP11CBasePlayerS1_"
|
"IPointsForKill" "_ZN14CTeamplayRules14IPointsForKillEP11CBasePlayerS1_"
|
||||||
@ -84,6 +85,12 @@
|
|||||||
|
|
||||||
// NapalmLagFix
|
// NapalmLagFix
|
||||||
"RadiusDamage" "_ZN10CGameRules12RadiusDamageERK15CTakeDamageInfoRK6VectorfiP11CBaseEntity"
|
"RadiusDamage" "_ZN10CGameRules12RadiusDamageERK15CTakeDamageInfoRK6VectorfiP11CBaseEntity"
|
||||||
|
|
||||||
|
// V
|
||||||
|
"CTFFlameThrower::FireProjectile" "_ZN16CTFWeaponBaseGun14FireProjectileEP9CTFPlayer"
|
||||||
|
"CTFFlameThrower::FireFlameRocket" "_ZN16CTFWeaponBaseGun15FireFlameRocketEP9CTFPlayer"
|
||||||
|
"CTFPlayer::GetMaxHealth" "_ZNK11CBaseEntity12GetMaxHealthEv"
|
||||||
|
"CBaseEntity::GetBaseEntity" "_ZN11CBaseEntity13GetBaseEntityEv"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Options"
|
"Options"
|
||||||
@ -180,4 +187,17 @@
|
|||||||
"GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib"
|
"GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"#default"
|
||||||
|
{
|
||||||
|
"#supported"
|
||||||
|
{
|
||||||
|
"game" "synergy"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Keys"
|
||||||
|
{
|
||||||
|
"GiveNamedItem" "_ZN11CBasePlayer13GiveNamedItemEPKcib"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user