Skip to content

Instantly share code, notes, and snippets.

@ProdigySim
Created March 11, 2012 00:49
Show Gist options
  • Save ProdigySim/2014256 to your computer and use it in GitHub Desktop.
Save ProdigySim/2014256 to your computer and use it in GitHub Desktop.
Testing address functions of sourcemod
#include <sourcemod>
new Handle:g_hConf;
public OnPluginStart()
{
g_hConf = LoadGameConfigFile("addrtest");
RegConsoleCmd("addrtest_win", WinTest);
RegConsoleCmd("addrtest_lin", LinTest);
}
public Action:WinTest(client, args)
{
new Address:noRead = GameConfGetAddress(g_hConf, "CDirector_noread");
noRead = Address:LoadFromAddress(noRead+Address:8, NumberType_Int32); // "read" 8
noRead = Address:LoadFromAddress(noRead, NumberType_Int32); // "read" 0
new Address:read = GameConfGetAddress(g_hConf, "CDirector_read");
ReplyToCommand(client, "%s : %08x %08x", read == noRead ? "Same" : "Diff", noRead, read);
return Plugin_Handled;
}
public Action:LinTest(client, args)
{
new Address:noRead = GameConfGetAddress(g_hConf, "CDirector_noread");
noRead = Address:LoadFromAddress(noRead, NumberType_Int32); // "read" 0
new Address:read = GameConfGetAddress(g_hConf, "CDirector_read");
ReplyToCommand(client, "%s : %08x %08x", read == noRead ? "Same" : "Diff", noRead, read);
return Plugin_Handled;
}
"Games"
{
"left4dead2"
{
"Addresses"
{
"CDirector_noread"
{
"windows"
{
"signature" "DirectorMusicBanks_OnRoundStart"
}
"linux"
{
"signature" "TheDirector"
}
}
"CDirector_read"
{
"windows"
{
"signature" "DirectorMusicBanks_OnRoundStart"
"read" "8"
}
"linux"
{
"signature" "TheDirector"
}
"read" "0"
}
}
"Signatures"
{
/* Used solely to get the offset for TheDirector */
"DirectorMusicBanks_OnRoundStart"
{
"library" "server"
"windows" "\x83\xEC\x14\x57\x8B\xF9\x8B\x0D\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x84\xC0\x0F\x2A\x2A\x2A\x2A\x2A\x53\x55\x6A\x24\xE8"
/* 83 EC 14 57 8B F9 8B 0D ? ? ? ? E8 ? ? ? ? 84 C0 0F ? ? ? ? ? 53 55 6A 24 E8 */
}
/* Find the Director/ZombieManager singleton classes */
"TheDirector"
{
"library" "server"
"linux" "@TheDirector"
}
}
}
}
@ProdigySim
Copy link
Author

] addrtest_win
Same : 03104000 03104000

addrtest_lin
Same : 0a145ef0 0a145ef0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment