More demonware progress

This commit is contained in:
momo5502 2022-09-17 08:47:58 +02:00
parent 100dc49beb
commit e0b6ba12ee

View File

@ -296,7 +296,7 @@ namespace demonware
if (server) if (server)
{ {
server->handle_input(buf, len, { s, to, tolen }); server->handle_input(buf, len, {s, to, tolen});
return len; return len;
} }
@ -482,6 +482,7 @@ namespace demonware
#endif #endif
utils::hook::detour handle_auth_reply_hook; utils::hook::detour handle_auth_reply_hook;
bool handle_auth_reply_stub(void* a1, void* a2, void* a3) bool handle_auth_reply_stub(void* a1, void* a2, void* a3)
{ {
// Skip bdAuth::validateResponseSignature // Skip bdAuth::validateResponseSignature
@ -497,6 +498,20 @@ namespace demonware
//const auto* args = "StartServer"; //const auto* args = "StartServer";
//game::UI_RunMenuScript(0, &args); //game::UI_RunMenuScript(0, &args);
} }
void register_hook(const std::string& process, void* stub)
{
const utils::nt::library game_module{};
auto result = false;
result = result || utils::hook::iat(game_module, "wsock32.dll", process, stub);
result = result || utils::hook::iat(game_module, "WS2_32.dll", process, stub);
if (!result)
{
throw std::runtime_error("Failed to hook: " + process);
}
}
} }
class component final : public component_interface class component final : public component_interface
@ -504,62 +519,42 @@ namespace demonware
public: public:
component() component()
{ {
udp_servers.create<stun_server>("phoenix.stun.us.demonware.net");
udp_servers.create<stun_server>("phoenix.stun.eu.demonware.net");
udp_servers.create<stun_server>("phoenix.stun.jp.demonware.net");
udp_servers.create<stun_server>("phoenix.stun.au.demonware.net");
udp_servers.create<stun_server>("stun.us.demonware.net"); udp_servers.create<stun_server>("stun.us.demonware.net");
udp_servers.create<stun_server>("stun.eu.demonware.net"); udp_servers.create<stun_server>("stun.eu.demonware.net");
udp_servers.create<stun_server>("stun.jp.demonware.net"); udp_servers.create<stun_server>("stun.jp.demonware.net");
udp_servers.create<stun_server>("stun.au.demonware.net"); udp_servers.create<stun_server>("stun.au.demonware.net");
tcp_servers.create<auth3_server>("mwr-pc-steam-auth3.prod.demonware.net"); tcp_servers.create<auth3_server>("ops3-pc-auth3.prod.demonware.net");
tcp_servers.create<lobby_server>("mwr-pc-steam-lobby.prod.demonware.net"); tcp_servers.create<lobby_server>("ops3-pc-lobby.prod.demonware.net");
tcp_servers.create<umbrella_server>("prod.umbrella.demonware.net"); tcp_servers.create<umbrella_server>("prod.umbrella.demonware.net");
} }
/*void* load_import(const std::string& library, const std::string& function) override
{
if (library == "WS2_32.dll")
{
if (function == "#3") return io::closesocket_stub;
if (function == "#4") return io::connect_stub;
if (function == "#5") return io::getpeername_stub;
if (function == "#6") return io::getsockname_stub;
if (function == "#10") return io::ioctlsocket_stub;
if (function == "#16") return io::recv_stub;
if (function == "#17") return io::recvfrom_stub;
if (function == "#18") return io::select_stub;
if (function == "#19") return io::send_stub;
if (function == "#20") return io::sendto_stub;
if (function == "#52") return io::gethostbyname_stub;
if (function == "getaddrinfo") return io::getaddrinfo_stub;
if (function == "freeaddrinfo") return io::freeaddrinfo_stub;
}
if (function == "InternetGetConnectedState")
{
return io::internet_get_connected_state_stub;
}
return nullptr;
}*/
void post_unpack() override void post_unpack() override
{ {
server_thread = utils::thread::create_named_thread("Demonware", server_main); server_thread = utils::thread::create_named_thread("Demonware", server_main);
/*utils::hook::set<uint8_t>(0x7C0AD9_b, 0x0); // CURLOPT_SSL_VERIFYPEER register_hook("send", io::send_stub);
utils::hook::set<uint8_t>(0x7C0AC5_b, 0xAF); // CURLOPT_SSL_VERIFYHOST register_hook("recv", io::recv_stub);
utils::hook::set<uint8_t>(0xA1327C_b, 0x0); // HTTPS -> HTTP register_hook("sendto", io::sendto_stub);
register_hook("recvfrom", io::recvfrom_stub);
register_hook("connect", io::connect_stub);
register_hook("closesocket", io::closesocket_stub);
register_hook("ioctlsocket", io::ioctlsocket_stub);
register_hook("gethostbyname", io::gethostbyname_stub);
register_hook("getaddrinfo", io::getaddrinfo_stub);
register_hook("freeaddrinfo", io::freeaddrinfo_stub);
register_hook("getpeername", io::getpeername_stub);
register_hook("getsockname", io::getsockname_stub);
std::memcpy(reinterpret_cast<void*>(0x8D0298_b), //utils::hook::set<uint8_t>(0x7C0AD9_b, 0x0); // CURLOPT_SSL_VERIFYPEER
"http://prod.umbrella.demonware.net/v1.0/", sizeof("http://prod.umbrella.demonware.net/v1.0/")); //utils::hook::set<uint8_t>(0x7C0AC5_b, 0xAF); // CURLOPT_SSL_VERIFYHOST
std::memcpy(reinterpret_cast<void*>(0x8D05A8_b), //utils::hook::set<uint8_t>(0xA1327C_b, 0x0); // HTTPS -> HTTP
"http://prod.uno.demonware.net/v1.0/", sizeof("http://prod.uno.demonware.net/v1.0/"));
std::memcpy(reinterpret_cast<void*>(0x9EDB08_b), "http://%s:%d/auth/", sizeof("http://%s:%d/auth/"));
utils::hook::copy_string(0x1430B96E0_g, "http://prod.umbrella.demonware.net");
utils::hook::copy_string(0x1430B9BE0_g, "http://prod.uno.demonware.net/v1.0");
utils::hook::copy_string(0x1430B93C8_g, "http://%s:%d/auth/");
/*
// utils::hook::set<uint8_t>(0x19F8C0_b, 0xC3); // SV_SendMatchData, not sure // utils::hook::set<uint8_t>(0x19F8C0_b, 0xC3); // SV_SendMatchData, not sure
utils::hook::nop(0x19BB67_b, 5); // LiveStorage_SendMatchDataComplete (crashes at the end of match) utils::hook::nop(0x19BB67_b, 5); // LiveStorage_SendMatchDataComplete (crashes at the end of match)
utils::hook::nop(0x19BC3F_b, 5); // LiveStorage_GettingStoreConfigComplete probably (crashes randomly) utils::hook::nop(0x19BC3F_b, 5); // LiveStorage_GettingStoreConfigComplete probably (crashes randomly)