/// <summary> /// Processes the packet. /// </summary> /// <param name="evt">Evt.</param> private void ProcessPacket(Event evt) { byte[] data = new byte[1024 + 4]; evt.Packet.CopyTo(data); BitBuffer buffer = new BitBuffer(128); buffer.FromArray(data, evt.Packet.Length); OpCodes op = (OpCodes)buffer.ReadInt(); uint id = buffer.ReadUInt(); if (DEBUG) { Console.WriteLine($"OPCODE: {op.ToString()}"); Console.WriteLine($"PEERID: {id.ToString()}"); } if (evt.Peer.ID != id) { Console.WriteLine($"ID Mismatch! {evt.Peer.ID} vs. {id}"); return; } Packet packet = evt.Packet; switch (op) { case OpCodes.PlayerLogin: //Answer OK SendToSingleClient(CreateAnswerPacketLogin("OK", evt.Peer.ID), evt.Peer.ID); break; } }
public static void RegisterHandlers(object targetClass) { handlers = new Dictionary <OpCodes, IPacketHandler>(); var types = Assembly.GetExecutingAssembly().GetTypes(); foreach (var type in types) { foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { PacketHandlerAttribute attribute = (PacketHandlerAttribute)method.GetCustomAttributes(typeof(PacketHandlerAttribute), false).SingleOrDefault(); if (attribute != null) { OpCodes opCode = attribute.OpCode; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Registered opCode handler: " + opCode.ToString()); Console.ForegroundColor = ConsoleColor.White; Type packetType = method.GetParameters()[1].ParameterType; Delegate del = Delegate.CreateDelegate(typeof(Action <,>).MakeGenericType(typeof(NetConnection), packetType), targetClass, method); IPacketHandler handler = (IPacketHandler)Activator.CreateInstance(typeof(PacketHandler <>).MakeGenericType(packetType), del); handlers.Add(opCode, handler); } } } }
public Command(OpCodes opcode, List <string> flags, List <string> operands) { this.Opcode = opcode.ToString("g"); this.Space = "SNES"; this.Flags = flags; this.Operands = operands; }
public static string AddImpliedCode(string source, OpCodes opcode) { bool knownOpcode = Enum.IsDefined(typeof (OpCodes), opcode); StringBuilder s = new StringBuilder(source.Length + 300); if (!source.Contains("using WowTools.Core")) { s.Append( @"using System; using System.Collections.Generic; using WowTools.Core;").AppendLine().AppendLine(); } int tab = 0; if (!source.Contains("namespace WoWPacketViewer")) { s.Append("namespace WoWPacketViewer").AppendLine(); s.Append("{").AppendLine(); tab++; } if (!source.Contains(" class ")) { s.AppendFormat(" public class {0} : Parser", GetClassName(opcode)).AppendLine(); s.Append(" {").AppendLine(); tab++; } if(!source.Contains(" void ")) // hacky: assumes parser functions return void { if(!knownOpcode) { s.AppendFormat(" [Parser((OpCodes){0})]", opcode).AppendLine(); } string funcName = knownOpcode ? opcode.ToString() : "Handle" + (uint) opcode; s.AppendFormat(" public void {0}()", funcName).AppendLine(); s.Append(" {").AppendLine(); tab++; } var lines = source.Split(new[] {Environment.NewLine}, StringSplitOptions.None); foreach(string line in lines) { s.Append(new string(' ', 4*tab)); // add tabulation s.Append(line).AppendLine(); } for (int i = tab - 1; i >= 0; i--) { s.Append(new string(' ', 4 * i)).Append("}").AppendLine(); } using (var debug = new StreamWriter("LastParser.cs")) // output complete code for possible debugging { debug.WriteLine(s.ToString()); } return s.ToString(); }
public static Instruction Decode(int value) { OpCodes opCode = (OpCodes)((value & 0xFF000000) >> 24); if (_instructions.ContainsKey(opCode)) { return(_instructions[opCode](value)); } else { return(new Halt(0)); throw new Exception("Unknown opcode: " + opCode.ToString()); } }
private void HandleENETMessage(Event evt) { Console.WriteLine($"\nreceived by {Context.Self.Path}" + $"\nsender {Sender.Path}\n"); byte[] data = new byte[1024 + 4]; evt.Packet.CopyTo(data); //var test = evt.Packet.Length; BitBuffer buffer = new BitBuffer(128); buffer.FromArray(data, evt.Packet.Length); OpCodes op = (OpCodes)buffer.ReadInt(); uint id = buffer.ReadUInt(); if (DEBUG) { Console.WriteLine($"OPCODE: {op.ToString()}"); Console.WriteLine($"PEERID: {id.ToString()}"); } if (evt.Peer.ID != id) { Console.WriteLine($"ID Mismatch! {evt.Peer.ID} vs. {id}"); return; } Packet packet = evt.Packet; switch (op) { case OpCodes.PlayerLogin: //Answer OK SendToSingleClient(CreateAnswerPacketLogin("OK", evt.Peer.ID), evt.Peer.ID); break; } //Destroy all evt.Packet.Dispose(); }
internal static void Emit(this StreamWriter sw, OpCodes Operator, object operand) { var cmd = new StringBuilder(Operator.ToString()); if (operand != null) { cmd.Append(' '); if (operand is bool) { cmd.Append((bool)operand ? "ON" : "OFF"); } else if (operand is string) { cmd.Append(operand); } else { throw new ApplicationException("What is that?"); } } sw.WriteLine(cmd.ToString()); }
public static string GetClassName(OpCodes opcode) { return ToCamel(opcode.ToString()) + "Parser"; }
private void PacketHandle(ClientConnection Client) { this.Timer.Run(Client); if (Client.Data.Length > 1) { OpCodes oP = Client.GetOP(Client.Data); Console.WriteLine(oP.ToString()); this.OutPacket.Clear(); Client.Data.Seek(6); switch (oP) { case OpCodes.CMSG_CHAR_CREATE: { CHAR_CREATE_Handler handler2 = new CHAR_CREATE_Handler(); Client.Send(OpCodes.SMSG_CHAR_CREATE, handler2.CreateCharacter(Client.Data, Client, this.DbManager)); break; } case OpCodes.CMSG_CHAR_ENUM: { CHAR_ENUM_Handler handler = new CHAR_ENUM_Handler(); Client.Send(OpCodes.SMSG_CHAR_ENUM, handler.CreateList(Client, this.DbManager)); break; } case OpCodes.CMSG_CHAR_DELETE: { CHAR_DELETE_Handler handler3 = new CHAR_DELETE_Handler(); Client.Send(OpCodes.SMSG_CHAR_DELETE, handler3.DeleteCharacter(Client.Data, Client, this.DbManager)); break; } case OpCodes.CMSG_PLAYER_LOGIN: { ulong num4; EnterWorld world = new EnterWorld(); Client.Data.Get(out num4); this.DbManager.Write("UPDATE characters SET online=1 WHERE guid='" + num4.ToString() + "'"); world.Login(Client, num4); break; } case OpCodes.MSG_NULL_ACTION: Client.Disconnect(); break; case OpCodes.CMSG_TUTORIAL_FLAG: uint num6; Client.Data.Get(out num6); this.DbManager.Write("UPDATE characters SET tutorialflags='" + num6.ToString() + "' WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); break; case OpCodes.CMSG_TUTORIAL_CLEAR: { string[] strArray = new string[] { "UPDATE characters SET tutorialflags='", uint.MaxValue.ToString(), "' WHERE guid='", Client.PlayerBase.guid.ToString(), "'" }; this.DbManager.Write(string.Concat(strArray)); break; } case OpCodes.CMSG_TUTORIAL_RESET: this.DbManager.Write("UPDATE characters SET tutorialflags=0 WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); break; case OpCodes.CMSG_QUERY_TIME: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_QUERY_TIME_RESPONSE, this.OutPacket); break; case OpCodes.CMSG_PLAYER_LOGOUT: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0, Client); break; case OpCodes.CMSG_LOGOUT_REQUEST: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0x4e20, Client); break; case OpCodes.CMSG_LOGOUT_CANCEL: this.logout.CancelLogout(Client); break; case OpCodes.CMSG_NAME_QUERY: ulong num5; Client.Data.Get(out num5); if (num5 != Client.PlayerBase.guid) { this.MySqlReader = this.DbManager.Read("SELECT name, race, class, gender FROM characters WHERE guid='" + num5.ToString() + "'"); if (!this.MySqlReader.Read()) { this.MySqlReader.Close(); } else { this.OutPacket.Add(num5); this.OutPacket.Add(this.MySqlReader[0].ToString()); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)this.MySqlReader.GetByte(1)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(3)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(2)); this.MySqlReader.Close(); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); } } else { this.OutPacket.Add(Client.PlayerBase.guid); this.OutPacket.Add(Client.PlayerBase.name); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)Client.PlayerBase.race); this.OutPacket.Add((uint)Client.PlayerBase.gender); this.OutPacket.Add((uint)Client.PlayerBase.class_); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); } break; case OpCodes.CMSG_MESSAGECHAT: case OpCodes.CMSG_UPDATE_ACCOUNT_DATA: case OpCodes.CMSG_GMTICKET_GETTICKET: case OpCodes.CMSG_SET_ACTIVE_MOVER: case OpCodes.CMSG_MEETINGSTONE_INFO: case OpCodes.CMSG_MOVE_TIME_SKIPPED: case OpCodes.CMSG_BATTLEFIELD_STATUS: break; case OpCodes.CMSG_PING: uint num3; Client.Data.Get(out num3); this.OutPacket.Add(num3); Client.Send(OpCodes.SMSG_PONG, this.OutPacket); break; case OpCodes.CMSG_AUTH_SESSION: { uint num; uint num2; DatabaseManager manager; Client.Data.Get(out num); Client.Data.Seek(4); Client.Data.Get(out Client.User.Name); Client.User.Name = Client.User.Name.ToLower(); Client.User.Hash = new byte[40]; Client.Data.Get(out num2); byte[] array = Client.Data.GetArray(20); lock ((manager = StaticCore.RealmDbManager)) { this.MySqlReader = StaticCore.RealmDbManager.Read("SELECT sessionkey, level FROM accounts WHERE name='" + Client.User.Name + "'"); } if (!this.MySqlReader.Read()) { Client.Disconnect(); this.MySqlReader.Close(); } else { this.MySqlReader.GetBytes(0, (long)0, Client.User.Hash, 0, 40); Client.User.GMLevel = this.MySqlReader.GetInt32(1); this.MySqlReader.Close(); lock ((manager = StaticCore.RealmDbManager)) { StaticCore.RealmDbManager.Write("UPDATE accounts SET inworld=1, lastrealmid='" + StaticCore.RealmID.ToString() + "' WHERE name='" + Client.User.Name + "'"); } SHA1 sha = new SHA1CryptoServiceProvider(); ByteArrayBuilderV2 rv = new ByteArrayBuilderV2(); rv.Add(Encoding.ASCII.GetBytes(Client.User.Name.ToUpper())); rv.Add((uint)0); rv.Add(num2); rv.Add((uint)0xdeadbabe); rv.Add(Client.User.Hash); if (!WorldServer.Utils.IsSameByteArray(sha.ComputeHash((byte[])rv), array)) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else if (num != 0x16f3) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else { this.OutPacket.Add((byte)12); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } } break; } case OpCodes.CMSG_REQUEST_RAID_INFO: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_RAID_INSTANCE_INFO, this.OutPacket); break; default: Console.WriteLine("unhandled OpCode (" + oP.ToString() + ")"); break; } Client.MRE.Set(); } }
private void PacketHandle(ClientConnection Client) { ArrayList list = new ArrayList(); lock (Client.Packets) { foreach (ByteArrayBuilderV2 rv in Client.Packets) { list.Add(rv); } Client.Packets.Clear(); } foreach (ByteArrayBuilderV2 rv2 in list) { ulong num5; this.Timer.Run(Client); OpCodes oP = Client.GetOP(rv2); Console.WriteLine(oP.ToString()); this.OutPacket.Clear(); rv2.pos = 6; switch (oP) { case OpCodes.CMSG_PLAYER_LOGOUT: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0, Client); goto Label_0E44; case OpCodes.CMSG_LOGOUT_REQUEST: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0x4e20, Client); goto Label_0E44; case OpCodes.CMSG_LOGOUT_CANCEL: this.logout.CancelLogout(Client); goto Label_0E44; case OpCodes.CMSG_NAME_QUERY: rv2.Get(out num5); Console.WriteLine("name guid:{0}", num5); if (num5 != Client.PlayerBase.guid) { break; } this.OutPacket.Add(Client.PlayerBase.guid); this.OutPacket.Add(Client.PlayerBase.name); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)Client.PlayerBase.race); this.OutPacket.Add((uint)Client.PlayerBase.gender); this.OutPacket.Add((uint)Client.PlayerBase.class_); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_ITEM_QUERY_SINGLE: ulong num9; uint num10; rv2.Get(out num10); rv2.Get(out num9); Console.WriteLine("\nitem entry: " + num10.ToString() + " guid: " + num9.ToString()); this.OutPacket.Add(num10); this.OutPacket.Add((uint)4); this.OutPacket.Add((uint)1); this.OutPacket.Add("Circle of Flame"); this.OutPacket.Add("qname"); this.OutPacket.Add("honorname"); this.OutPacket.Add("enchname"); this.OutPacket.Add((uint)0x6e6c); this.OutPacket.Add((uint)4); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)100); this.OutPacket.Add((uint)10); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0x3b); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add(new byte[0x48]); this.OutPacket.Add((uint)7); this.OutPacket.Add((uint)100); this.OutPacket.Add(new byte[60]); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)10); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)20); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)50); this.OutPacket.Add((uint)10); this.OutPacket.Add(new byte[120]); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_ITEM_QUERY_SINGLE_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_PLAYER_LOGIN: { ulong num4; EnterWorld world = new EnterWorld(); rv2.Get(out num4); Console.WriteLine("PlayerBase guid:{0}", num4); this.DbManager.Write("UPDATE characters SET online=1 WHERE guid='" + num4.ToString() + "'"); world.Login(Client, num4); goto Label_0E44; } case OpCodes.CMSG_CHAR_CREATE: { CHAR_CREATE_Handler handler2 = new CHAR_CREATE_Handler(); Client.Send(OpCodes.SMSG_CHAR_CREATE, handler2.CreateCharacter(rv2, Client, this.DbManager)); goto Label_0E44; } case OpCodes.CMSG_CHAR_ENUM: case OpCodes.CMSG_UNKNOWN_908: { CHAR_ENUM_Handler handler = new CHAR_ENUM_Handler(); Client.Send(OpCodes.SMSG_CHAR_ENUM, handler.CreateList(Client, this.DbManager)); goto Label_0E44; } case OpCodes.CMSG_CHAR_DELETE: { CHAR_DELETE_Handler handler3 = new CHAR_DELETE_Handler(); Client.Send(OpCodes.SMSG_CHAR_DELETE, handler3.DeleteCharacter(rv2, Client, this.DbManager)); goto Label_0E44; } case OpCodes.MSG_NULL_ACTION: Client.Disconnect(); goto Label_0E44; case OpCodes.MSG_MOVE_START_FORWARD: case OpCodes.MSG_MOVE_START_BACKWARD: case OpCodes.MSG_MOVE_STOP: case OpCodes.MSG_MOVE_START_STRAFE_LEFT: case OpCodes.MSG_MOVE_START_STRAFE_RIGHT: case OpCodes.MSG_MOVE_STOP_STRAFE: case OpCodes.MSG_MOVE_JUMP: case OpCodes.MSG_MOVE_START_TURN_LEFT: case OpCodes.MSG_MOVE_START_TURN_RIGHT: case OpCodes.MSG_MOVE_STOP_TURN: case OpCodes.MSG_MOVE_START_PITCH_UP: case OpCodes.MSG_MOVE_START_PITCH_DOWN: case OpCodes.MSG_MOVE_STOP_PITCH: case OpCodes.MSG_MOVE_SET_RUN_MODE: case OpCodes.MSG_MOVE_SET_WALK_MODE: case OpCodes.MSG_MOVE_START_SWIM: case OpCodes.MSG_MOVE_STOP_SWIM: case OpCodes.MSG_MOVE_SET_FACING: case OpCodes.MSG_MOVE_SET_PITCH: case OpCodes.MSG_MOVE_HEARTBEAT: this.Movement.Move(Client, rv2); goto Label_0E44; case OpCodes.CMSG_MESSAGECHAT: case OpCodes.CMSG_UPDATE_ACCOUNT_DATA: case OpCodes.CMSG_GMTICKET_GETTICKET: case OpCodes.CMSG_SET_ACTIVE_MOVER: case OpCodes.CMSG_MEETINGSTONE_INFO: case OpCodes.CMSG_MOVE_TIME_SKIPPED: case OpCodes.CMSG_BATTLEFIELD_STATUS: goto Label_0E44; case OpCodes.CMSG_TUTORIAL_FLAG: uint num6; rv2.Get(out num6); this.DbManager.Write("UPDATE characters SET tutorialflags='" + num6.ToString() + "' WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); goto Label_0E44; case OpCodes.CMSG_TUTORIAL_CLEAR: { string[] strArray = new string[] { "UPDATE characters SET tutorialflags='", uint.MaxValue.ToString(), "' WHERE guid='", Client.PlayerBase.guid.ToString(), "'" }; this.DbManager.Write(string.Concat(strArray)); goto Label_0E44; } case OpCodes.CMSG_TUTORIAL_RESET: this.DbManager.Write("UPDATE characters SET tutorialflags=0 WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); goto Label_0E44; case OpCodes.CMSG_PING: uint num3; rv2.Get(out num3); this.OutPacket.Add(num3); Client.Send(OpCodes.SMSG_PONG, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_AUTH_SESSION: { uint num; uint num2; DatabaseManager manager; rv2.Get(out num); rv2.Seek(4); rv2.Get(out Client.User.Name); Client.User.Name = Client.User.Name.ToLower(); Client.User.Hash = new byte[40]; rv2.Get(out num2); byte[] array = rv2.GetArray(20); lock ((manager = StaticCore.RealmDbManager)) { this.MySqlReader = StaticCore.RealmDbManager.Read("SELECT sessionkey, level, burning FROM accounts WHERE name='" + Client.User.Name + "'"); } if (!this.MySqlReader.Read()) { Client.Disconnect(); this.MySqlReader.Close(); } else { this.MySqlReader.GetBytes(0, (long)0, Client.User.Hash, 0, 40); Client.User.GMLevel = this.MySqlReader.GetInt32(1); Client.User.BCEnabled = this.MySqlReader.GetBoolean(2); this.MySqlReader.Close(); lock ((manager = StaticCore.RealmDbManager)) { StaticCore.RealmDbManager.Write("UPDATE accounts SET inworld=1, lastrealmid='" + StaticCore.RealmID.ToString() + "' WHERE name='" + Client.User.Name + "'"); } SHA1 sha = new SHA1CryptoServiceProvider(); ByteArrayBuilderV2 rv3 = new ByteArrayBuilderV2(); rv3.Add(Encoding.ASCII.GetBytes(Client.User.Name.ToUpper())); rv3.Add((uint)0); rv3.Add(num2); rv3.Add((uint)0xdeadbabe); rv3.Add(Client.User.Hash); if (!WorldServer.Utils.IsSameByteArray(sha.ComputeHash((byte[])rv3), array)) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else if (num != 0x1992) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else { this.OutPacket.Add((byte)12); this.OutPacket.Add((byte)0xb0); this.OutPacket.Add((byte)9); this.OutPacket.Add((byte)2); this.OutPacket.Add((byte)0); this.OutPacket.Add((byte)2); this.OutPacket.Add((uint)0); if (Client.User.BCEnabled) { this.OutPacket.Add((byte)1); } else { this.OutPacket.Add((byte)0); } Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } } goto Label_0E44; } case OpCodes.CMSG_SWAP_INV_ITEM: byte num7; byte num8; rv2.Get(out num7); rv2.Get(out num8); Console.WriteLine("from: {0} to: {1}", num7, num8); this.OutPacket.Add((byte)4); this.OutPacket.Add((ulong)400); this.OutPacket.Add((ulong)0); this.OutPacket.Add((byte)0); Client.Send(OpCodes.SMSG_INVENTORY_CHANGE_FAILURE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_QUERY_TIME: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_QUERY_TIME_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_REQUEST_RAID_INFO: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_RAID_INSTANCE_INFO, this.OutPacket); goto Label_0E44; default: WorldServer.Utils.konzol((byte[])rv2); Console.WriteLine("unhandled OpCode (" + oP.ToString() + ")"); goto Label_0E44; } this.MySqlReader = this.DbManager.Read("SELECT name, race, class, gender FROM characters WHERE guid='" + num5.ToString() + "'"); if (!this.MySqlReader.Read()) { this.MySqlReader.Close(); } else { this.OutPacket.Add(num5); this.OutPacket.Add(this.MySqlReader[0].ToString()); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)this.MySqlReader.GetByte(1)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(3)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(2)); this.MySqlReader.Close(); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); } Label_0E44 :; } }
public override string ToString() { return(" II{ Op: " + iROp.ToString() + ", OriOp: " + originalOp.ToString() + ", A: " + bci.regs.regA + ", C: " + bci.regs.regC + ", B: " + bci.regs.regB + ", D: " + bci.regs.regD + " };"); }
private static void Disasm(Attributes.Code codeAttr, ConstantPool pool, CountingStreamWriter writer, string[] sourceFile) { byte[] code = codeAttr.CodeBytes; int i = 0; bool lastWide = false; Attributes.LineNumberTable lnt = codeAttr.Attributes.Where(A => A is Attributes.LineNumberTable).FirstOrDefault() as Attributes.LineNumberTable; Attributes.LineNumberTable newLnt = new Attributes.LineNumberTable(); int lastLine = 0; while (i < code.Length) { if ((lnt != null) && (sourceFile != null)) { try { var lns = lnt.Table.Where(ln => ln.StartPC <= i); if (lns.Count() > 0) { int currLine = lns.Aggregate((i1, i2) => i1.StartPC > i2.StartPC ? i1 : i2).LineNumberInFile; if (lastLine != currLine) { writer.WriteLine(" ## {0}", sourceFile[currLine]); } lastLine = currLine; } } catch (Exception) { } } newLnt.Table.Add(new Attributes.LineNumberTable.LineNumber((ushort)i, (ushort)writer.CurrLine)); OpCodes op = (OpCodes)code[i]; if (!lastWide) { writer.Write(" {0,4:X} : ", i); } if (op == OpCodes.wide) { writer.Write("wide "); i++; lastWide = true; continue; } string opStr = op.ToString(); string operandStr = ""; if (opStr[0] == '_') { opStr = opStr.Substring(1); } writer.Write(opStr); ByteCode.JavaInstructionDescption descr = ByteCode.JavaInstructions[op]; int operandSize = descr.Size - 1; if (lastWide) { operandSize *= 2; lastWide = false; } switch (descr.OpType) { case ByteCode.JavaOperandType.ConstPool: ushort index = (ushort)BitConverterBE.ReadAsInt32(code, i + 1, operandSize); operandStr = pool[index].ToString(); break; case ByteCode.JavaOperandType.ConstValue: case ByteCode.JavaOperandType.LocalVar: operandStr = BitConverterBE.ReadAsInt32(code, i + 1, operandSize).ToString(); break; case ByteCode.JavaOperandType.Offset: short offset = (short)BitConverterBE.ReadAsInt32(code, i + 1, operandSize); operandStr = String.Format("{0,4:X}", (i + offset)); break; case ByteCode.JavaOperandType.Special: switch (op) { case OpCodes.iinc: int op1 = BitConverterBE.ReadAsInt32(code, i + 1, operandSize / 2); int op2 = BitConverterBE.ReadAsInt32(code, i + 1 + operandSize / 2, operandSize / 2); operandStr = String.Format("{0}, {1}", op1, op2); break; case OpCodes.lookupswitch: int paddingLength = (4 - ((i + 1) % 4)) % 4; int _default = BitConverterBE.ReadAsInt32(code, i + paddingLength + 1, 4); int npairs = BitConverterBE.ReadAsInt32(code, i + paddingLength + 5, 4); int pairsStart = i + paddingLength + 9; operandSize = npairs * 8 + 8 + paddingLength; writer.WriteLine(" default: {0,4:X}, npairs: {1}", _default, npairs); for (int pair = 0; pair < npairs; pair++) { int pairValue = BitConverterBE.ReadAsInt32(code, pairsStart + (pair * 8), 4); int pairOffset = BitConverterBE.ReadAsInt32(code, pairsStart + (pair * 8) + 4, 4); writer.WriteLine(" {0,4:X} : {1}", pairOffset, pairValue); } break; case OpCodes.tableswitch: paddingLength = (4 - ((i + 1) % 4)) % 4; _default = BitConverterBE.ReadAsInt32(code, i + paddingLength + 1, 4); int low = BitConverterBE.ReadAsInt32(code, i + paddingLength + 5, 4); int hight = BitConverterBE.ReadAsInt32(code, i + paddingLength + 9, 4); writer.WriteLine(" default: {0,4:X}, low: {1}, hight: {2}", _default, low, hight); int jmpCount = hight - low + 1; int jmpStart = i + paddingLength + 13; operandSize = jmpCount * 4 + 13 + paddingLength; for (int jmp = 0; jmp < jmpCount; jmp++) { writer.WriteLine(" {0,4:X} : {1}", BitConverterBE.ReadAsInt32(code, jmpStart + jmp * 4, 4), low + jmp); } break; case OpCodes.invokeinterface: case OpCodes.invokedynamic: index = (ushort)BitConverterBE.ReadAsInt32(code, i + 1, 2); operandStr = pool[index].ToString(); break; case OpCodes.newarray: operandStr = ArrayTypes[code[i + 1]]; break; case OpCodes.multianewarray: index = (ushort)BitConverterBE.ReadAsInt32(code, i + 1, 2); byte dismensions = code[i + 3]; operandStr = String.Format("{0}, {1}", dismensions, pool[index].ToString()); break; } ; break; } writer.WriteLine(" {0}", operandStr); i += 1 + operandSize; } if (Program.DebugBytecode) { if (lnt != null) { codeAttr.Attributes.Remove(lnt); } codeAttr.Attributes.Add(newLnt); } }