MinecraftConsoles/Minecraft.Client/Common/Network/PlatformNetworkManagerInterface.h
MrTheShy 4f2352361a Add Mojang/Ely.by/offline authentication system
The old Windows64 port had no real player identity — it used hardcoded
fake XUIDs, so anyone could impersonate anyone. This replaces that with
proper auth supporting Mojang, Ely.by, and offline accounts.

MCAuth library (new, MCAuth/):
  Mojang auth via MSA device code flow (XBL, SISU, MC services),
  Ely.by via Yggdrasil with 2FA, offline UUID generation matching
  Java Edition (MD5 v3 from "OfflinePlayer:<name>"). Multi-account
  manager with background token refresh, per-slot sessions, and
  on-disk token persistence. Server-side session verification via
  Mojang/Ely.by hasJoined API. Skin fetching and PNG validation
  from texture servers.

Network protocol (version bumped to 80):
  Three new packets (AuthScheme, AuthResponse, AuthResult) implement
  a server-driven auth handshake before login completes. Player
  identity migrated from 64-bit XUID to 128-bit GameUUID backed by
  two uint64 fields (hi/lo). readPlayerUID/writePlayerUID now
  serialize 16 bytes on the wire. Old and new clients cannot connect
  to each other — version mismatch is rejected at PreLogin.

Save migration:
  Map data mappings auto-migrate from old format: the old 64-bit
  XUID is placed in hi, lo is set to 0 as a sentinel. On first
  access by the real player, the sentinel entry is upgraded in-place
  to the full 128-bit UUID. Format detection is by file size (2080,
  2112, or 4160 bytes). Player .dat filenames inside saveData.ms
  change from decimal XUID to dashed UUID — old saves need manual
  entry renaming in the archive.

UI:
  NativeUIRenderer: immediate-mode drawing system (quads, text,
  9-slice panels, scrollbars, focus lists) for rendering auth
  screens without Flash/Scaleform. UIScene_MSAuth handles device
  code display, Ely.by credential input with 2FA, per-account
  skin head preview, and multi-account add/remove/switch.

Server:
  online-mode and auth-provider (mojang/elyby) in server.properties.
  Whitelist and ban checks validate against the server-verified UUID.
  Incompatible auth scheme logs which provider the server expects
  vs what the client is using.

Also fixes a pre-existing exploit where any client could send a
DebugOptionsPacket to grant themselves CraftAnything and other debug
privileges on any server — now requires OP status server-side.
2026-03-23 01:14:23 +01:00

128 lines
4.8 KiB
C++

#pragma once
using namespace std;
#include <vector>
#include <qnet.h>
#include "..\..\..\Minecraft.World\C4JThread.h"
#include "NetworkPlayerInterface.h"
#include "SessionInfo.h"
class ClientConnection;
class Minecraft;
class CGameNetworkManager;
// This is the interface to be implemented by the platform-specific versions of the PlatformNetworkManagers. This API is used directly by GameNetworkManager so that
// it can remain as platform independent as possible.
// This value should be incremented if the server version changes, or the game session data changes
#define MINECRAFT_NET_VERSION VER_NETWORK
typedef struct _SearchForGamesData
{
DWORD sessionIDCount;
XSESSION_SEARCHRESULT_HEADER *searchBuffer;
XNQOS **ppQos;
SessionID *sessionIDList;
XOVERLAPPED *pOverlapped;
} SearchForGamesData;
class CPlatformNetworkManager
{
friend class CGameNetworkManager;
public:
typedef enum
{
JOIN_FAILED_SERVER_FULL,
JOIN_FAILED_INSUFFICIENT_PRIVILEGES,
JOIN_FAILED_NONSPECIFIC,
} eJoinFailedReason;
virtual bool Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize) = 0;
virtual void Terminate() = 0;
virtual int GetJoiningReadyPercentage() = 0;
virtual int CorrectErrorIDS(int IDS) = 0;
virtual void DoWork() = 0;
virtual int GetPlayerCount() = 0;
virtual int GetOnlinePlayerCount() = 0;
virtual int GetLocalPlayerMask(int playerIndex) = 0;
virtual bool AddLocalPlayerByUserIndex( int userIndex ) = 0;
virtual bool RemoveLocalPlayerByUserIndex( int userIndex ) = 0;
virtual INetworkPlayer *GetLocalPlayerByUserIndex( int userIndex ) = 0;
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex) = 0;
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid) = 0;
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId) = 0;
virtual bool ShouldMessageForFullSession() = 0;
virtual INetworkPlayer *GetHostPlayer() = 0;
virtual bool IsHost() = 0;
virtual bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo) = 0;
virtual bool LeaveGame(bool bMigrateHost) = 0;
virtual bool IsInSession() = 0;
virtual bool IsInGameplay() = 0;
virtual bool IsReadyToPlayOrIdle() = 0;
virtual bool IsInStatsEnabledSession() = 0;
virtual bool SessionHasSpace(unsigned int spaceRequired = 1) = 0;
virtual void SendInviteGUI(int quadrant) = 0;
virtual bool IsAddingPlayer() = 0;
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, int publicSlots = MINECRAFT_NET_MAX_PLAYERS, int privateSlots = 0) = 0;
virtual int JoinGame(FriendSessionInfo *searchResult, int dwLocalUsersMask, int dwPrimaryUserIndex ) = 0;
virtual void CancelJoinGame() {};
virtual bool SetLocalGame(bool isLocal) = 0;
virtual bool IsLocalGame() = 0;
virtual void SetPrivateGame(bool isPrivate) = 0;
virtual bool IsPrivateGame() = 0;
virtual bool IsLeavingGame() = 0;
virtual void ResetLeavingGame() = 0;
virtual void RegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam) = 0;
virtual void UnRegisterPlayerChangedCallback(int iPad, void (*callback)(void *callbackParam, INetworkPlayer *pPlayer, bool leaving), void *callbackParam) = 0;
virtual void HandleSignInChange() = 0;
virtual bool _RunNetworkGame() = 0;
virtual void SetGamePlayState() {}
private:
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
virtual void _HostGame(int usersMask, int publicSlots = MINECRAFT_NET_MAX_PLAYERS, int privateSlots = 0) = 0;
virtual bool _StartGame() = 0;
public:
virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr) = 0;
private:
virtual bool RemoveLocalPlayer( INetworkPlayer *pNetworkPlayer ) = 0;
public:
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index) = 0;
virtual bool SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index) = 0;
virtual wstring GatherStats() = 0;
virtual wstring GatherRTTStats() = 0;
private:
virtual void SetSessionTexturePackParentId( int id ) = 0;
virtual void SetSessionSubTexturePackId( int id ) = 0;
virtual void Notify(int ID, ULONG_PTR Param) = 0;
public:
virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly) = 0;
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession) = 0;
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ) = 0;
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) = 0;
virtual void ForceFriendsSessionRefresh() = 0;
#ifndef _XBOX
virtual void FakeLocalPlayerJoined() {}; // Temporary method whilst we don't have real networking to make this happen
#endif
#ifdef _DURANGO
virtual wstring GetDisplayNameByGamertag(wstring gamertag) = 0;
#endif
};