示例#1
0
        /// <summary>
        /// 텔레포트 요청시 유효한 요청인지 확인 & 사용자 레벨에 따른 맵 이동 제한
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="client"></param>
        private void isPossibleTeleport(byte[] buffer, ref Client client)
        {
            MSG_C2S_REQ_TELEPORT reqTel = new MSG_C2S_REQ_TELEPORT();

            reqTel.Deserialize(ref buffer);
            if (reqTel.wTargetLine > Config.TeleportList.Count)
            {
                //bad request. if approval, ZS is crash.
                MSG_S2C_SAY pSay = new MSG_S2C_SAY();
                pSay.MsgHeader.dwPCID = client.Uid;
                pSay.szWords          = ByteTools.bSubString("Invalid request", 0x40);
                byte[] pSayByte = pSay.Serialize();
                //Config.mConvert.Convert_S2C(ref pSayByte, client.Ver);
                Write(ref client, pSayByte);
                Logger.WriteSDB(string.Format("[Try Crash]  {0}  {1}  {2}  {3}/{4}", client.Account, client.Character, client.IPadress, reqTel.wTargetLine, Config.TeleportList.Count));
                //client.TcpClient.Client.Disconnect(false);
            }
            else if (client.Level < Config.TeleportList[reqTel.wTargetLine].MapLv)
            {
                //account level is low
                MSG_S2C_SAY pSay = new MSG_S2C_SAY();
                pSay.MsgHeader.dwPCID = client.Uid;
                pSay.szWords          = ByteTools.bSubString(string.Format("{0}, You can not use this map at your level", client.Account), 0x40);
                byte[] pSayByte = pSay.Serialize();
                //Config.mConvert.Convert_S2C(ref pSayByte, client.Ver);
                Write(ref client, pSayByte);
            }
            else
            {
                Config.mConvert.Crypter.Encrypt(ref buffer, ClientVer.v562);
                ZoneServer.ZS[client.ZoneStatus].Send(buffer);
            }
        }
示例#2
0
        public virtual bool Parse()
        {
            if (RawRequest.Length < Size)
            {
                return(false);
            }

            Version    = RawRequest[MagicData.Length];
            PacketType = (NatPacketType)RawRequest[MagicData.Length + 1];
            Cookie     = BitConverter.ToUInt32(ByteTools.SubBytes(RawRequest, MagicData.Length + 2, 4));

            return(true);
        }
示例#3
0
        //This works fine as shared
        /// <summary>
        /// Injects a custom bitmap into a .bin file
        /// </summary>
        /// <param name="OriginalData">The original file we want to import our image into</param>
        /// <param name="Image">Our image to import</param>
        /// <param name="Codec">The N64Codec to use</param>
        /// <param name="ImageOffset">The offset of the image within the file</param>
        /// <param name="PaletteOffset">The offset of the palette within the file</param>
        public byte[] InjectImageIntoByteArray(int ImageOffset, int PaletteOffset, byte[] OriginalData, Bitmap Image, N64Codec Codec)
        {
            byte[] imageData = null, paletteData = null;

            N64GraphicsCoding.Convert(ref imageData, ref paletteData, Codec, Image);

            ByteTools.TrimEnd(paletteData);

            Array.Copy(imageData, 0, OriginalData, ImageOffset, imageData.Length);
            Array.Copy(paletteData, 0, OriginalData, PaletteOffset, paletteData.Length);

            return(OriginalData);
        }
        public override AudioFile Read(string fileName)
        {
            AudioFile audioFile = new AudioFile();

            byte[] vs    = File.ReadAllBytes(fileName + ".wav");
            int    index = 0;

            //Check File Validity
            if (ByteTools.BytesToString(vs, ref index, 4) != "RIFF")
            {
                throw new FileLoadException("File Header Invalid");
            }
            int tFileLength = (int)ByteTools.BytesToUInt(vs, ref index);

            if (ByteTools.BytesToString(vs, ref index, 4) != "WAVE")
            {
                throw new FileLoadException("File Header Invalid");
            }
            if (ByteTools.BytesToString(vs, ref index, 4) != "fmt ")
            {
                throw new FileLoadException("File Header Invalid");
            }
            //Read Format
            AudioFileFormat format           = new AudioFileFormat();
            int             lengthOfHeader   = (int)ByteTools.BytesToUInt(vs, ref index);
            int             indexAfterHeader = index + lengthOfHeader;

            index               += 2;
            format.nChannels     = ByteTools.BytesToUShort(vs, ref index);
            format.SampleRate    = ByteTools.BytesToUInt(vs, ref index);
            index               += 6;
            format.BitsPerSample = ByteTools.BytesToUShort(vs, ref index);
            index                = indexAfterHeader;
            //Check Validity Again
            while (ByteTools.BytesToString(vs, ref index, 4) != "data")
            {
                index -= 3;
                if (index > 100)
                {
                    throw new FileLoadException("File Header Invalid");
                }
            }
            //Read Audio Data
            audioFile.audioSize = ByteTools.BytesToUInt(vs, ref index);
            audioFile.audioData = new byte[(int)audioFile.audioSize];
            Array.Copy(vs, index, audioFile.audioData, 0, (int)audioFile.audioSize);
            //Return All Necessary Data
            audioFile.fileFormat = format;
            return(audioFile);
        }
示例#5
0
 protected virtual void GenerateServerInfoHeader(List <byte> header, GameServer server)
 {
     //add has key flag
     header.Add((byte)GameServerFlags.HasKeysFlag);
     //we add server public ip here
     header.AddRange(ByteTools.GetIPBytes(server.RemoteQueryReportIP));
     //we check host port is standard port or not
     CheckNonStandardPort(header, server);
     // now we check if there are private ip
     CheckPrivateIP(header, server);
     // we check private port here
     CheckPrivatePort(header, server);
     //we check icmp support here
     CheckICMPSupport(header, server);
 }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            UInt32 FileOffset = (UInt32)numericUpDown1.Value;

            FileOffset = FileOffset - (UInt32)GlobalData.Instance.ftable_arr[(int)numericUpDown2.Value];
            FileOffset = FileOffset - 0x2008;

            UInt32 TableOffset = (UInt32)GlobalData.Instance.ftable_arr[(int)numericUpDown2.Value] + 0x10;

            while (ByteTools.Read4Bytes(GlobalData.Instance.ROM, TableOffset) != FileOffset)
            {
                TableOffset += 0x08;
            }
            TableOffset = TableOffset - (UInt32)GlobalData.Instance.ftable_arr[(int)numericUpDown2.Value] - 0x10;
            TableOffset = TableOffset / 0x04 / 0x02;
            MessageBox.Show(TableOffset.ToString());
        }
示例#7
0
        public static byte[] SayMsg(uint uid, string msg, pSayType type)
        {
            MSG_S2C_HEADER header = new MSG_S2C_HEADER(uid, 0x1800);

            byte[] buffer = header.Serialize();
            buffer = ByteTools.CombineBytes(buffer, new byte[] { Convert.ToByte((byte)type) }, BitConverter.GetBytes(-1));
            if (type == pSayType.Notice)
            {
                buffer = ByteTools.CombineBytes(buffer, ByteTools.String2Bytes("NOTICE", 0x15));
            }
            else
            {
                buffer = ByteTools.CombineBytes(buffer, ByteTools.String2Bytes("SYSTEM", 0x15));
            }
            buffer = ByteTools.CombineBytes(buffer, ByteTools.String2Bytes(msg));
            BitConverter.GetBytes(buffer.Length).CopyTo(buffer, 0);
            return(buffer);
        }
示例#8
0
        public bool Parse(byte[] recv)
        {
            ushort length = ByteTools.ToUInt16(ByteTools.SubBytes(recv, 0, 2), true);

            if (length != recv.Length)
            {
                return(false);
            }

            byte[] ip   = ByteTools.SubBytes(recv, 3, 4);
            byte[] port = ByteTools.SubBytes(recv, 7, 2);

            IPEndPoint iPEnd = ByteTools.GetIPEndPoint(ip, port);

            TargetServerIP       = iPEnd.Address.ToString();
            TargetServerHostPort = iPEnd.Port.ToString();

            return(true);
        }
示例#9
0
        public bool Parse(byte[] recv)
        {
            ushort length = ByteTools.ToUInt16(ByteTools.SubBytes(recv, 0, 2), true);

            //if(recv.Length<length)
            //{
            //    return false;
            //}

            byte[] ip   = ByteTools.SubBytes(recv, 3, 4);
            byte[] port = ByteTools.SubBytes(recv, 7, 2);
            Array.Reverse(port);

            IPEndPoint iPEnd = ByteTools.GetIPEndPoint(ip, port);

            TargetServerIP       = iPEnd.Address.ToString();
            TargetServerHostPort = iPEnd.Port.ToString();

            return(true);
        }
        public override bool Parse()
        {
            if (!base.Parse())
            {
                return(false);
            }
            PortType    = RawRequest[13];
            ClientIndex = RawRequest[14];

            NatResult = (NATNegotiationResult)RawRequest[15];

            NatType = (NATNegotiationType)BitConverter.ToInt32(
                ByteTools.SubBytes(RawRequest, 17, sizeof(int)));
            MappingScheme = (NATNegotiationMappingScheme)BitConverter.ToInt32(
                ByteTools.SubBytes(RawRequest, 19, sizeof(int)));
            GameName = Encoding.ASCII.GetString(
                ByteTools.SubBytes(RawRequest, 23, RawRequest.Length - 23));

            return(true);
        }