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); }
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); }
public BattleNetPacket(bnet.protocol.Header h, IProtoBuf b) { this.headerSize = -1; this.bodySize = -1; this.header = h; this.body = b; }
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); } }
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); }
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); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); } } }
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] }
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); }
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); }
public BEBinaryReader(ResponseFrame input) { _stream = input.RawStream; }
public BattleNetPacket(Header h, IProtoBuf b) { this.header = h; this.body = b; }
public BattleNetPacket(Header h, IProtoBuf b) { this.header = h; this.body = b; }
public BEBinaryReader(ResponseFrame input) { _stream = input.RawStream; }
public bool SendClientRequest(int type, IProtoBuf body, ClientRequestConfig clientRequestConfig, RequestPhase requestPhase = 1, int subID = 0) { return(this.SendClientRequestImpl(type, body, clientRequestConfig, requestPhase, subID)); }