From ca282b3258165d9ab00ffc32056e74ac57a3e9f4 Mon Sep 17 00:00:00 2001 From: yugecin Date: Sat, 4 Apr 2020 19:38:30 +0200 Subject: [PATCH] adjust RakPeer_GetTime --- common.h | 16 ++++++++++++++++ rakpeer.c | 8 ++++---- rakpeer.h | 11 +++++------ reliability.h | 3 +++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/common.h b/common.h index 12e6701..c7380d1 100644 --- a/common.h +++ b/common.h @@ -1,6 +1,22 @@ /* vim: set filetype=c ts=8 noexpandtab: */ +#define NULL 0 #define _CRT_SECURE_NO_DEPRECATE #define STATIC_ASSERT(E) typedef char __static_assert_[(E)?1:-1] #define EXPECT_SIZE(S,SIZE) STATIC_ASSERT(sizeof(S)==(SIZE)) + +#pragma pack(push, 1) +struct PlayerID { + int binaryAddress; + short port; + short __pad; +}; +EXPECT_SIZE(struct PlayerID, 0x8); + +struct CRaknetTimeNS { + int lo32; + int hi32; +}; +EXPECT_SIZE(struct CRaknetTimeNS, 0x8); +#pragma pack(pop) diff --git a/rakpeer.c b/rakpeer.c index 7cc21f5..8e720b2 100644 --- a/rakpeer.c +++ b/rakpeer.c @@ -89,11 +89,10 @@ int __declspec(naked) RakPeer__OnConnectionRequest( } } -static -unsigned int __declspec(naked) RakPeer__GetTime(struct CRakPeer *this) +__declspec(naked) +unsigned int __stdcall RakPeer__GetTime() { _asm { - mov ecx, [esp+0x4] /*this*/ mov eax, 0x44E9D0 jmp eax } @@ -209,7 +208,8 @@ sendimmediateresponse: playerId, 0, 0, - RakPeer__GetTime(this) + RakPeer__GetTime(), + 0 ); remoteSystem->connectMode = DISCONNECT_ASAP_SILENTLY; ret: diff --git a/rakpeer.h b/rakpeer.h index 56f3dd7..5655b11 100644 --- a/rakpeer.h +++ b/rakpeer.h @@ -34,12 +34,6 @@ #define UNRELIABLE 0xB #pragma pack(push,1) -struct PlayerID { - int binaryAddress; - short port; - short __pad; -}; -EXPECT_SIZE(struct PlayerID, 0x8); struct CRemoteSystem { char _pad0[0x10-0x0]; @@ -86,6 +80,11 @@ struct CRakPeer { }; #pragma pack(pop) +/** +Only seems to fetch lo32 +*/ +unsigned int __stdcall RakPeer__GetTime(); + int __stdcall RakPeer__GetIndexFromPlayerID( struct CRakPeer *this, struct PlayerID playerId, diff --git a/reliability.h b/reliability.h index bc595b0..a1a902b 100644 --- a/reliability.h +++ b/reliability.h @@ -1,6 +1,9 @@ /* vim: set filetype=c ts=8 noexpandtab: */ +/** +1 when handled (ptrOutIsPacketFlood might be 1), 0 when invalid +*/ int __stdcall ReliabilityLayer__HandleSocketReceiveFromConnectedPlayer( struct CReliabilityLayer *this, char *buffer,