internal void SetCalleeSaves(SpillContext *context) { EBX.SetCalleeReg(&context->ebx); EDI.SetCalleeReg(&context->edi); ESI.SetCalleeReg(&context->esi); EBP.SetCalleeReg(&context->ebp); }
public static Characters SignCharcher() { Characters characters = new Characters(); string authCode = ESI.GetAuthorizationToken(); if (string.IsNullOrEmpty(authCode)) { return(null); } ESITokenData etd = ESI.GetESITokenData(authCode, TokenType.AuthorizationCode); // 若是无法获取 ESIToken 则返回空 if (etd == null) { return(null); } // 将AccessToken过期时间提前5s, 防止细微时间错位 characters.AccessTokenExpiredTime = DateTime.Now.AddSeconds(etd.ExpiresIn - 5); characters.AccessToken = etd.AccessToken; characters.RefreshToken = etd.RefreshToken; ESICharacterVerificationData cvd = ESI.GetESICharacterVerificationData(characters.AccessToken); characters.CharacterID = cvd.CharacterID; ESICharacterPublicData cpd = ESI.GetCharacterPublicData(characters.CharacterID); characters.CharacterName = cpd.CharacterName; characters.CorporationID = cpd.CorporationID; return(characters); }
void SetCalleeSaves(CalleeSaveRegistersX86 *calleeSaveRegisters) { EBX.SetCalleeReg(&calleeSaveRegisters->EBX); EDI.SetCalleeReg(&calleeSaveRegisters->EDI); ESI.SetCalleeReg(&calleeSaveRegisters->ESI); EBP.SetCalleeReg(&calleeSaveRegisters->EBP); }
public MemoryStream GetESIZipStream(Material material, IList <Property> properties) { IList <ExportPropertyGeneral> propertiesMapped = MapProperites(properties, material.MaterialInfo.SourceId); XDocument xml1 = ESI.FillXmlFileNew(material.MaterialInfo.Name, propertiesMapped); MemoryStream memoryStreamEsi = new MemoryStream(); TextWriter twEsi = new StreamWriter(memoryStreamEsi); twEsi.Write(System.Text.ASCIIEncoding.UTF8.GetString(Encoding.UTF8.GetBytes(xml1.ToStringWithDeclaration()))); twEsi.Flush(); MemoryStream zipStreamEsi = new MemoryStream(); using (ZipFile zip = new ZipFile()) { memoryStreamEsi.Seek(0, SeekOrigin.Begin); zip.AddEntry("Esi ProCAST " + material.MaterialInfo.Name.Replace("/", "") + " " + material.MaterialInfo.Standard.Replace("-", "") + ".xml", memoryStreamEsi); if (propertiesMapped.Where(p => p.Type == TMPropertyTypeEnum.StressStrain && p.SelectedForExports[ExportTypeEnum.Esi] == true).Any()) { ESI.AddEntryForSS1(zip, propertiesMapped); } zip.Save(zipStreamEsi); } return(zipStreamEsi); }
internal void ClearCalleeSaves() { EBX.ClearCalleeReg(); ESI.ClearCalleeReg(); EDI.ClearCalleeReg(); EBP.ClearCalleeReg(); }
internal void ClearFrame(UIntPtr calleeSaveMask, bool framePointerOmitted) { if (!framePointerOmitted) { VTable.Assert((calleeSaveMask & 0x10) == 0, "EBP should not be callee saved"); EBP.ClearFrameReg(); } if ((calleeSaveMask & 0x1) != 0) { EBX.ClearFrameReg(); } if ((calleeSaveMask & 0x8) != 0) { EBP.ClearFrameReg(); } if ((calleeSaveMask & 0x4) != 0) { ESI.ClearFrameReg(); } if ((calleeSaveMask & 0x2) != 0) { EDI.ClearFrameReg(); } }
// called from clipboard hook, or when enter is pressed in character name field private void SearchCharacter() { Dispatcher.BeginInvoke(new Action(delegate() { try { if (string.IsNullOrEmpty(tbSearchQuery.Text)) { return; } var characterNames = tbSearchQuery.Text.Split(','); foreach (var name in characterNames) { var id = ESI.GetCharacterIdString(name); if (string.IsNullOrEmpty(id)) { continue; } var url = string.Format("https://zkillboard.com/character/{0}/", id); Logger.Instance.Write("Url: " + url); Process.Start(url); } } catch (Exception ex) { Logger.Instance.Write(ex.ToString()); } })); }
internal void ScanLiveRegs(UIntPtr mask, NonNullReferenceVisitor referenceVisitor) { EDI.ScanLiveReg((mask >> 2) & 0x3, referenceVisitor); ESI.ScanLiveReg((mask >> 4) & 0x3, referenceVisitor); EBX.ScanLiveReg((mask >> 0) & 0x3, referenceVisitor); EBP.ScanLiveReg((mask >> 6) & 0x3, referenceVisitor); }
internal void PopFrame(UIntPtr *framePointer, UIntPtr calleeSaveMask, bool framePointerOmitted, bool hasTransitionRecord) { UIntPtr *calleeSaveStart; if (framePointerOmitted) { calleeSaveStart = framePointer - 1; } else { VTable.Assert((calleeSaveMask & 0x100) == 0, "EBP should not be callee saved"); calleeSaveStart = framePointer; EBP.PopFrameReg(ref calleeSaveStart); } if (hasTransitionRecord) { calleeSaveStart -= sizeof(CallStack.TransitionRecord) / sizeof(UIntPtr); } // Note: the order in which these appear is important! if ((calleeSaveMask & 0x1) != 0) { EBX.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x80) != 0) { EBP.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x4) != 0) { ESI.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x2) != 0) { EDI.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x8) != 0) { R12.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x10) != 0) { R13.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x20) != 0) { R14.PopFrameReg(ref calleeSaveStart); } if ((calleeSaveMask & 0x40) != 0) { R15.PopFrameReg(ref calleeSaveStart); } }
/// <summary> /// 从 ESI 获取价格数据更新本地数据库 /// </summary> /// <param name="location"></param> private void UpdateMarketPrice(Locations location) { DCEVEDataContext dc = new DCEVEDataContext(); MarketPrice mp; if (_marketPriceOfLocation == null) { // 若该字段为空则说明数据库还没有此数据, 新建一条 mp = new MarketPrice() { TypeID = typeID, LocationID = location.LocationID, ExpiresDateTime = DateTime.MinValue }; dc.MarketPrice.InsertOnSubmit(mp); } else { // 若不为空则从新的 DataContext 获取该数据 mp = dc.MarketPrice.Single(p => p.TypeID == typeID && p.LocationID == location.LocationID); } // 数据过期时间 DateTime expriesDateTime = new DateTime(); // 从 ESI 获取价格数据 IEnumerable <ESIMarketOrder> marketOrders = ESI.GetMarketOrders(mp.TypeID, location.RegionID, ref expriesDateTime); // 仅获取对应位置的数据 marketOrders = marketOrders.Where(p => p.LocationID == mp.LocationID); if (marketOrders.Where(p => p.IsBuyOrder).Count() == 0) { mp.MaxBuyPrice = 0; } else { mp.MaxBuyPrice = marketOrders.Where(p => p.IsBuyOrder).Max(p => p.Price); } // TODO: 当售价为 0 时, 即没有出售单时, 应该做些处理 // 设置 PriceAsProduct 和 PriceAsMaterial 属性, 根据不同情况做不同处理 if (marketOrders.Where(p => !p.IsBuyOrder).Count() == 0) { mp.MinSellPrice = 0; } else { mp.MinSellPrice = marketOrders.Where(p => !p.IsBuyOrder).Min(p => p.Price); } // 数据过期时间 mp.ExpiresDateTime = expriesDateTime; // 更新数据库 dc.SubmitChanges(); }
internal void ClearCalleeSaves() { EBX.ClearCalleeReg(); ESI.ClearCalleeReg(); EDI.ClearCalleeReg(); EBP.ClearCalleeReg(); R12.ClearCalleeReg(); R13.ClearCalleeReg(); R14.ClearCalleeReg(); R15.ClearCalleeReg(); }
void SetCalleeSaves(CalleeSaveRegistersX64 *calleeSaveRegisters) { EBX.SetCalleeReg(&calleeSaveRegisters->EBX); EDI.SetCalleeReg(&calleeSaveRegisters->EDI); ESI.SetCalleeReg(&calleeSaveRegisters->ESI); EBP.SetCalleeReg(&calleeSaveRegisters->EBP); R12.SetCalleeReg(&calleeSaveRegisters->R12); R13.SetCalleeReg(&calleeSaveRegisters->R13); R14.SetCalleeReg(&calleeSaveRegisters->R14); R15.SetCalleeReg(&calleeSaveRegisters->R15); }
internal void SetCalleeSaves(SpillContext *context) { EBX.SetCalleeReg(&context->bx); EDI.SetCalleeReg(&context->di); ESI.SetCalleeReg(&context->si); EBP.SetCalleeReg(&context->bp); R12.SetCalleeReg(&context->r12); R13.SetCalleeReg(&context->r13); R14.SetCalleeReg(&context->r14); R15.SetCalleeReg(&context->r15); }
/// <summary> /// 更新 AccessToken /// </summary> public string GetAccessToken() { if (DateTime.Now > AccessTokenExpiredTime) { // 更新 AccessToken ESITokenData etd = ESI.GetESITokenData(RefreshToken); // 将AccessToken过期时间提前5s, 防止细微时间错位 AccessTokenExpiredTime = DateTime.Now.AddSeconds(etd.ExpiresIn - 5); AccessToken = etd.AccessToken; } return(AccessToken); }
/// <summary> /// 更新系统价格 /// </summary> /// <returns></returns> public static bool Update() { // TODO: 暂时每次启动时更新一次, 后期根据需要修改 // 数据过期时间 DateTime expiresIn = new DateTime(); // 从 ESI 获取系统价格数据 List <ESIMarketPrice> eSIMarketPrices = ESI.GetMarketPrices(ref expiresIn); // 如果获取不成功则返回 if (eSIMarketPrices == null) { return(false); } DCEVEDataContext dc = new DCEVEDataContext(); dc.UniversePrice.DeleteAllOnSubmit(dc.UniversePrice); // 清空所有旧数据 dc.SubmitChanges(); UniversePrice up; foreach (var mp in eSIMarketPrices) { // 判断物品类型数据库是否有跟踪, 无跟踪则跳过 if (dc.invTypes.SingleOrDefault(t => t.typeID == mp.TypeID) == null) { continue; } // 新建数据 up = new UniversePrice(); // 更新数据 up.TypeID = mp.TypeID; up.AdjustedPrice = mp.AdjustedPrice; up.AveragePrice = mp.AveragePrice; up.ExpiresIn = expiresIn; dc.UniversePrice.InsertOnSubmit(up); } // 提交数据库 dc.SubmitChanges(); return(true); }
/// <summary> /// 获取角色和军团(若有权限)拥有的蓝图列表 /// 蓝图不单独更新, 所有角色批量更新, 防止有蓝图给予等现象 /// </summary> /// <returns></returns> public List <OwnedBluePrints> GetBluePrints() { DateTime updateTime = DateTime.Now; // 通过ESI获取角色拥有的蓝图列表 List <ESIBluePrint> lstBluePrint = ESI.GetBluePrints(CharacterID, GetAccessToken()); // 若获取失败, 则返回空值 if (lstBluePrint == null) { return(null); } List <OwnedBluePrints> lstOwnedBluePrints = new List <OwnedBluePrints>(); OwnedBluePrints ownedBluePrints; // 将ESI获得的数据转换为Linq对象 foreach (var bp in lstBluePrint) { ownedBluePrints = new OwnedBluePrints() { ItemID = bp.ItemID, BluePrintID = bp.TypeID, Owner = CharacterID, CharacterOwned = true, LocationID = bp.LocationID, LocationFlag = bp.LocationFlag, Quantity = bp.Quantity, TimeEfficiency = bp.TimeEfficiency, MaterialEfficiency = bp.MaterialEfficiency, Runs = bp.Runs, UpdateTime = updateTime }; lstOwnedBluePrints.Add(ownedBluePrints); } // 如果角色有军团权限, 则获取军团拥有的蓝图 if (Corporation) { lstBluePrint = ESI.GetBluePrints(CharacterID, GetAccessToken(), true); foreach (var bp in lstBluePrint) { ownedBluePrints = new OwnedBluePrints() { ItemID = bp.ItemID, BluePrintID = bp.TypeID, Owner = CharacterID, CharacterOwned = false, LocationID = bp.LocationID, LocationFlag = bp.LocationFlag, Quantity = bp.Quantity, TimeEfficiency = bp.TimeEfficiency, MaterialEfficiency = bp.MaterialEfficiency, Runs = bp.Runs, UpdateTime = updateTime }; lstOwnedBluePrints.Add(ownedBluePrints); } } return(lstOwnedBluePrints); }
/// <summary> /// 清空并重新获取角色的技能数据(提交数据库) /// </summary> /// <returns>是否更新成功</returns> public bool UpdateSkills() { // 通过ESI获取角色的技能信息 ESICharacterSkillList csl = ESI.GetCharacterSkillList(CharacterID, GetAccessToken()); if (csl == null) { return(false); } DCEVEDataContext dc = new DCEVEDataContext(); // 清空原有技能数据 dc.CharacterSkills.DeleteAllOnSubmit(CharacterSkills); dc.SubmitChanges(); var targetSkillID = dc.invTypes.Where(p => CONST.TargetSkillsGroupID.Contains(p.groupID)).Select(p => p.typeID); CharacterSkills skill; // 只提取有用的技能数据且处理角色数据 foreach (var s in csl.SkillList) { // 若技能 ID 不在要存储的技能ID队列里面, 则跳过 if (!targetSkillID.Contains(s.SkillID)) { continue; } // 若是要存储的技能, 则创建对应的数据记录 skill = new CharacterSkills() { CharacterID = CharacterID, SkillID = s.SkillID, Level = s.TrainedSkillLevel }; CharacterSkills.Add(skill); } dc.SubmitChanges(); // 分析角色能力 // 制造能力 ManuCapability = (from s in dc.industryActivitySkills join c in dc.CharacterSkills on s.skillID equals c.SkillID where c.CharacterID == CharacterID && s.activityID == CONST.ManufactActivityID && c.Level >= s.level select s.skillID).Count(); NumManufactureLine = 1; var targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 3387); // 批量生产学 if (targetSkill != null) { NumManufactureLine += targetSkill.Level; } targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 24625); // 高级量产技术 if (targetSkill != null) { NumManufactureLine += targetSkill.Level; } // 科研能力 ReseCapability = (from s in dc.industryActivitySkills join c in dc.CharacterSkills on s.skillID equals c.SkillID where c.CharacterID == CharacterID && CONST.ResearchActivitiesID.Contains(s.activityID) && c.Level >= s.level select s.skillID).Count(); NumResearchLine = 1; targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 3406); // 实验室运作理论 if (targetSkill != null) { NumResearchLine += targetSkill.Level; } targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 24624); // 高级实验室运作理论 if (targetSkill != null) { NumResearchLine += targetSkill.Level; } // 市场订单量 if (Market) { NumMarketOrder = 5; targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 3443); // 贸易学 if (targetSkill != null) { NumMarketOrder += targetSkill.Level * 4; } targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 3444); // 零售技巧 if (targetSkill != null) { NumMarketOrder += targetSkill.Level * 8; } targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 16596); // 批发技巧 if (targetSkill != null) { NumMarketOrder += targetSkill.Level * 16; } targetSkill = CharacterSkills.SingleOrDefault(p => p.SkillID == 18580); // 商业巨头 if (targetSkill != null) { NumMarketOrder += targetSkill.Level * 32; } } dc.SubmitChanges(); return(true); }