Exemplo n.º 1
0
        object OnCall(string typeName, string methodName, object thisObj, params object[] args)
        {
            if (typeName == "ConnectAPI" && methodName == "QueueGamePacket")
            {
                int       packetID = (int)args[0];
                IProtoBuf body     = (IProtoBuf)args[1];
                return(ConnectAPI_QueueGamePacket(packetID, body));
            }
            if (typeName == "ConnectAPI" && methodName == "PacketReceived")
            {
                PegasusPacket         p     = (PegasusPacket)args[0];
                Queue <PegasusPacket> state = (Queue <PegasusPacket>)args[1];
                return(ConnectAPI_PacketReceived(p, state));
            }
            else if (typeName == "bgs.RPCConnection" && methodName == "QueuePacket")
            {
                RPCConnection   thiz   = (RPCConnection)thisObj;
                BattleNetPacket packet = (BattleNetPacket)args[0];
                return(RPCConnection_QueuePacket(thiz, packet));
            }
            else if (typeName == "bgs.RPCConnection" && methodName == "PacketReceived")
            {
                RPCConnection   thiz   = (RPCConnection)thisObj;
                BattleNetPacket packet = (BattleNetPacket)args[0];
                return(RPCConnection_PacketReceived(thiz, packet));
            }

            return(null);
        }
Exemplo n.º 2
0
        public void QueueResponse(RPCContext context, IProtoBuf message)
        {
            if (message == null || context.Header == null)
            {
                this.m_logSource.LogError("QueueResponse: invalid response");
                return;
            }
            if (this.serviceHelper.GetImportedServiceById(context.Header.ServiceId) == null)
            {
                this.m_logSource.LogError("QueueResponse: error, unrecognized service id: " + context.Header.ServiceId);
                return;
            }
            this.m_logSource.LogDebug(string.Concat(new object[]
            {
                "QueueResponse: type=",
                this.serviceHelper.GetImportedServiceById(context.Header.ServiceId).GetMethodName(context.Header.MethodId),
                " data=",
                message
            }));
            Header header = context.Header;

            header.SetServiceId(254u);
            header.SetMethodId(0u);
            header.SetSize(message.GetSerializedSize());
            context.Header = header;
            BattleNetPacket packet = new BattleNetPacket(context.Header, message);

            this.QueuePacket(packet);
        }
Exemplo n.º 3
0
 public BattleNetPacket(bnet.protocol.Header h, IProtoBuf b)
 {
     this.headerSize = -1;
     this.bodySize   = -1;
     this.header     = h;
     this.body       = b;
 }
Exemplo n.º 4
0
        public ResponseFrame MakeFrame(IProtoBuf stream)
        {
            var bodyLen = TypeInterpreter.BytesToInt32(Len, 0);

            if (MaxFrameSize - 8 < bodyLen) throw new DriverInternalError("Frame length mismatch");

            var frame = new ResponseFrame() { FrameHeader = this, RawStream = stream };
            return frame;
        }
 public static byte[] ToByteArray(IProtoBuf protobuf)
 {
     unsafe
     {
         byte[] numArray = new byte[protobuf.GetSerializedSize()];
         protobuf.Serialize(new MemoryStream(numArray));
         return(numArray);
     }
 }
Exemplo n.º 6
0
    public static byte[] ToByteArray(IProtoBuf protobuf)
    {
        uint serializedSize = protobuf.GetSerializedSize();

        byte[]       array  = new byte[serializedSize];
        MemoryStream stream = new MemoryStream(array);

        protobuf.Serialize(stream);
        return(array);
    }
Exemplo n.º 7
0
        private void LogOutgoingPacket(BattleNetPacket packet, bool wasMetered)
        {
            if (this.m_logSource == null)
            {
                LogAdapter.Log(LogLevel.Warning, "tried to log with null log source, skipping");
                return;
            }
            bool      flag      = false;
            IProtoBuf protoBuf  = (IProtoBuf)packet.GetBody();
            Header    header    = packet.GetHeader();
            uint      serviceId = header.ServiceId;
            uint      methodId  = header.MethodId;
            string    text      = (!wasMetered) ? "QueueRequest" : "QueueRequest (METERED)";

            if (!string.IsNullOrEmpty(protoBuf.ToString()))
            {
                ServiceDescriptor importedServiceById = this.serviceHelper.GetImportedServiceById(serviceId);
                string            text2 = (importedServiceById != null) ? importedServiceById.GetMethodName(methodId) : "null";
                if (!text2.Contains("KeepAlive"))
                {
                    this.m_logSource.LogDebug("{0}: type = {1}, header = {2}, request = {3}", new object[]
                    {
                        text,
                        text2,
                        header.ToString(),
                        protoBuf.ToString()
                    });
                }
            }
            else
            {
                ServiceDescriptor importedServiceById2 = this.serviceHelper.GetImportedServiceById(serviceId);
                string            text3 = (importedServiceById2 != null) ? importedServiceById2.GetMethodName(methodId) : null;
                if (text3 != "bnet.protocol.connection.ConnectionService.KeepAlive" && text3 != null)
                {
                    this.m_logSource.LogDebug("{0}: type = {1}, header = {2}", new object[]
                    {
                        text,
                        text3,
                        header.ToString()
                    });
                }
                else
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                this.m_logSource.LogDebugStackTrace("LogOutgoingPacket: ", 32, 1);
            }
        }
Exemplo n.º 8
0
        private void LogOutgoingPacket(BattleNetPacket packet, bool wasMetered)
        {
            string methodName;

            if (this.m_logSource == null)
            {
                LogAdapter.Log(LogLevel.Warning, "tried to log with null log source, skipping");
                return;
            }
            bool      flag      = false;
            IProtoBuf body      = (IProtoBuf)packet.GetBody();
            Header    header    = packet.GetHeader();
            uint      serviceId = header.ServiceId;
            uint      methodId  = header.MethodId;
            string    str       = (!wasMetered ? "QueueRequest" : "QueueRequest (METERED)");

            if (string.IsNullOrEmpty(body.ToString()))
            {
                ServiceDescriptor importedServiceById = this.serviceHelper.GetImportedServiceById(serviceId);
                if (importedServiceById != null)
                {
                    methodName = importedServiceById.GetMethodName(methodId);
                }
                else
                {
                    methodName = null;
                }
                string str1 = methodName;
                if (!(str1 != "bnet.protocol.connection.ConnectionService.KeepAlive") || str1 == null)
                {
                    flag = true;
                }
                else
                {
                    this.m_logSource.LogDebug("{0}: type = {1}, header = {2}", new object[] { str, str1, header.ToString() });
                }
            }
            else
            {
                ServiceDescriptor serviceDescriptor = this.serviceHelper.GetImportedServiceById(serviceId);
                string            str2 = (serviceDescriptor != null ? serviceDescriptor.GetMethodName(methodId) : "null");
                if (!str2.Contains("KeepAlive"))
                {
                    this.m_logSource.LogDebug("{0}: type = {1}, header = {2}, request = {3}", new object[] { str, str2, header.ToString(), body.ToString() });
                }
            }
            if (!flag)
            {
                this.m_logSource.LogDebugStackTrace("LogOutgoingPacket: ", 32, 1);
            }
        }
 public override byte[] Encode()
 {
     if (this.Body is IProtoBuf)
     {
         IProtoBuf body = (IProtoBuf)this.Body;
         this.Size = (int)body.GetSerializedSize();
         byte[] destinationArray = new byte[(this.Size + 4) + 4];
         Array.Copy(BitConverter.GetBytes(this.Type), 0, destinationArray, 0, 4);
         Array.Copy(BitConverter.GetBytes(this.Size), 0, destinationArray, 4, 4);
         body.Serialize(new MemoryStream(destinationArray, 8, this.Size));
         return(destinationArray);
     }
     return(null);
 }
Exemplo n.º 10
0
        public ResponseFrame MakeFrame(IProtoBuf stream)
        {
            int bodyLen = TypeInterpreter.BytesToInt32(Len, 0);

            if (MaxFrameSize - 8 < bodyLen)
            {
                throw new DriverInternalError("Frame length mismatch");
            }

            var frame = new ResponseFrame {
                FrameHeader = this, RawStream = stream
            };

            return(frame);
        }
Exemplo n.º 11
0
    public override byte[] Encode()
    {
        if (!(this.body is IProtoBuf))
        {
            return(null);
        }
        IProtoBuf body           = (IProtoBuf)this.body;
        int       serializedSize = (int)this.header.GetSerializedSize();
        int       count          = (int)body.GetSerializedSize();

        byte[] buffer = new byte[(2 + serializedSize) + count];
        buffer[0] = (byte)((serializedSize >> 8) & 0xff);
        buffer[1] = (byte)(serializedSize & 0xff);
        this.header.Serialize(new MemoryStream(buffer, 2, serializedSize));
        body.Serialize(new MemoryStream(buffer, 2 + serializedSize, count));
        return(buffer);
    }
Exemplo n.º 12
0
    private bool SendClientRequestImpl(int type, IProtoBuf body, ClientRequestConfig clientRequestConfig, RequestPhase requestPhase, int subID)
    {
        if (type == 0)
        {
            return(false);
        }
        if ((requestPhase < RequestPhase.STARTUP) || (requestPhase > RequestPhase.RUNNING))
        {
            return(false);
        }
        ClientRequestConfig config    = (clientRequestConfig != null) ? clientRequestConfig : this.m_defaultConfig;
        int           requestedSystem = config.RequestedSystem;
        SystemChannel orCreateSystem  = this.GetOrCreateSystem(requestedSystem);

        if (requestPhase < orCreateSystem.CurrentPhase)
        {
            return(false);
        }
        if (orCreateSystem.WasEverInRunningPhase && (requestPhase < RequestPhase.RUNNING))
        {
            return(false);
        }
        if (body == null)
        {
            return(false);
        }
        ClientRequestType item = new ClientRequestType {
            Type = type,
            ShouldRetryOnError = config.ShouldRetryOnError,
            SubID      = subID,
            Body       = ProtobufUtil.ToByteArray(body),
            Phase      = requestPhase,
            RetryCount = 0,
            RequestId  = this.GetNextRequestId()
        };

        if (item.Phase == RequestPhase.STARTUP)
        {
            orCreateSystem.Phases.StartUp.PendingSend.Enqueue(item);
        }
        else
        {
            orCreateSystem.Phases.Running.PendingSend.Enqueue(item);
        }
        return(true);
    }
Exemplo n.º 13
0
        public override byte[] Encode()
        {
            if (!(this.body is IProtoBuf))
            {
                return(null);
            }
            IProtoBuf protoBuf        = (IProtoBuf)this.body;
            int       serializedSize  = (int)this.header.GetSerializedSize();
            int       serializedSize2 = (int)protoBuf.GetSerializedSize();

            byte[] array = new byte[2 + serializedSize + serializedSize2];
            array[0] = (byte)(serializedSize >> 8 & 255);
            array[1] = (byte)(serializedSize & 255);
            this.header.Serialize(new MemoryStream(array, 2, serializedSize));
            protoBuf.Serialize(new MemoryStream(array, 2 + serializedSize, serializedSize2));
            return(array);
        }
Exemplo n.º 14
0
        private object ConnectAPI_QueueGamePacket(int packetID, IProtoBuf body)
        {
            using (StreamWriter sw = new StreamWriter("packets.txt", true))
            {
                //if (packetID == 115) return null; // ping

                /*if (packetID == 15 && !allow)
                 * {
                 *      return "";
                 * }*/

                sw.WriteLine("{\n" +
                             "\"method\": \"ConnectAPI.QueueGamePacket\",\n" +
                             "\"type\": " + packetID + ",\n" +
                             "\"packet\": " + JsonConvert.SerializeObject(body, Formatting.Indented) + "\n" +
                             "}");
            }
            return(null);
        }
Exemplo n.º 15
0
 private void LogOutgoingPacket(BattleNetPacket packet, bool wasMetered)
 {
     if (this.m_logSource == null)
     {
         UnityEngine.Debug.LogWarning("tried to log with null log source, skipping");
     }
     else
     {
         bool                 flag      = false;
         IProtoBuf            body      = (IProtoBuf)packet.GetBody();
         bnet.protocol.Header header    = packet.GetHeader();
         uint                 serviceId = header.ServiceId;
         uint                 methodId  = header.MethodId;
         string               str       = !wasMetered ? "QueueRequest" : "QueueRequest (METERED)";
         if (!string.IsNullOrEmpty(body.ToString()))
         {
             ServiceDescriptor importedServiceById = this.serviceHelper.GetImportedServiceById(serviceId);
             object[]          args = new object[] { str, (importedServiceById != null) ? importedServiceById.GetMethodName(methodId) : "null", header.ToString(), body.ToString() };
             this.m_logSource.LogDebug("{0}: type = {1}, header = {2}, request = {3}", args);
         }
         else
         {
             ServiceDescriptor descriptor2 = this.serviceHelper.GetImportedServiceById(serviceId);
             string            str2        = (descriptor2 != null) ? descriptor2.GetMethodName(methodId) : null;
             if ((str2 != "bnet.protocol.connection.ConnectionService.KeepAlive") && (str2 != null))
             {
                 object[] objArray2 = new object[] { str, str2, header.ToString() };
                 this.m_logSource.LogDebug("{0}: type = {1}, header = {2}", objArray2);
             }
             else
             {
                 flag = true;
             }
         }
         if (!flag)
         {
             this.m_logSource.LogDebugStackTrace("LogOutgoingPacket: ", 0x20, 1);
         }
     }
 }
Exemplo n.º 16
0
 public RPCContext QueueRequest(uint serviceId, uint methodId, IProtoBuf message, RPCContextDelegate callback = null, uint objectId = 0)
 {
     //
     // Current member / type: bgs.RPCContext bgs.RPCConnection::QueueRequest(System.UInt32,System.UInt32,IProtoBuf,bgs.RPCContextDelegate,System.UInt32)
     // File path: C:\apktool\WoW Companion_2.0.27325\assets\bin\Data\Managed\Assembly-CSharp.dll
     //
     // Product version: 2018.2.803.0
     // Exception in: bgs.RPCContext QueueRequest(System.UInt32,System.UInt32,IProtoBuf,bgs.RPCContextDelegate,System.UInt32)
     //
     // La référence d'objet n'est pas définie à une instance d'un objet.
     //    à ž..Žƒ() dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 93
     //    à ž..”(•Ÿ ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 24
     //    à †”.–.Visit(ICodeNode ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeVisitor.cs:ligne 69
     //    à ž..œ(DecompilationContext ™, •Ÿ €–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildLockStatements.cs:ligne 19
     //    à ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:ligne 88
     //    à ‚–.™“.‹(MethodBody €–, ILanguage ) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:ligne 70
     //    à Telerik.JustDecompiler.Decompiler.Extensions.›“(™“ œ“, ILanguage , MethodBody €–, DecompilationContext& ™) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:ligne 95
     //    à Telerik.JustDecompiler.Decompiler.Extensions.š“(MethodBody €–, ILanguage , DecompilationContext& ™,  œ–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:ligne 58
     //    à ——.ƒ˜.—(ILanguage , MethodDefinition €,  œ–) dans C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\WriterContextServices\BaseWriterContextService.cs:ligne 117
     //
     // mailto: [email protected]
 }
Exemplo n.º 17
0
        public RPCContext QueueRequest(uint serviceId, uint methodId, IProtoBuf message, RPCContextDelegate callback = null, uint objectId = 0u)
        {
            if (message == null)
            {
                return(null);
            }
            object obj = this.tokenLock;
            uint   num;

            lock (obj)
            {
                num = RPCConnection.nextToken;
                RPCConnection.nextToken += 1u;
            }
            RPCContext rPCContext = new RPCContext();

            if (callback != null)
            {
                rPCContext.Callback = callback;
                this.waitingForResponse.Add(num, rPCContext);
            }
            Header          header          = this.CreateHeader(serviceId, methodId, objectId, num, message.GetSerializedSize());
            BattleNetPacket battleNetPacket = new BattleNetPacket(header, message);

            rPCContext.Header  = header;
            rPCContext.Request = message;
            if (!this.m_connMetering.AllowRPCCall(serviceId, methodId))
            {
                this.m_pendingOutboundPackets.Add(battleNetPacket);
                this.LogOutgoingPacket(battleNetPacket, true);
            }
            else
            {
                this.QueuePacket(battleNetPacket);
            }
            return(rPCContext);
        }
Exemplo n.º 18
0
    public RPCContext QueueRequest(uint serviceId, uint methodId, IProtoBuf message, RPCContextDelegate callback = null, uint objectId = 0)
    {
        uint nextToken;

        if (message == null)
        {
            return(null);
        }
        object tokenLock = this.tokenLock;

        lock (tokenLock)
        {
            nextToken = RPCConnection.nextToken;
            RPCConnection.nextToken++;
        }
        RPCContext context = new RPCContext();

        if (callback != null)
        {
            context.Callback = callback;
            this.waitingForResponse.Add(nextToken, context);
        }
        bnet.protocol.Header h    = this.CreateHeader(serviceId, methodId, objectId, nextToken, message.GetSerializedSize());
        BattleNetPacket      item = new BattleNetPacket(h, message);

        context.Header  = h;
        context.Request = message;
        if (!this.m_connMetering.AllowRPCCall(serviceId, methodId))
        {
            this.m_pendingOutboundPackets.Add(item);
            this.LogOutgoingPacket(item, true);
            return(context);
        }
        this.QueuePacket(item);
        return(context);
    }
Exemplo n.º 19
0
 public BEBinaryReader(ResponseFrame input)
 {
     _stream = input.RawStream;
 }
Exemplo n.º 20
0
 public BattleNetPacket(Header h, IProtoBuf b)
 {
     this.header = h;
     this.body = b;
 }
Exemplo n.º 21
0
 public BattleNetPacket(Header h, IProtoBuf b)
 {
     this.header = h;
     this.body   = b;
 }
Exemplo n.º 22
0
 public BEBinaryReader(ResponseFrame input)
 {
     _stream = input.RawStream;
 }
Exemplo n.º 23
0
 public bool SendClientRequest(int type, IProtoBuf body, ClientRequestConfig clientRequestConfig, RequestPhase requestPhase = 1, int subID = 0)
 {
     return(this.SendClientRequestImpl(type, body, clientRequestConfig, requestPhase, subID));
 }