コード例 #1
0
        public static Assembly CompileParser(string source, OpCodes opcode)
        {
            source = AddImpliedCode(source, opcode);
            using (CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"))
            {
                CompilerParameters cp = new CompilerParameters();

                cp.GenerateInMemory = true;
                cp.TreatWarningsAsErrors = false;
                cp.GenerateExecutable = false;
                cp.ReferencedAssemblies.Add("System.dll");
                cp.ReferencedAssemblies.Add("System.Core.dll");
                cp.ReferencedAssemblies.Add("WowTools.Core.dll");
                cp.ReferencedAssemblies.Add("WoWPacketViewer.exe");

                CompilerResults cr = provider.CompileAssemblyFromSource(cp, source);

                if (cr.Errors.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (CompilerError ce in cr.Errors)
                        sb.AppendFormat("{0}", ce).AppendLine();
                    throw new Exception(sb.ToString());
                }

                return cr.CompiledAssembly;
            }
        }
コード例 #2
0
ファイル: Packet.cs プロジェクト: arkanoid1/mywowtools
 public Packet(Direction direction, OpCodes opcode, byte[] data, uint unixtime, uint tickscount)
 {
     Direction = direction;
     Code = opcode;
     Data = data;
     UnixTime = unixtime;
     TicksCount = tickscount;
 }
コード例 #3
0
 public Command(OpCodes opcode, List <string> flags,
                List <string> operands)
 {
     this.Opcode   = opcode.ToString("g");
     this.Space    = "SNES";
     this.Flags    = flags;
     this.Operands = operands;
 }
コード例 #4
0
 public VMOpCode GetOpCodeValue(int value)
 {
     if (OpCodes.TryGetValue(value, out var opc))
     {
         return(opc);
     }
     return(VMOpCode.Nop);
 }
コード例 #5
0
ファイル: NetworkManager.cs プロジェクト: AliDeym/Bifler
        /// <summary>
        /// Writes the specified packet into the network.
        /// </summary>
        /// <param name="opCode">OpCode of the specified Packet.</param>
        public void WritePacket(OpCodes opCode)
        {
            var packet = packets [(byte)opCode];

            packet.HandleWrite();

            packet.SendData(stream);
        }
コード例 #6
0
ファイル: Packet.cs プロジェクト: frostmourne/toms_tools
 public Packet(Direction direction, OpCodes opcode, byte[] data, uint unixtime, uint tickscount)
 {
     Direction  = direction;
     Code       = opcode;
     Data       = data;
     UnixTime   = unixtime;
     TicksCount = tickscount;
 }
コード例 #7
0
 /// <summary>
 /// create an instance of a MonitorMessage with a list of int as the message body
 /// </summary>
 /// <param name="_op">the operation type</param>
 /// <param name="_as">0 if operation was succesfull, non zero otherwise</param>
 /// <param name="_aps">error code, 0 if not error</param>
 /// <param name="_body">body of the message</param>
 public MonitorMessage(OpCodes _op, int _as, int _aps, int[] _body)
 {
     Body = _body.Select(x => x.ToString()).ToArray();
     As = _as;
     Aps = _aps;
     OpCode = _op;
     OpCode_Raw = (int)_op;
 }
コード例 #8
0
 public void OpCodesLessThanOrEqualTo255()
 {
     foreach (string s in Enum.GetNames(typeof(OpCodes)))
     {
         OpCodes code = (OpCodes)Enum.Parse(typeof(OpCodes), s);
         Assert.IsTrue((int)code <= 255, $"OpCode {s} had a value of {(int)code:X}, which is more than the maximum allowed of FF.");
     }
 }
コード例 #9
0
 /// <summary>
 /// Contains an IRMap translated opcode and the registers at execution time for a particular bytecode instruction.
 /// </summary>
 /// <param name="iROp"></param>
 /// <param name="originalOp"></param>
 /// <param name="originalIndex">Index of original instruction.</param>
 /// <param name="regA"></param>
 /// <param name="regB"></param>
 /// <param name="regC"></param>
 public IntegratedInstruction(IRMap iROp, BytecodeInstruction bci)
 {
     this.bci      = bci;
     this.iROp     = iROp;
     registers     = bci.regs;
     originalOp    = bci.opcode;
     originalIndex = bci.index;
 }
コード例 #10
0
 public void OpCodesGreaterThanZero()
 {
     foreach (string s in Enum.GetNames(typeof(OpCodes)))
     {
         OpCodes code = (OpCodes)Enum.Parse(typeof(OpCodes), s);
         Assert.IsTrue((int)code >= 0, $"OpCode {s} had a value of {(int)code:X}, which is less than the minimum allowed of 00.");
     }
 }
コード例 #11
0
 /// <summary>
 /// create an instance of a MonitorMessage with a list of strings as the message body
 /// </summary>
 /// <param name="_op">the operation type</param>
 /// <param name="_as">0 if operation was succesfull, non zero otherwise</param>
 /// <param name="_aps">error code, 0 if not error</param>
 /// <param name="_body">body of the message</param>
 public MonitorMessage(OpCodes _op, int _as, int _aps, string[] _body)
 {
     Body = _body;
     As = _as;
     Aps = _aps;
     OpCode = _op;
     OpCode_Raw = (int) _op;
 }
コード例 #12
0
        public static void HandleOpCodes(Decode decode)
        {
            try
            {
                Systems sys = (Systems)decode.Packet;
                sys.PacketInformation = decode;
                PacketReader reader = new PacketReader(sys.PacketInformation.buffer);
                LogDebug.Show("Opcode: {0}", decode.opcode);
                OpCodes opc = (OpCodes)decode.opcode;
                if (opc == OpCodes._MSG_LOGIN)
                {
                    {
                        string usernameShift = reader.String(32);
                        string passwordMd5   = reader.String(32);
                        reader.Skip(4);
                        string clientMac = reader.String(32);
                        reader.Skip(32);
                        uint        unk3     = reader.UInt32();
                        StringShift shift    = new StringShift();
                        string      username = shift.Parser(usernameShift);
                        LogDebug.Show("username: {0}", username);
                        LogDebug.Show("password_md5: {0}", passwordMd5);
                        LogDebug.Show("MAC: {0}", clientMac);
                        LogDebug.Show("unk3: {0}", unk3);
                        int res = UserLogin(username, passwordMd5, clientMac);
                        switch (res)
                        {
                        case (int)AuthenticationStatus.OK:
                        {
                            sys.client.SendC(ServerList());
                            break;
                        }

                        case (int)AuthenticationStatus.BANNED:
                        {
                            sys.client.SendC(UserFail(0xF0, Reason.BANNED));
                            break;
                        }

                        default:
                        {
                            sys.client.SendC(UserFail(0xF0, Reason.AUTH_FAILED));
                            break;
                        }
                        }
                    }
                }
                else
                {
                    LogConsole.Show("Default Opcode: {0:X} - {1}", decode.opcode, opc);
                    LogDebug.HexDump(sys.PacketInformation.buffer, 16, true, false);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
コード例 #13
0
        internal void LogIL(OpCode opcode, object arg, bool fake = false, string extra = null)
        {
            if (debug)
            {
                var argStr     = FormatArgument(arg, extra);
                var space      = argStr.Length > 0 ? " " : "";
                var opcodeName = opcode.ToString();
                if (opcodeName.StartsWith("br") && opcodeName != "break")
                {
                    opcodeName += " =>";
                }
                opcodeName = opcodeName.PadRight(10);
                FileLog.LogBuffered(string.Format("{0}{1}{2}{3}", CodePos(), opcodeName, space, argStr));
            }

            if (fake)
            {
                return;
            }

            offset += opcode.SizeOffset();
            var isSingleByte = OpCodes.TakesSingleByteArgument(opcode);

            if (arg is LocalBuilder)
            {
                if (opcode.OperandType != OperandType.InlineNone)
                {
                    offset += isSingleByte ? 1 : 2;
                }
                return;
            }
            if (arg is Label[])
            {
                offset += 4 + ((Label[])arg).Length * 4;
                return;
            }
            if (arg is Label)
            {
                offset += isSingleByte ? 1 : 4;
                return;
            }
            if (arg is byte || arg is sbyte)
            {
                offset += 1;
                return;
            }
            if (arg is short)
            {
                offset += 2;
                return;
            }
            if (arg is long || arg is double)
            {
                offset += 8;
                return;
            }
            offset += 4;
        }
コード例 #14
0
ファイル: Day16.cs プロジェクト: xepherys/AdventOfCode
        public static void Day16b1()
        {
            List <Set> sets = ParseSets();
            OpCodes    oc   = new OpCodes();

            oc.TestAllForOpCodes(sets);

            Dictionary <int, List <string[]> > valueSets = oc.GetValueSets();
        }
コード例 #15
0
        public void IdentifyStopCode()
        {
            var input        = "99,30,40,50";
            var intProcessor = new IntCodeProcessor(input);

            OpCodes actual = intProcessor.FindOperation(0);

            actual.ShouldBe(OpCodes.Stop);
        }
コード例 #16
0
        public void IdentifyMultiplicationCode()
        {
            var input        = "2,3,11,0";
            var intProcessor = new IntCodeProcessor(input);

            OpCodes actual = intProcessor.FindOperation(0);

            actual.ShouldBe(OpCodes.Multiplication);
        }
コード例 #17
0
        public void IdentifyAdditionCode()
        {
            var input        = "1,9,10,3";
            var intProcessor = new IntCodeProcessor(input);

            OpCodes actual = intProcessor.FindOperation(0);

            actual.ShouldBe(OpCodes.Addition);
        }
コード例 #18
0
ファイル: BaseHeldEntity.cs プロジェクト: dogfood1/UServer3
        private bool RPC_OnPlayerAttack(ERPCNetworkType type, Message message)
        {
            if (MeleeAim.HasCooldown() || AutoGather.HasCooldown())
            {
                return(true);
            }
            using (PlayerAttack playerAttack = PlayerAttack.Deserialize(message.read))
            {
                var attack = playerAttack.attack;
                if (attack.hitID == 0)
                {
                    return(true);
                }

                #region [BaseResource]
                var resource = Get <BaseResource>(attack.hitID);
                if (resource != null)
                {
                    attack.hitItem   = 0;
                    attack.hitBone   = 0;
                    attack.hitPartID = 0;
                    var pos = Settings.ManualGather_Bonus ? resource.GetHitPosition() : resource.Position;

                    // Если это OreResource
                    if (pos != resource.Position)
                    {
                        attack.hitPositionWorld = pos;
                        attack.hitNormalWorld   = pos;
                    }
                    AutoGather.SetCooldown((EPrefabUID)PrefabID);
                    if (VirtualServer.BaseClient.write.Start())
                    {
                        VirtualServer.BaseClient.write.PacketID(Message.Type.RPCMessage);
                        VirtualServer.BaseClient.write.EntityID(this.UID);
                        VirtualServer.BaseClient.write.UInt32((UInt32)ERPCMethodUID.PlayerAttack);
                        PlayerAttack.Serialize(VirtualServer.BaseClient.write, playerAttack);
                        VirtualServer.BaseClient.Send();
                        return(true);
                    }
                }
                #endregion

                #region [BasePlayer]
                if (Settings.Aimbot_Melee_Manual)
                {
                    var player = Get <BasePlayer>(playerAttack.attack.hitID);
                    if (player != null)
                    {
                        var typeHit = OpCodes.GetTargetHit((EHumanBone)attack.hitBone, Settings.Aimbot_Melee_Manual_AutoHeadshot);
                        MeleeAim.SetCooldown((EPrefabUID)this.PrefabID);
                        return(SendMeleeAttack(player, typeHit, player.Position));
                    }
                }
                #endregion
            }
            return(false);
        }
コード例 #19
0
 public static BitBuffer AddEntityHeader(this BitBuffer buffer, Peer peer, OpCodes opCode, bool clearBuffer = true)
 {
     if (clearBuffer)
     {
         buffer.Clear();
     }
     buffer.AddUShort((ushort)opCode).AddUInt(peer.ID);
     return(buffer);
 }
コード例 #20
0
ファイル: Instruction.cs プロジェクト: claassen/RIVM
 public Instruction(int value)
 {
     _opCode = (OpCodes)((value & 0xFF000000) >> 24);
     HasImmediate = (value & 0x00100000) != 0;
     _r1 =   (Register)((value & 0x000F0000) >> 16);
     _r2 =   (Register)((value & 0x0000F000) >> 12);
     _r3 =   (Register)((value & 0x00000F00) >> 8);
     _memoryAccessSize = value & 0x0000000F;
 }
コード例 #21
0
ファイル: Instruction.cs プロジェクト: Xtremrules/dot42
        public Instruction(OpCodes opcode, object operand, params Register[] registers)
            : this()
        {
            OpCode = opcode;
            Operand = operand;

            if (registers != null)
                Registers = new List<Register>(registers);
        }
コード例 #22
0
ファイル: MemCached.cs プロジェクト: jackjet870/MemCached
 /// <summary>
 /// 存储缓存
 /// </summary>
 /// <param name="code">存储方式</param>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象(需要可序列化)</param>
 /// <param name="expiry">缓存时长,0秒表示永久</param>
 /// <param name="cas">版本号(0表示忽略)</param>
 /// <exception cref="SocketException"></exception>
 /// <returns></returns>
 private OprationStatus Store(OpCodes code, string key, object value, TimeSpan expiry, long cas = 0)
 {
     return(this.Request <OprationStatus>(client =>
     {
         var valueBytes = client.ToBinary(value);
         var request = new StoreRequest(code, key, valueBytes, expiry, cas);
         return client.Send(request).Status;
     }));
 }
コード例 #23
0
 public Instruction(int value)
 {
     _opCode           = (OpCodes)((value & 0xFF000000) >> 24);
     HasImmediate      = (value & 0x00100000) != 0;
     _r1               = (Register)((value & 0x000F0000) >> 16);
     _r2               = (Register)((value & 0x0000F000) >> 12);
     _r3               = (Register)((value & 0x00000F00) >> 8);
     _memoryAccessSize = value & 0x0000000F;
 }
コード例 #24
0
ファイル: Instruction.cs プロジェクト: furesoft/HackIt-master
        public static Instruction Load(OpCodes opcode, object argument)
        {
            var instr = new Instruction();

            instr.Argument = argument;
            instr.OpCode   = opcode;

            return(instr);
        }
コード例 #25
0
        /// <summary>
        /// Retrieves a packet from stored handlers (using their OpCode).
        /// </summary>
        /// <param name="code">OpCode | Byte</param>
        /// <returns></returns>
        public Packet GetPacket(OpCodes code)
        {
            if (packets.ContainsKey((byte)code))
            {
                return(packets [(byte)code]);
            }

            return(null);
        }
コード例 #26
0
ファイル: StoreRequest.cs プロジェクト: jackjet870/MemCached
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="code">存储方式</param>
 /// <param name="key">键</param>
 /// <param name="value">值</param>
 /// <param name="expiry">时间</param>
 /// <param name="cas">版本号验证值(0表示忽略)</param>
 public StoreRequest(OpCodes code, string key, byte[] value, TimeSpan expiry, long cas = 0)
 {
     this.opCode = code;
     this.Key    = Encoding.ASCII.GetBytes(key);
     this.Value  = value;
     this.Expiry = (int)expiry.TotalSeconds;
     this.Flags  = 0;
     this.CAS    = cas;
 }
コード例 #27
0
        public void EmitBrtrue(ILabel label)
        {
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }
            var idx = ((AsmLabel)label).Idx;

            OpCodes.Add($"brtrue Label_{idx}");
        }
コード例 #28
0
ファイル: Instruction.cs プロジェクト: nathanial/lunula-fork
 public Instruction(uint code)
 {
     // 6 bits for the opcode
     // 13 bits for A
     // 13 bits for B
     OpCode = (OpCodes)(code & 0x3F);
     A = (ushort)((code >> 6) & 0x1FFF);
     B = (ushort)(code >> 19);
     AX = code >> 6;
 }
コード例 #29
0
ファイル: Instruction.cs プロジェクト: oujunke/Dexer
        public Instruction(OpCodes opcode, object operand, params Register[] registers) : this()
        {
            OpCode  = opcode;
            Operand = operand;

            if (registers != null)
            {
                Registers = new List <Register>(registers);
            }
        }
コード例 #30
0
        public void MarkLabel(ILabel label)
        {
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }
            var idx = ((AsmLabel)label).Idx;

            OpCodes.Add($"Label_{idx}:");
        }
コード例 #31
0
        private static float GetMeleeSpeed(EPrefabUID prefabUID)
        {
            var cooldown = OpCodes.GetMeleeHeldSpeed(prefabUID);

            if (Settings.AutoGather_Fast == false)
            {
                cooldown *= 2f;
            }
            return(cooldown);
        }
コード例 #32
0
        public void InstructionInputDependenciesEntryExists()
        {
            // Check all instructions have a dependency entry in the operand dependancy hashmap
            var values = Enum.GetValues(typeof(OpCodes.Op)).Cast <OpCodes.Op>();

            foreach (OpCodes.Op o in values)
            {
                OpCodes.GetInfo(o);
            }
        }
コード例 #33
0
ファイル: Method.cs プロジェクト: warlomak/MdInternals
        public OpCode GetNextOpCode(double currentIndex)
        {
            OpCode result = OpCodes.Where(i => i.Index > currentIndex).OrderBy(m => m.Index).FirstOrDefault();

            if (result == null)
            {
                result = ModuleOpCodes.Where(i => i.Index > currentIndex).OrderBy(m => m.Index).FirstOrDefault();
            }
            return(result);
        }
コード例 #34
0
        internal static ConversionInstruction GetInstruction(OpCodes opcode)
        {
            ConversionInstruction result = _knownInstructions[(int)opcode];

            if (null == result)
            {
                throw new ArgumentException();
            }
            return(result);
        }
コード例 #35
0
 public Instruction(uint code)
 {
     // 6 bits for the opcode
     // 13 bits for A
     // 13 bits for B
     OpCode = (OpCodes)(code & 0x3F);
     A      = (ushort)((code >> 6) & 0x1FFF);
     B      = (ushort)(code >> 19);
     AX     = code >> 6;
 }
コード例 #36
0
 public static bool Manual(PlayerProjectileAttack attack)
 {
     if (Instance.TargetPlayer != null)
     {
         EHumanBone typeHit = OpCodes.GetTargetHit((EHumanBone)attack.playerAttack.attack.hitBone, Settings.Aimbot_Range_Manual_AutoHeadshot);
         SendRangeAttack(Instance.TargetPlayer, typeHit, attack, Instance.TargetPlayer.Position);
         return(true);
     }
     return(false);
 }
コード例 #37
0
 public static IReadOnlySet <object> Apply(OpCodes op, IEnumerable left, IEnumerable right)
 {
     return(new HashSet <object>(op switch
     {
         OpCodes.Intersection => left.GetIntersection(right),
         OpCodes.Union => left.GetUnion(right),
         OpCodes.Difference => left.GetDifference(right),
         OpCodes.SymmetricDifference => left.GetSymmetricDifference(right),
         _ => throw new NotImplementedException(),
     }));
コード例 #38
0
        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();
        }
コード例 #39
0
ファイル: OpcodeDB.cs プロジェクト: Gintama/VoragineTools
 public static uint GetOpcode(OpCodes enumValue)
 {
     if(!Enabled)
     {
         return (uint) enumValue;
     }
     if (!EnumToNumber.ContainsKey(enumValue))
     {
         return 0;
     }
     return EnumToNumber[enumValue];
 }
コード例 #40
0
        public Instruction GenericInst(OpCodes code, AddressingModes addrMode, Action<GenericInstruction, int, int> exec, ArgumentType param1type = ArgumentType.None, ArgumentType param2type = ArgumentType.None)
        {
            var inst = new GenericInstruction(cpu, code, addrMode, param1type != ArgumentType.None) { runFunction = exec };

            if (param1type != ArgumentType.None)
            {
                inst.decodeArgumentsFunction = delegate(GenericInstruction sender, Memory.MemoryBin bin, ref InstructionDecodeContext context, ref int offset, ref int param1, ref int param2)
                {
                    switch (param1type)
                    {
                        case ArgumentType.None:
                            break;
                        default:
                        case ArgumentType.I1:
                            param1 = inst.DecodeInt1Argument(bin, ref offset);
                            break;
                        case ArgumentType.I2:
                            param1 = inst.DecodeInt2Argument(bin, ref offset);
                            break;
                        case ArgumentType.I3:
                            param1 = inst.DecodeInt3Argument(bin, ref offset);
                            break;
                    }

                    switch (param2type)
                    {
                        case ArgumentType.None:
                            break;
                        default:
                        case ArgumentType.I1:
                            param2 = inst.DecodeInt1Argument(bin, ref offset);
                            break;
                        case ArgumentType.I2:
                            param2 = inst.DecodeInt2Argument(bin, ref offset);
                            break;
                        case ArgumentType.I3:
                            param2 = inst.DecodeInt3Argument(bin, ref offset);
                            break;
                    }
                };
            }

            return inst;
        }
コード例 #41
0
ファイル: Character.cs プロジェクト: karliky/wowwow
		public override void ToAllPlayerNear( OpCodes code, byte []data, int after, int len )
		{
			account.ToAllPlayerNear( code, data, after, len );
		}
コード例 #42
0
ファイル: Character.cs プロジェクト: karliky/wowwow
		public void Send( OpCodes op, byte []b )
		{
			account.Handler.Send( op, b, b.Length );
		}
コード例 #43
0
ファイル: Character.cs プロジェクト: karliky/wowwow
		public override void ToAllPlayerNear( OpCodes code, byte []data )
		{
			account.ToAllPlayerNear( code, data );
		}
コード例 #44
0
 public static bool HasParser(OpCodes opcode)
 {
     return Parsers.ContainsKey(opcode) || MethodParsers.ContainsKey(opcode);
 }
コード例 #45
0
ファイル: Character.cs プロジェクト: karliky/wowwow
		public void Send( OpCodes op, byte []b, int len )
		{
			account.Handler.Send( op, b, len );
		}
コード例 #46
0
ファイル: Net.cs プロジェクト: karliky/wowwow
 public void Send( OpCodes opcode, byte []buffer, int len )
 {
     Send( (int)opcode, buffer, len );
 }
コード例 #47
0
        // Ack/Nack have same format accept for OpCode
        /// <summary>
        /// Handle details of creating Ack/Nack messages.  These are sent by the listener
        /// to clients on any message recived accept an InviteRequest (in this case an invite
        /// is sent).  Since the listener is so central to communications, clients attempt to
        /// communicate to it as reliably as possible and will retry sending a message several
        /// times if not Acked.
        /// Ack/Nack contains the standard header plus the sequence # of the message being
        /// acknowledge or negative-acknowledged
        /// </summary>
        /// <param name="ackSeq"></param>
        /// <param name="opCode"></param>
        /// <returns></returns>
        internal byte[] AckNackCreateHelper(int ackSeq, OpCodes opCode)
        {
            // Break Conversation into byte array
            byte[] ackSeqBytes = BitConverter.GetBytes(ackSeq);

            // Allocate buffer
            int bodyLength = ackSeqBytes.Length;
            int copyPos = 0;
            byte[] messageBody = AllocateMessageBuffer(opCode, bodyLength, ref copyPos);

            //Store sequence number
            Array.Copy(ackSeqBytes, 0, messageBody, copyPos, ackSeqBytes.Length);

            return messageBody;
        }
コード例 #48
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public OpCodeInvokeRangeInfo(OpCodes code)
     : base(code)
 {
 }
コード例 #49
0
 public GcodeOpCode(OpCodes opcode)
 {
     this.OpCode = opcode;
     this.Parameter = new GcodeParameter[0];
 }
コード例 #50
0
ファイル: Packet.cs プロジェクト: Gintama/VoragineTools
 public void DecompressDataAndSetOpcode(OpCodes opcode)
 {
     Data = Data.Decompress();
     OpcodeNumber = OpcodeDB.GetOpcode(opcode);
 }
コード例 #51
0
ファイル: Instruction.cs プロジェクト: Xtremrules/dot42
 public Instruction(OpCodes opcode, params Register[] registers)
     : this(opcode, null, registers)
 {
 }
コード例 #52
0
ファイル: Instruction.cs プロジェクト: Xtremrules/dot42
 public Instruction(OpCodes opcode)
     : this(opcode, null, (Register[])null)
 {
 }
コード例 #53
0
        /// <summary>
        /// Handle the common creation action of both Create and Terminate.  Format of both
        /// is to contain the standard header (with the appropriate OpCode) and the conversation
        /// name
        /// </summary>
        /// <param name="opCode"></param>
        /// <returns></returns>
        internal byte[] TerminateLeaveCreateHelper(OpCodes opCode)
        {
            // Break Conversation into byte array
            byte[] idBytes = MessageEncoding.GetBytes(_applicationID);

            // Allocate buffer
            int bodyLength = idBytes.Length;
            int copyPos = 0;
            byte[] messageBody = AllocateMessageBuffer(opCode, bodyLength, ref copyPos);

            //Store Conversation Name
            Array.Copy(idBytes, 0, messageBody, copyPos, idBytes.Length);

            return messageBody;
        }
コード例 #54
0
        // - - - - - -
        // Message base management
        // - - - - - -
        /// <summary>
        /// Allocates a message buffer and places the standard header info
        ///  copyStartPos is updated with the location to start writing message specific data
        ///
        /// opCode - Code to put in header
        /// bodyBytes - number of bytes required for the message body
        /// copyStartPos - Position in returned array to starting writing the body
        /// Standard layout of header
        /// 000 - 015: OppCommGuid
        /// 016 - 020: Sequence #
        /// 021 - 021: Opcode
        /// </summary>
        /// <param name="opCode"></param>
        /// <param name="bodyBytes"></param>
        /// <param name="copyStartPos"></param>
        /// <returns></returns>
        internal byte[] AllocateMessageBuffer(OpCodes opCode, int bodyBytes, ref int copyStartPos)
        {
            byte[] messageBuffer = new byte[MessageHeaderLength + bodyBytes];
            int copyPos = 0;

            // device ID
            Array.Copy(OppCommDeviceIDBytes, 0, messageBuffer, copyPos, OppCommDeviceIDBytes.Length);
            copyPos += OppCommDeviceIDBytes.Length;

            // Application ID
            Array.Copy(_applicationIDBytes, 0, messageBuffer, copyPos, _applicationIDBytes.Length);
            copyPos += _applicationIDBytes.Length;

            // Sequence #
            _currentSeq += 1;
            byte[] seqBytes = BitConverter.GetBytes(_currentSeq);
            Array.Copy(seqBytes, 0, messageBuffer, copyPos, seqBytes.Length);
            copyPos += 4;

            // OpCode
            messageBuffer[copyPos] = (byte)opCode;
            copyPos += 1;

            copyStartPos = MessageHeaderLength;

            return messageBuffer;
        }
コード例 #55
0
ファイル: Character.cs プロジェクト: karliky/wowwow
		public override void ToAllPlayerNearExceptMe( OpCodes code, byte []data, int len )
		{
			account.ToAllPlayerNearExceptMe( code, data, len );
		}
コード例 #56
0
 public static string GetClassName(OpCodes opcode)
 {
     return ToCamel(opcode.ToString()) + "Parser";
 }
コード例 #57
0
ファイル: Net.cs プロジェクト: karliky/wowwow
 public void Send( OpCodes opcode, byte []buffer )
 {
     if ( buffer == null )
         return;
     mutex.WaitOne();
     if ( result == null )
         result=new ByteArrayBuilder();
     buffer[ 1 ] = (byte)( ( buffer.Length - 2 ) & 0xff );
     buffer[ 0 ] = (byte)( ( ( buffer.Length - 2 ) >> 8 ) & 0xff );
     buffer[ 2 ] = (byte)( (int)opcode & 0xff );
     buffer[ 3 ] = (byte)( ( (int)opcode >> 8 ) & 0xff );
     if ( needEncode )
         Encode( buffer );
     result.Add( buffer );
     mutex.ReleaseMutex();
 }
コード例 #58
0
ファイル: Program.cs プロジェクト: arkanoid1/mywowtools
        private static void HexLike(GenericReader gr, StreamWriter hex, uint id, uint sess_id, string time, byte direction, OpCodes opcode)
        {
            int length = (int)(gr.Remaining);

            string dir = "";

            if (direction == 0)
                dir = "C->S";
            else
                dir = "S->C";

            hex.WriteLine("Packet {0}, id {1}, {2} ({3}), len {4}", dir, id, opcode, (ushort)opcode, length);
            //hex.WriteLine("Session {0}, time {1}", sess_id, time);

            int byteIndex = 0;

            int full_lines = length >> 4;
            int rest = length & 0x0F;

            if ((full_lines == 0) && (rest == 0)) // empty packet (no data provided)
            {
                hex.WriteLine("0000: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ................");
            }
            else
            {
                for (int i = 0; i < full_lines; ++i, byteIndex += 0x10)
                {
                    StringBuilder bytes = new StringBuilder();
                    StringBuilder chars = new StringBuilder();

                    for (int j = 0; j < 0x10; ++j)
                    {
                        int c = gr.ReadByte();

                        bytes.Append(c.ToString("X2"));

                        bytes.Append(' ');

                        if (c >= 0x20 && c < 0x80)
                            chars.Append((char)c);
                        else
                            chars.Append('.');
                    }

                    hex.WriteLine(byteIndex.ToString("X4") + ": " + bytes.ToString() + "| " + chars.ToString());
                }

                if (rest != 0)
                {
                    StringBuilder bytes = new StringBuilder();
                    StringBuilder chars = new StringBuilder(rest);

                    for (int j = 0; j < 0x10; ++j)
                    {
                        if (j < rest)
                        {
                            int c = gr.ReadByte();

                            bytes.Append(c.ToString("X2"));

                            bytes.Append(' ');

                            if (c >= 0x20 && c < 0x80)
                                chars.Append((char)c);
                            else
                                chars.Append('.');
                        }
                        else
                            bytes.Append("-- ");
                    }
                    hex.WriteLine(byteIndex.ToString("X4") + ": " + bytes.ToString() + "| " + chars.ToString());
                }
            }

            hex.WriteLine();
        }
コード例 #59
0
ファイル: Receiver.cs プロジェクト: bradsjm/LaJustPowerMeter
        /// <summary>
        /// Processes the device not responding (V1 receiver only).
        /// </summary>
        /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
        private void Process_HoguNotResponding(OpCodes opCode)
        {
            DeviceId id = new DeviceId();
            switch (opCode)
            {
                case OpCodes.ChungNotResponding:
                    id = _ChungDeviceId;
                    break;

                case OpCodes.HongNotResponding:
                    id = _HongDeviceId;
                    break;
            }

            Trace.TraceInformation("{0}. Process_HoguNotResponding: {1} Id={2}", CLASSNAME, opCode, id);

            if (id.IsValid())
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    OnDeviceStatusUpdate(new DeviceStatusEventData() { Receiver = this, DeviceId = id, DeviceStatus = DeviceStatusEnum.NotResponding });
                });
            }
        }
コード例 #60
0
ファイル: Instruction.cs プロジェクト: Xtremrules/dot42
 public Instruction(OpCodes opcode, object operand)
     : this(opcode, operand, null)
 {
 }