private void OnAuthorizeKeys() { AuthInfoEvent.Reset(); Connection.WritePacket(new AuthInfoRequestPacket()); var response = AuthInfoEvent.WaitForPacket(5000); if (response == null) { Log.Warning("Did not receive response on auth info event, disconnecting chat server"); Disconnect(); return; } AuthInfoResponsePacket packet; try { packet = new AuthInfoResponsePacket(response); } catch (BncsPacketException) { Log.Warning("Received non valid response from auth info event, disconnecting chat server"); Disconnect(); return; } Context.ServerToken = packet.ServerToken; var gameFile = Path.Combine(Context.Gamefolder, "Game.exe"); var fi = new FileInfo(gameFile); var fileInfo = $"{fi.Name} {fi.LastWriteTimeUtc:MM\\/dd\\/yy HH:mm:ss} {fi.Length}"; var fvi = FileVersionInfo.GetVersionInfo(gameFile); var exeversion = ((fvi.FileMajorPart << 24) | (fvi.FileMinorPart << 16) | (fvi.FileBuildPart << 8) | 0); //var checkVersionHash = CheckRevisionV1.FastComputeHash(packet.FormulaString, mpqFile, gameFile, bnetFile, d2File); var checkVersionHash = BitConverter.ToUInt32(new byte[] { 218, 18, 86, 73 }); AuthCheckEvent.Reset(); Connection.WritePacket(new AuthCheckRequestPacket( Context.ClientToken, Context.ServerToken, exeversion, checkVersionHash, fileInfo, Context.KeyOwner)); var checkResponse = AuthCheckEvent.WaitForPacket(5000); if (checkResponse == null) { Log.Warning("Did not receive response on auth check event, disconnecting chat server"); Disconnect(); return; } _ = new AuthCheckResponsePacket(checkResponse); }
private void OnAuthorizeKeys() { AuthInfoEvent.Reset(); Connection.WritePacket(new AuthInfoRequestPacket()); var packet = new AuthInfoResponsePacket(AuthInfoEvent.WaitForPacket()); Context.ServerToken = packet.ServerToken; var result = CheckRevisionV4.CheckRevision(packet.FormulaString); AuthCheckEvent.Reset(); Connection.WritePacket(new AuthCheckRequestPacket( Context.ClientToken, Context.ServerToken, result.Version, result.Checksum, result.Info, Context.ClassicKey, Context.ExpansionKey)); _ = new AuthCheckResponsePacket(AuthCheckEvent.WaitForPacket()); }