private static void TestScriptAudioAccessImpl(Game game) { using (var script = new ScriptClass(game.Services)) { Assert.DoesNotThrow(() => script.AccessAudioService(), "Access to the audio service failed."); Assert.IsTrue(script.AudioServiceNotNull(), "The Audio service is null."); } }
/// <summary> /// 初始化 /// </summary> /// <param name="_scriptClass"></param> public SerivceRunner() { var atts = typeof(T).GetCustomAttributes(typeof(ScriptClass), true); if (atts.Length > 0) { this.scriptClass = atts[0] as ScriptClass; this.scriptClass.Name = $@"Srv_{typeof(T).Name}"; //自动生成类名称 this.scriptMethods = this.scriptClass.GetScriptMethods(typeof(T)); //获取注入的标记 var inject_attr = typeof(T).GetCustomAttributes(typeof(Inject), true); if (inject_attr.Length > 0) { InjectAttributes.AddRange((IEnumerable <Inject>)inject_attr); } } //方法内语句 //customCodeLoader = new CustomCodeLoader(scriptClass.Language, scriptClass.AssociatedScriptRoot, configHelper); }
private ScriptClass Read_ScriptClass(BinaryReader reader) { var result = new ScriptClass(); result.Version = ReadVersion(reader, 3, 0x1411DD3F0); result.Name = ReadString(reader); if (result.Version >= 2) { result.ScriptType = reader.ReadUInt32(); } result.Properties = Read_List(reader, Read_Property, 1, 0x1411D2360); if (result.Version >= 3) { result.DisplayName = ReadString(reader); result.Tooltip = ReadString(reader); } return(result); }
public override bool Run() { IFuzzerPayload payload = (IFuzzerPayload)Payload; // Make script with inherited class ScriptHelper scripts = ScriptHelper.CreateFromFile(Script.FullName, new ScriptHelper.ScriptOptions() { includeUsings = new string[] { "XPloit.Core.Extensions", "XPloit.Core.Helpers" }, IncludeFiles = new string[] { typeof(ScriptClass).Assembly.Location, // XPloit.Modules typeof(Module).Assembly.Location // XPloit.Core }, Inherited = new Type[] { typeof(StreamFuzzer.ScriptClass) } }); WriteInfo("Loading file ..."); string file = File.ReadAllText(Script.FullName, Encoding.ASCII); WriteInfo("File loaded", StringHelper.Convert2KbWithBytes(file.Length), System.ConsoleColor.Green); for (int max = To, st = Math.Max(Step, 1); From <= max; From += st) { WriteInfo("Checking ", From.ToString(), ConsoleColor.Green); byte[] data; if (CreatePattern) { data = PatternHelper.CreateRaw(From); } else { data = new byte[From]; for (int x = data.Length - 1; x >= 0; x--) { data[x] = (byte)NotPatternChar; } } ScriptClass obj = scripts.CreateNewInstance <ScriptClass>(); obj.Encoding = Encoding; try { obj.Stream = payload.CreateStream(data); obj.Run(data); obj.Dispose(); CopyPropertiesToActiveModule("From"); } catch (Exception e) { WriteInfo("Good news :) Payload send fail!"); WriteError(e.Message); return(true); } } return(true); }
public bool TryUpdatePositions(FontMetrics fontMetrics, GlyphPositioningCollection collection, KerningMode kerningMode, out bool kerned) { kerned = false; bool updated = false; for (ushort i = 0; i < collection.Count; i++) { if (!collection.ShouldProcess(fontMetrics, i)) { continue; } ScriptClass current = CodePoint.GetScriptClass(collection.GetGlyphShapingData(i).CodePoint); BaseShaper shaper = ShaperFactory.Create(current, kerningMode); ushort index = i; ushort count = 1; while (i < collection.Count - 1) { // We want to assign the same feature lookups to individual sections of the text rather // than the text as a whole to ensure that different language shapers do not interfere // with each other when the text contains multiple languages. GlyphShapingData nextData = collection.GetGlyphShapingData(i + 1); ScriptClass next = CodePoint.GetScriptClass(nextData.CodePoint); if (next is not ScriptClass.Common and not ScriptClass.Unknown and not ScriptClass.Inherited && next != current) { break; } i++; count++; } if (shaper.MarkZeroingMode == MarkZeroingMode.PreGPos) { ZeroMarkAdvances(fontMetrics, collection, index, count); } // Assign Substitution features to each glyph. shaper.AssignFeatures(collection, index, count); IEnumerable <Tag> stageFeatures = shaper.GetShapingStageFeatures(); SkippingGlyphIterator iterator = new(fontMetrics, collection, index, default); foreach (Tag stageFeature in stageFeatures) { List <(Tag Feature, ushort Index, LookupTable LookupTable)> lookups = this.GetFeatureLookups(in stageFeature, current); if (lookups.Count == 0) { continue; } // Apply features in order. foreach ((Tag Feature, ushort Index, LookupTable LookupTable)featureLookup in lookups) { Tag feature = featureLookup.Feature; iterator.Reset(index, featureLookup.LookupTable.LookupFlags); while (iterator.Index < index + count) { List <TagEntry> glyphFeatures = collection.GetGlyphShapingData(iterator.Index).Features; if (!HasFeature(glyphFeatures, in feature)) { iterator.Next(); continue; } bool success = featureLookup.LookupTable.TryUpdatePosition(fontMetrics, this, collection, featureLookup.Feature, iterator.Index, count - (iterator.Index - index)); kerned |= success && (feature == KernTag || feature == VKernTag); updated |= success; iterator.Next(); } } } if (shaper.MarkZeroingMode == MarkZeroingMode.PostGpos) { ZeroMarkAdvances(fontMetrics, collection, index, count); } FixCursiveAttachment(collection, index, count); FixMarkAttachment(collection, index, count); if (updated) { UpdatePositions(fontMetrics, collection, index, count); } } return(updated); }
public void ApplySubstitution(FontMetrics fontMetrics, GlyphSubstitutionCollection collection, KerningMode kerningMode) { for (ushort i = 0; i < collection.Count; i++) { // Choose a shaper based on the script. // This determines which features to apply to which glyphs. ScriptClass current = CodePoint.GetScriptClass(collection.GetGlyphShapingData(i).CodePoint); BaseShaper shaper = ShaperFactory.Create(current, kerningMode); ushort index = i; ushort count = 1; while (i < collection.Count - 1) { // We want to assign the same feature lookups to individual sections of the text rather // than the text as a whole to ensure that different language shapers do not interfere // with each other when the text contains multiple languages. GlyphShapingData nextData = collection.GetGlyphShapingData(i + 1); ScriptClass next = CodePoint.GetScriptClass(nextData.CodePoint); if (next is not ScriptClass.Common and not ScriptClass.Unknown and not ScriptClass.Inherited && next != current) { break; } i++; count++; } // Assign Substitution features to each glyph. shaper.AssignFeatures(collection, index, count); IEnumerable <Tag> stageFeatures = shaper.GetShapingStageFeatures(); int currentCount = collection.Count; SkippingGlyphIterator iterator = new(fontMetrics, collection, index, default); foreach (Tag stageFeature in stageFeatures) { List <(Tag Feature, ushort Index, LookupTable LookupTable)> lookups = this.GetFeatureLookups(in stageFeature, current); if (lookups.Count == 0) { continue; } // Apply features in order. foreach ((Tag Feature, ushort Index, LookupTable LookupTable)featureLookup in lookups) { Tag feature = featureLookup.Feature; iterator.Reset(index, featureLookup.LookupTable.LookupFlags); while (iterator.Index < index + count) { List <TagEntry> glyphFeatures = collection.GetGlyphShapingData(iterator.Index).Features; if (!HasFeature(glyphFeatures, in feature)) { iterator.Next(); continue; } featureLookup.LookupTable.TrySubstitution(fontMetrics, this, collection, featureLookup.Feature, iterator.Index, count - (iterator.Index - index)); iterator.Next(); // Account for substitutions changing the length of the collection. if (collection.Count != currentCount) { count = (ushort)(count - (currentCount - collection.Count)); currentCount = collection.Count; } } } } } }
private void TestScriptCreationDestructionImpl(Game game) { ScriptClass script = null; Assert.DoesNotThrow(() => script = new ScriptClass(game.Services), "Creation of the Script failed"); Assert.DoesNotThrow(() => script.Dispose(), "Destruction of the script failed."); }
/// <summary> /// Creates a Shaper based on the given script language. /// </summary> /// <param name="script">The script language.</param> /// <param name="kerningMode">The kerning mode.</param> /// <returns>A shaper for the given script.</returns> public static BaseShaper Create(ScriptClass script, KerningMode kerningMode) => script switch {