From 6f6564cc4dc0c8a885c6d20fd4ff0a4a51d21a30 Mon Sep 17 00:00:00 2001 From: Ivailo Spasov Date: Mon, 21 Jan 2013 22:27:24 +0200 Subject: [PATCH] Fix windows build and some minor fixes Signed-off-by: Ivailo Spasov --- l4d1_signature_linux.h | 18 ++++++++--------- l4d1_signature_win32.h | 18 ++++++++--------- l4d2_signature_win32.h | 18 ++++++++--------- l4dtoolz_mm.cpp | 42 +++++++++++++++++++--------------------- msvc8/l4dtoolz_mm.vcproj | 8 ++++++++ signature.cpp | 15 ++++++++------ signature.h | 8 ++++---- 7 files changed, 68 insertions(+), 59 deletions(-) diff --git a/l4d1_signature_linux.h b/l4d1_signature_linux.h index 2c81898..76f7dd9 100644 --- a/l4d1_signature_linux.h +++ b/l4d1_signature_linux.h @@ -10,50 +10,50 @@ const char* matchmaking_dll_alt = "matchmaking.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"; 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> &, bool) //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_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> &, bool) //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"; 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) //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"; 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) //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_new = "\x02\x10\x90\x90"; -char* human_limit_org = NULL; +void* human_limit_org = NULL; //_ZL10maxplayersRK8CCommand //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_new = "\x02\x07\x90\x90"; -char* players_org = NULL; +void* players_org = NULL; const char* players_new2 = "\x03\x1D\x89\xC2\xEB"; -char* players_org2 = NULL; +void* players_org2 = NULL; //CBaseServer::SetReservationCookie(unsigned long long, char const*, ...) //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_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"; unsigned char lobby_match_new[] = {0x01, 0x04, 0xC3}; -char* lobby_match_org = NULL; +void* lobby_match_org = NULL; #endif //_INCLUDE_L4D1_SIGNATURE_LINUX_ diff --git a/l4d1_signature_win32.h b/l4d1_signature_win32.h index b9d9c52..41d2bde 100644 --- a/l4d1_signature_win32.h +++ b/l4d1_signature_win32.h @@ -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"; 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"; 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"; -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"; 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_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_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* 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_new = "\x01\x00\xC3"; -char* unreserved_org = NULL; +void* unreserved_org = NULL; const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3"; unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3}; -char* lobby_match_org = NULL; +void* lobby_match_org = NULL; #endif //_INCLUDE_L4D1_SIGNATURE_WIN32_ diff --git a/l4d2_signature_win32.h b/l4d2_signature_win32.h index d560bed..5c4a1d2 100644 --- a/l4d2_signature_win32.h +++ b/l4d2_signature_win32.h @@ -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"; 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"; 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"; -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"; 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_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_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* 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_new = "\x01\x00\xC3"; -char* unreserved_org = NULL; +void* unreserved_org = NULL; const char* lobby_match = "\x06\xB8\x08\x00\x00\x00\xC3"; unsigned char lobby_match_new[] = {0x01, 0x01, 0xC3}; -char* lobby_match_org = NULL; +void* lobby_match_org = NULL; #endif //_INCLUDE_L4D2_SIGNATURE_WIN32_ diff --git a/l4dtoolz_mm.cpp b/l4dtoolz_mm.cpp index ee33077..c48c59f 100644 --- a/l4dtoolz_mm.cpp +++ b/l4dtoolz_mm.cpp @@ -31,9 +31,9 @@ void l4dtoolz::OnChangeMaxplayers ( IConVar *var, const char *pOldValue, float f return; } 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; - if(lobby_match_ptr != NULL) { + if(lobby_match_ptr) { lobby_match_new[2] = new_value; write_signature(lobby_match_ptr, lobby_match_new); } 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(max_players_server_browser, server_bplayers_org); - if(lobby_match_ptr != NULL) + if(lobby_match_ptr) 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 ) { if(tmp_player == NULL || tmp_player2 == NULL) { - Msg("L4DToolZ init error\n"); return; } write_signature(tmp_player, players_org); + free(players_org); + players_org = NULL; write_signature(tmp_player2, players_org2); + free(players_org2); + players_org2 = NULL; } 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); - if(base_addr.addr == NULL) - find_base(matchmaking_dll_alt, &base_addr); - if(!lobby_match_ptr) { 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); if(!max_players_friend_lobby) { 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) { 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) { @@ -171,12 +171,12 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool #else lobby_sux_ptr = find_signature(lobby_sux, &base_addr, 0); #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 if(!max_players_server_browser) { - max_players_server_browser = find_signature(server_bplayers, &base_addr 0); - get_original_signature(max_players_server_browser, server_bplayers_new, &server_bplayers_org); + max_players_server_browser = find_signature(server_bplayers, &base_addr, 0); + get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org); } #endif if(!tmp_player) { @@ -188,9 +188,9 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool tmp_player2 = tmp_player; #endif 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); - get_original_signature(tmp_player2, players_new2, &players_org2); + get_original_signature(tmp_player2, players_new2, players_org2); write_signature(tmp_player2, players_new2); engine->ServerCommand("maxplayers 32\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) { 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); if(!chuman_limit) { 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 if(!max_players_server_browser) { 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 @@ -231,8 +231,6 @@ bool l4dtoolz::Unload(char *error, size_t maxlen) write_signature(lobby_sux_ptr, lobby_sux_org); write_signature(max_players_server_browser, server_bplayers_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(lobby_match_ptr, lobby_match_org); @@ -241,9 +239,9 @@ bool l4dtoolz::Unload(char *error, size_t maxlen) free(lobby_sux_org); free(server_bplayers_org); free(human_limit_org); - free(players_org); - free(players_org2); free(unreserved_org); + free(lobby_match_org); + return true; } diff --git a/msvc8/l4dtoolz_mm.vcproj b/msvc8/l4dtoolz_mm.vcproj index ce32cf9..c7848b3 100644 --- a/msvc8/l4dtoolz_mm.vcproj +++ b/msvc8/l4dtoolz_mm.vcproj @@ -840,6 +840,10 @@ RelativePath="..\l4dtoolz_mm.cpp" > + + + +