experiments pt8

This commit is contained in:
quaK 2022-10-01 17:18:43 +03:00
parent e8616b25df
commit 184855ad14
5 changed files with 124 additions and 69 deletions

View File

@ -17,6 +17,11 @@ namespace dedicated
{
namespace
{
bool party_is_server_dedicated_stub()
{
return true;
}
void sync_gpu_stub()
{
std::this_thread::sleep_for(1ms);
@ -109,6 +114,9 @@ namespace dedicated
dvars::override::register_bool("intro", false, game::DVAR_FLAG_READ);
// Is party dedicated
utils::hook::jump(0x5DFC10_b, party_is_server_dedicated_stub);
// Hook R_SyncGpu
utils::hook::jump(0xE08AE0_b, sync_gpu_stub, true);
@ -192,46 +200,51 @@ namespace dedicated
//utils::hook::set<uint8_t>(0x3A1940_b, 0xC3); // DB_ReadPackedLoadedSounds // not done
// iw7 patches
utils::hook::set<uint8_t>(0xE06060_b, 0xC3); // directx
utils::hook::set<uint8_t>(0xE05B80_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xDD2760_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE05E20_b, 0xC3); // ^ buffer
utils::hook::set<uint8_t>(0xE11270_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xDD3C50_b, 0xC3); // ^
utils::hook::set(0xE06060_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE06060_b, 0xC3); // directx
utils::hook::set(0xE05B80_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE05B80_b, 0xC3); // ^
utils::hook::set(0xDD2760_b, 0xC3C033); //utils::hook::set<uint8_t>(0xDD2760_b, 0xC3); // ^
utils::hook::set(0xE05E20_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE05E20_b, 0xC3); // ^ buffer
utils::hook::set(0xE11270_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE11270_b, 0xC3); // ^
utils::hook::set(0xDD3C50_b, 0xC3C033); //utils::hook::set<uint8_t>(0xDD3C50_b, 0xC3); // ^
utils::hook::set(0x0C1210_b, 0xC3C033); //utils::hook::set<uint8_t>(0x0C1210_b, 0xC3); // ^ idk
utils::hook::set<uint8_t>(0x0C12B0_b, 0xC3); // ^ idk
utils::hook::set<uint8_t>(0xE423A0_b, 0xC3); // directx
utils::hook::set<uint8_t>(0xE04680_b, 0xC3); // ^
utils::hook::set(0x0C12B0_b, 0xC3C033); //utils::hook::set<uint8_t>(0x0C12B0_b, 0xC3); // ^ idk
utils::hook::set(0xE423A0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE423A0_b, 0xC3); // directx
utils::hook::set(0xE04680_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE04680_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE00ED0_b, 0xC3); // Image_Create1DTexture_PC
utils::hook::set<uint8_t>(0xE00FC0_b, 0xC3); // Image_Create2DTexture_PC
utils::hook::set<uint8_t>(0xE011A0_b, 0xC3); // Image_Create3DTexture_PC
utils::hook::set<uint8_t>(0xE015C0_b, 0xC3); // Image_CreateCubeTexture_PC
utils::hook::set<uint8_t>(0xE01300_b, 0xC3); // Image_CreateArrayTexture_PC
utils::hook::set(0xE00ED0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE00ED0_b, 0xC3); // Image_Create1DTexture_PC
utils::hook::set(0xE00FC0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE00FC0_b, 0xC3); // Image_Create2DTexture_PC
utils::hook::set(0xE011A0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE011A0_b, 0xC3); // Image_Create3DTexture_PC
utils::hook::set(0xE015C0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE015C0_b, 0xC3); // Image_CreateCubeTexture_PC
utils::hook::set(0xE01300_b, 0xC3C033); //utils::hook::set<uint8_t>(0xE01300_b, 0xC3); // Image_CreateArrayTexture_PC
utils::hook::set<uint8_t>(0x5F1EA0_b, 0xC3); // renderer
utils::hook::set<uint8_t>(0x0C1370_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xDD26E0_b, 0xC3); // directx
utils::hook::set<uint8_t>(0x5F0610_b, 0xC3); // ^
utils::hook::set<uint8_t>(0x5F0580_b, 0xC3); // ^
utils::hook::set<uint8_t>(0x5F0820_b, 0xC3); // ^
utils::hook::set<uint8_t>(0x5F0790_b, 0xC3); // ^
utils::hook::set(0x5F1EA0_b, 0xC3C033); //utils::hook::set<uint8_t>(0x5F1EA0_b, 0xC3); // renderer
utils::hook::set(0x0C1370_b, 0xC3C033); //utils::hook::set<uint8_t>(0x0C1370_b, 0xC3); // ^
utils::hook::set(0xDD26E0_b, 0xC3C033); //utils::hook::set<uint8_t>(0xDD26E0_b, 0xC3); // directx
utils::hook::set(0x5F0610_b, 0xC3C033); //utils::hook::set<uint8_t>(0x5F0610_b, 0xC3); // ^
utils::hook::set(0x5F0580_b, 0xC3C033); //utils::hook::set<uint8_t>(0x5F0580_b, 0xC3); // ^
utils::hook::set(0x5F0820_b, 0xC3C033); //utils::hook::set<uint8_t>(0x5F0820_b, 0xC3); // ^
utils::hook::set(0x5F0790_b, 0xC3C033); //utils::hook::set<uint8_t>(0x5F0790_b, 0xC3); // ^
utils::hook::set(0xDD42A0_b, 0xC3C033); // shutdown
utils::hook::set(0xDD42E0_b, 0xC3C033); // ^
utils::hook::set(0xDD42E0_b, 0xC3C033); // ^
utils::hook::set(0xDD4280_b, 0xC3C033); // ^
// r_loadForRenderer
utils::hook::set<uint8_t>(0xE114A0_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE11380_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE113D0_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE476F0_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE11420_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xDD2300_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xDD2610_b, 0xC3); // ^
utils::hook::set<uint8_t>(0xE11F40_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE114A0_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE11380_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE113D0_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE476F0_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE11420_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xDD2300_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xDD2610_b, 0xC3); // ^
//utils::hook::set<uint8_t>(0xE11F40_b, 0xC3); // ^
// skip R_GetFrameIndex check in DB_LoadLevelXAssets
utils::hook::set<uint8_t>(0x3B9E72_b, 0xEB);
// don't release buffer
utils::hook::set<uint8_t>(0xDD4430_b, 0xEB);
utils::hook::set<uint8_t>(0xDD4430_b, 0xC3);
// R_LoadWorld
utils::hook::set<uint8_t>(0xDD14C0_b, 0xC3);
@ -240,7 +253,13 @@ namespace dedicated
utils::hook::set<uint8_t>(0xD02CB0_b, 0xC3);
// renderer
utils::hook::set<uint8_t>(0xDD4370_b, 0xC3);
//utils::hook::set<uint8_t>(0xDD4370_b, 0xC3);
// image stream (pak)
utils::hook::set<uint8_t>(0xA7DB10_b, 0xC3); // DB_CreateGfxImageStreamInternal
// sound stream (sabl, sabs)
//utils::hook::nop(0xCFDC03_b, 2);
command::add("startserver", []()
{

View File

@ -60,16 +60,6 @@ namespace network
return cl_dispatch_connectionless_packet_hook.invoke<bool>(client_num, from, msg, time);
}
void sockadr_to_netadr(const sockaddr* s, game::netadr_s* a)
{
if (s->sa_family == 2)
{
a->type = game::NA_IP;
*(int*)&a->ip = *(int*)&s->sa_data[2];
a->port = *(unsigned short*)(&s->sa_data[0]);
}
}
int dw_send_to_stub(const int length, const char* data, game::netadr_s* to)
{
if (!*game::query_socket || *game::query_socket == INVALID_SOCKET)
@ -85,6 +75,16 @@ namespace network
return sendto(*game::query_socket, data, length, 0, &s, sizeof(sockaddr));
}
void sockadr_to_netadr(const sockaddr* s, game::netadr_s* a)
{
if (s->sa_family == 2)
{
a->type = game::NA_IP;
*(int*)&a->ip = *(int*)&s->sa_data[2];
a->port = *(unsigned short*)(&s->sa_data[0]);
}
}
int dw_recv_from_stub(game::netadr_s* from, char* data, int maxsize)
{
sockaddr s = {};
@ -166,28 +166,28 @@ namespace network
if (sock == INVALID_SOCKET)
{
console::warn("WARNING: UDP_OpenSocket: socket\n");
return INVALID_SOCKET;
return 0;
}
u_long arg = 1;
if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR)
{
console::warn("WARNING: UDP_OpenSocket: ioctl FIONBIO\n");
return INVALID_SOCKET;
return 0;
}
char optval[4] = { 0 };
optval[0] = 1;
if (setsockopt(sock, 0xFFFF, SO_BROADCAST, optval, 4) == SOCKET_ERROR)
char optval[4] = { 1, 0, 0, 0 };
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, optval, sizeof(optval)) == SOCKET_ERROR)
{
console::warn("WARNING: UDP_OpenSocket: setsockopt SO_BROADCAST\n");
return INVALID_SOCKET;
return 0;
}
if (bind(sock, reinterpret_cast<sockaddr*>(&address), sizeof(address)) == SOCKET_ERROR)
{
console::warn("WARNING: UDP_OpenSocket: bind\n");
closesocket(sock);
return INVALID_SOCKET;
return 0;
}
return sock;
@ -203,13 +203,13 @@ namespace network
{
*game::query_socket = create_socket(
net_ip->current.string, net_port->current.integer + port_diff, IPPROTO_UDP);
if (*game::query_socket != INVALID_SOCKET)
if (*game::query_socket)
{
break;
}
}
if (*game::query_socket == INVALID_SOCKET)
if (!*game::query_socket)
{
console::warn("WARNING: Couldn't allocate IP/UDP port, LAN discovery will not work!\n");
return;
@ -230,6 +230,11 @@ namespace network
return PROTOCOL;
}
int dw_get_addr_handle_connection_task_status_stub()
{
return 1; // TASK_COMPLETE
}
void reconnect_migratated_client(void*, game::netadr_s* from, const int, const int, const char*,
const char*, bool)
{
@ -330,7 +335,7 @@ namespace network
utils::hook::set<uint8_t>(0xC56030_b, 0xEB);
utils::hook::set<uint8_t>(0xC5341A_b, 0xEB);
utils::hook::set<uint8_t>(0xC4FFC6_b, 0xEB);
utils::hook::nop(0xC533BD_b, 2);
utils::hook::set<uint8_t>(0xC533B4_b, 0xEB);
// ignore unregistered connection
utils::hook::jump(0xC4F200_b, 0xC4F1AB_b);
@ -379,12 +384,20 @@ namespace network
// increase snaps
//dvars::override::register_int("sv_remote_client_snapshot_msec", 33, 33, 100, game::DVAR_FLAG_NONE);
dvars::override::register_float("cl_timeout", 3600.0f, 0.0f, 3600.0f, game::DVAR_FLAG_NONE);
dvars::override::register_float("cl_connectTimeout", 3600.0f, 0.0f, 3600.0f, game::DVAR_FLAG_NONE);
dvars::override::register_int("sv_timeout", 1800, 0, 1800, game::DVAR_FLAG_NONE); // no work
dvars::override::register_int("sv_connectTimeout", 1800, 0, 1800, game::DVAR_FLAG_NONE); // ^
//dvars::override::register_int("sv_zombietime", 1800, 0, 1800, game::DVAR_FLAG_NONE); // ^
dvars::override::register_int("pt_connectTimeout", 60000, 0, 60000, game::DVAR_FLAG_READ);
dvars::override::register_int("ds_serverConnectTimeout", 60000, 0, -1, game::DVAR_FLAG_READ);
dvars::override::register_int("dw_addrHandleTimeout", -1, 0, -1, game::DVAR_FLAG_READ);
// ignore built in "print" oob command and add in our own
//utils::hook::set<uint8_t>(0x9B0326_b, 0xEB);
//network::on("print", [](const game::netadr_s&, const std::string_view& data)
@ -393,18 +406,26 @@ namespace network
// console::info(message.data());
//});
// Use our own socket since the game's socket doesn't work with non localhost addresses
// why? no idea
//utils::hook::jump(0x0, create_socket);
// initialize query_socket
utils::hook::jump(0xD57C7E_b, net_init_stub);
// use our own protocol version
utils::hook::jump(0xCE8290_b, get_protocol_version_stub);
//utils::hook::jump(0xCE8290_b, get_protocol_version_stub);
//utils::hook::set<uint8_t>(0x4030F0_b, 0xC3);
//utils::hook::nop(0x9B014B_b, 2);
// don't establish secure conenction pt2
/*utils::hook::nop(0xC572A2_b, 2);
utils::hook::nop(0xC72980_b, 2);
utils::hook::nop(0xC73512_b, 2);
utils::hook::nop(0xC739C9_b, 2);
utils::hook::set<uint8_t>(0xCFD928_b, 0xEB);*/
//utils::hook::jump(0xD93390_b, dw_get_addr_handle_connection_task_status_stub);
#ifdef DEBUG
//dvars::override::register_bool("frontEndSceneEnabled", false, game::DVAR_FLAG_READ);
#endif
}
};
}

View File

@ -31,9 +31,13 @@ namespace party
void perform_game_initialization()
{
command::execute("onlinegame 1", true);
//command::execute("exec default_xboxlive.cfg", true);
command::execute("xblive_privatematch 1", true);
//command::execute("xstartprivateparty", true);
command::execute("xstartprivatematch", true);
//command::execute("xstopparty 0", true);
//command::execute("xstartprivateparty 0", true);
command::execute("xstartprivatematch 0", true);
command::execute("uploadstats", true);
//command::execute("entitlements_delay 0", true);
}
void connect_to_party(const game::netadr_s& target, const std::string& mapname, const std::string& gametype)
@ -117,17 +121,10 @@ namespace party
auto* private_clients = game::Dvar_FindVar("ui_privateClients");
auto* hardcore = game::Dvar_FindVar("ui_hardcore");
//game::Com_FrontEndScene_Shutdown();
//utils::hook::invoke<void>(0x9D8900_b, game::Party_GetActiveParty(), true);
//if (!game::environment::is_dedi() && !game::Com_FrontEndScene_IsActive())
//{
// game::Com_Shutdown("EXE_ENDOFGAME");
//}
//utils::hook::invoke<void>(0x9D6F40_b, game::Lobby_GetPartyData(), mapname->current.string, gametype->current.string);
game::Com_FrontEndScene_ShutdownAndDisable();
utils::hook::invoke<void>(0xE4DDC0_b); // Sys_WaitWorkerCmds
utils::hook::invoke<void>(0xBAFFD0_b, ""); // Com_ShutdownInternal
game::SV_CmdsMP_StartMapForParty(
mapname->current.string,
gametype->current.string,

View File

@ -406,6 +406,11 @@ namespace game
int useZlib;
};
enum CriticalSection : std::int32_t
{
CRITSECT_DEMONWARE = 39,
};
namespace entity
{
enum connstate_t : std::uint32_t
@ -505,8 +510,16 @@ namespace game
{
char __pad0[11444];
PartyPreloadMapStage preloadingMapStage;
char __pad1[101];
bool m_gameStartSkipCountdown;
char __pad2[110];
int lobbyFlags;
bool gameStartRequested;
};
static_assert(offsetof(PartyData, preloadingMapStage) == 11444);
static_assert(offsetof(PartyData, m_gameStartSkipCountdown) == 11549);
static_assert(offsetof(PartyData, lobbyFlags) == 11660);
static_assert(offsetof(PartyData, gameStartRequested) == 11664);
}
using namespace party;
@ -524,10 +537,13 @@ namespace game
bool isSaveGame;
bool isRestart;
bool isFrontEnd;
char __pad0[2];
bool serverThreadStartup;
}; //static_assert(sizeof(SvServerInitSettings) == 212);
static_assert(offsetof(SvServerInitSettings, maxClientCount) == 196);
static_assert(offsetof(SvServerInitSettings, isMapPreloaded) == 204);
static_assert(offsetof(SvServerInitSettings, isFrontEnd) == 207);
static_assert(offsetof(SvServerInitSettings, serverThreadStartup) == 210);
}
using namespace sv;

View File

@ -97,6 +97,8 @@ namespace game
WEAK symbol<unsigned int(int controllerIndex)> Live_SyncOnlineDataFlags{ 0xDC5CE0 };
WEAK symbol<PartyData* ()> Lobby_GetPartyData{ 0x9C3E20 };
WEAK symbol<Material* (const char* material)> Material_RegisterHandle{ 0xE11CE0 };
WEAK symbol<void(netadr_s*, sockaddr*)> NetadrToSockadr{ 0xCE6B90 };
@ -106,7 +108,7 @@ namespace game
WEAK symbol<int(netadr_s a, netadr_s b)> NET_CompareAdr{ 0xBB49B0 };
WEAK symbol<int(netadr_s a, netadr_s b)> NET_CompareBaseAdr{ 0xBB4A00 };
WEAK symbol<PartyData* ()> Lobby_GetPartyData{ 0x9C3E20 };
WEAK symbol<PartyData* ()> Party_GetActiveParty{ 0x9CC010 };
WEAK symbol<GfxFont* (const char* font, int size)> R_RegisterFont{ 0xDFC670 };
WEAK symbol<int(const char* text, int maxChars, GfxFont* font)> R_TextWidth{ 0xDFC770 };