public Users(Process.Process process) { _userFileName = process.Settings["users/filename"]; _userDocument = new XmlDocument(); _userDocument.Load(_userFileName); _userList = new UserList(CommonXml.GetNode(_userDocument.DocumentElement, "users")); _groupList = new GroupList(CommonXml.GetNode(_userDocument.DocumentElement, "groups")); }
private static unsafe void CreateProcess(byte *str_addr, byte *exec_path, uint priority) { var sb = new StringBuilder(); while (*str_addr != '\0') { sb.Append(*str_addr); str_addr++; } var commandLine = sb.ToString(); var cmd = CommandlineParser.Parse(commandLine, Kernel.Variables); var path = new StringBuilder(); while (*exec_path != '\0') { sb.Append(*exec_path); str_addr++; } var file = Kernel.FileSystem.GetFile(path.ToString()); var buffer = Cosmos.Core.Memory.Heap.Alloc((uint)file.mSize); var stream = file.GetFileStream(); int tmpByte = stream.ReadByte(); var bufferPtr = buffer; while (tmpByte != -1) { *bufferPtr = (byte)tmpByte; tmpByte = stream.ReadByte(); } var process = new Process.Process(commandLine, cmd.Args, (int)priority); process.PCB.Context = new INTs.IRQContext { CS = process.PCB.Context.CS, EAX = process.PCB.Context.EAX, EBX = process.PCB.Context.EBX, ECX = process.PCB.Context.ECX, EDX = process.PCB.Context.EDX, EDI = process.PCB.Context.EDI, EFlags = process.PCB.Context.EFlags, EIP = (uint)buffer, ESI = process.PCB.Context.ESI, ESP = process.PCB.Context.ESP, Interrupt = process.PCB.Context.Interrupt, MMXContext = process.PCB.Context.MMXContext, Param = process.PCB.Context.Param, UserESP = process.PCB.Context.UserESP }; // TODO: Setting PC register in process.Context to pointer to the buffer. ProcessManager.ProcessList.Add(process); ProcessManager.ReadyQueue.Enqueue(process); }
public RoundRobin(int[] burstTime, int[] process, int Qauntum) { for (int i = 0; i < burstTime.Length; i++) { Process.Process p = new Process.Process(); p.burst_time = burstTime[i]; p.process_num = process[i]; processList.Add(p); } NumberOfProcess = process.Length; this.Quntaum = Qauntum; }
private void AddPlugin(String fileName, Process.Process process) { //Create a new assembly from the plugin file we're adding.. Assembly pluginAssembly = Assembly.LoadFrom(fileName); //Next we'll loop through all the Types found in the assembly foreach (Type pluginType in pluginAssembly.GetTypes()) { if (pluginType.IsPublic) //Only look at public types { if (!pluginType.IsAbstract) //Only look at non-abstract types { //Gets a type Object of the interface we need the plugins to match Type typeInterface = pluginType.GetInterface("Sharpcms.Base.Library.Plugin.IPlugin", true); //Make sure the interface we want to use actually exists if (typeInterface != null) { //Create a new available plugin since the type implements the IPlugin interface AvailablePlugin newPlugin = new AvailablePlugin { //Set the filename where we found it AssemblyPath = fileName, //Create a new instance and store the instance in the collection for later use //We could change this later on to not load an instance.. we have 2 options //1- Make one instance, and use it whenever we need it.. it's always there //2- Don't make an instance, and instead make an instance whenever we use it, then close it //For now we'll just make an instance of all the plugins Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())) }; //Set the Plugin's host to this class which inherited IPluginHost newPlugin.Instance.Host = this; //Set the Plugin's process newPlugin.Instance.Process = process; //Call the initialization sub of the plugin newPlugin.Instance.Initialize(); // Do not add the BasePlugin if (!newPlugin.Instance.Name.StartsWith("BasePlugin")) { //Add the new plugin to our collection here _colAvailablePlugins.Add(newPlugin); } } } } } }
public static void ExtractTar(string tarArchive, string destinationFolder) { using (Stream stream = File.OpenRead(tarArchive)) { var reader = ReaderFactory.Open(stream); while (reader.MoveToNextEntry()) { if (!reader.Entry.IsDirectory) { var opt = new ExtractionOptions { ExtractFullPath = true, Overwrite = true, WriteSymbolicLink = (symbolicLink, actualPath) => { if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) { var symbolicLinkDirectory = Path.GetDirectoryName(symbolicLink); if (!Directory.Exists(symbolicLinkDirectory)) { Directory.CreateDirectory(symbolicLinkDirectory); } var result = new Process.Process() .SetWorkingDirectory(symbolicLinkDirectory) .SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH")) .Execute("ln", "-s", actualPath, symbolicLink); if (result.HasErrorOutput()) { System.Console.WriteLine(result.ErrorOutput); } } else { System.Console.WriteLine( $"Could not write symlink {symbolicLink} -> {actualPath}, for more information please see https://github.com/dotnet/runtime/issues/24271"); } } }; reader.WriteEntryToDirectory(destinationFolder, opt); } } } }
/// <summary> /// Searches the passed Path for Plugins /// </summary> /// <param name="process"> </param> /// <param name="path">Directory to search for Plugins in</param> public void FindPlugins(Process.Process process, String path) { //First empty the collection, we're reloading them all _colAvailablePlugins.Clear(); //Go through all the files in the plugin directory foreach (String fileOn in Directory.GetFiles(path)) { FileInfo file = new FileInfo(fileOn); // Preliminary check, must be .dll if (file.Extension.Equals(".dll")) { AddPlugin(fileOn, process); //Add the 'plugin' } } }
/// <summary> /// Searches the Application's Startup Directory for Plugins /// </summary> public void FindPlugins(Process.Process process) { FindPlugins(process, AppDomain.CurrentDomain.BaseDirectory); }