More fixes

This commit is contained in:
Federico Cecchetto 2022-02-28 15:13:03 +01:00
parent 0eda36b7a1
commit f4903da8eb
2 changed files with 2 additions and 64 deletions

View File

@ -160,12 +160,6 @@ namespace auth
const auto xuid = strtoull(steam_id.data(), nullptr, 16); const auto xuid = strtoull(steam_id.data(), nullptr, 16);
if (xuid == auth::get_guid())
{
network::send(*from, "error", "You are already connected to this server!", '\n');
return;
}
if (xuid != key.get_hash()) if (xuid != key.get_hash())
{ {
//MessageBoxA(nullptr, steam_id.data(), std::to_string(key.get_hash()).data(), 0); //MessageBoxA(nullptr, steam_id.data(), std::to_string(key.get_hash()).data(), 0);

View File

@ -11,8 +11,6 @@
namespace network namespace network
{ {
SOCKET sock;
namespace namespace
{ {
@ -114,7 +112,7 @@ namespace network
} }
address.sin_family = AF_INET; address.sin_family = AF_INET;
address.sin_port = ntohs(port); address.sin_port = ntohs(static_cast<short>(port));
const auto sock = ::socket(AF_INET, SOCK_DGRAM, protocol); const auto sock = ::socket(AF_INET, SOCK_DGRAM, protocol);
@ -142,7 +140,7 @@ namespace network
{ {
sockaddr s = {}; sockaddr s = {};
game::NetadrToSockadr(a3, &s); game::NetadrToSockadr(a3, &s);
return sendto(sock, src, size, 0, &s, 16) >= 0; return sendto(*game::query_socket, src, size, 0, &s, 16) >= 0;
} }
void send(const game::netadr_s& address, const std::string& command, const std::string& data, const char separator) void send(const game::netadr_s& address, const std::string& command, const std::string& data, const char separator)
@ -152,10 +150,6 @@ namespace network
packet.push_back(separator); packet.push_back(separator);
packet.append(data); packet.append(data);
#ifdef DEBUG
console::info("[Network] Sending command %s\n", command.data());
#endif
send_data(address, packet); send_data(address, packet);
} }
@ -221,53 +215,6 @@ namespace network
return dvar; return dvar;
} }
utils::hook::detour bind_socket_hook;
SOCKET bind_socket_stub(const char* net_interface, u_short port, int protocol)
{
#ifdef DEBUG
printf("[Socket] Attempting to create socket\n");
#endif
sock = socket(2, 2, protocol);
u_long argp;
char optval;
struct sockaddr name;
memset(&name, 0, sizeof(name));
name.sa_family = 2;
if (sock == -1)
{
#ifdef DEBUG
printf("[Socket] Error creating socket\n");
#endif
WSAGetLastError();
return 0;
}
argp = 1;
optval = 1;
if (ioctlsocket(sock, -2147195266, &argp) == -1 || setsockopt(sock, 0xFFFF, 32, &optval, 4) == -1)
return 0;
*(WORD*)name.sa_data = ntohs(port);
if (bind(sock, &name, 16) != -1)
{
#ifdef DEBUG
printf("[Socket] Socket binded!\n");
#endif
return sock;
}
#ifdef DEBUG
printf("[Socket] Closing socket\n");
#endif
closesocket(sock);
return 0;
}
class component final : public component_interface class component final : public component_interface
{ {
public: public:
@ -279,9 +226,6 @@ namespace network
return; return;
} }
// creating our own variable for socket use
bind_socket_hook.create(0x140512B40, bind_socket_stub);
// redirect dw_sendto to raw socket // redirect dw_sendto to raw socket
//utils::hook::jump(0x1404D850A, reinterpret_cast<void*>(0x1404D849A)); //utils::hook::jump(0x1404D850A, reinterpret_cast<void*>(0x1404D849A));
utils::hook::call(0x140513467, dw_send_to_stub); // H1MP64(1.4) utils::hook::call(0x140513467, dw_send_to_stub); // H1MP64(1.4)