Beispiel #1
0
 public static void Close()
 {
     Flush();
     if (m_Server != null)
     {
         try
         {
             m_Server.Shutdown(SocketShutdown.Both);
         }
         catch
         {
         }
         try
         {
             m_Server.Close();
         }
         catch
         {
         }
         m_Server = null;
     }
     if (m_Logger != null)
     {
         m_Logger.WriteLine();
         m_Logger.WriteLine("#####\tEnding packet log on {0}\t#####", DateTime.Now);
         m_Logger.Flush();
         m_Logger.Close();
         m_Logger = null;
     }
     if (m_Protocol != null)
     {
         m_Protocol.WriteLine();
         m_Protocol.WriteLine("#####\tEnding protocol log on {0}\t#####", DateTime.Now);
         m_Protocol.Flush();
         m_Protocol.Close();
         m_Protocol = null;
     }
     m_ServerIP       = null;
     m_ServerIPEP     = null;
     m_ServerHost     = null;
     m_Tree           = null;
     m_Buffer         = null;
     OnRecv           = null;
     OnSend           = null;
     OnPacketHandle   = null;
     m_Table          = null;
     m_UnpackBuffer   = null;
     m_OutputBuffer   = null;
     m_CryptoProvider = null;
 }
Beispiel #2
0
        static unsafe Network()
        {
            Engine.WantDirectory("Data/Logs/Network/");
            m_Leaves = new UnpackLeaf[0x201];
            int index = 0;

            m_Tree            = new UnpackLeaf(index);
            m_Leaves[index++] = m_Tree;
            fixed(short *numRef = m_Table)
            {
                short *numPtr = numRef;

                for (short i = 0; i <= 0x100; i = (short)(i + 1))
                {
                    UnpackLeaf tree = m_Tree;
                    numPtr++;
                    int num3 = numPtr[0];
                    int num4 = num3 & 15;
                    for (int j = num3 >> 4; --num4 >= 0; j = j >> 1)
                    {
                        switch ((j & 1))
                        {
                        case 0:
                            if (tree.m_Left == null)
                            {
                                tree.m_Left       = new UnpackLeaf(index);
                                m_Leaves[index++] = tree.m_Left;
                            }
                            tree = tree.m_Left;
                            break;

                        case 1:
                            if (tree.m_Right == null)
                            {
                                tree.m_Right      = new UnpackLeaf(index);
                                m_Leaves[index++] = tree.m_Right;
                            }
                            tree = tree.m_Right;
                            break;
                        }
                    }
                    tree.m_Value = i;
                }
            }

            m_Table = null;
        }
Beispiel #3
0
        static unsafe Network()
        {
            Engine.WantDirectory("Data/Logs/Network/");
            m_Leaves = new UnpackLeaf[0x201];
            int index = 0;
            m_Tree = new UnpackLeaf(index);
            m_Leaves[index++] = m_Tree;
            fixed (short* numRef = m_Table)
            {
                short* numPtr = numRef;
                for (short i = 0; i <= 0x100; i = (short) (i + 1))
                {
                    UnpackLeaf tree = m_Tree;
                    numPtr++;
                    int num3 = numPtr[0];
                    int num4 = num3 & 15;
                    for (int j = num3 >> 4; --num4 >= 0; j = j >> 1)
                    {
                        switch ((j & 1))
                        {
                            case 0:
                                if (tree.m_Left == null)
                                {
                                    tree.m_Left = new UnpackLeaf(index);
                                    m_Leaves[index++] = tree.m_Left;
                                }
                                tree = tree.m_Left;
                                break;

                            case 1:
                                if (tree.m_Right == null)
                                {
                                    tree.m_Right = new UnpackLeaf(index);
                                    m_Leaves[index++] = tree.m_Right;
                                }
                                tree = tree.m_Right;
                                break;
                        }
                    }
                    tree.m_Value = i;
                }
            }
            m_Table = null;
        }
Beispiel #4
0
        public override unsafe int Decrypt(byte[] input, int inputStart, int count, byte[] output, int outputStart)
        {
            fixed(byte *numRef = output)
            {
                byte *numPtr = numRef + outputStart;

                fixed(UnpackCacheEntry *entryRef = Network.m_CacheEntries)
                {
                    fixed(byte *numRef2 = Network.m_OutputBuffer)
                    {
                        fixed(byte *numRef3 = input)
                        {
                            UnpackLeaf leaf = this.m_Leaf;

                            UnpackLeaf[] leaves  = Network.m_Leaves;
                            byte *       numPtr3 = numRef3;
                            byte *       numPtr4 = numPtr3 + count;

                            while (numPtr3 < numPtr4)
                            {
                                UnpackCacheEntry entry = entryRef[leaf.m_Cache[*(numPtr3++)]];
                                leaf = leaves[entry.m_NextIndex];
                                byte *numPtr2 = numRef2 + entry.m_ByteIndex;
                                byte *numPtr5 = numPtr + entry.m_ByteCount;
                                while (numPtr < numPtr5)
                                {
                                    *(numPtr++) = *(numPtr2++);
                                }
                            }
                            this.m_Leaf = leaf;
                            if (numPtr >= (numRef + output.Length))
                            {
                                throw new InternalBufferOverflowException("Network::Decompress(): Buffer overflow.");
                            }
                        }
                    }
                }

                return((int)((long)(((numPtr - outputStart) - numRef) / 1)));
            }
        }
Beispiel #5
0
 public unsafe override int Decrypt(byte[] input, int inputStart, int count, byte[] output, int outputStart)
 {
     fixed (byte* numRef = output)
     {
         byte* numPtr = numRef + outputStart;
         fixed (UnpackCacheEntry* entryRef = Network.m_CacheEntries)
         {
             fixed (byte* numRef2 = Network.m_OutputBuffer)
             {
                 fixed (byte* numRef3 = input)
                 {
                     UnpackLeaf leaf = this.m_Leaf;
                     UnpackLeaf[] leaves = Network.m_Leaves;
                     byte* numPtr3 = numRef3;
                     byte* numPtr4 = numPtr3 + count;
                     while (numPtr3 < numPtr4)
                     {
                         UnpackCacheEntry entry = entryRef[leaf.m_Cache[*(numPtr3++)]];
                         leaf = leaves[entry.m_NextIndex];
                         byte* numPtr2 = numRef2 + entry.m_ByteIndex;
                         byte* numPtr5 = numPtr + entry.m_ByteCount;
                         while (numPtr < numPtr5)
                         {
                             *(numPtr++) = *(numPtr2++);
                         }
                     }
                     this.m_Leaf = leaf;
                     if (numPtr >= (numRef + output.Length))
                     {
                         throw new InternalBufferOverflowException("Network::Decompress(): Buffer overflow.");
                     }
                 }
             }
         }
         return (int) ((long) (((numPtr - outputStart) - numRef) / 1));
     }
 }
Beispiel #6
0
        public static unsafe void LoadUnpackCache()
        {
            m_OutputBuffer = new byte[0x18975];
            m_CacheEntries = new UnpackCacheEntry[0x10000];
            fixed(UnpackCacheEntry *entryRef = m_CacheEntries)
            {
                UnpackCacheEntry *entryPtr = entryRef;

                fixed(byte *numRef = m_OutputBuffer)
                {
                    Stack stack = new Stack();

                    stack.Push(m_Tree);
                    while (stack.Count > 0)
                    {
                        UnpackLeaf leaf2 = (UnpackLeaf)stack.Pop();
                        if (leaf2.m_Left != null)
                        {
                            stack.Push(leaf2.m_Left);
                        }
                        if (leaf2.m_Right != null)
                        {
                            stack.Push(leaf2.m_Right);
                        }
                        int[] numArray = new int[0x100];
                        for (int i = 0; i < 0x100; i++)
                        {
                            byte *     numPtr = numRef + m_OutputIndex;
                            UnpackLeaf left   = leaf2;
                            int        num2   = 0;
                            int        num    = 8;
                            while (--num >= 0)
                            {
                                switch (((i >> num) & 1))
                                {
                                case 0:
                                    left = left.m_Left;
                                    break;

                                case 1:
                                    left = left.m_Right;
                                    break;
                                }
                                if ((left != null) && (left.m_Value != -1))
                                {
                                    switch ((left.m_Value >> 8))
                                    {
                                    case 0:
                                        numPtr[num2++] = (byte)left.m_Value;
                                        break;

                                    case 1:
                                        num = 0;
                                        break;
                                    }
                                    left = m_Tree;
                                }
                            }
                            entryPtr->m_NextIndex = left.m_Index;
                            entryPtr->m_ByteIndex = m_OutputIndex;
                            entryPtr->m_ByteCount = num2;
                            numArray[i]           = (int)((long)((entryPtr - entryRef) / sizeof(UnpackCacheEntry)));
                            entryPtr++;
                            m_OutputIndex += num2;
                        }
                        leaf2.m_Cache = numArray;
                    }
                }
            }
        }
Beispiel #7
0
 public static void Close()
 {
     Flush();
     if (m_Server != null)
     {
         try
         {
             m_Server.Shutdown(SocketShutdown.Both);
         }
         catch
         {
         }
         try
         {
             m_Server.Close();
         }
         catch
         {
         }
         m_Server = null;
     }
     if (m_Logger != null)
     {
         m_Logger.WriteLine();
         m_Logger.WriteLine("#####\tEnding packet log on {0}\t#####", DateTime.Now);
         m_Logger.Flush();
         m_Logger.Close();
         m_Logger = null;
     }
     if (m_Protocol != null)
     {
         m_Protocol.WriteLine();
         m_Protocol.WriteLine("#####\tEnding protocol log on {0}\t#####", DateTime.Now);
         m_Protocol.Flush();
         m_Protocol.Close();
         m_Protocol = null;
     }
     m_ServerIP = null;
     m_ServerIPEP = null;
     m_ServerHost = null;
     m_Tree = null;
     m_Buffer = null;
     OnRecv = null;
     OnSend = null;
     OnPacketHandle = null;
     m_Table = null;
     m_UnpackBuffer = null;
     m_OutputBuffer = null;
     m_CryptoProvider = null;
 }
Beispiel #8
0
 protected override void InitKeys(uint seed)
 {
     this.m_Leaf = Network.m_Tree;
 }
Beispiel #9
0
 protected override void InitKeys(uint seed)
 {
     this.m_Leaf = Network.m_Tree;
 }