From 5a7e62dd6fc0880c7cc49833e5274ee79737f466 Mon Sep 17 00:00:00 2001 From: explorer Date: Sat, 26 Oct 2024 16:13:36 +0300 Subject: [PATCH] prevent buffer underrun on ack build-up --- Copy_Command.hpp | 2 +- Post_Network_Data_Received.hpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Copy_Command.hpp b/Copy_Command.hpp index aa0adb8..1f55866 100644 --- a/Copy_Command.hpp +++ b/Copy_Command.hpp @@ -376,7 +376,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu __int8 Is_Melee = *(__int32*)((unsigned __int32)Weapon_Data + 352) * (*(__int32*)((unsigned __int32)Weapon_Data + 348) ^ 1) <= 1; - __int32 Action = *(__int32*)((unsigned __int32)Local_Player + 7080) != 0; + __int8 Action = *(__int32*)((unsigned __int32)Local_Player + 7080) != 0; __int8 Reviving = *(void**)((unsigned __int32)Local_Player + 8076) != INVALID_HANDLE_VALUE; diff --git a/Post_Network_Data_Received.hpp b/Post_Network_Data_Received.hpp index 349a103..0c663c6 100755 --- a/Post_Network_Data_Received.hpp +++ b/Post_Network_Data_Received.hpp @@ -69,19 +69,22 @@ void* Original_Post_Network_Data_Received_Caller; void __thiscall Redirected_Post_Network_Data_Received(void* Unknown_Parameter, __int32 Commands_Acknowledged) { - void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712); - - void* Prediction_Frame = *(void**)((unsigned __int32)Local_Player + 900 + (150 - ((Commands_Acknowledged - 1) % 150 + 1) * 150 % -~150) * 4); - - if (Prediction_Frame != nullptr) + if (Commands_Acknowledged >= 0) { - Predicton_Copy.Construct(Local_Player, Prediction_Frame, (void*)Predicton_Copy_Compare); + void* Local_Player = *(void**)((unsigned __int32)Client_Module + 7498712); - using Transfer_Data_Type = __int32(__thiscall*)(Prediction_Copy_Structure* Prediction_Copy, void* Unknown_Parameter, __int32 Entity_Number, Prediction_Descriptor_Structure* Descriptor); + void* Prediction_Frame = *(void**)((unsigned __int32)Local_Player + 900 + (150 - ((Commands_Acknowledged - 1) % 150 + 1) * 150 % -~150) * 4); - Transfer_Data_Type((unsigned __int32)Client_Module + 1573744)(&Predicton_Copy, nullptr, -1, (Prediction_Descriptor_Structure*)((unsigned __int32)Client_Module + 7236480)); + if (Prediction_Frame != nullptr) + { + Predicton_Copy.Construct(Local_Player, Prediction_Frame, (void*)Predicton_Copy_Compare); - *(__int32*)((unsigned __int32)Local_Player + 5324) += Commands_Acknowledged - Commands_Acknowledged % 150; + using Transfer_Data_Type = __int32(__thiscall*)(Prediction_Copy_Structure* Prediction_Copy, void* Unknown_Parameter, __int32 Entity_Number, Prediction_Descriptor_Structure* Descriptor); + + Transfer_Data_Type((unsigned __int32)Client_Module + 1573744)(&Predicton_Copy, nullptr, -1, (Prediction_Descriptor_Structure*)((unsigned __int32)Client_Module + 7236480)); + + *(__int32*)((unsigned __int32)Local_Player + 5324) += Commands_Acknowledged - Commands_Acknowledged % 150; + } } (decltype(&Redirected_Post_Network_Data_Received)(Original_Post_Network_Data_Received_Caller))(Unknown_Parameter, Commands_Acknowledged);