public GarlicBreadCommandContext(DiscordBotBase bot, IPrefix prefix, CachedUserMessage message, IServiceScope scope, RuntimeFlags flags) : base(bot, prefix, message, scope.ServiceProvider) { ServiceScope = scope; Flags = flags; Member = base.Member; }
public DiagnosticsHost(IHost host, IModuleManager moduleManager, IBootSequenceFactory bootSequenceFactory, IDiagnosticsCollector diagnostics, RuntimeFlags runtimeFlags, ILogger <DiagnosticsHost> logger) { _host = host; _moduleManager = moduleManager; _bootSequenceFactory = bootSequenceFactory; _diagnostics = diagnostics; _runtimeFlags = runtimeFlags; _logger = logger; }
public static void RaiseFlag(RuntimeFlags flag) { var flagFilePath = ResolveFlagFilePath(flag); using (var file = File.Create(flagFilePath)) { Logger.Info($"Raising flag: {flag}"); Logger.Debug($"Flag file path: {flagFilePath}"); } }
public DiagnosticsHostBuilder(ISImplHostBuilder hostBuilder, IModuleManager moduleManager, IBootSequenceFactory bootSequenceFactory, IDiagnosticsCollector diagnostics, RuntimeFlags runtimeFlags, ILogger <DiagnosticsHost> logger) { _hostBuilder = hostBuilder; _moduleManager = moduleManager; _bootSequenceFactory = bootSequenceFactory; _diagnostics = diagnostics; _runtimeFlags = runtimeFlags; _logger = logger; _diagnostics.RegisterLapTime("HostBuilder created"); }
public static void WaitTilResolved(RuntimeFlags flag) { RaiseFlag(flag); var flagFilePath = ResolveFlagFilePath(flag); var timeoutCounter = MaxTimeoutCount; while (File.Exists(flagFilePath) && timeoutCounter > 0) { Thread.Sleep(MaxTimeoutDuration); timeoutCounter--; } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.RenderModel = binaryReader.ReadTagReference(); this.CollisionModel = binaryReader.ReadTagReference(); this.Animation = binaryReader.ReadTagReference(); this.Physics = binaryReader.ReadTagReference(); this.PhysicsModel = binaryReader.ReadTagReference(); this.DisappearDistance = binaryReader.ReadSingle(); this.BeginFadeDistance = binaryReader.ReadSingle(); this.fieldpad = binaryReader.ReadBytes(4); this.ReduceToL1 = binaryReader.ReadSingle(); this.ReduceToL2 = binaryReader.ReadSingle(); this.ReduceToL3 = binaryReader.ReadSingle(); this.ReduceToL4 = binaryReader.ReadSingle(); this.ReduceToL5 = binaryReader.ReadSingle(); this.fieldskip = binaryReader.ReadBytes(4); this.ShadowFadeDistance = ((ShadowFadeDistanceEnum)(binaryReader.ReadInt16())); this.fieldpad0 = binaryReader.ReadBytes(2); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(56)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(20)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(248)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(28)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(92)); this.fieldpad1 = binaryReader.ReadBytes(4); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(20)); this.DefaultDialogue = binaryReader.ReadTagReference(); this.UNUSED = binaryReader.ReadTagReference(); this.ModelFlags = ((Flags)(binaryReader.ReadInt32())); this.DefaultDialogueEffect = binaryReader.ReadStringID(); int i; for (i = 0; (i < 32); i = (i + 1)) { this.RenderonlyNodeFlags00[i] = new RenderonlyNodeFlagsBlock(); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.RenderonlyNodeFlags00[i].ReadFields(binaryReader))); } for (i = 0; (i < 32); i = (i + 1)) { this.RenderonlySectionFlags00[i] = new RenderonlySectionFlagsBlock(); pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.RenderonlySectionFlags00[i].ReadFields(binaryReader))); } this.ModelRuntimeFlags = ((RuntimeFlags)(binaryReader.ReadInt32())); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(48)); this.HologramShader = binaryReader.ReadTagReference(); this.HologramControlFunction = binaryReader.ReadStringID(); return(pointerQueue); }
private static RuntimeFlags ParseArgs(string[] args) { var flags = new RuntimeFlags(); // Define and parse commands var cmd = new RootCommand("SImpl .NET Stack runtime") { new Option <bool>( new[] { "--diagnostics", "-d" }, getDefaultValue: () => false, description: "Enable stack diagnostics"), new Option <bool>( new[] { "--verbose", "-v" }, getDefaultValue: () => false, description: "Enable verbose logging") }; var requiresBoot = false; cmd.Handler = CommandHandler.Create <bool, bool>((diagnostics, verbose) => { // Parse args into flags flags.Diagnostics = diagnostics; flags.Verbose = verbose; // Args has been parsed requiresBoot = true; }); cmd.Invoke(args); if (!requiresBoot) { Environment.Exit(0); } return(flags); }
static HashSet <Thread> threads = new HashSet <Thread>(); //потоки, выполняющие скрипты static public int ExecScript(string sc, Dictionary <string, object> vars = null, List <Func> fs = null) //выполнить скрипт { RuntimeFlags flags = RuntimeFlags.None; if (sc[0] == '[') { string f = sc.Substring(1, sc.IndexOf(']') - 1); sc = sc.Remove(0, f.Length + 2); string[] sFlags = GetPars(f).ToArray(); sFlags.AsParallel().ForAll(s => s = s.Trim()); foreach (var flag in sFlags) { switch (flag) { case "Exclusive": flags = flags | RuntimeFlags.Exclusive; break; case "Block": flags = flags | RuntimeFlags.Block; break; default: MessageBox.Show("Не найден атрибут " + flag + ", выполнение прервано", "Ошибка"); return(0); } } } Thread th = null;//новый поток th = new Thread(() => { string c = ""; try { List <Func> funcs = fs == null ? new List <Func>() : fs; //функции, созданные в этом потоке Dictionary <string, object> vs = vars == null ? new Dictionary <string, object>() : vars; //переменные в этом потоке foreach (var cmd in GetCommands(sc)) //перебираю и запускаю все команды поочереди { c = cmd.Trim(); RunCmd(cmd.Trim(), funcs, vs);//выполняю очередную команду } } catch (Exception e) { MessageBox.Show(e.Message, "Ошибка"); MessageBox.Show(c); } threads.Remove(th); //после завершения удаляю поток из списка активных }); th.SetApartmentState(ApartmentState.STA); //хз зачем threads.Add(th); //добавляю поток в активные th.Start(); //запускаю выполнение if (flags.HasFlag(RuntimeFlags.Block)) //если стоит флаг блокировки, ждём поток { th.Join(); } if (flags.HasFlag(RuntimeFlags.Exclusive)) { return(1); } return(0); }//выполнить скрипт с загруженными командами
public void Read(ReaderContext ctxt, BlobReader reader) { var actualCb = reader.ReadUInt32(); if (actualCb != cb) throw new PEException("invalid CLIHeader.ActualCb"); MajorRuntimeVersion = reader.ReadUInt16(); MinorRuntimeVersion = reader.ReadUInt16(); MetaData.Read(reader); Flags = (RuntimeFlags)reader.ReadUInt32(); EntryPointToken = reader.ReadUInt32(); Resources.Read(reader); StrongNameSignature.Read(reader); var actualCodeManagerTable = reader.ReadUInt64(); if (actualCodeManagerTable != codeManagerTable) throw new PEException("invalid CLIHeader.CodeManagerTable"); VtableFixups.Read(reader); var actualExportAddressTableJumps = reader.ReadUInt64(); if (actualExportAddressTableJumps != exportAddressTableJumps) throw new PEException("invalid CLIHeader.ExportAddressTableJumps"); var actualManagedNativeHeader = reader.ReadUInt64(); if (actualManagedNativeHeader != managedNativeHeader) throw new PEException("invalid CLIHeader.ManagedNativeHeader"); }
protected override void LoadInternal(VirtualReader rdr) { s = rdr.ReadUInt32(); maVer = rdr.ReadUInt16(); miVer = rdr.ReadUInt16(); dats = new CLRDatas(this); dats.IsLoading = true; Rva mdAdr = rdr.ReadRva(); uint mdSze = rdr.ReadUInt32(); f = (RuntimeFlags)rdr.ReadUInt32(); if ((f & RuntimeFlags.NativeEntryPoint) == RuntimeFlags.NativeEntryPoint) { Rva ep = rdr.ReadRva(); rdr.SaveLocation(); rdr.SetPosition(ep); byte[] ec = NativeHelper.GetNativeCodes(rdr); rdr.LoadLocation(); e = ep; dats.Add(new CLRData() { Address = ep, Data = ec }); } else { t = rdr.ReadUInt32(); } Rva resAdr = rdr.ReadRva(); uint resSze = rdr.ReadUInt32(); Rva snAdr = rdr.ReadRva(); uint snSze = rdr.ReadUInt32(); Rva cmAdr = rdr.ReadRva(); uint cmSze = rdr.ReadUInt32(); Rva vtAdr = rdr.ReadRva(); uint vtSze = rdr.ReadUInt32(); Rva eatAdr = rdr.ReadRva(); uint eatSze = rdr.ReadUInt32(); Rva mnAdr = rdr.ReadRva(); uint mnSze = rdr.ReadUInt32(); rdr.SetPosition(resAdr); res = rdr.ReadBytes((int)resSze); rdr.SetPosition(snAdr); sn = rdr.ReadBytes((int)snSze); rdr.SetPosition(cmAdr); cm = rdr.ReadBytes((int)cmSze); rdr.SetPosition(eatAdr); eat = rdr.ReadBytes((int)eatSze); rdr.SetPosition(mnAdr); mn = rdr.ReadBytes((int)mnSze); vt = new VTableFixups(this); vt.Load(rdr, vtAdr, vtSze); md = new MetadataRoot(this); md.Load(rdr, mdAdr); dats.IsLoading = false; // Save the read info MetadataDirEntry = new CLRDataDirectoryEntry("MetaData", mdAdr, mdSze); ResourceDirEntry = new CLRDataDirectoryEntry("Resources", resAdr, resSze); StrongNameDirEntry = new CLRDataDirectoryEntry("Strong Name Signature", snAdr, snSze); CodeManagerTableDirEntry = new CLRDataDirectoryEntry("Code Manager Table", cmAdr, cmSze); VTableFixupsDirEntry = new CLRDataDirectoryEntry("VTable Fixups", vtAdr, vtSze); ExportAddressTableJumpsDirEntry = new CLRDataDirectoryEntry("Export Address Table Jumps", eatAdr, eatSze); ManagedNativeHeaderDirEntry = new CLRDataDirectoryEntry("Managed Native Header", mnAdr, mnSze); }
public HierarchyModel(BinaryReader binaryReader) { this.renderModel = binaryReader.ReadTagReference(); this.collisionModel = binaryReader.ReadTagReference(); this.animation = binaryReader.ReadTagReference(); this.physics = binaryReader.ReadTagReference(); this.physicsModel = binaryReader.ReadTagReference(); this.disappearDistanceWorldUnits = binaryReader.ReadSingle(); this.beginFadeDistanceWorldUnits = binaryReader.ReadSingle(); this.padding = binaryReader.ReadBytes(4); this.reduceToL1WorldUnitsSuperLow = binaryReader.ReadSingle(); this.reduceToL2WorldUnitsLow = binaryReader.ReadSingle(); this.reduceToL3WorldUnitsMedium = binaryReader.ReadSingle(); this.reduceToL4WorldUnitsHigh = binaryReader.ReadSingle(); this.reduceToL5WorldUnitsSuperHigh = binaryReader.ReadSingle(); this.skip0 = binaryReader.ReadBytes(4); this.shadowFadeDistance = (ShadowFadeDistance)binaryReader.ReadInt16(); this.padding1 = binaryReader.ReadBytes(2); { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelVariantBlock)); this.variants = new ModelVariantBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.variants[i] = new ModelVariantBlock(binaryReader); } } } { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelMaterialBlock)); this.materials = new ModelMaterialBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.materials[i] = new ModelMaterialBlock(binaryReader); } } } { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(GlobalDamageInfoBlock)); this.newDamageInfo = new GlobalDamageInfoBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.newDamageInfo[i] = new GlobalDamageInfoBlock(binaryReader); } } } { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelTargetBlock)); this.targets = new ModelTargetBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.targets[i] = new ModelTargetBlock(binaryReader); } } } { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelRegionBlock)); this.modelRegionBlock = new ModelRegionBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.modelRegionBlock[i] = new ModelRegionBlock(binaryReader); } } } { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelNodeBlock)); this.modelNodeBlock = new ModelNodeBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.modelNodeBlock[i] = new ModelNodeBlock(binaryReader); } } } this.padding2 = binaryReader.ReadBytes(4); { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(ModelObjectDataBlock)); this.modelObjectData = new ModelObjectDataBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.modelObjectData[i] = new ModelObjectDataBlock(binaryReader); } } } this.defaultDialogueTheDefaultDialogueTagForThisModelOverridenByVariants = binaryReader.ReadTagReference(); this.uNUSED = binaryReader.ReadTagReference(); this.flags = (Flags)binaryReader.ReadInt32(); this.defaultDialogueEffectTheDefaultDialogueTagForThisModelOverridenByVariants = binaryReader.ReadStringID(); this.renderOnlyNodeFlags = new RenderOnlyNodeFlags[32]; for (int i = 0; i < 32; ++i) { this.renderOnlyNodeFlags[i] = new RenderOnlyNodeFlags(binaryReader); } this.renderOnlySectionFlags = new RenderOnlySectionFlags[32]; for (int i = 0; i < 32; ++i) { this.renderOnlySectionFlags[i] = new RenderOnlySectionFlags(binaryReader); } this.runtimeFlags = (RuntimeFlags)binaryReader.ReadInt32(); { var count = binaryReader.ReadInt32(); var address = binaryReader.ReadInt32(); var elementSize = Marshal.SizeOf(typeof(GlobalScenarioLoadParametersBlock)); this.scenarioLoadParameters = new GlobalScenarioLoadParametersBlock[count]; using (binaryReader.BaseStream.Pin()) { for (int i = 0; i < count; ++i) { binaryReader.BaseStream.Position = address + i * elementSize; this.scenarioLoadParameters[i] = new GlobalScenarioLoadParametersBlock(binaryReader); } } } this.hologramShader = binaryReader.ReadTagReference(); this.hologramControlFunction = binaryReader.ReadStringID(); Initialize(); }
public DiscordCommandContext CreateContext(CachedUserMessage message, IPrefix prefix, RuntimeFlags flags) { return(new GarlicBreadCommandContext(this, prefix, message, _services.CreateScope(), flags)); }
private static INanoContainer InitBootContainer(IHostBuilder hostBuilder, ILogger logger, RuntimeFlags flags, DiagnosticsCollector diagnostics) { var container = new NanoContainer.NanoContainer(); // Register container container.Register <INanoContainer>(container); // Register logging container.Register <ILogger>(() => logger); // Register parameters container.Register <IHostBuilder>(hostBuilder); container.Register <IDiagnosticsCollector>(diagnostics); container.Register <RuntimeFlags>(flags); // Register core services container.Register <IModuleManager, ModuleManager>(); container.Register <IBootSequenceFactory, BootSequenceFactory>(); container.Register <IRuntimeServices, RuntimeServices>(); // Register host builder and boot manager container.Register <IHostBootManager, HostBootManager>(); container.Register <ISImplHostBuilder, SImplHostBuilder>(); // register application builder and boot manager container.Register <IApplicationBootManager, ApplicationBootManager>(); // Handle cli flags if (flags.Diagnostics) { container.AddDiagnostics(); } if (flags.Verbose) { container.AddVerbosity(); } return(container); }
private static string ResolveFlagFilePath(RuntimeFlags flag) { return(Path.Combine(AppFolders.FlagsDir, flag.ToString())); }
public static bool IsFlagPresent(RuntimeFlags flag) { var flagFilePath = ResolveFlagFilePath(flag); return(File.Exists(flagFilePath)); }