Ejemplo n.º 1
0
        private static void OnReceiveHandler(IAsyncResult ar)
        {
            try
            {
                int numBytes = _Socket.EndReceive(ar);

                if (numBytes > 0)
                {
                    byte[] buffer = _pBuf;
                    int bufferSize = numBytes;

                    PacketIn pack = new PacketIn(buffer, 0, bufferSize);
                    OnReceive(pack);
                    BeginReceive();

                }
                else
                {
                    Close();
                }
            }
            catch
            {

            }
        }
Ejemplo n.º 2
0
        public static void OnReceive(PacketIn packet)
        {
            lock (packet)
            {
                packet.Size = packet.GetUint32();
                packet.Opcode = packet.GetUint8();

                Handle(packet);
            }
        }
Ejemplo n.º 3
0
        public static void Handle(PacketIn packet)
        {
            if (!Enum.IsDefined(typeof(Opcodes), (byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            _logger.Debug($"HandlePacket{packet}");

            switch ((Opcodes)packet.Opcode)
            {
            case Opcodes.LCR_CHECK:

                byte Result = packet.GetUint8();

                switch ((CheckResult)Result)
                {
                case CheckResult.LAUNCHER_OK:
                    Start();
                    break;

                case CheckResult.LAUNCHER_VERSION:
                    string Message = packet.GetString();
                    Print(Message);
                    Close();
                    break;

                case CheckResult.LAUNCHER_FILE:

                    string File = packet.GetString();
                    byte[] Bt   = Encoding.ASCII.GetBytes(File);

                    FileInfo   Info = new FileInfo("mythloginserviceconfig.xml");
                    FileStream Str  = Info.Create();
                    Str.Write(Bt, 0, Bt.Length);          // Bt is sent from the server (configs/mythloginserviceconfig.xml) - it overwrites the file on the client side.
                    Str.Close();
                    break;
                }
                break;

            case Opcodes.LCR_START:

                Accueil.Acc.ReceiveStart();

                byte response = packet.GetUint8();
                _logger.Debug($"HandlePacket. Response Code : {response}");

                if (response == 1)     //invalud user/pass
                {
                    _logger.Warn($"Invalid User / Pass");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Invalid User / Pass";
                    return;
                }
                else if (response == 2)     //banned
                {
                    _logger.Warn($"Account is banned");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Account is banned";
                    return;
                }
                else if (response == 3)     //account not active
                {
                    _logger.Warn($"Account is not active");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Account is not active";
                    return;
                }
                else if (response > 3)
                {
                    _logger.Error($"Unknown Response");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Unknown Response";
                    return;
                }
                else
                {
                    authToken = packet.GetString();
                    _logger.Info($"Authentication Token Received : {authToken}");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Starting Client..";
                    try
                    {
                        string CurrentDir = Directory.GetCurrentDirectory();
                        patchExe();
                        UpdateWarData();

                        _logger.Info($"Starting Client {CurrentDir}\\WAR.exe");

                        Process Pro = new Process();
                        Pro.StartInfo.FileName  = "WAR.exe";
                        Pro.StartInfo.Arguments = " --acctname=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(User)) + " --sesstoken=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(authToken));
                        _logger.Info($"Starting process WAR.exe");
                        Pro.Start();
                        Directory.SetCurrentDirectory(CurrentDir);
                    }
                    catch (Exception e)
                    {
                        _logger.Info($"Failed to start Client {e.ToString()}");
                        Print(e.ToString());
                    }
                }

                break;

            case Opcodes.LCR_INFO:
            {
                _logger.Info($"Processing LCR_INFO : Number Realms : {packet.GetUint8()} Name : {packet.GetString()} Parsed : {packet.GetParsedString()}");

                //Accueil.Acc.ClearRealms();
                //byte RealmsCount = packet.GetUint8();
                //for (byte i = 0; i < RealmsCount; ++i)
                //{
                //    bool Online = packet.GetUint8() > 0;
                //    string Name = packet.GetString();
                //    uint OnlinePlayers = packet.GetUint32();
                //    uint OrderCount = packet.GetUint32();
                //    uint DestructionCount = packet.GetUint32();

                //    //Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, OrderCount, DestructionCount);

                //}
            } break;
            }
        }
Ejemplo n.º 4
0
        public static void Handle(PacketIn packet)
        {
            if(!Enum.IsDefined(typeof(Opcodes),(byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            switch((Opcodes)packet.Opcode)
            {
                case Opcodes.LCR_CHECK:

                    byte Result = packet.GetUint8();

                    switch((CheckResult)Result)
                    {
                        case CheckResult.LAUNCHER_OK:
                            Start();
                            break;
                        case CheckResult.LAUNCHER_VERSION:
                            string Message = packet.GetString();
                            Print(Message);
                            Close();
                            break;
                        case CheckResult.LAUNCHER_FILE:

                            string File = packet.GetString();
                            byte[] Bt = ASCIIEncoding.ASCII.GetBytes(File);

                            FileInfo Info = new FileInfo("mythloginserviceconfig.xml");
                            FileStream Str = Info.Create();
                            Str.Write(Bt, 0, Bt.Length);
                            Str.Close();
                            break;
                    }
                    break;

                case Opcodes.LCR_START:

                    Accueil.Acc.ReceiveStart();

                    byte Res = packet.GetUint8();

                    if (Res >= 1)
                    {
                        Print("Error : wrong account !\n\r");
                        return;
                    }
                    else
                    {
                        Auth = packet.GetString();
                        Print("Lancement avec : " + Auth);
                        try
                        {
                            // Je Fawk | 13 April 2014 | Modified to game folder path taken from from Accueil
                            string CurrentDir = Accueil.pathToGameFolder;
                            #region Old code
                            //string CurrentDir = Directory.GetCurrentDirectory();
                            #endregion Old code
                            patchExe();
                            UpdateWarData();
                            Process Pro = new Process();
                            Pro.StartInfo.FileName = "WAR.exe";
                            Pro.StartInfo.Arguments = " --acctname=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(User)) + " --sesstoken=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Auth));
                            Pro.Start();
                            Directory.SetCurrentDirectory(CurrentDir);
                        }
                        catch (Exception e)
                        {
                            Print(e.ToString());
                        }
                    }

                    break;

                case Opcodes.LCR_INFO:
                    {
                        Accueil.Acc.ClearRealms();
                        byte RealmsCount = packet.GetUint8();
                        for (byte i = 0; i < RealmsCount; ++i)
                        {
                            bool Online = packet.GetUint8() > 0;
                            string Name = packet.GetString();
                            UInt32 OnlinePlayers = packet.GetUint32();
                            UInt32 OrderCount = packet.GetUint32();
                            UInt32 DestructionCount = packet.GetUint32();

                            Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, DestructionCount, DestructionCount);

                        }
                    }break;
            }
        }
Ejemplo n.º 5
0
Archivo: Client.cs Proyecto: uvbs/DoR
        static public void Handle(PacketIn packet)
        {
            if (!Enum.IsDefined(typeof(Opcodes), (byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            switch ((Opcodes)packet.Opcode)
            {
            case Opcodes.LCR_CHECK:

                byte Result = packet.GetUint8();

                switch ((CheckResult)Result)
                {
                case CheckResult.LAUNCHER_OK:
                    Start();
                    break;

                case CheckResult.LAUNCHER_VERSION:
                    string Message = packet.GetString();
                    Print(Message);
                    Close();
                    break;

                case CheckResult.LAUNCHER_FILE:

                    string File = packet.GetString();
                    byte[] Bt   = ASCIIEncoding.ASCII.GetBytes(File);

                    FileInfo   Info = new FileInfo("mythloginserviceconfig.xml");
                    FileStream Str  = Info.Create();
                    Str.Write(Bt, 0, Bt.Length);
                    Str.Close();
                    break;
                }
                break;

            case Opcodes.LCR_START:

                Accueil.Acc.ReceiveStart();

                byte Res = packet.GetUint8();

                if (Res >= 1)
                {
                    Print("Error : wrong account !\n\r");
                    return;
                }
                else
                {
                    Auth = packet.GetString();
                    Print("Launching with : " + Auth);
                    try
                    {
                        string CurrentDir = Directory.GetCurrentDirectory();
                        patchExe();
                        UpdateWarData();
                        Process Pro = new Process();
                        Pro.StartInfo.FileName  = "WAR.exe";
                        Pro.StartInfo.Arguments = " --acctname=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(User)) + " --sesstoken=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Auth));
                        Pro.Start();
                        Directory.SetCurrentDirectory(CurrentDir);
                    }
                    catch (Exception e)
                    {
                        Print(e.ToString());
                    }
                }

                break;

            case Opcodes.LCR_INFO:
            {
                Accueil.Acc.ClearRealms();
                byte RealmsCount = packet.GetUint8();
                for (byte i = 0; i < RealmsCount; ++i)
                {
                    bool   Online           = packet.GetUint8() > 0;
                    string Name             = packet.GetString();
                    UInt32 OnlinePlayers    = packet.GetUint32();
                    UInt32 OrderCount       = packet.GetUint32();
                    UInt32 DestructionCount = packet.GetUint32();

                    Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, DestructionCount, DestructionCount);
                }
            } break;
            }
        }