Пример #1
0
 public static CloudStorageBase Get()
 {
     if (Handler == null)
     {
         lock (LockObj)
         {
             if (Handler == null)
             {
                 Assembly[] LoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                 foreach (var Dll in LoadedAssemblies)
                 {
                     Type[] AllTypes = Dll.GetTypes();
                     foreach (var PotentialConfigType in AllTypes)
                     {
                         if (PotentialConfigType != typeof(CloudStorageBase) && typeof(CloudStorageBase).IsAssignableFrom(PotentialConfigType))
                         {
                             Handler = Activator.CreateInstance(PotentialConfigType) as CloudStorageBase;
                             break;
                         }
                     }
                 }
             }
         }
         if (Handler == null)
         {
             throw new AutomationException("Attempt to use CloudStorageBase.Get() and it doesn't appear that there are any modules that implement this class.");
         }
     }
     return(Handler);
 }
Пример #2
0
        public List <Dll> Post(ApiCall call)
        {
            var formresult = Kooboo.Lib.NETMultiplePart.FormReader.ReadForm(call.Context.Request.PostData);

            var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempDir);

            var dlls = new List <Dll>();

            foreach (var item in formresult.Files)
            {
                Dll newdll = new Dll();
                newdll.AssemblyName = Path.GetFileNameWithoutExtension(item.FileName);
                newdll.Content      = item.Bytes;

                var path = Path.Combine(tempDir, newdll.AssemblyName + ".dll");
                File.WriteAllBytes(path, newdll.Content);
                newdll.AssemblyVersion = AssemblyName.GetAssemblyName(path).Version.ToString();

                File.Delete(path);

                dlls.Add(newdll);
            }
            Directory.Delete(tempDir);

            foreach (var dll in dlls)
            {
                Data.GlobalDb.Dlls.AddOrUpdate(dll);
            }

            return(dlls);
        }
Пример #3
0
    protected void registerDLL(string name)
    {
        Dll dll = new Dll();

        dll.init(name);
        mDllLibraryList.Add(dll.getName(), dll);
    }
Пример #4
0
    public void init()
    {
        Dll dll = new Dll();

        dll.init(WINMM_DLL);
        mDllLibraryList.Add(dll.getName(), dll);
    }
Пример #5
0
 private static void Init()
 {
     if (!init)
     {
         string findJvmDir = FindJvmDir();
         AddEnvironmentPath(findJvmDir);
         var args = new JavaVMInitArgs();
         try
         {
             //just load DLL
             Dll.JNI_GetDefaultJavaVMInitArgs(&args);
             init = true;
         }
         catch (BadImageFormatException ex)
         {
             // it didn't help, throw original exception
             throw new JNIException("Can't initialize jni4net. (32bit vs 64bit JVM vs CLR ?)"
                                    + "\nCLR architecture: " + ((IntPtr.Size == 8) ? "64bit" : "32bit")
                                    + "\nJAVA_HOME: " + (Bridge.Setup == null || Bridge.Setup.JavaHome == null
                                                             ? "null"
                                                             : Path.GetFullPath(Bridge.Setup.JavaHome))
                                    , ex);
         }
     }
 }
Пример #6
0
        public void GetData(Resource res, Format format, int subresource, Size3 dim, IntPtr dst, uint size)
        {
            Debug.Assert(IO.SupportedFormats.Contains(format) || format == Format.R8_UInt);
            int pixelSize = 4;

            if (format == Format.R32G32B32A32_Float)
            {
                pixelSize = 16;
            }
            if (format == Format.R8_UInt)
            {
                pixelSize = 1;
            }

            // verify expected size
            Debug.Assert((uint)(dim.Product * pixelSize) == size);

            var data        = context.MapSubresource(res, subresource, MapMode.Read, MapFlags.None);
            int rowSize     = dim.Width * pixelSize;
            int sliceOffset = data.SlicePitch - data.RowPitch * dim.Height;

            for (int curZ = 0; curZ < dim.Depth; ++curZ)
            {
                for (int curY = 0; curY < dim.Height; ++curY)
                {
                    Dll.CopyMemory(dst, data.DataPointer, (uint)rowSize);
                    dst += rowSize;
                    data.DataPointer += data.RowPitch;
                }
                data.DataPointer += sliceOffset;
            }

            context.UnmapSubresource(res, subresource);
        }
Пример #7
0
        /// <summary>
        /// 私聊消息处理事件
        /// </summary>
        private static void FriendMessageHandler(string fn)
        {
            Task task = new Task(() =>
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ReceiveMessage PrivateMessage = JsonConvert.DeserializeObject <ReceiveMessage>(fn);
                string message = ProgressMessage.Start(PrivateMessage);
                var b          = Encoding.UTF8.GetBytes(message);
                message        = GB18030.GetString(Encoding.Convert(Encoding.UTF8, GB18030, b));
                int msgID      = PrivateMessage.CurrentPacket.Data.MsgSeq;

                ReceiveMessage.Data data = PrivateMessage.CurrentPacket.Data;
                if (PrivateMessage.CurrentPacket.Data.FromUin == Save.curentQQ && !Save.ReceiveSelfMsg)
                {
                    Dll.AddMsgToSave(new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin));
                    return;
                }
                int logid = LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "[↓]收到好友消息", $"QQ:{data.FromUin} {message}", "处理中...");
                var c     = new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin);
                Dll.AddMsgToSave(c);
                int pluginid = pluginManagment.CallFunction(FunctionEnums.Functions.PrivateMsg, 11, msgID, data.FromUin, Marshal.StringToHGlobalAnsi(message), 0);
                stopwatch.Stop();
                string updatemsg = $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s";
                if (pluginid > 0)
                {
                    updatemsg += $"(由 {pluginManagment.Plugins[pluginid - 1].appinfo.Name} 结束消息处理)";
                }
                LogHelper.UpdateLogStatus(logid, updatemsg);
            }); task.Start();
        }
Пример #8
0
        /// <summary>
        /// Injects the cheat.
        /// </summary>
        public static void Inject()
        {
            Console.WriteLine("[*] Initialized, injecting wallhack / esp.");
            Console.WriteLine("[*] Please wait...");

            FileInfo DllFile = new FileInfo("Library/RadicalHeights.Cheat." + Version + ".dll");

            if (DllFile.Exists)
            {
                Thread.Sleep(7000);

                bool Injected = Dll.TryInject(RadicalHeights.AttachedProcess, DllFile.FullName);

                if (Injected)
                {
                    Console.WriteLine("[*] ------------ HACK INJECTED ------------");
                }
                else
                {
                    Console.WriteLine("[*] Error, failed to inject into RadicalHeights.exe.");
                }
            }
            else
            {
                Console.WriteLine("[*] Error, Dll not found.");
            }
        }
Пример #9
0
        public ManualTransmission()
        {
            IniFile ini = new IniFile(path);

            animdict = ini.Read("animdict", "MTSupport");
            anim     = ini.Read("anim", "MTSupport");

            Tick += OnTick;
            mtlib = Dll.GetModuleHandle(@"Gears.asi");
            if (mtlib == IntPtr.Zero)
            {
                Logger.Write(logpath, "Process not found!");
            }
            else
            {
                Logger.Write(logpath, "Process present!");
            }

            IsActive         = CheckAddr <FnBool>(mtlib, "MT_IsActive");
            AddIgnoreVehicle = CheckAddr <SetInt>(mtlib, "MT_AddIgnoreVehicle");
            NeutralGear      = CheckAddr <FnBool>(mtlib, "MT_NeutralGear");
            ShiftMode        = CheckAddr <GetInt>(mtlib, "MT_GetShiftMode");

            if (IsActive == null || AddIgnoreVehicle == null || NeutralGear == null)
            {
                mtPresent = false;
                Logger.Write(logpath, "MTSupport disabled!");
            }
            else
            {
                mtPresent = true;
                Logger.Write(logpath, "MTSupport initialized!");
            }
        }
Пример #10
0
    public static void Main()
    {
        Dll l = new Dll();
        int i, lastscore = 7095000, numplayers = 431, player = 0;

        long[] players = new long[numplayers];
        for (i = 3; i <= lastscore; i++)
        {
            if (i % 23 != 0)
            {
                l.inc();
                l.insert(i);
            }
            else
            {
                players[player] += i;
                for (int j = 0; j < 7; j++)
                {
                    l.dec();
                }
                players[player] += l.getCurrent();
                l.delete();
            }
            player = (player + 1) % numplayers;
        }

        Array.Sort(players);
        Console.WriteLine(players[numplayers - 1]);
    }
Пример #11
0
        private void buttonReadImage_Click(object sender, RoutedEventArgs e)
        {
            OutputCallback = UVSSOutputCallback;//图像数据,高度,宽度,通道数
            Dll.SetOutputCallback(OutputCallback);

            Dll.StartReadImage();
        }
Пример #12
0
        public static LocalizationProvider GetLocalizationProvider(string InLocalizationProviderId, LocalizationProvider.LocalizationProviderArgs InLocalizationProviderArgs)
        {
            if (CachedLocalizationProviderTypes == null)
            {
                // Find all types that derive from LocalizationProvider in any of our DLLs
                CachedLocalizationProviderTypes = new Dictionary <string, Type>();
                var LoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (var Dll in LoadedAssemblies)
                {
                    var AllTypes = Dll.GetTypes();
                    foreach (var PotentialLocalizationNodeType in AllTypes)
                    {
                        if (PotentialLocalizationNodeType != typeof(LocalizationProvider) && !PotentialLocalizationNodeType.IsAbstract && !PotentialLocalizationNodeType.IsInterface && typeof(LocalizationProvider).IsAssignableFrom(PotentialLocalizationNodeType))
                        {
                            // Types should implement a static StaticGetLocalizationProviderId method
                            var Method = PotentialLocalizationNodeType.GetMethod("StaticGetLocalizationProviderId");
                            if (Method != null)
                            {
                                try
                                {
                                    var LocalizationProviderId = Method.Invoke(null, null) as string;
                                    CachedLocalizationProviderTypes.Add(LocalizationProviderId, PotentialLocalizationNodeType);
                                }
                                catch
                                {
                                    BuildCommand.LogWarning("Type '{0}' threw when calling its StaticGetLocalizationProviderId method.", PotentialLocalizationNodeType.FullName);
                                }
                            }
                            else
                            {
                                BuildCommand.LogWarning("Type '{0}' derives from LocalizationProvider but is missing its StaticGetLocalizationProviderId method.", PotentialLocalizationNodeType.FullName);
                            }
                        }
                    }
                }
            }

            Type LocalizationNodeType;

            CachedLocalizationProviderTypes.TryGetValue(InLocalizationProviderId, out LocalizationNodeType);
            if (LocalizationNodeType != null)
            {
                try
                {
                    return(Activator.CreateInstance(LocalizationNodeType, new object[] { InLocalizationProviderArgs }) as LocalizationProvider);
                }
                catch
                {
                    BuildCommand.LogWarning("Unable to create an instance of the type '{0}'", LocalizationNodeType.FullName);
                }
            }
            else
            {
                throw new AutomationException("Could not find a localization provider for: '" + InLocalizationProviderId + "'");
            }

            return(null);
        }
Пример #13
0
        public void FreeLoadedLibraries()
        {
            this.ThrowIfDisposed();

            foreach (ModuleHandle Dll in this.LoadedLibraries.ToArray())
            {
                Dll.Dispose();
            }
        }
Пример #14
0
        public void Cache(Dll model)
        {
            var sql = dllTable.InsertOrReplace(model);

            using (var con = ConnectionManager.Instance.CacheConnection)
            {
                con.Execute(sql);
            }
        }
Пример #15
0
        /// <summary>
        /// 群消息处理事件
        /// </summary>
        private static void GroupMessageHandler(string fn)
        {
            Task task = new Task(() =>
            {
                string msg          = fn;
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ReceiveMessage groupMessage = JsonConvert.DeserializeObject <ReceiveMessage>(msg);
                ReceiveMessage.Data data    = groupMessage.CurrentPacket.Data;
                //群文件事件
                if (groupMessage.CurrentPacket.Data.MsgType == "GroupFileMsg")
                {
                    JObject fileupload        = JObject.Parse(data.Content);
                    MemoryStream stream       = new MemoryStream();
                    BinaryWriter binaryWriter = new BinaryWriter(stream);
                    BinaryWriterExpand.Write_Ex(binaryWriter, fileupload["FileID"].ToString());
                    BinaryWriterExpand.Write_Ex(binaryWriter, fileupload["FileName"].ToString());
                    BinaryWriterExpand.Write_Ex(binaryWriter, Convert.ToInt64(fileupload["FileSize"].ToString()));
                    BinaryWriterExpand.Write_Ex(binaryWriter, 0);
                    pluginManagment.CallFunction(FunctionEnums.Functions.Upload, 1, GetTimeStamp(), data.FromGroupId,
                                                 data.FromUserId, Convert.ToBase64String(stream.ToArray()));
                    stopwatch.Stop();
                    LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "文件上传", $"来源群:{data.FromGroupId}({data.FromGroupName}) 来源QQ:{data.FromUserId}({data.FromNickName}) " +
                                       $"文件名:{fileupload["FileName"]} 大小:{Convert.ToDouble(fileupload["FileSize"]) / 1000}KB FileID:{fileupload["FileID"]}", $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s");
                    return;
                }
                string message = ProgressMessage.Start(groupMessage);
                var b          = Encoding.UTF8.GetBytes(message);
                message        = GB18030.GetString(Encoding.Convert(Encoding.UTF8, GB18030, b));

                //表示自己发送出去的消息, 写入消息列表
                int msgID = groupMessage.CurrentPacket.Data.MsgSeq;
                if (groupMessage.CurrentPacket.Data.FromUserId == Save.curentQQ && !Save.ReceiveSelfMsg)
                {
                    Dll.AddMsgToSave(new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin));
                    return;
                }
                int logid = LogHelper.WriteLog(LogLevel.InfoReceive, "OPQBot框架", "[↓]收到消息", $"群:{data.FromGroupId}({data.FromGroupName}) QQ:{data.FromUserId}({data.FromNickName}) {message}", "处理中...");
                var c     = new Deserizition.Message(msgID, data.MsgRandom, data.MsgSeq, data.FromUin, data.FromGroupId, data.MsgTime, message, data.TempUin);
                Dll.AddMsgToSave(c);//保存消息到消息列表
                byte[] messageBytes = GB18030.GetBytes(message + "\0");
                var messageIntptr   = Marshal.AllocHGlobal(messageBytes.Length);
                Marshal.Copy(messageBytes, 0, messageIntptr, messageBytes.Length);
                //调用插件功能
                int pluginid = pluginManagment.CallFunction(FunctionEnums.Functions.GroupMsg, 2, msgID, data.FromGroupId, data.FromUserId,
                                                            "", messageIntptr, 0);
                Marshal.FreeHGlobal(messageIntptr);
                GC.Collect();
                stopwatch.Stop();
                string updatemsg = $"√ {stopwatch.ElapsedMilliseconds / (double)1000:f2} s";
                if (pluginid > 0)
                {
                    updatemsg += $"(由 {pluginManagment.Plugins[pluginid - 1].appinfo.Name} 结束消息处理)";
                }
                LogHelper.UpdateLogStatus(logid, updatemsg);
            }); task.Start();
        }
Пример #16
0
        private T CheckAddr <T>(IntPtr lib, string Func) where T : class
        {
            IntPtr mtproc = Dll.GetProcAddress(lib, Func);

            if (mtproc == IntPtr.Zero)
            {
                Logger.Write(logpath, $"Process {lib} not found!");
            }
            return(Marshal.GetDelegateForFunctionPointer <T>(mtproc));
        }
Пример #17
0
        public Stream GetResource(string ResourceName)
        {
            string fullname = Dll.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(ResourceName));

            if (string.IsNullOrEmpty(fullname))
            {
                return(null);
            }
            return(Dll.GetManifestResourceStream(fullname));
        }
Пример #18
0
        public static void CreateJavaVM(out JavaVM jvm, out JNIEnv env, bool attachIfExists, params string[] options)
        {
            Init();
            IntPtr njvm;
            IntPtr nenv;
            var    args = new JavaVMInitArgs();

            args.version = JNI_VERSION_1_4;

            if (options.Length > 0)
            {
                args.nOptions = options.Length;
                var opt = new JavaVMOption[options.Length];
                for (int i = 0; i < options.Length; i++)
                {
                    opt[i].optionString = Marshal.StringToHGlobalAnsi(options[i]);
                }

                fixed(JavaVMOption *a = &opt[0])
                {
                    args.options = a;
                }
            }
            JNIResult result;

            if (attachIfExists)
            {
                IntPtr njvma;
                int    count;
                result = Dll.JNI_GetCreatedJavaVMs(out njvma, 1, out count);
                if (result != JNIResult.JNI_OK)
                {
                    throw new JNIException("Can't enumerate current JVMs " + result);
                }
                if (count > 0)
                {
                    njvm   = njvma;
                    jvm    = new JavaVM(njvm);
                    result = jvm.AttachCurrentThread(out env, args);
                    if (result != JNIResult.JNI_OK)
                    {
                        throw new JNIException("Can't join current JVM " + result);
                    }
                    return;
                }
            }
            result = Dll.JNI_CreateJavaVM(out njvm, out nenv, &args);
            if (result != JNIResult.JNI_OK)
            {
                Console.Error.WriteLine("Can't load JVM (already have one ?)");
                throw new JNIException("Can't load JVM (already have one ?) " + result);
            }
            jvm = new JavaVM(njvm);
            env = new JNIEnv(nenv);
        }
Пример #19
0
 public ReflectionCaller FindType(string TypeName)
 {
     foreach (Type type in Dll.GetTypes())
     {
         if (type.Name.EndsWith(TypeName))
         {
             Type = type;
         }
     }
     return(this);
 }
Пример #20
0
        public void Cache(RecognizedObjectResource recognizedResource)
        {
            var recognizedModel = new RecognizedObject()
            {
                Id        = recognizedResource.Id,
                Name      = recognizedResource.Name,
                ContentId = recognizedResource.Content.Id,
                Modified  = recognizedResource.Modified
            };
            var contentModel = new Content()
            {
                Id            = recognizedResource.Content.Id,
                Name          = recognizedResource.Content.Name,
                AssetBundleId = recognizedResource.Content.AssetBundle.Id,
                DllId         = recognizedResource.Content.Dll.Id,
                Modified      = recognizedResource.Content.Modified
            };

            if (recognizedResource.Content.Dll != null)
            {
                contentModel.DllId = recognizedResource.Content.Dll.Id;
            }
            var assetBundleModel = new AssetBundle()
            {
                Id       = recognizedResource.Content.AssetBundle.Id,
                Name     = recognizedResource.Content.AssetBundle.Name,
                Modified = recognizedResource.Content.AssetBundle.Modified
            };

            Dll dll = null;

            if (recognizedResource.Content?.Dll != null)
            {
                dll = new Dll()
                {
                    Id       = recognizedResource.Content.Dll.Id,
                    Name     = recognizedResource.Content.Dll.Name,
                    Modified = recognizedResource.Content.Dll.Modified
                };
            }

            using (var con = Connection)
            {
                con.Execute(recognizedObjectTable.InsertOrReplace(recognizedModel));
                con.Execute(contentTable.InsertOrReplace(contentModel));
                con.Execute(assetBundleTable.InsertOrReplace(assetBundleModel));

                if (dll != null)
                {
                    con.Execute(dllTable.InsertOrReplace(dll));
                }
            }
        }
Пример #21
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            if (Dll != null)
            {
                Dll.Dispose();
            }

            if (Pdb != null)
            {
                Pdb.Dispose();
            }
        }
Пример #22
0
    public static void CallFunction()
    {
        GameObject ob = GameObject.FindGameObjectWithTag("Drawing");

        if (ob != null && flag == false)
        {
            int det = Dll.Load();
            if (det == 1)
            {
                print("Detected");
                flag = true;
            }
        }
    }
Пример #23
0
        public IEnumerator Load(Dll model)
        {
            if (dllInfos.TryGetValue(model.Id, out var info))
            {
                if (ConnectionManager.Instance.ApiReachable && info.Syncronised == false)
                {
                    yield return(DownloadFile(info.Api));
                }

                LoadFile(info.Prefered);
            }
            else
            {
                ConsoleGUI.Instance.WriteLn($"Could not found DllInfo with an id of { model?.Id }.", Color.red);
            }
        }
Пример #24
0
 public void Dispose()
 {
     if (!disposed)
     {
         // KillMemCallbacks(); // not needed when not single instance
         if (Dll != null)
         {
             Dll.Dispose();
         }
         if (CD != null)
         {
             CD.Dispose();
         }
         disposed = true;
     }
 }
Пример #25
0
        private static void StartExecutionThread(object main)
        {
            Dll d = (main as Dll);



            try
            {
                Assembly a = Assembly.Load
                             (
                    File.ReadAllBytes(d.Path)
                             );



                MethodInfo entry_point = a.EntryPoint;

                if (entry_point != null)
                {
                    Type entry_point_type = entry_point.DeclaringType;
                    if (!entry_point_type.IsAbstract)
                    {
                        InvokeEntryPoint(entry_point, entry_point_type);
                    }

                    else
                    {
                        IEnumerable <Type> exporting_types = a.ExportedTypes;
                        Type start_assembly_type           = exporting_types.First();
                        InvokeEntryPoint(entry_point, start_assembly_type);
                    }


                    stop_run_dll_mutex.WaitOne();
                    awaiting_dlls.Remove(d.Name);
                    running_dlls.Add(d.Name, d);
                    running_dll_executing_threads.Add(d.Name, Thread.CurrentThread);
                    stop_run_dll_mutex.ReleaseMutex();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #26
0
        public void StartDll(string dll_name)
        {
            if (ValidateOnStartDll(ref dll_name))
            {
                Dll to_start = awaiting_dlls[dll_name];

                Thread t = new Thread(new ParameterizedThreadStart(StartExecutionThread));
                t.IsBackground = true;



                t.Start(to_start);

                //awaiting_dlls.Remove(dll_name);
                //running_dlls.Add(dll_name, to_start);
                //running_dll_executing_threads.Add(to_start.Name, t);
            }
        }
Пример #27
0
        public static void LoadDll(string name)
        {
            if (dll != null)
            {
                Log.WriteLine("dll already loaded! be careful!", Log.MessageType.Error);
                return;
            }

            var p = Filesystem.GetPath(name);

            if (p == null)
            {
                Log.ThrowFatal("could not find " + name);
            }
            var tempDll = Assembly.LoadFile(p);

            Log.WriteLine("loaded prog " + name + "..");

            dll = (Dll)tempDll.CreateInstance("game.GameDLL");
            try
            {
                if (dll == null)
                {
                    throw new Exception();
                }
                dll?.Init();
            }
            catch
            {
                Log.ThrowFatal("an error occured when initializing the game dll.");
                return;
            }

            Log.WriteLine(dll.title + " loaded successfully", Log.MessageType.Good);

            if (dll.title != DEF_GAME_TITLE)
            {
                Log.WriteLine("Game module is modified. Please only continue if you are aware and trust the author. In order to maximise modularity, game modules have *full access* to your system. BE VERY CAREFUL!!", Log.MessageType.Warning);
            }
            Engine.SetTitle(dll.title);
            Engine.SetIcon("icon.png");
        }
Пример #28
0
        public void StopDll(string dll_name)
        {
            if (running_dll_executing_threads.ContainsKey(dll_name))
            {
                if (ValidateOnStopThread(dll_name))
                {
                    running_dll_executing_threads[dll_name].Abort();
                    running_dll_executing_threads.Remove(dll_name);

                    Dll tmp = running_dlls[dll_name];

                    running_dlls.Remove(dll_name);

                    awaiting_dlls.Add(dll_name, tmp);

                    NotifyPropertyChanged("RunningDlls_data_source");
                    NotifyPropertyChanged("AwaitingDlls_data_source");
                }
            }
        }
Пример #29
0
        private void LoadFile(Dll model)
        {
            if (dllInfos[model.Id].assembly is null)
            {
                var name = AssemblyName.GetAssemblyName(Path.Combine(CachePath, $"{ model.Name }.dll"));
                dllInfos[model.Id].assembly = Assembly.Load(name);

                if (dllInfos[model.Id].assembly != null)
                {
                    ConsoleGUI.Instance.WriteLn($"Loading of assembly({ model.Name }) succesful.", Color.green);
                }
                else
                {
                    ConsoleGUI.Instance.WriteLn($"Loading of assembly({ model.Name }) failed.", Color.red);
                }
            }
            else
            {
                ConsoleGUI.Instance.WriteLn($"loading of assembly({ model.Name }) skipped, already loaded.", Color.magenta);
            }
        }
Пример #30
0
        public static McpConfigData Find(string ConfigName)
        {
            if (Configs == null)
            {
                // Load all secret configs by trying to instantiate all classes derived from McpConfig from all loaded DLLs.
                // Note that we're using the default constructor on the secret config types.
                Configs = new Dictionary <string, McpConfigData>();
                Assembly[] LoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (var Dll in LoadedAssemblies)
                {
                    Type[] AllTypes = Dll.GetTypes();
                    foreach (var PotentialConfigType in AllTypes)
                    {
                        if (PotentialConfigType != typeof(McpConfigData) && typeof(McpConfigData).IsAssignableFrom(PotentialConfigType))
                        {
                            try
                            {
                                McpConfigData Config = Activator.CreateInstance(PotentialConfigType) as McpConfigData;
                                if (Config != null)
                                {
                                    Configs.Add(Config.Name, Config);
                                }
                            }
                            catch
                            {
                                BuildCommand.LogWarning("Unable to create McpConfig: {0}", PotentialConfigType.Name);
                            }
                        }
                    }
                }
            }
            McpConfigData LoadedConfig;

            Configs.TryGetValue(ConfigName, out LoadedConfig);
            if (LoadedConfig == null)
            {
                throw new AutomationException("Unable to find requested McpConfig: {0}", ConfigName);
            }
            return(LoadedConfig);
        }