Fix windows build and some minor fixes

Signed-off-by: Ivailo Spasov <ivailosp@abv.bg>
This commit is contained in:
Ivailo Spasov 2013-01-21 22:27:24 +02:00
parent 2b9ddf260d
commit 6f6564cc4d
7 changed files with 68 additions and 59 deletions

View File

@ -10,50 +10,50 @@ const char* matchmaking_dll_alt = "matchmaking.so";
//fuction is in engine.so //fuction is in engine.so
const char* friends_lobby = "\x18\x55\x89\xE5\x56\x53\x83\xEC\x10\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\xC3\x8B\xC3\xC3\x8B\x83"; const char* friends_lobby = "\x18\x55\x89\xE5\x56\x53\x83\xEC\x10\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\xC3\x8B\xC3\xC3\x8B\x83";
unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3}; unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3};
char* friends_lobby_org = NULL; void* friends_lobby_org = NULL;
//CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int, CUtlVector<CLC_SplitPlayerConnect, CUtlMemory<CLC_SplitPlayerConnect, int>> &, bool) //CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int, CUtlVector<CLC_SplitPlayerConnect, CUtlMemory<CLC_SplitPlayerConnect, int>> &, bool)
//fuction is in engine.so //fuction is in engine.so
const char* lobby_sux = "\x0B\x8B\x86\x78\x01\x00\x00\x85\xC0\x74\xC3\x8B"; const char* lobby_sux = "\x0B\x8B\x86\x78\x01\x00\x00\x85\xC0\x74\xC3\x8B";
const char* lobby_sux_new = "\x02\x08\x90\x90"; const char* lobby_sux_new = "\x02\x08\x90\x90";
char* lobby_sux_org = NULL; void* lobby_sux_org = NULL;
//CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int, CUtlVector<CLC_SplitPlayerConnect, CUtlMemory<CLC_SplitPlayerConnect, int>> &, bool) //CBaseServer::ConnectClient(netadr_s &, int, int, int, char const*, char const*, char const*, int, CUtlVector<CLC_SplitPlayerConnect, CUtlMemory<CLC_SplitPlayerConnect, int>> &, bool)
//fuction is in engine.so //fuction is in engine.so
const char* max_players = "\x10\xFF\xC3\xC3\x03\xC3\xC3\x29\xC7\x3B\xBE\x78\x01\x00\x00\x0F\x8F"; const char* max_players = "\x10\xFF\xC3\xC3\x03\xC3\xC3\x29\xC7\x3B\xBE\x78\x01\x00\x00\x0F\x8F";
char max_players_new[]= {0x06, 0x08, 0x83, 0xFF, 0x3C, 0x90, 0x90, 0x90}; char max_players_new[]= {0x06, 0x08, 0x83, 0xFF, 0x3C, 0x90, 0x90, 0x90};
char* max_players_org = NULL; void* max_players_org = NULL;
//CServerGameClients::GetMaxHumanPlayers(void) //CServerGameClients::GetMaxHumanPlayers(void)
//fuction is in server.so //fuction is in server.so
const char* server_bplayers ="\x21\x55\x89\xE5\x53\x83\xEC\x14\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\xC3\x8B\x83\xC3\xC3\xC3\xC3\x8B\x10\xB8\xFF\xFF\xFF\xFF\x85\xD2"; const char* server_bplayers ="\x21\x55\x89\xE5\x53\x83\xEC\x14\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\xC3\x8B\x83\xC3\xC3\xC3\xC3\x8B\x10\xB8\xFF\xFF\xFF\xFF\x85\xD2";
unsigned char server_bplayers_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3}; unsigned char server_bplayers_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3};
char* server_bplayers_org = NULL; void* server_bplayers_org = NULL;
//CTerrorGameRules::ClientConnected(edict_t *, char const*, char const*, char *, int) //CTerrorGameRules::ClientConnected(edict_t *, char const*, char const*, char *, int)
//fuction is in server.so //fuction is in server.so
const char* human_limit = "\x11\x8B\x55\xC3\x8B\x02\x89\x14\xC3\xFF\x90\xC3\x02\x00\x00\x39\xF8\x7E"; const char* human_limit = "\x11\x8B\x55\xC3\x8B\x02\x89\x14\xC3\xFF\x90\xC3\x02\x00\x00\x39\xF8\x7E";
const char* human_limit_new = "\x02\x10\x90\x90"; const char* human_limit_new = "\x02\x10\x90\x90";
char* human_limit_org = NULL; void* human_limit_org = NULL;
//_ZL10maxplayersRK8CCommand //_ZL10maxplayersRK8CCommand
//fuction is in engine.so //fuction is in engine.so
const char* players = "\x13\x83\xBB\xC3\xC3\xC3\xC3\x01\x7F\xC3\x8B\x80\x0C\xC3\xC3\x00\x89\xC3\xC3\xE8"; const char* players = "\x13\x83\xBB\xC3\xC3\xC3\xC3\x01\x7F\xC3\x8B\x80\x0C\xC3\xC3\x00\x89\xC3\xC3\xE8";
const char* players_new = "\x02\x07\x90\x90"; const char* players_new = "\x02\x07\x90\x90";
char* players_org = NULL; void* players_org = NULL;
const char* players_new2 = "\x03\x1D\x89\xC2\xEB"; const char* players_new2 = "\x03\x1D\x89\xC2\xEB";
char* players_org2 = NULL; void* players_org2 = NULL;
//CBaseServer::SetReservationCookie(unsigned long long, char const*, ...) //CBaseServer::SetReservationCookie(unsigned long long, char const*, ...)
//function in engine.so //function in engine.so
const char* unreserved = "\x1F\x55\x89\xE5\x57\x56\x53\x81\xEC\x4C\x01\x00\x00\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\x00\x8B\x75\xC3\x8B\x55\xC3\x8B\x45"; const char* unreserved = "\x1F\x55\x89\xE5\x57\x56\x53\x81\xEC\x4C\x01\x00\x00\xE8\xC3\xC3\xC3\xC3\x81\xC3\xC3\xC3\xC3\x00\x8B\x75\xC3\x8B\x55\xC3\x8B\x45";
const char* unreserved_new = "\x01\x00\xC3"; const char* unreserved_new = "\x01\x00\xC3";
char* unreserved_org = NULL; void* unreserved_org = NULL;
const char* lobby_match = "\x0A\x55\x89\xE5\xB8\x08\x00\x00\x00\x5D\xC3"; const char* lobby_match = "\x0A\x55\x89\xE5\xB8\x08\x00\x00\x00\x5D\xC3";
unsigned char lobby_match_new[] = {0x01, 0x04, 0xC3}; unsigned char lobby_match_new[] = {0x01, 0x04, 0xC3};
char* lobby_match_org = NULL; void* lobby_match_org = NULL;
#endif //_INCLUDE_L4D1_SIGNATURE_LINUX_ #endif //_INCLUDE_L4D1_SIGNATURE_LINUX_

View File

@ -8,39 +8,39 @@ const char* matchmaking_dll_alt = "matchmaking.dll";
const char* friends_lobby = "\x12\x56\x8B\xF1\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x01\x8B\x50\x48"; const char* friends_lobby = "\x12\x56\x8B\xF1\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x01\x8B\x50\x48";
unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3}; unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3};
char* friends_lobby_org = NULL; void* friends_lobby_org = NULL;
const char* max_players = "\x28\x83\xBE\xC3\xC3\x00\x00\x00\x74\xC3\x8B\x54\xC3\xC3\x8B\x06\x8B\x7A\xC3\x8B\x50\x10\x8B\xCE\xFF\xD2\x2B\xF8\x8B\x06\x8B\x50\x08\x8B\xCE\xFF\xD2\x03\xC7\x3B\x86"; const char* max_players = "\x28\x83\xBE\xC3\xC3\x00\x00\x00\x74\xC3\x8B\x54\xC3\xC3\x8B\x06\x8B\x7A\xC3\x8B\x50\x10\x8B\xCE\xFF\xD2\x2B\xF8\x8B\x06\x8B\x50\x08\x8B\xCE\xFF\xD2\x03\xC7\x3B\x86";
unsigned char max_players_new[]= {0x06, 0x26, 0x83, 0xF8, 0x3C, 0x90, 0x90, 0x90}; unsigned char max_players_new[]= {0x06, 0x26, 0x83, 0xF8, 0x3C, 0x90, 0x90, 0x90};
char* max_players_org = NULL; void* max_players_org = NULL;
const char* lobby_sux_new = "\x02\x07\x90\x90"; const char* lobby_sux_new = "\x02\x07\x90\x90";
char* lobby_sux_org = NULL; void* lobby_sux_org = NULL;
const char* server_bplayers = "\x1D\x56\x8B\xF1\xE8\xC3\xC3\xC3\xC3\x8B\x4C\x24\x08\x89\x01\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x11\x8B\x42\x48"; const char* server_bplayers = "\x1D\x56\x8B\xF1\xE8\xC3\xC3\xC3\xC3\x8B\x4C\x24\x08\x89\x01\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x11\x8B\x42\x48";
unsigned char server_bplayers_new[] = {0x05, 0x1A, 0xB8, 0x3C, 0x00, 0x00, 0x00}; unsigned char server_bplayers_new[] = {0x05, 0x1A, 0xB8, 0x3C, 0x00, 0x00, 0x00};
char* server_bplayers_org = NULL; void* server_bplayers_org = NULL;
const char* human_limit = "\x15\x8B\x13\x8B\x82\xC3\xC3\x00\x00\x8B\xCB\xFF\xD0\x3B\xF8\x7C\xC3\x8B\xC3\xC3\xC3\x8B"; const char* human_limit = "\x15\x8B\x13\x8B\x82\xC3\xC3\x00\x00\x8B\xCB\xFF\xD0\x3B\xF8\x7C\xC3\x8B\xC3\xC3\xC3\x8B";
const char* human_limit_new = "\x01\x0E\xEB"; const char* human_limit_new = "\x01\x0E\xEB";
char* human_limit_org = NULL; void* human_limit_org = NULL;
const char* players = "\x15\x83\x3D\xC3\xC3\xC3\xC3\x02\x7C\xC3\x83\xC4\x08\xC7\x44\xC3\xC3\xC3\xC3\xC3\xC3\xFF"; const char* players = "\x15\x83\x3D\xC3\xC3\xC3\xC3\x02\x7C\xC3\x83\xC4\x08\xC7\x44\xC3\xC3\xC3\xC3\xC3\xC3\xFF";
const char* players_new = "\x01\x07\xEB"; const char* players_new = "\x01\x07\xEB";
char* players_org = NULL; void* players_org = NULL;
const char* players2 = "\x10\x56\x8B\xF1\x8B\x86\xC3\x02\x00\x00\x8B\x4C\x24\x08\x3B\xC8\x7F"; const char* players2 = "\x10\x56\x8B\xF1\x8B\x86\xC3\x02\x00\x00\x8B\x4C\x24\x08\x3B\xC8\x7F";
const char* players_new2 = "\x02\x0F\x90\x90"; const char* players_new2 = "\x02\x0F\x90\x90";
char* players_org2 = NULL; void* players_org2 = NULL;
const char* unreserved = "\x1E\x81\xEC\xC3\xC3\x00\x00\x55\x8B\xAC\xC3\xC3\xC3\x00\x00\x56\x8B\xB4\xC3\xC3\xC3\x00\x00\x57\x8B\xBC\xC3\xC3\xC3\x00\x00"; const char* unreserved = "\x1E\x81\xEC\xC3\xC3\x00\x00\x55\x8B\xAC\xC3\xC3\xC3\x00\x00\x56\x8B\xB4\xC3\xC3\xC3\x00\x00\x57\x8B\xBC\xC3\xC3\xC3\x00\x00";
const char* unreserved_new = "\x01\x00\xC3"; const char* unreserved_new = "\x01\x00\xC3";
char* unreserved_org = NULL; void* unreserved_org = NULL;
const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3"; const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3";
unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3}; unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3};
char* lobby_match_org = NULL; void* lobby_match_org = NULL;
#endif //_INCLUDE_L4D1_SIGNATURE_WIN32_ #endif //_INCLUDE_L4D1_SIGNATURE_WIN32_

View File

@ -8,39 +8,39 @@ const char* matchmaking_dll_alt = "matchmaking.dll";
const char* friends_lobby = "\x12\x56\x8B\xF1\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x01\x8B\x50\x48"; const char* friends_lobby = "\x12\x56\x8B\xF1\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x01\x8B\x50\x48";
unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3}; unsigned char friends_lobby_new[] = {0x06, 0x00, 0xB8, 0x3C, 0x00, 0x00, 0x00, 0xC3};
char* friends_lobby_org = NULL; void* friends_lobby_org = NULL;
const char* max_players = "\x28\x83\xBE\xC3\xC3\x00\x00\x00\x74\xC3\x8B\x54\xC3\xC3\x8B\x06\x8B\x7A\xC3\x8B\x50\x10\x8B\xCE\xFF\xD2\x2B\xF8\x8B\x06\x8B\x50\x08\x8B\xCE\xFF\xD2\x03\xC7\x3B\x86"; const char* max_players = "\x28\x83\xBE\xC3\xC3\x00\x00\x00\x74\xC3\x8B\x54\xC3\xC3\x8B\x06\x8B\x7A\xC3\x8B\x50\x10\x8B\xCE\xFF\xD2\x2B\xF8\x8B\x06\x8B\x50\x08\x8B\xCE\xFF\xD2\x03\xC7\x3B\x86";
unsigned char max_players_new[]= {0x06, 0x26, 0x83, 0xF8, 0x3C, 0x90, 0x90, 0x90}; unsigned char max_players_new[]= {0x06, 0x26, 0x83, 0xF8, 0x3C, 0x90, 0x90, 0x90};
char* max_players_org = NULL; void* max_players_org = NULL;
const char* lobby_sux_new = "\x02\x07\x90\x90"; const char* lobby_sux_new = "\x02\x07\x90\x90";
char* lobby_sux_org = NULL; void* lobby_sux_org = NULL;
const char* server_bplayers = "\x1D\x56\x8B\xF1\xE8\xC3\xC3\xC3\xC3\x8B\x4C\x24\x08\x89\x01\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x11\x8B\x42\x48"; const char* server_bplayers = "\x1D\x56\x8B\xF1\xE8\xC3\xC3\xC3\xC3\x8B\x4C\x24\x08\x89\x01\x8B\x0D\xC3\xC3\xC3\xC3\x85\xC9\x74\xC3\x8B\x11\x8B\x42\x48";
unsigned char server_bplayers_new[] = {0x05, 0x1A, 0xB8, 0x3C, 0x00, 0x00, 0x00}; unsigned char server_bplayers_new[] = {0x05, 0x1A, 0xB8, 0x3C, 0x00, 0x00, 0x00};
char* server_bplayers_org = NULL; void* server_bplayers_org = NULL;
const char* human_limit = "\x15\x8B\x13\x8B\x82\xC3\xC3\x00\x00\x8B\xCB\xFF\xD0\x3B\xF8\x7C\xC3\x8B\xC3\xC3\xC3\x8B"; const char* human_limit = "\x15\x8B\x13\x8B\x82\xC3\xC3\x00\x00\x8B\xCB\xFF\xD0\x3B\xF8\x7C\xC3\x8B\xC3\xC3\xC3\x8B";
const char* human_limit_new = "\x01\x0E\xEB"; const char* human_limit_new = "\x01\x0E\xEB";
char* human_limit_org = NULL; void* human_limit_org = NULL;
const char* players = "\x15\x83\x3D\xC3\xC3\xC3\xC3\x02\x7C\xC3\x83\xC4\x08\xC7\x44\xC3\xC3\xC3\xC3\xC3\xC3\xFF"; const char* players = "\x15\x83\x3D\xC3\xC3\xC3\xC3\x02\x7C\xC3\x83\xC4\x08\xC7\x44\xC3\xC3\xC3\xC3\xC3\xC3\xFF";
const char* players_new = "\x01\x07\xEB"; const char* players_new = "\x01\x07\xEB";
char* players_org = NULL; void* players_org = NULL;
const char* players2 = "\x10\x56\x8B\xF1\x8B\x86\xC3\x02\x00\x00\x8B\x4C\x24\x08\x3B\xC8\x7F"; const char* players2 = "\x10\x56\x8B\xF1\x8B\x86\xC3\x02\x00\x00\x8B\x4C\x24\x08\x3B\xC8\x7F";
const char* players_new2 = "\x02\x0F\x90\x90"; const char* players_new2 = "\x02\x0F\x90\x90";
char* players_org2 = NULL; void* players_org2 = NULL;
const char* unreserved = "\x1E\x81\xEC\xC3\xC3\x00\x00\x55\x8B\xAC\xC3\xC3\xC3\x00\x00\x56\x8B\xB4\xC3\xC3\xC3\x00\x00\x57\x8B\xBC\xC3\xC3\xC3\x00\x00"; const char* unreserved = "\x1E\x81\xEC\xC3\xC3\x00\x00\x55\x8B\xAC\xC3\xC3\xC3\x00\x00\x56\x8B\xB4\xC3\xC3\xC3\x00\x00\x57\x8B\xBC\xC3\xC3\xC3\x00\x00";
const char* unreserved_new = "\x01\x00\xC3"; const char* unreserved_new = "\x01\x00\xC3";
char* unreserved_org = NULL; void* unreserved_org = NULL;
const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3"; const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3";
unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3}; unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3};
char* lobby_match_org = NULL; void* lobby_match_org = NULL;
#endif //_INCLUDE_L4D2_SIGNATURE_WIN32_ #endif //_INCLUDE_L4D2_SIGNATURE_WIN32_

View File

@ -31,9 +31,9 @@ void l4dtoolz::OnChangeMaxplayers ( IConVar *var, const char *pOldValue, float f
return; return;
} }
if(new_value != old_value) { if(new_value != old_value) {
if(new_value) { if(new_value >= 0) {
max_players_new[4] = friends_lobby_new[3] = server_bplayers_new[3] = new_value; max_players_new[4] = friends_lobby_new[3] = server_bplayers_new[3] = new_value;
if(lobby_match_ptr != NULL) { if(lobby_match_ptr) {
lobby_match_new[2] = new_value; lobby_match_new[2] = new_value;
write_signature(lobby_match_ptr, lobby_match_new); write_signature(lobby_match_ptr, lobby_match_new);
} else { } else {
@ -49,7 +49,7 @@ void l4dtoolz::OnChangeMaxplayers ( IConVar *var, const char *pOldValue, float f
write_signature(lobby_sux_ptr, lobby_sux_org); write_signature(lobby_sux_ptr, lobby_sux_org);
write_signature(max_players_server_browser, server_bplayers_org); write_signature(max_players_server_browser, server_bplayers_org);
if(lobby_match_ptr != NULL) if(lobby_match_ptr)
write_signature(lobby_match_ptr, lobby_match_org); write_signature(lobby_match_ptr, lobby_match_org);
} }
} }
@ -76,11 +76,14 @@ void l4dtoolz::OnChangeRemovehumanlimit ( IConVar *var, const char *pOldValue, f
void l4dtoolz::OnChangeIvailosp ( IConVar *var, const char *pOldValue, float flOldValue ) void l4dtoolz::OnChangeIvailosp ( IConVar *var, const char *pOldValue, float flOldValue )
{ {
if(tmp_player == NULL || tmp_player2 == NULL) { if(tmp_player == NULL || tmp_player2 == NULL) {
Msg("L4DToolZ init error\n");
return; return;
} }
write_signature(tmp_player, players_org); write_signature(tmp_player, players_org);
free(players_org);
players_org = NULL;
write_signature(tmp_player2, players_org2); write_signature(tmp_player2, players_org2);
free(players_org2);
players_org2 = NULL;
} }
void l4dtoolz::OnChangeUnreserved ( IConVar *var, const char *pOldValue, float flOldValue ) void l4dtoolz::OnChangeUnreserved ( IConVar *var, const char *pOldValue, float flOldValue )
@ -147,22 +150,19 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
find_base(matchmaking_dll, &base_addr); find_base(matchmaking_dll, &base_addr);
if(base_addr.addr == NULL)
find_base(matchmaking_dll_alt, &base_addr);
if(!lobby_match_ptr) { if(!lobby_match_ptr) {
lobby_match_ptr = find_signature(lobby_match, &base_addr, 1); lobby_match_ptr = find_signature(lobby_match, &base_addr, 1);
get_original_signature(lobby_match, lobby_match_new, &lobby_match_org); get_original_signature(lobby_match_ptr, lobby_match_new, lobby_match_org);
} }
find_base(engine_dll, &base_addr); find_base(engine_dll, &base_addr);
if(!max_players_friend_lobby) { if(!max_players_friend_lobby) {
max_players_friend_lobby = find_signature(friends_lobby, &base_addr, 0); max_players_friend_lobby = find_signature(friends_lobby, &base_addr, 0);
get_original_signature(max_players_friend_lobby, friends_lobby_new, &friends_lobby_org); get_original_signature(max_players_friend_lobby, friends_lobby_new, friends_lobby_org);
} }
if(!max_players_connect) { if(!max_players_connect) {
max_players_connect = find_signature(max_players, &base_addr, 0); max_players_connect = find_signature(max_players, &base_addr, 0);
get_original_signature(max_players_connect, max_players_new, &max_players_org); get_original_signature(max_players_connect, max_players_new, max_players_org);
} }
if(!lobby_sux_ptr) { if(!lobby_sux_ptr) {
@ -171,12 +171,12 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
#else #else
lobby_sux_ptr = find_signature(lobby_sux, &base_addr, 0); lobby_sux_ptr = find_signature(lobby_sux, &base_addr, 0);
#endif #endif
get_original_signature(lobby_sux_ptr, lobby_sux_new, &lobby_sux_org); get_original_signature(lobby_sux_ptr, lobby_sux_new, lobby_sux_org);
} }
#ifdef WIN32 #ifdef WIN32
if(!max_players_server_browser) { if(!max_players_server_browser) {
max_players_server_browser = find_signature(server_bplayers, &base_addr 0); max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
get_original_signature(max_players_server_browser, server_bplayers_new, &server_bplayers_org); get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
} }
#endif #endif
if(!tmp_player) { if(!tmp_player) {
@ -188,9 +188,9 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
tmp_player2 = tmp_player; tmp_player2 = tmp_player;
#endif #endif
if(tmp_player2) { if(tmp_player2) {
get_original_signature(tmp_player, players_new, &players_org); get_original_signature(tmp_player, players_new, players_org);
write_signature(tmp_player, players_new); write_signature(tmp_player, players_new);
get_original_signature(tmp_player2, players_new2, &players_org2); get_original_signature(tmp_player2, players_new2, players_org2);
write_signature(tmp_player2, players_new2); write_signature(tmp_player2, players_new2);
engine->ServerCommand("maxplayers 32\n"); engine->ServerCommand("maxplayers 32\n");
engine->ServerCommand("L4DToolZ ivailosp@abv.bg\n"); engine->ServerCommand("L4DToolZ ivailosp@abv.bg\n");
@ -199,20 +199,20 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
} }
if(!unreserved_ptr) { if(!unreserved_ptr) {
unreserved_ptr = find_signature(unreserved, &base_addr, 0); unreserved_ptr = find_signature(unreserved, &base_addr, 0);
get_original_signature(unreserved_ptr, unreserved_new, &unreserved_org); get_original_signature(unreserved_ptr, unreserved_new, unreserved_org);
} }
find_base(server_dll, &base_addr); find_base(server_dll, &base_addr);
if(!chuman_limit) { if(!chuman_limit) {
chuman_limit = find_signature(human_limit, &base_addr, 0); chuman_limit = find_signature(human_limit, &base_addr, 0);
get_original_signature(chuman_limit, human_limit_new, &human_limit_org); get_original_signature(chuman_limit, human_limit_new, human_limit_org);
} }
#ifndef WIN32 #ifndef WIN32
if(!max_players_server_browser) { if(!max_players_server_browser) {
max_players_server_browser = find_signature(server_bplayers, &base_addr, 0); max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
get_original_signature(max_players_server_browser, server_bplayers_new, &server_bplayers_org); get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
} }
#endif #endif
@ -231,8 +231,6 @@ bool l4dtoolz::Unload(char *error, size_t maxlen)
write_signature(lobby_sux_ptr, lobby_sux_org); write_signature(lobby_sux_ptr, lobby_sux_org);
write_signature(max_players_server_browser, server_bplayers_org); write_signature(max_players_server_browser, server_bplayers_org);
write_signature(chuman_limit, human_limit_org); write_signature(chuman_limit, human_limit_org);
write_signature(tmp_player, players_org);
write_signature(tmp_player2, players_org2);
write_signature(unreserved_ptr, unreserved_org); write_signature(unreserved_ptr, unreserved_org);
write_signature(lobby_match_ptr, lobby_match_org); write_signature(lobby_match_ptr, lobby_match_org);
@ -241,9 +239,9 @@ bool l4dtoolz::Unload(char *error, size_t maxlen)
free(lobby_sux_org); free(lobby_sux_org);
free(server_bplayers_org); free(server_bplayers_org);
free(human_limit_org); free(human_limit_org);
free(players_org);
free(players_org2);
free(unreserved_org); free(unreserved_org);
free(lobby_match_org);
return true; return true;
} }

View File

@ -840,6 +840,10 @@
RelativePath="..\l4dtoolz_mm.cpp" RelativePath="..\l4dtoolz_mm.cpp"
> >
</File> </File>
<File
RelativePath="..\signature.cpp"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
@ -866,6 +870,10 @@
RelativePath="..\l4dtoolz_mm.h" RelativePath="..\l4dtoolz_mm.h"
> >
</File> </File>
<File
RelativePath="..\signature.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"

View File

@ -55,7 +55,7 @@ void *find_signature(const char* mask, struct base_addr_t *base_addr, int pure)
tmp = pBasePtr; tmp = pBasePtr;
for(i = 1; i <= mask[SIGN_LEN_BYTE]; ++i) { for(i = 1; i <= mask[SIGN_LEN_BYTE]; ++i) {
if(pure && mask[i] == '\xC3'){ if(!pure && mask[i] == '\xC3'){
tmp++; tmp++;
continue; continue;
} }
@ -167,7 +167,7 @@ int write_signature(const void* addr, const void* signature)
#ifdef WIN32 #ifdef WIN32
HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
WriteProcessMemory(hProcess, (void *)(u_addr+sign_off), (void *)(u_addr_sign+SIGN_HEADER_LEN), sign_len, NULL); WriteProcessMemory(h_process, (void *)(u_addr+sign_off), (void *)(u_addr_sign+SIGN_HEADER_LEN), sign_len, NULL);
CloseHandle(h_process); CloseHandle(h_process);
#else #else
@ -183,25 +183,27 @@ int read_signature(const void *addr, void *signature)
{ {
unsigned int u_addr_sign; unsigned int u_addr_sign;
unsigned int sign_len; unsigned int sign_len;
unsigned int sign_off;
unsigned int u_addr; unsigned int u_addr;
sign_len = ((unsigned char *)signature)[SIGN_LEN_BYTE]; sign_len = ((unsigned char *)signature)[SIGN_LEN_BYTE];
sign_off = ((unsigned char *)signature)[SIGN_OFFSET_BYTE];
u_addr = (unsigned int)addr; u_addr = (unsigned int)addr;
u_addr_sign = (unsigned int)signature; u_addr_sign = (unsigned int)signature;
#ifdef WIN32 #ifdef WIN32
HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
ReadProcessMemory(h_process, (void *)(u_addr+sign_len), (void *)(u_addr_sign+SIGN_HEADER_LEN), sign_len, NULL); ReadProcessMemory(h_process, (void *)(u_addr+sign_off), (void *)(u_addr_sign+SIGN_HEADER_LEN), sign_len, NULL);
CloseHandle(h_process); CloseHandle(h_process);
#else #else
lock_region(addr, sign_len, 1); lock_region(addr, sign_len, 1);
memcpy((void *)(u_addr_sign+SIGN_HEADER_LEN), (void *)(u_addr+sign_len), sign_len); memcpy((void *)(u_addr_sign+SIGN_HEADER_LEN), (void *)(u_addr+sign_off), sign_len);
lock_region(addr, sign_len, 0); lock_region(addr, sign_len, 0);
#endif #endif
return 0; return 0;
} }
int get_original_signature(const void *offset, const void *new_sig, void **org_sig) int get_original_signature(const void *offset, const void *new_sig, void *&org_sig)
{ {
unsigned int sign_len; unsigned int sign_len;
@ -209,7 +211,8 @@ int get_original_signature(const void *offset, const void *new_sig, void **org_s
return 0; return 0;
sign_len = ((unsigned char *)new_sig)[SIGN_LEN_BYTE]; sign_len = ((unsigned char *)new_sig)[SIGN_LEN_BYTE];
*org_sig = malloc(sign_len + SIGN_HEADER_LEN); org_sig = malloc(sign_len + SIGN_HEADER_LEN);
memset(org_sig, 0, sign_len + SIGN_HEADER_LEN);
memcpy(org_sig, new_sig, SIGN_HEADER_LEN); memcpy(org_sig, new_sig, SIGN_HEADER_LEN);
return read_signature(offset, org_sig); return read_signature(offset, org_sig);
} }

View File

@ -6,10 +6,10 @@ struct base_addr_t{
unsigned int len; unsigned int len;
}; };
void *find_signature(const char* mask, struct base_addr_t* base_addr, int pure); void *find_signature(const char *mask, struct base_addr_t *base_addr, int pure);
int find_base(const char* name, struct base_addr_t * base_addr); int find_base(const char *name, struct base_addr_t *base_addr);
int write_signature(const void* addr, const void* signature); int write_signature(const void *addr, const void *signature);
int read_signature(const void *addr, void *signature); int read_signature(const void *addr, void *signature);
int get_original_signature(const void *offset, const void *new_sig, void** org_sig); int get_original_signature(const void *offset, const void *new_sig, void *&org_sig);
#endif //_INCLUDE_SIGNATURE_ #endif //_INCLUDE_SIGNATURE_