//event handler to manage the errors private static void verifyErrors(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { SimpleLog.Error(args.Message); } }
/// <summary> /// Log a message at specified level /// </summary> /// <param name="level">level to log</param> /// <param name="message">message to log</param> public void Log(LogLevel level, object message) { var messageToLog = String.Format("{0}|{1}", level, message); switch (level) { case LogLevel.Debug: SimpleLog.Info(messageToLog); break; case LogLevel.Error: SimpleLog.Error(messageToLog); break; case LogLevel.Fatal: SimpleLog.Error(messageToLog); break; case LogLevel.Info: SimpleLog.Info(messageToLog); break; case LogLevel.Warning: SimpleLog.Warning(messageToLog); break; default: SimpleLog.Error(messageToLog); break; } }
public override void Enable() { if (Enabled) { return; } config = LoadConfig <Configs>() ?? new Configs(); changeAddress = Common.Scanner.ScanText("41 80 7E 2F 06 75 1E 48 8D 0D"); if (SafeMemory.ReadBytes(changeAddress, 5, out originalBytes)) { if (SafeMemory.WriteBytes(changeAddress, new byte[] { 0x41, 0xF6, 0x46, 0x36, 0x10 })) // cmp byte ptr [r14+2Fh], 6 -> test byte ptr [r14+36h], 10 { base.Enable(); } else { SimpleLog.Error("Failed to write new instruction"); } } else { SimpleLog.Error("Failed to read original instruction"); } if (config.FixCones) { ModifyCones(true); } }
//Lay role de authorize protected void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs evt) { if (FormsAuthentication.CookiesSupported == true) { if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { try { //Lay username ra string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; string roles = string.Empty; //Lay role cua username using (RSMEntities entities = new RSMEntities()) { User user = entities.Users.SingleOrDefault(u => u.Username.Equals(username)); roles = user.Role.RoleName; } //Set Role vao, sau nay co the authorize bang annotation evt.User = new System.Security.Principal.GenericPrincipal( new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';')); } catch (Exception ex) { SimpleLog.Error(ex.Message); } } } }
private string SaveHtml(DataSet ds, Hermeticus h) { // template management var param = new Dictionary <string, string> { { "TITLE", h.Displays["FR"].Label }, { "DESCRIPTION", h.Displays["FR"].Tooltip }, { "BODY", ds.ToHtml(new HtmlSettings() { WithLineFeeds = true }) }, { "SERVER", Info.ServerName }, { "DATE", String.Format("YYYY-MM-DD HH:MM", DateTime.Now) } }; var output = $"{OutputPath}{h.Name}.html"; try { var text = File.ReadAllText("templates/result.html"); text = Regex.Replace(text, @"\{(.+?)\}", m => param[m.Groups[1].Value]); File.WriteAllText(output, text); } catch (Exception e) { SimpleLog.Error($"error reading 'templates/result.html' or writing file {output}. Error [{e.Message}]"); } return(output); }
private void FrameworkOnUpdate(Framework framework) { try { var player = Service.ClientState.LocalPlayer; if (player == null) { return; } // Shield Percentage as a byte is at address 0x1997 var shieldRawPercentage = (*(byte *)(player.Address + 0x1997)) / 100f; var playerHpPercentage = (float)player.CurrentHp / player.MaxHp; var playerHpDownPercentage = 1f - playerHpPercentage; var shieldOverPercentage = shieldRawPercentage - playerHpDownPercentage; shieldOverPercentage = shieldOverPercentage < 0 ? 0 : shieldOverPercentage; var shieldPercentage = shieldRawPercentage - shieldOverPercentage; if (shieldOverPercentage > 1) { shieldOverPercentage = 1; } shieldGrid->AtkResNode.X = playerHpPercentage * 148; shieldGrid->AtkResNode.Width = shieldPercentage > 0 ? (ushort)(shieldPercentage * 148 + 12 + 0.5f) : (ushort)0; shieldGrid->AtkResNode.Flags_2 |= 1; shieldGridOver->AtkResNode.Width = shieldOverPercentage > 0 ? (ushort)(shieldOverPercentage * 148 + 12 + 0.5f) : (ushort)0; } catch (Exception ex) { SimpleLog.Error(ex); } }
public override void Setup() { if (Ready) { return; } try { if (setUiPositionAddress == IntPtr.Zero) { setUiPositionAddress = Service.SigScanner.ScanText("40 53 48 83 EC 20 80 A2 ?? ?? ?? ?? ??"); } if (chatPanelControlAddress == IntPtr.Zero) { chatPanelControlAddress = Service.SigScanner.ScanText("40 55 57 48 81 EC ?? ?? ?? ?? 48 8B F9 45 8B C8"); } if (setUiPositionAddress == IntPtr.Zero || chatPanelControlAddress == IntPtr.Zero) { SimpleLog.Error($"Failed to setup {GetType().Name}: Failed to find required functions."); return; } Ready = true; } catch (Exception ex) { SimpleLog.Error($"Failed to setup {this.GetType().Name}: {ex.Message}"); } }
private void *PrintMessageDetour(RaptureLogModule *raptureLogModule, XivChatType xivChatType, IntPtr senderName, IntPtr message, uint senderId, byte param) { try { if (chatTypes.Contains(xivChatType)) { // Need to hook it manually to handle changing the name until API4 var stdSender = StdString.ReadFromPointer(senderName); var parsedSender = SeString.Parse(stdSender.RawData); if (Parse(ref parsedSender)) { stdSender.RawData = parsedSender.Encode(); var allocatedString = Service.LibcFunction.NewString(stdSender.RawData); var retVal = printChatHook.Original(raptureLogModule, xivChatType, allocatedString.Address, message, senderId, param); allocatedString.Dispose(); return(retVal); } } } catch (Exception ex) { SimpleLog.Error(ex); } return(printChatHook.Original(raptureLogModule, xivChatType, senderName, message, senderId, param)); }
private byte SetOptionDetour(ConfigModule *configmodule, uint index, int value, int a4, byte a5, byte a6) { try { var opt = configmodule->GetOption(index); changes.Insert(0, new LoggedConfigChange() { Index = index, Option = opt->OptionID, Value = value, a4 = a4, a5 = a5, a6 = a6 }); if (changes.Count > 200) { changes.RemoveRange(200, changes.Count - 200); } } catch (Exception ex) { SimpleLog.Error(ex); } return(setOptionHook.Original(configmodule, index, value, a4, a5, a6)); }
public WorldTravelSelect(AtkUnitBase *address) { UnitBase = address; try { RootNode = UnitBase->RootNode; if (RootNode == null) { return; } WindowComponent = (AtkComponentNode *)RootNode->ChildNode; InformationBox = (AtkComponentNode *)WindowComponent->AtkResNode.PrevSiblingNode; InformationBoxBorder = (AtkNineGridNode *)InformationBox->AtkResNode.PrevSiblingNode; WorldListComponent = (AtkComponentNode *)InformationBoxBorder->AtkResNode.PrevSiblingNode; WorldListHeader = (AtkTextNode *)WorldListComponent->AtkResNode.PrevSiblingNode; CurrentWorldContainer = WorldListHeader->AtkResNode.PrevSiblingNode; HomeWorldContainer = CurrentWorldContainer->PrevSiblingNode; WorldInfoHeader = (AtkTextNode *)HomeWorldContainer->PrevSiblingNode; CurrentWorldName = (AtkTextNode *)CurrentWorldContainer->ChildNode; CurrentWorldHeaderUnderline = (AtkNineGridNode *)CurrentWorldName->AtkResNode.PrevSiblingNode; CurrentWorldHeader = (AtkTextNode *)CurrentWorldHeaderUnderline->AtkResNode.PrevSiblingNode; CurrentWorldIcon = (AtkImageNode *)CurrentWorldHeader->AtkResNode.PrevSiblingNode; IsValid = true; } catch (Exception ex) { SimpleLog.Error(ex); IsValid = false; } }
/// <summary> /// Gets the orb walker mode logic. /// </summary> protected void PerformAssemblyLogic() { switch (_currentBuild) { case Build.AD_Mode: { _adMode.PerformAssemblyLogic(); } break; case Build.AP_Mode: { _apMode.PerformAssemblyLogic(); } break; case Build.General_Mode: { _generalMode.PerformAssemblyLogic(); } break; case Build.Support_Mode: { _supportMode.PerformAssemblyLogic(); } break; default: SimpleLog.Error("Mode was not detected in PerformAssemblyLogic()"); break; } }
private void OnToast(ref SeString message, ref ToastOptions options, ref bool isHandled) { try { if (isHandled) { return; } if (Config.Hide) { if (Config.ShowInCombat && Service.Condition[ConditionFlag.InCombat]) { return; } } else { var messageStr = message.ToString(); if (Config.Exceptions.All(x => !messageStr.Contains(x))) { return; } } isHandled = true; } catch (Exception ex) { SimpleLog.Error(ex); } }
public bool ExtractFromDataTable(ExtractionType et, DataTable dt) { if (!DetectFromDataTable(et, dt)) { return(false); } var col = (dt.Columns.Cast <DataColumn>().First( c => (c.ColumnName == "query_hash" && et == ExtractionType.QueryPlans) || ((c.ColumnName == "query_hash" || c.ColumnName == "sql_hash") && et == ExtractionType.SqlText))).Ordinal; HandlesList = dt.Rows.Cast <DataRow>().Select(r => r.Field <String>(col)).ToDictionary(k => k, v => new CacheObject()); if (Extract(et)) { try { SaveAll(et); } catch (Exception e) { SimpleLog.Error(e.Message); return(false); } } else { return(false); } return(true); }
/// <summary> /// Log an exception message at specified level /// </summary> /// <param name="level">level to log</param> /// <param name="debugMessage">message to log</param> /// <param name="exception">The exception to log</param> public void Log(LogLevel level, string debugMessage, Exception exception) { var messageToLog = String.Format("{0}|{1}", level, debugMessage); SimpleLog.Error(messageToLog); SimpleLog.Log(exception); }
public override void Setup() { if (Ready) { return; } try { if (mainChatWindowControlAddress == IntPtr.Zero) { mainChatWindowControlAddress = PluginInterface.TargetModuleScanner.ScanText("40 55 41 54 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 45 1F 80 B9 ?? ?? ?? ?? ??"); } if (subChatWindowControlAddress == IntPtr.Zero) { subChatWindowControlAddress = PluginInterface.TargetModuleScanner.ScanText("40 55 53 56 41 54 41 56 41 57 48 8D AC 24"); } if (mainChatWindowControlAddress == IntPtr.Zero || subChatWindowControlAddress == IntPtr.Zero) { SimpleLog.Error($"Failed to setup {GetType().Name}: Failed to find required functions."); return; } Ready = true; } catch (Exception ex) { SimpleLog.Error($"Failed to setup {this.GetType().Name}: {ex.Message}"); } }
private unsafe bool DrawClockConfig(int id, int index, string[] icons, ref bool hasChanged, ref MoveAction moveAction) { switch (id) { case 0: { var et = DateTimeOffset.FromUnixTimeSeconds(*(long *)(Service.Framework.Address.BaseAddress + 0x1608)); DrawClockConfig(index, LocString("Eorzea Time"), icons[0], ref hasChanged, ref TweakConfig.ShowET, ref TweakConfig.CustomFormatET, ref moveAction, et); break; } case 1: { DrawClockConfig(index, LocString("Local Time"), icons[1], ref hasChanged, ref TweakConfig.ShowLT, ref TweakConfig.CustomFormatLT, ref moveAction, DateTimeOffset.Now); break; } case 2: { DrawClockConfig(index, LocString("Server Time"), icons[2], ref hasChanged, ref TweakConfig.ShowST, ref TweakConfig.CustomFormatST, ref moveAction, DateTimeOffset.Now.UtcDateTime); break; } default: { // Broken TweakConfig.Order = new[] { 0, 1, 2 }; SimpleLog.Error("Broken Config Detected. Automatically Fixed"); hasChanged = true; return(false); } } return(true); }
private void Cleanup() { try { var destroyList = new List <ulong>(); foreach (var inventoryName in new[] { "Inventory", "InventoryLarge", "InventoryExpansion" }) { var atkUnitBase = Common.GetUnitBase(inventoryName); if (atkUnitBase == null) { continue; } var doUpdate = false; for (var n = 0; n < atkUnitBase->UldManager.NodeListCount; n++) { var node = atkUnitBase->UldManager.NodeList[n]; if (node == null) { continue; } if (node->NodeID == CustomNodes.InventoryGil) { if (node->ParentNode != null && node->ParentNode->ChildNode == node) { node->ParentNode->ChildNode = node->PrevSiblingNode; } if (node->PrevSiblingNode != null) { node->PrevSiblingNode->NextSiblingNode = node->NextSiblingNode; } if (node->NextSiblingNode != null) { node->NextSiblingNode->PrevSiblingNode = node->PrevSiblingNode; } doUpdate = true; destroyList.Add((ulong)node); } } if (doUpdate) { atkUnitBase->UldManager.UpdateDrawNodeList(); } } foreach (var a in destroyList) { var node = (AtkResNode *)a; if (node == null) { continue; } node->Destroy(true); } } catch (Exception ex) { SimpleLog.Error(ex); } }
private void FrameworkOnUpdate(Framework framework) { try { UpdateNotificationToastText(); } catch (Exception ex) { SimpleLog.Error(ex); } }
private void FrameworkOnUpdate(Framework framework) { try { UpdateTargetStatus(); } catch (Exception ex) { SimpleLog.Error(ex); } }
private void FrameworkOnOnUpdateEvent(Framework framework) { try { CheckWindow(); } catch (Exception ex) { SimpleLog.Error(ex); } }
private void FrameworkOnUpdate(Framework framework) { try { UpdateCastBar(); } catch (Exception ex) { SimpleLog.Error(ex); } }
private void UpdatePartyUi(bool done) { try { for (var index = 0; index < 11; index++) { if (index >= data->PlayerCount && index < 8 || index >= 8 + data->QinXinCount) { continue; } if (!done) //改名 { #if DEBUG if (!Config.PartyName) { return; } if (index >= 8) { return; } var lvlname = stringarray->MemberStrings(index).GetLvlName(); var job = data->MemberData(index).JobId; SplitString(lvlname, true, out var lvl, out var namejob); job = job > 0xF293 ? job - 0xF294 : 0; if (namejob != GetJobName(job) || data->MemberData(index).JobId != party->JobId[index]) { Plugin.Common.WriteSeString(stringarray->MemberStrings(index).Name, lvl + " " + GetJobName(job)); *((byte *)data + 0x1C + index * 0x9C) = 1; //Changed } #endif } else //改HP { if (Config.HpPercent) { var textNode = (AtkTextNode *)GetNodeById(party->Member(index).hpComponentBase, 2); if (textNode != null) { SetHp(textNode, data->MemberData(index)); } } if (Config.MpShield) { ShieldOnMp(index); } } } } catch (Exception e) { SimpleLog.Error(e); throw; } }
private void FrameworkUpdate(Framework framework) { try { UpdateAll(); } catch (Exception ex) { SimpleLog.Error("Exception in FrameworkUpdate"); SimpleLog.Error(ex); } }
public static int Main() { ////Debugger.Launch(); var arguments = GetArguments(); GetAssemblyData(out var executingAssemblyLocation, out var executingAssemblyFileName); Configure(executingAssemblyFileName); SimpleLog.Info($"Full Commandline: {Environment.CommandLine}"); SimpleLog.Info($"Detected Attributes: {arguments}"); SimpleLog.Info($"RunHiddenConsole Executing Assembly FullName: {executingAssemblyFileName}"); var targetExecutablePath = GetTargetExecutablePath(executingAssemblyLocation, executingAssemblyFileName); if (targetExecutablePath == null) { SimpleLog.Error("Unable to find target executable name in own executable name."); return(-7001); } var startInfo = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = Directory.GetCurrentDirectory(), Arguments = arguments, FileName = targetExecutablePath, }; try { var proc = Process.Start(startInfo); if (proc == null) { SimpleLog.Error("Unable to start the target process."); return(-7002); } // process will close as soon as its waiting for interactive input. proc.StandardInput.Close(); proc.WaitForExit(); return(proc.ExitCode); } catch (Exception ex) { SimpleLog.Error("Starting target process threw an unknown Exception: " + ex); SimpleLog.Log(ex); return(-7003); } }
private void OnFrameworkUpdate(Framework framework) { try { UpdateDeepDungeonStatus(); } catch (Exception ex) { SimpleLog.Error(ex); } }
public static int Main(string[] args) { var executingAssembly = Assembly.GetExecutingAssembly(); var fullName = Path.GetFileName(executingAssembly.Location); SimpleLog.Prefix = $"{fullName}."; SimpleLog.Info($"RunHiddenConsole Executing Assembly FullName: {fullName}"); var match = Regex.Match(fullName, @"(.+)w(\.\w{1,3})"); if (!match.Success) { SimpleLog.Error("Unable to find target executable name in own executable name."); return(-7001); } var targetExecutableName = match.Groups[1].Value + match.Groups[2].Value; var fullDirectory = Path.GetDirectoryName(executingAssembly.Location) ?? string.Empty; var executable = Path.Combine(fullDirectory, targetExecutableName); var startInfo = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = Directory.GetCurrentDirectory(), Arguments = string.Join(" ", args), FileName = executable, }; try { var proc = Process.Start(startInfo); if (proc == null) { SimpleLog.Error("Unable to start the target process."); return(-7002); } // process will close as soon as its waiting for interactive input. proc.StandardInput.Close(); proc.WaitForExit(); return(proc.ExitCode); } catch (Exception ex) { SimpleLog.Error("Starting target process threw an unknown Exception: " + ex); return(-7003); } }
private void UpdateTarget() { try { if (tTextNode == null || ttTextNode == null) { return; } var tname = Plugin.Common.ReadSeString(tTextNode->NodeText.StringPtr).TextValue.Trim(); var ttname = Plugin.Common.ReadSeString(ttTextNode->NodeText.StringPtr).TextValue.Trim(); if (tname.Length >= 1) { var number = tname.Substring(0, 1); if (PartyNumber.Contains(number)) { tname = tname.Substring(1); } else { SplitString(tname, true, out tname, out _); } var index = GetIndex(tname); if (index != -1) { var jobId = data->MemberData(index).JobId; jobId = jobId == 0 ? 0 : jobId - 0xF294; var job = GetJobName(jobId); SetName(tTextNode, PartyNumber.Contains(number) ? number + job : job); } } if (ttname.Length >= 1) { var number = ttname.Substring(0, 1); if (PartyNumber.Contains(number)) { ttname = ttname.Substring(1); } var index = GetIndex(ttname); if (index != -1) { var jobid = data->MemberData(index).JobId; jobid = jobid == 0 ? 0 : jobid - 0xF294; var job = GetJobName(jobid); SetName(ttTextNode, PartyNumber.Contains(number) ? number + job : job); } } } catch (Exception e) { SimpleLog.Error(e); } }
private void OnFrameworkUpdate(Framework framework) { try { foreach (var w in windowsWithCommunityFinder) { UpdateCommunityFinderButton(PluginInterface.Framework, w); } } catch (Exception ex) { SimpleLog.Error(ex); } }
/// <summary> /// Pour transformer toutes les exceptions en XmlBlasterException /// </summary> /// <param name="ex"></param> internal static void HandleException(Exception ex) { logger.Error("HandleException() {0}", ex.Message); logger.Error("HandleException() {0}", ex.StackTrace); //string msgBoxTitle = "Error" ; try { throw ex; } catch (XmlRpcFaultException fex) { //MessageBox.Show("Fault Response: " + fex.FaultCode + " " // + fex.FaultString, msgBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); throw new XmlBlasterException(fex.FaultString, fex); } catch (WebException webEx) { //MessageBox.Show("WebException: " + webEx.Message, msgBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); if (webEx.Response != null) { webEx.Response.Close(); } throw new XmlBlasterException(webEx); } catch (XmlRpcServerException xmlRpcEx) { //MessageBox.Show("XmlRpcServerException: " + xmlRpcEx.Message, // msgBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); throw new XmlBlasterException(xmlRpcEx); } catch (Exception defEx) { //MessageBox.Show("Exception: " + defEx.Message, msgBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Error); throw new XmlBlasterException(defEx); } }
public override void Disable() { if (!Enabled) { return; } if (!SafeMemory.WriteBytes(changeAddress, originalBytes)) { SimpleLog.Error("Failed to write original instruction"); } base.Disable(); }