Example #1
0
        public DllHeader(Dll dll, short pos)
            : base(0x00)
        {
            uint size = dll.Size;
            if (size > (65535 - 8)) size = 65535 - 8;
            DllSize = (ushort)size;

            EnsureCapacity((ushort)(DllSize + 3));

            m_Writer.Write((byte)0x03);
            m_Writer.Write((ushort)pos);
            m_Writer.Write((byte[])dll.Data, 0, DllSize);
        }
Example #2
0
        public SimpleDllHeader(Dll dll)
            : base(0x00)
        {
            uint size = dll.Size;
            if (size > (65535 - 10)) size = 65535 - 10;
            DllSize = (ushort)size;

            EnsureCapacity((ushort)(DllSize + 5));

            m_Writer.Write((byte)0x05);
            m_Writer.Write((uint)dll.Size);
            m_Writer.Write((byte[])dll.Data, 0, DllSize);
        }
Example #3
0
        private static Plugin[] ReadLoadingOrder()
        {
            if (!File.Exists(Config.PluginInitOrderFile))
            {
                return(new Plugin[0]);
            }

            string[] info   = File.ReadAllLines(Config.PluginInitOrderFile);
            int      loaded = 0;

            Plugin[] order = new Plugin[info.Length];

            char[] splitter = new char[1];
            splitter[0] = ',';
            for (int i = 0; i < info.Length; i++)
            {
                string[] row = info[i].Split(splitter, 2);
                row[0] = row[0].Trim();
                row[1] = row[1].Trim();
                Dll c_dll = null;
                for (int j = 0; j < Dlls.Length; j++)
                {
                    if (Dlls[j].Name == row[0])
                    {
                        c_dll = Dlls[j];
                        break;
                    }
                }
                if (c_dll != null)
                {
                    int  number;
                    bool is_number = int.TryParse(row[1], out number);
                    for (int j = 0; j < c_dll.Plugins.Length; j++)
                    {
                        if (((is_number) && (number == c_dll.Plugins[j].Id)) || ((!is_number) && (row[1] == c_dll.Plugins[j].Name)))
                        {
                            order[loaded++] = c_dll.Plugins[j];
                            break;
                        }
                    }
                }
            }
            if (loaded != order.Length)
            {
                Plugin[] tmp = new Plugin[loaded];
                Array.Copy(order, tmp, loaded);
                order = tmp;
            }
            return(order);
        }
Example #4
0
        public SimpleDllHeader(Dll dll)
            : base(0x00)
        {
            uint size = dll.Size;

            if (size > (65535 - 10))
            {
                size = 65535 - 10;
            }
            DllSize = (ushort)size;

            EnsureCapacity((ushort)(DllSize + 5));

            m_Writer.Write((byte)0x05);
            m_Writer.Write((uint)dll.Size);
            m_Writer.Write((byte[])dll.Data, 0, DllSize);
        }
Example #5
0
        public DllHeader(Dll dll, short pos)
            : base(0x00)
        {
            uint size = dll.Size;

            if (size > (65535 - 8))
            {
                size = 65535 - 8;
            }
            DllSize = (ushort)size;

            EnsureCapacity((ushort)(DllSize + 3));

            m_Writer.Write((byte)0x03);
            m_Writer.Write((ushort)pos);
            m_Writer.Write((byte[])dll.Data, 0, DllSize);
        }
Example #6
0
        public DllContent(Dll dll, uint offset)
            : base(0x00)
        {
            uint size = dll.Size - offset;

            if (size > (65535 - 6))
            {
                size = 65535 - 6;
            }
            DllChunkSize = (ushort)size;
            DllOffset    = offset;

            EnsureCapacity((ushort)(DllChunkSize + 1));

            m_Writer.Write((byte)0x04);
            m_Writer.Write((byte[])dll.Data, (int)DllOffset, DllChunkSize);
        }
Example #7
0
        static Dll()
        {
            m_md5Provider = new MD5CryptoServiceProvider();
            if (Config.Is64Bit || Config.IsUnix)
            {
                Console.WriteLine("UOExt: 64bit or Unix env. Plugins info will be loaded from XML.");
            }


            if (!Directory.Exists(Config.ClientPluginsPath))
            {
                Dlls = new Dll[0];
                m_loadingOrder = new Plugin[0];
                return;
            }
            if (!File.Exists(Config.PluginInitOrderFile))
            {
                ConsoleColor cc = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("UOExt: Warning: No plugin init order file found. Loading all plugins.");
                Console.WriteLine("UOExt:           Path '{0}'", Config.PluginInitOrderFile);
                Console.ForegroundColor = cc;

                string[] files = Directory.GetFiles(Config.ClientPluginsPath, "*.plg");

                Dlls = new Dll[files.Length];
                for (int i = 0; i < files.Length; i++)
                {
                    Dlls[i] = new Dll(files[i], (ushort)i);
                }

                Queue<Plugin> order = new Queue<Plugin>();
                for (int i = 0; i < Dlls.Length; i++)
                {
                    for (int j = 0; j < Dlls[i].Plugins.Length; j++) order.Enqueue(Dlls[i].Plugins[j]);
                }
                m_loadingOrder = order.ToArray();

            }
            else
            {
                string[] info = File.ReadAllLines(Config.PluginInitOrderFile);

                Dictionary<string, Dll> dlls = new Dictionary<string,Dll>();
                Queue<Plugin> order = new Queue<Plugin>();

                ushort dll_id = 0;

                char[] splitter = new char[1];
                splitter[0] = ',';
                for (int i = 0; i < info.Length; i++)
                {
                    string[] row = info[i].Split(splitter, 2);
                    row[0] = row[0].Trim().ToUpper();

                    if (row[0][0] == ';') continue;
                    if (row.Length < 2)
                    {
                        ConsoleColor cc = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("UOExt: Warning: Illegal string found in plugin init order file. Skipping.");
                        Console.WriteLine("UOExt:           String: '{0}'", info[i]);
                        Console.ForegroundColor = cc;
                        continue;
                    }

                    row[1] = row[1].Trim();
                    ushort current_id;
                    if (!dlls.ContainsKey(row[0]))
                        dlls[row[0]] = new Dll(row[0], dll_id++);

                    current_id = dlls[row[0]].Id;

                    int number;
                    bool is_number = int.TryParse(row[1], out number);
                    for (int j = 0; j < dlls[row[0]].Plugins.Length; j++)
                        if (((is_number) && (number == dlls[row[0]].Plugins[j].Id)) || ((!is_number) && (dlls[row[0]].Plugins[j].Name == row[1])))
                        {
                            order.Enqueue(dlls[row[0]].Plugins[j]);
                            break;
                        }
                        
                }

                Dlls = new Dll[dlls.Count];
                foreach (Dll dll in dlls.Values)
                    Dlls[dll.Id] = dll;

                m_loadingOrder = order.ToArray();
            }
        }
Example #8
0
        public DllContent(Dll dll, uint offset)
            : base(0x00)
        {
            uint size = dll.Size - offset;
            if (size > (65535 - 6)) size = 65535 - 6;
            DllChunkSize = (ushort)size;
            DllOffset = offset;

            EnsureCapacity((ushort)(DllChunkSize + 1));

            m_Writer.Write((byte)0x04);
            m_Writer.Write((byte[])dll.Data, (int)DllOffset, DllChunkSize);
        }
Example #9
0
        static Dll()
        {
            m_md5Provider = new MD5CryptoServiceProvider();
            if (Config.Is64Bit || Config.IsUnix)
            {
                Console.WriteLine("UOExt: 64bit or Unix env. Plugins info will be loaded from XML.");
            }


            if (!Directory.Exists(Config.ClientPluginsPath))
            {
                Dlls           = new Dll[0];
                m_loadingOrder = new Plugin[0];
                return;
            }
            if (!File.Exists(Config.PluginInitOrderFile))
            {
                ConsoleColor cc = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("UOExt: Warning: No plugin init order file found. Loading all plugins.");
                Console.WriteLine("UOExt:           Path '{0}'", Config.PluginInitOrderFile);
                Console.ForegroundColor = cc;

                string[] files = Directory.GetFiles(Config.ClientPluginsPath, "*.plg");

                Dlls = new Dll[files.Length];
                for (int i = 0; i < files.Length; i++)
                {
                    Dlls[i] = new Dll(files[i], (ushort)i);
                }

                Queue <Plugin> order = new Queue <Plugin>();
                for (int i = 0; i < Dlls.Length; i++)
                {
                    for (int j = 0; j < Dlls[i].Plugins.Length; j++)
                    {
                        order.Enqueue(Dlls[i].Plugins[j]);
                    }
                }
                m_loadingOrder = order.ToArray();
            }
            else
            {
                string[] info = File.ReadAllLines(Config.PluginInitOrderFile);

                Dictionary <string, Dll> dlls  = new Dictionary <string, Dll>();
                Queue <Plugin>           order = new Queue <Plugin>();

                ushort dll_id = 0;

                char[] splitter = new char[1];
                splitter[0] = ',';
                for (int i = 0; i < info.Length; i++)
                {
                    string[] row = info[i].Split(splitter, 2);
                    row[0] = row[0].Trim().ToUpper();

                    if (row[0][0] == ';')
                    {
                        continue;
                    }
                    if (row.Length < 2)
                    {
                        ConsoleColor cc = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("UOExt: Warning: Illegal string found in plugin init order file. Skipping.");
                        Console.WriteLine("UOExt:           String: '{0}'", info[i]);
                        Console.ForegroundColor = cc;
                        continue;
                    }

                    row[1] = row[1].Trim();
                    ushort current_id;
                    if (!dlls.ContainsKey(row[0]))
                    {
                        dlls[row[0]] = new Dll(row[0], dll_id++);
                    }

                    current_id = dlls[row[0]].Id;

                    int  number;
                    bool is_number = int.TryParse(row[1], out number);
                    for (int j = 0; j < dlls[row[0]].Plugins.Length; j++)
                    {
                        if (((is_number) && (number == dlls[row[0]].Plugins[j].Id)) || ((!is_number) && (dlls[row[0]].Plugins[j].Name == row[1])))
                        {
                            order.Enqueue(dlls[row[0]].Plugins[j]);
                            break;
                        }
                    }
                }

                Dlls = new Dll[dlls.Count];
                foreach (Dll dll in dlls.Values)
                {
                    Dlls[dll.Id] = dll;
                }

                m_loadingOrder = order.ToArray();
            }
        }