@@ -173,16 +173,17 @@ TInstanceHook(void, "?moveSpawnView@Player@@QEAAXAEBVVec3@@V?$AutomaticID@VDimen
173173        return  original (this , pos, dimid);
174174    fixPlayerPosition (this , false );
175175}
176- //  这个函数没有了,我也不知这个修的是啥,就注释了
177- // TClasslessInstanceHook(__int64,
178- //                        "?move@ChunkViewSource@@QEAAXAEBVBlockPos@@H_NW4ChunkSourceViewGenerateMode@@V?$function@$$"
179- //                        "A6AXV?$buffer_span_mut@V?$shared_ptr@VLevelChunk@@@std@@@@V?$buffer_span@I@@@Z@std@@@Z",
180- //                        BlockPos a2, int a3, unsigned __int8 a4, int a5, __int64 a6) {
181- //     if (validPosition(a2))
182- //         return original(this, a2, a3, a4, a5, a6);
183- //     fixPlayerPosition(movingViewPlayer);
184- //     return 0;
185- // }
176+ 
177+ TClasslessInstanceHook (
178+     __int64,
179+     " ?move@ChunkViewSource@@QEAAXAEBVBlockPos@@H_NW4ChunkSourceViewGenerateMode@@V?$function@$$A6AXV?$buffer_span_mut" 
180+     " @V?$shared_ptr@VLevelChunk@@@std@@@@V?$buffer_span@I@@@Z@std@@PEBM@Z"  ,
181+     BlockPos a2, int  a3, bool  a4, enum  class  ChunkSourceViewGenerateMode  a5, void * a6, void * a7, const  float * a8) {
182+     if  (validPosition (a2))
183+         return  original (this , a2, a3, a4, a5, a6, a7, a8);
184+     fixPlayerPosition (movingViewPlayer);
185+     return  0 ;
186+ }
186187
187188TInstanceHook (void , " ?move@Player@@UEAAXAEBVVec3@@@Z"  , Player, Vec3 pos) {
188189    if  (validPosition (pos))
@@ -191,6 +192,53 @@ TInstanceHook(void, "?move@Player@@UEAAXAEBVVec3@@@Z", Player, Vec3 pos) {
191192    this ->kick (" error move"  );
192193}
193194
195+ //  Built-in packet filter
196+ //  #include "llapi/mc/NetworkPeer.hpp"
197+ //  #include "llapi/mc/NetworkConnection.hpp"
198+ //  static inline bool checkPktId(unsigned int id) {
199+ //     id &= 0x3ff;
200+ //     return id==0 || id == 0x01 || id == 0x5e || id == 0xc1;
201+ // }
202+ // 
203+ //  static inline bool& connState(void* conn) {
204+ //     return dAccess<bool, 362>(conn);
205+ // }
206+ // 
207+ //  TInstanceHook(NetworkPeer::DataStatus,
208+ //               "?receivePacket@NetworkConnection@@QEAA?AW4DataStatus@NetworkPeer@@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAVNetworkSystem@@AEBV?$shared_ptr@V?$time_point@Usteady_clock@chrono@std@@V?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@23@@chrono@std@@@5@@Z",
209+ //               NetworkConnection, string* data, __int64 a3, __int64** a4) {
210+ //     auto status = original(this, data, a3, a4);
211+ //     if (status == NetworkPeer::DataStatus::HasData) {
212+ //         auto stream = ReadOnlyBinaryStream(*data, false);
213+ //         auto packetId = stream.getUnsignedVarInt();
214+ //         if (packetId == 0) {
215+ //             data->clear();
216+ //             return NetworkPeer::DataStatus::NoData;
217+ //         }
218+ //         if (!data->empty()) {
219+ //             if (checkPktId(packetId)) {
220+ //                 connState(this) = true;
221+ //             } else {
222+ //                 if (!connState(this)) {
223+ //                     data->clear();
224+ //                     return NetworkPeer::DataStatus::NoData;
225+ //                 }
226+ //             }
227+ //         }
228+ //     }
229+ //     return status;
230+ // }
231+ // 
232+ //  THook(void*,
233+ //       "??0NetworkConnection@@QEAA@AEBVNetworkIdentifier@@V?$shared_ptr@VNetworkPeer@@@std@@V?$time_point@Usteady_clock@"
234+ //       "chrono@std@@V?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@23@@chrono@3@_NV?$NonOwnerPointer@VIPacketObserver@@@"
235+ //       "Bedrock@@AEAVScheduler@@@Z",
236+ //       void* thi, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7) {
237+ //     auto res = original(thi, a1, a2, a3, a4, a5, a6,a7);
238+ //     connState(thi) = false;
239+ //     return res;
240+ // }
241+ 
194242//  Fix wine stop
195243TClasslessInstanceHook (void , " ?leaveGameSync@ServerInstance@@QEAAXXZ"  ) {
196244    original (this );
@@ -302,9 +350,8 @@ TClasslessInstanceHook(
302350    return  original (this , a2, a3, a4, a5, a6, a7, a8, a9);
303351}
304352
305- //  Try Fix  BDS Crash 
353+ //  Try fixing  BDS crash 
306354//  Beta
307- 
308355THook (void *, " ??0ScopedTimer@ImguiProfiler@@QEAA@PEBD0_N@Z"  , void * self, char * a2, char * a3, char  a4) {
309356    if  (ll::globalConfig.enableFixBDSCrash ) {
310357        return  nullptr ;
@@ -405,6 +452,7 @@ TInstanceHook(std::shared_ptr<class ChunkViewSource>,
405452    auto  result = ChunkViewSource (chunkSource, ChunkSource::LoadMode::Deferred);
406453    return  std::make_shared<ChunkViewSource>(result);
407454}
455+ 
408456/* 
409457// Fix carried item display 
410458// Fix armor display 
@@ -463,25 +511,28 @@ TClasslessInstanceHook(void, "?sendEvent@ActorEventCoordinator@@QEAAXAEBV?$Event
463511    } 
464512} 
465513*/ 
466- //  Fix LevelChunkPacket crash
467- #include  " llapi/mc/LevelChunkPacket.hpp" 
468- 
469- TInstanceHook (StreamReadResult, " ?_read@LevelChunkPacket@@EEAA?AW4StreamReadResult@@AEAVReadOnlyBinaryStream@@@Z"  ,
470-               LevelChunkPacket, ReadOnlyBinaryStream* bs) {
471-     size_t  readPointer = bs->getReadPointer ();
472-     bs->getVarInt ();
473-     bs->getVarInt ();
474-     unsigned  int  varInt = bs->getUnsignedVarInt ();
475-     if  (varInt != -2 ) {
476-         bs->getUnsignedVarInt ();
477-     }
478-     bool  boolean = bs->getBool ();
479-     if  (boolean) {
480-         varInt = bs->getUnsignedVarInt ();
481-         if  (varInt > 10000 ) {
482-             return  StreamReadResult::Valid;
483-         }
514+ //  Fix horion client's crash module
515+ #include  " llapi/mc/PlayerListPacket.hpp" 
516+ #include  " llapi/mc/ExtendedStreamReadResult.hpp" 
517+ 
518+ TInstanceHook (ExtendedStreamReadResult,
519+               " ?readExtended@PlayerListPacket@@UEAA?AUExtendedStreamReadResult@@AEAVReadOnlyBinaryStream@@@Z"  ,
520+               PlayerListPacket, ReadOnlyBinaryStream) {
521+     return  ExtendedStreamReadResult{StreamReadResult::Valid, " "  };
522+ }
523+ 
524+ //  Fix SubClient exploit: Getting OP by using OP's xuid to join server
525+ #include  " llapi/mc/SubClientLoginPacket.hpp" 
526+ 
527+ TInstanceHook (StreamReadResult, " ?_read@SubClientLoginPacket@@EEAA?AW4StreamReadResult@@AEAVReadOnlyBinaryStream@@@Z"  ,
528+               SubClientLoginPacket, class  ReadOnlyBinaryStream & binaryStream) {
529+     size_t  readPointer = binaryStream.getReadPointer ();
530+     unsigned  int  header = binaryStream.getUnsignedInt ();
531+     unsigned  int  senderSubClientId = (header >> 10 ) & 3 ;
532+     unsigned  int  targetSubClientId = (header >> 12 ) & 3 ;
533+     binaryStream.setReadPointer (readPointer);
534+     if  (targetSubClientId != 0  || senderSubClientId != 0 ) {
535+         return  StreamReadResult::Valid;
484536    }
485-     bs->setReadPointer (readPointer);
486-     return  original (this , bs);
537+     return  original (this , binaryStream);
487538}
0 commit comments