Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EGCResults hook::functions::ISteamGameCoordinator__SendMessage( uintptr_t thisptr, uint32 unMsgType, ProtoBufMsgHeader_t* pubData, uint32 cubData ) {
- const auto msg_id = unMsgType & 0x7FFFFFFF;
- if ( msg_id == k_EMsgClientToGCEquipItems ) {
- const auto body = (void*)((uintptr_t)pubData + (sizeof( ProtoBufMsgHeader_t ) + pubData->m_cubProtoBufExtHdr));
- const auto body_bytes = cubData - (sizeof( ProtoBufMsgHeader_t ) + pubData->m_cubProtoBufExtHdr);
- const auto header = (const void*)((uintptr_t)pubData + sizeof( ProtoBufMsgHeader_t ));
- const auto header_size = pubData->m_cubProtoBufExtHdr;
- if ( header_size > 0 ) {
- CMsgClientToGCEquipItems OriginalBody;
- CMsgProtoBufHeader OriginalHeader;
- CMsgClientToGCEquipItemsResponse FakeBody;
- FakeBody.set_so_cache_version_id( 0 );
- CMsgProtoBufHeader FakeHeader;
- if ( OriginalBody.ParsePartialFromArray( body, body_bytes ) ) {
- std::vector<BYTE> bytes_of_message;
- if ( OriginalHeader.ParsePartialFromArray( header, header_size ) ) {
- FakeHeader.set_job_id_target( OriginalHeader.job_id_source( ) );
- }
- ProtoBufMsgHeader_t meta_header = { 0xA0A, (uint32_t)FakeHeader.ByteSizeLong( ) };
- bytes_of_message.resize( sizeof( meta_header ) + FakeHeader.ByteSizeLong( ) + FakeBody.ByteSizeLong( ) );
- *reinterpret_cast<ProtoBufMsgHeader_t*>(bytes_of_message.data( )) = meta_header;
- FakeHeader.SerializeToArray( bytes_of_message.data( ) + sizeof( ProtoBufMsgHeader_t ), FakeHeader.ByteSizeLong( ) );
- FakeBody.SerializeToArray( bytes_of_message.data( ) + sizeof( ProtoBufMsgHeader_t ) + FakeHeader.ByteSizeLong( ), FakeBody.ByteSizeLong( ) );
- cheat_data.MessageList.push( bytes_of_message );
- const auto& data = OriginalBody.equips( ).Get( 0 );
- CEconItem* item = g_pLocalInventory->FindItem( data.item_id( ) );
- if ( item ) {
- item->Equip( data.new_class( ), data.new_slot( ) );
- g_pLocalInventory->SOUpdated( g_pLocalInventory->m_pSOID, item, ESOCacheEvent::eSOCacheEvent_Incremental );
- }
- }
- }
- return EGCResults::k_EGCResultOK;
- }
- auto ret = hook::original::fpSClientSendMessage( thisptr, unMsgType, pubData, cubData );
- return ret;
- }
- EGCResults hook::functions::ISteamGameCoordinator__RetrieveMessage( uintptr_t thisptr, uint32* punMsgType, ProtoBufMsgHeader_t* pubDest, uint32 cubDest, uint32* pcubMsgSize ) {
- if ( !cheat_data.MessageList.empty( ) )
- {
- const auto& Message = cheat_data.MessageList.front( );
- *pcubMsgSize = (uint32)Message.size( );
- if ( cubDest < *pcubMsgSize )
- return EGCResults::k_EGCResultBufferTooSmall;
- auto MessageHeader = reinterpret_cast<const ProtoBufMsgHeader_t*>(Message.data( ));
- *punMsgType = MessageHeader->m_EMsgFlagged;
- util::memcpy( (void*)pubDest, MessageHeader, Message.size( ) );
- cheat_data.MessageList.pop( );
- return EGCResults::k_EGCResultOK;
- }
- return hook::original::fpSClientRetrieveMessage( thisptr, punMsgType, pubDest, cubDest, pcubMsgSize );
- }
- bool hook::functions::ISteamGameCoordinator__IsMessageAvailable( uintptr_t thisptr, uint32* pcubMsgSize ) {
- // std::cout << "ismsgav: " << _ReturnAddress() << std::endl;
- if ( !cheat_data.MessageList.empty( ) )
- {
- *pcubMsgSize = cheat_data.MessageList.front( ).size( );
- return true;
- }
- return hook::original::fpSClientIsMessageAvailable( thisptr, pcubMsgSize );
- }
- void __fastcall hook::functions::RunFrame( uintptr_t rcx ) {
- if ( !cheat_data.MessageList.empty( ) ) functions_call::OnGCMessageAvailable( global::g_CGCClient );
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement