/// <summary> /// Initializes a new instance of the <see cref="IlInfoAdapter" /> class. /// </summary> /// <param name="converter">The converter.</param> /// <param name="info">The information.</param> /// <exception cref="ArgumentNullException">info</exception> /// <inheritdoc /> public IlInfoAdapter(IConverter converter, ILInfo info) : base(converter) { Info = info ?? throw new ArgumentNullException(nameof(info)); Address = Info.Address; Flags = Info.Flags; Length = Info.Length; LocalVarSignatureToken = Info.LocalVarSignatureToken; MaxStack = Info.MaxStack; }
private Dictionary <string, Dictionary <string, ILInfo> > AssessILInfo(string country, bool core) { Dictionary <string, Dictionary <string, ILInfo> > ilInfos = new Dictionary <string, Dictionary <string, ILInfo> >(); CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); foreach (CountryConfig.SystemRow system in GetPublicSystems(country)) { // UDB (aka non-core) ILS are kept in a separate policy CountryConfig.PolicyRow ilPol = ccf.GetPolicyRowByName(system.ID, core ? DefPol.SPECIAL_POL_ILSDEF : DefPol.SPECIAL_POL_ILSUDBDEF); if (ilPol == null || ilPol.Switch != DefPar.Value.ON || ilPol.Private == DefPar.Value.YES) { continue; } foreach (CountryConfig.FunctionRow ilFunc in ccf.GetFunctionRowsByPolicyIDAndFunctionName(ilPol.ID, DefFun.DefIl)) { if (ilFunc.Switch != DefPar.Value.ON || ilFunc.Private == DefPar.Value.YES) { continue; } ILInfo ilInfo = new ILInfo() { LabelEmpty = ilFunc.Comment == string.Empty }; string ilName = string.Empty; foreach (CountryConfig.ParameterRow ilPar in ilFunc.GetParameterRows()) { if (ilPar.Name.ToLower() == DefPar.DefIl.Name.ToLower()) { ilName = ilPar.Value.ToLower(); continue; } if (ilPar.Value == DefPar.Value.NA || ilPar.Private == DefPar.Value.YES) { continue; } ilInfo.Components.Add(ilPar); } if (ilName == string.Empty) { continue; // rather unlikely } if (!ilInfos.ContainsKey(ilName)) { ilInfos.Add(ilName, new Dictionary <string, ILInfo>()); } if (!ilInfos[ilName].ContainsKey(system.Name.ToLower())) // this is a security-request: ilName should be unique per system { ilInfos[ilName].Add(system.Name.ToLower(), ilInfo); } } } return(ilInfos); }
private void InitILInfo() { ClrModule module = Type?.Module; object mdImport = module?.MetadataImport; uint rva = 0; if (mdImport is IMetadataImport metadataImport) { if (metadataImport.GetRVA(_token, out rva, out uint flags) != 0) { // GetRVA fail return; } } else if (mdImport is MetaDataImport dacMetaDataImport) { rva = dacMetaDataImport.GetRva((int)_token); } ulong il = _runtime.GetILForModule(module, rva); if (il != 0) { _il = new ILInfo(); if (_runtime.ReadByte(il, out byte b)) { bool isTinyHeader = (b & (IMAGE_COR_ILMETHOD.FormatMask >> 1)) == IMAGE_COR_ILMETHOD.TinyFormat; if (isTinyHeader) { _il.Address = il + 1; _il.Length = b >> (int)(IMAGE_COR_ILMETHOD.FormatShift - 1); _il.LocalVarSignatureToken = IMAGE_COR_ILMETHOD.mdSignatureNil; } else if (_runtime.ReadDword(il, out uint tmp)) { _il.Flags = tmp; _runtime.ReadDword(il + 4, out tmp); _il.Length = (int)tmp; _runtime.ReadDword(il + 8, out tmp); _il.LocalVarSignatureToken = tmp; _il.Address = il + 12; } } } }
/// <summary> /// cast Ice Lance without requiring FoF, but if FoF active wait until buff stack count updated /// to ensure we don't break other Ice Lance logic that depends on FoF being accurate /// </summary> /// <param name="on"></param> /// <returns></returns> private static Sequence CreateIceLanceBehavior(UnitSelectionDelegate on = null, SimpleBooleanDelegate requirements = null) { UnitSelectionDelegate ondel = on ?? (o => Me.CurrentTarget); SimpleBooleanDelegate reqdel = requirements ?? (req => true); return(new Sequence( ctx => new ILInfo(ondel(ctx), Me.GetAuraStacks(FINGERS_OF_FROST), ctx), new Decorator( req => ILInfo.Ref(req).Unit != null && (ILInfo.Ref(req).StacksOfFOF > 0 || ILInfo.Ref(req).Unit.IsTrivial()) && Spell.CanCastHack("Ice Lance", ILInfo.Ref(req).Unit) && !ILInfo.Ref(req).Unit.IsImmune(WoWSpellSchool.Frost), new Sequence( Spell.Cast("Ice Lance", o => ((ILInfo)o).Unit, r => reqdel(ILInfo.Ref(r).SaveContext)), Helpers.Common.CreateWaitForLagDuration( until => ILInfo.Ref(until).StacksOfFOF != Me.GetAuraStacks(FINGERS_OF_FROST) || Me.GetAuraStacks(FINGERS_OF_FROST) == 0 ) ) ) )); }
private unsafe void InitILInfo() { ClrModule module = Type?.Module; ICorDebug.IMetadataImport metadataImport = module?.MetadataImport as ICorDebug.IMetadataImport; if (metadataImport != null) { uint rva; uint flags; if (metadataImport.GetRVA(_token, out rva, out flags) == 0) { ulong il = _runtime.GetILForModule(module, rva); if (il != 0) { _il = new ILInfo(); uint tmp; byte b; if (_runtime.ReadByte(il, out b)) { bool isTinyHeader = ((b & (IMAGE_COR_ILMETHOD.FormatMask >> 1)) == IMAGE_COR_ILMETHOD.TinyFormat); if (isTinyHeader) { _il.Address = il + 1; _il.Length = b >> (int)(IMAGE_COR_ILMETHOD.FormatShift - 1); _il.LocalVarSignatureToken = IMAGE_COR_ILMETHOD.mdSignatureNil; } else if (_runtime.ReadDword(il, out tmp)) { _il.Flags = tmp; _runtime.ReadDword(il + 4, out tmp); _il.Length = (int)tmp; _runtime.ReadDword(il + 8, out tmp); _il.LocalVarSignatureToken = tmp; _il.Address = il + 12; } } } } } }
/// <summary> /// cast Ice Lance only if FoF active. waits after cast until FoF stack count changes /// to ensure we don't double cast Ice Lance (since we queue spells) /// </summary> /// <param name="on"></param> /// <returns></returns> private static Sequence CreateIceLanceFoFBehavior(UnitSelectionDelegate onUnit = null, SimpleBooleanDelegate requirements = null) { UnitSelectionDelegate ondel = onUnit ?? (o => Me.CurrentTarget); SimpleBooleanDelegate reqdel = requirements ?? (req => true); return(new Sequence( ctx => new ILInfo(ondel(ctx), Me.GetAuraStacks(FINGERS_OF_FROST), ctx), new Decorator( // req => Spell.CanCastHack("Ice Lance", (req as ILInfo).Unit) && ((req as ILInfo).Unit != null && ((req as ILInfo).StacksOfFOF > 0 || (req as ILInfo).Unit.IsTrivial())), req => ILInfo.Ref(req).Unit != null && ILInfo.Ref(req).StacksOfFOF > 0 && Spell.CanCastHack("Ice Lance", ILInfo.Ref(req).Unit) && !ILInfo.Ref(req).Unit.IsImmune(WoWSpellSchool.Frost), new Sequence( new Action(r => Logger.Write(LogColor.Hilite, "^Fingers of Frost[{0}]: casting buffed Ice Lance", ILInfo.Ref(r).StacksOfFOF)), Spell.Cast("Ice Lance", mov => false, o => ILInfo.Ref(o).Unit, r => reqdel(ILInfo.Ref(r).SaveContext)), // ret => Unit.NearbyUnfriendlyUnits.Count(t => t.Distance <= 10) < 4), Helpers.Common.CreateWaitForLagDuration( until => ILInfo.Ref(until).StacksOfFOF != Me.GetAuraStacks(FINGERS_OF_FROST) ) ) ) )); }
private static extern void iluGetImageInfo([MarshalAs(UnmanagedType.LPStruct)] ILInfo Info);
// ILAPI void ILAPIENTRY iluGetImageInfo(ILinfo *Info); public static void GetImageInfo(ILInfo Info) { iluGetImageInfo(Info); }