public static bool CheckPassword(string us, string pw) { try { string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\RemoteHealthcare\DoctorLogin.txt"; string s; using (StreamReader sr = File.OpenText(path)) { s = sr.ReadLine(); while (s != null) { if (TagDecoder.GetValueByTag(Tag.UN, s) == us) { if (TagDecoder.GetValueByTag(Tag.PW, s) == pw) { return(true); } else { return(false); } } s = sr.ReadLine(); } return(us == "admin" && pw == "admin"); } } catch (Exception) { return(us == "admin" && pw == "admin"); } }
public static byte[] Encrypt(string plainText, string key) { byte[] encrypted; byte[] keyBytes = GetKeyBytes(key); FileWriter fileWriter = new FileWriter(); using (AesManaged aes = new AesManaged()) { ICryptoTransform encryptor = aes.CreateEncryptor(keyBytes, IV); using (MemoryStream ms = new MemoryStream()) { using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) { using (StreamWriter sw = new StreamWriter(cs)) { sw.Write(plainText); } encrypted = ms.ToArray(); } } } if (TagDecoder.GetValueByTag(Tag.PNU, plainText) != null) { string s = ""; foreach (byte encryptedByte in encrypted) { s += encryptedByte.ToString(); } fileWriter.WriteFile(TagDecoder.GetValueByTag(Tag.PNU, plainText), s); } return(encrypted); }
private void HandleSetResistance(string packet) { int resistancePercentage = int.Parse(TagDecoder.GetValueByTag(Tag.SR, packet)); Console.WriteLine(resistancePercentage); this.BleConnect.doctorMessage = $"Resistance to {resistancePercentage}%"; this.BleConnect.SetResistance(resistancePercentage); }
private void parse(TagDecoder p) { p.KeepOffsets = true; p.parse(this); SupportClass.CollectionsSupport.Sort(skipOffsets, null); className = null; }
private void HandlePacket(string packet) { string messageType = TagDecoder.GetValueByTag(Tag.MT, packet); if (messageType == "ergo") { this.HandleErgoMessage(packet); } }
public void SetDecoder(TagType tag, TagDecoder decoder) { if (_TagDecoders.ContainsKey(tag)) { _TagDecoders[tag] = decoder; } else { _TagDecoders.Add(tag, decoder); } }
public MovieMetaData(Stream swf, Stream swd) { try { init(); TagDecoder p = new TagDecoder(swf, swd); parse(p); } catch (IOException) { } }
static Dictionary <int, string> DeserializeTags(int tagCount, BinaryReader reader) { var tagKeyToValue = new Dictionary <int, string>(); for (var i = 0; i < tagCount; i++) { var tagKey = reader.ReadInt32(); var tagLen = reader.ReadInt32(); var tagValue = TagDecoder.GetString(reader.ReadBytes(tagLen)); tagKeyToValue.Add(tagKey, tagValue); } return(tagKeyToValue); }
public MovieMetaData(String u) { try { init(); Uri url = new Uri(u); Stream in_Renamed = System.Net.WebRequest.Create(url).GetResponse().GetResponseStream(); TagDecoder p = new TagDecoder(in_Renamed, url); parse(p); } catch (UriFormatException) { } catch (IOException) { } }
public SwfActionContainer(Stream swfIn, Stream swdIn) { TagDecoder p = new TagDecoder(swfIn, swdIn); try { process(p); errorProcessing = false; } catch (IOException io) { if (Trace.error) { Console.Error.Write(io.StackTrace); Console.Error.Flush(); } } }
private INode DecodeTag(BinaryReader input) { var tag = (TagType)input.ReadByte(); var length = GetInteger(input); var end = input.BaseStream.Position + length; //System.Diagnostics.Trace.WriteLine(string.Format("{0} @ {1:X}h+{2:X}h", tag, input.BaseStream.Position, length)); TagDecoder decoder = null; _TagDecoders.TryGetValue(tag, out decoder); var result = (decoder ?? DefaultTagDecoder)(input, tag, length); if (input.BaseStream.Position != end) { throw new InvalidOperationException(); } if (input.ReadByte() != TagEndMarker) { throw new InvalidDataException(); } return(result); }
private void HandleErgoMessage(string packet) { string action = TagDecoder.GetValueByTag(Tag.AC, packet); if (action == "resistance") { this.HandleSetResistance(packet); } else if (action == "emergencybrake") { this.HandleEmergencyBrake(packet); } else if (action == "brake") { this.HandleStopSession(packet); } else if (action == "message") { this.HandleDoctorsMessage(packet); } }
private INode DecodeTag(BinaryReader input) { var tag = (TagType)input.ReadByte(); var length = GetInteger(input); var end = input.BaseStream.Position + length; //System.Diagnostics.Trace.WriteLine(string.Format("{0} @ {1:X}h+{2:X}h", tag, input.BaseStream.Position, length)); TagDecoder decoder = null; _TagDecoders.TryGetValue(tag, out decoder); var result = (decoder ?? DefaultTagDecoder)(input, tag, length); if (input.BaseStream.Position != end) { // Triggered by two entries in LogMessage as of 3.15. // Looks like a tag has some extra bits, as the end length is a proper TagEndMarker. System.Diagnostics.Debug.WriteLine(string.Format("Position mismatch in XivStringDecoder.DecodeTag. Position {0} != predicted {1}.", input.BaseStream.Position, end)); input.BaseStream.Position = end; } if (input.ReadByte() != TagEndMarker) { throw new InvalidDataException(); } return(result); }
/// <summary> Ask a TagDecoder to do its magic, calling us /// upon each encounter of a new tag. /// </summary> internal virtual void process(TagDecoder d) { m_master = new ActionList(true); d.KeepOffsets = true; d.parse(this); }
public void SetDecoder(TagType tag, TagDecoder decoder) { if (_TagDecoders.ContainsKey(tag)) _TagDecoders[tag] = decoder; else _TagDecoders.Add(tag, decoder); }
static void Main(string[] args) { #region Compile string filename = "generic"; TimeSpan maxtargettime = new TimeSpan(0, 0, 0, 0, 10); string loadpath = "reference.ovr"; if (args.Length > 0) { loadpath = args[0]; } bool foundcode = false; int depth = 10; string loadname = "reference"; string exten = ".ovr"; string pth = Environment.CurrentDirectory; while (!foundcode) { if (loadpath.IsStartAndRemove(out loadpath, "::")) { loadpath = loadpath.Replace("/", "\\"); string[] fp = loadpath.Split("."); if (fp.Length >= 2) { exten = "." + fp.Last(); loadpath = loadpath.IfEndAndRemove(exten); fp = new string[0]; fp = loadpath.Split("\\"); if (fp.Length >= 2) { loadname = fp.Last(); loadpath = loadpath.IfEndAndRemove("\\" + loadname); pth += "\\" + loadpath; } else { loadname = loadpath; } } else { fp = new string[0]; fp = loadpath.Split("\\"); if (fp.Length >= 2) { loadname = fp.Last(); loadpath = loadpath.IfEndAndRemove("\\" + loadname); pth += "\\" + loadpath; } else { loadname = loadpath; } } } else { loadpath = loadpath.Replace("/", "\\"); string[] fp = loadpath.Split("."); if (fp.Length >= 2) { exten = "." + fp.Last(); loadpath = loadpath.IfEndAndRemove(exten); fp = new string[0]; fp = loadpath.Split("\\"); if (fp.Length >= 2) { loadname = fp.Last(); loadpath = loadpath.IfEndAndRemove("\\" + loadname); pth = loadpath; } else { loadname = loadpath; } } else { fp = new string[0]; fp = loadpath.Split("\\"); if (fp.Length >= 2) { loadname = fp.Last(); loadpath = loadpath.IfEndAndRemove("\\" + loadname); pth = loadpath; } else { loadname = loadpath; } } } if (exten != ".ovr" && exten != ".csdref") { foundcode = true; } else { string[] tmpl = File.ReadAllLines(pth + "\\" + loadname + exten); if (tmpl.Length >= 1) { loadpath = tmpl[0]; } } if (depth < 1) { throw new LoopLengthException(); } depth--; } string code = File.ReadAllText(pth + "\\" + loadname + exten); List <string> refassemblies = new List <string>(); if (TagDecoder.IsTag(code, "lib")) { string[] data = TagDecoder.WTags(code, "lib", true).Split('|'); foreach (string strd in data) { refassemblies.Add(strd); } code = TagDecoder.StripTags(code, "lib"); } string namesp = "CSCT"; string cla = "Generic"; string method = "CSD"; if (TagDecoder.IsTag(code, "detail")) { string[] data = TagDecoder.WTags(code, "detail", true).Split('|'); if (data.Length == 3) { namesp = data[0]; cla = data[1]; method = data[2]; } code = TagDecoder.StripTags(code, "detail"); } filename = cla; CSharpCodeProvider provider = new CSharpCodeProvider(); CompilerParameters parameters = new CompilerParameters(); parameters.ReferencedAssemblies.Add("System.dll"); parameters.ReferencedAssemblies.Add("Ruaraidheulib.dll"); parameters.ReferencedAssemblies.Add("CsDiag.exe"); foreach (string sref in refassemblies) { parameters.ReferencedAssemblies.Add(sref); } parameters.GenerateInMemory = true; parameters.GenerateExecutable = false; CompilerResults results = provider.CompileAssemblyFromSource(parameters, code); if (results.Errors.HasErrors) { StringBuilder sb = new StringBuilder(); foreach (CompilerError error in results.Errors) { sb.AppendLine(System.String.Format("Error ({0}): {1}", error.ErrorNumber, error.ErrorText)); } throw new InvalidOperationException(sb.ToString()); } Assembly assembly = results.CompiledAssembly; Type program = assembly.GetType(namesp + "." + cla); MethodInfo main = program.GetMethod(method); #endregion #region Init Save save = new Save(); Exception kill = null; string dat = ""; TimeSpan usertime = new TimeSpan(); TimeSpan ignoredtime = new TimeSpan(); StopLap sl = new StopLap(); Errorhandling eh = new Errorhandling(save, sl); sl.ResetS(); save.SaveLine("--------START_OF_TEST--------"); sl.StartS(); try { #endregion dat = (string)main.Invoke(null, new object[] { save, sl, eh }); #region Post sl.IgnoreTimeClick("Return"); } catch (Exception e) { kill = e; save.FastLine("PROGRAM_FORCIBLY_TERMINATED_DUE_TO_FATAL_EXCEPTION"); } sl.StopS(); if (kill == null) { save.SaveLine("---------END_OF_TEST---------"); } else { save.SaveLine("-------TEST_TERMINATED-------"); } save.SaveLine(""); save.SaveLine("COMPILING_DIAGNOSTIC"); dat += eh.GetTags(); System.Threading.Thread.Sleep(2000); save.SaveLine(""); save.SaveLine(""); save.SaveLine(""); #endregion #region Diag save.SaveLine("------DIAGNOSTIC_REPORT------"); save.SaveLine(""); save.SaveLine(""); //Report #region ID save.SaveLine("--ID_INFO--"); save.SaveLine(""); save.SaveLine("DATE: {0}", DateTime.Now); if (TagDecoder.IsTag(dat, "NN")) { filename = TagDecoder.WTags(dat, "NN"); } if (args.Length > 1) { filename = args[1]; } save.SaveLine("TEST: " + filename.ToUpper()); dat = dat.ToUpper(); if (TagDecoder.IsTag(dat, "DAT")) { string[] data = TagDecoder.WTags(dat, "DAT", true).Split('|'); if (data.Length >= 4) { save.SaveLine("NAME: " + data[0]); save.SaveLine("REPO: " + data[1]); save.SaveLine("FILE: " + data[2]); save.SaveLine("CLASS: " + data[3]); } } if (TagDecoder.IsTag(dat, "TT")) { maxtargettime = new TimeSpan(0, 0, 0, 0, TagDecoder.WTags(dat, "TT").ToInt32()); } string[] libs = Directory.GetFiles(Environment.CurrentDirectory, "*.dll"); Loop.For((i) => { string[] p = libs[i].Split('\\'); string ps = p.Last().ToUpper(); if (i == 0) { save.SaveLine("LIBRARY: " + ps); } else { save.SaveLine(" " + ps); } } , libs.Length); if (sl.userclicks > 0) { save.SaveLine("USER_INPUT: TRUE"); } else { save.SaveLine("USER_INPUT: FALSE"); } save.SaveLine("TARGET_TIME: {0}", maxtargettime); save.SaveLine(""); save.SaveLine(""); #endregion #region System save.SaveLine("--SYSTEM_INFO--"); save.SaveLine(""); save.SaveLine("DIRECTORY: " + System.Environment.CurrentDirectory); save.SaveLine("OS: " + System.Environment.OSVersion.ToString()); RegistryKey processor_name = Registry.LocalMachine.OpenSubKey(@"Hardware\Description\System\CentralProcessor\0", RegistryKeyPermissionCheck.ReadSubTree); if (processor_name != null) { if (processor_name.GetValue("ProcessorNameString") != null) { save.SaveLine("PROCESSOR: " + processor_name.GetValue("ProcessorNameString").ToString()); } } save.SaveLine("PROCESSOR_COUNT: " + System.Environment.ProcessorCount); save.SaveLine("MACHINE_NAME: " + System.Environment.MachineName); save.SaveLine("IS_64BIT_OS: " + System.Environment.Is64BitOperatingSystem); save.SaveLine("IS_64BIT_PROCESS: " + System.Environment.Is64BitProcess); save.SaveLine("PAGE_SIZE: " + System.Environment.SystemPageSize); save.SaveLine("CLR_VERSION: " + System.Environment.Version); save.SaveLine("WORKING_SET: " + System.Environment.WorkingSet); save.SaveLine(""); save.SaveLine(""); #endregion #region Profiling save.SaveLine("--PROFILING--"); save.SaveLine(""); save.SaveLine("TIME: {0}", sl.s.Elapsed); save.SaveLine("TARGET_TIME: {0}", maxtargettime); save.SaveLine("MISSING_TIME: {0}", sl.MissingTime()); for (int i = 0; i < sl.dt.Count; i++) { if (sl.ds[i].StartsWith("ut:ex")) { usertime += sl.dt[i]; } } save.SaveLine("USERTIME: {0}", usertime); save.SaveLine("USER_ADJUSTED_TOTAL: {0}", sl.s.Elapsed - usertime); for (int i = 0; i < sl.dt.Count; i++) { if (sl.ds[i].StartsWith("ig:ex")) { ignoredtime += sl.dt[i]; } } save.SaveLine("IGNORED_TIME: {0}", ignoredtime); save.SaveLine("IGNORED_ADJUSTED: {0}", sl.s.Elapsed - ignoredtime); save.SaveLine("IGNORED_ADJUSTED_TOTAL: {0}", (sl.s.Elapsed - ignoredtime) - usertime); save.SaveLine("---"); List <string> lstr = new List <string>(); List <Twoint> lint = new List <Twoint>(); if (TagDecoder.IsTag(dat, "FORCEEDIT")) { string[] data = TagDecoder.WTags(dat, "FORCEEDIT", true).Split('|'); for (int i = 0; i < data.Length; i++) { string[] d2 = data[i].Split(";+;"); string[] d3 = data[i].Split(";-;"); if (d2.Length == 2) { Twoint t = new Twoint(-1, -1); Loop.For((j) => { if (sl.ds[j] == d2[0]) { t.X = j; } if (sl.ds[j] == d2[1]) { t.Y = j; } } , sl.ds.Count); if (t.X != -1 && t.Y != -1) { lstr.Add("FORCECLICKJOIN-FE:ED(" + sl.ds[t.X].ToUpper() + " + " + sl.ds[t.Y].ToUpper() + "): " + (sl.dt[t.X] + sl.dt[t.Y]).ToString().ToUpper()); lint.Add(t); } } else if (d3.Length == 2) { Twoint t = new Twoint(-1, -1); Loop.For((j) => { if (sl.ds[j] == d3[0]) { t.X = j; } if (sl.ds[j] == d3[1]) { t.Y = j; } } , sl.ds.Count); if (t.X != -1 && t.Y != -1) { lstr.Add("FORCECLICKSUB-FE:ED(" + sl.ds[t.X].ToUpper() + " - " + sl.ds[t.Y].ToUpper() + "): " + (sl.dt[t.X] - sl.dt[t.Y]).ToString().ToUpper()); lint.Add(t); } } } } for (int i = 0; i < sl.dt.Count; i++) { bool rement = false; for (int j = 0; j < lint.Count; j++) { if (lint[j].X == i) { rement = true; if (lint[j].X > lint[j].Y) { save.SaveLine(lstr[j]); } } if (lint[j].Y == i) { rement = true; if (lint[j].Y > lint[j].X) { save.SaveLine(lstr[j]); } } } if (!rement) { save.SaveLine("TIMECLICK-{0}: {1}", sl.ds[i].ToUpper(), sl.dt[i]); } } save.SaveLine("---"); if (TagDecoder.IsTag(dat, "CLICKEDIT")) { string[] data = TagDecoder.WTags(dat, "CLICKEDIT", true).Split('|'); for (int i = 0; i < data.Length; i++) { string[] d2 = data[i].Split(":+:"); string[] d3 = data[i].Split(":-:"); if (d2.Length == 2) { Twoint t = new Twoint(-1, -1); Loop.For((j) => { if (sl.ds[j] == d2[0]) { t.X = j; } if (sl.ds[j] == d2[1]) { t.Y = j; } } , sl.ds.Count); if (t.X != -1 && t.Y != -1) { save.SaveLine("TIMECLICKJOIN-{0}: {1}", "CE:ED(" + sl.ds[t.X].ToUpper() + " + " + sl.ds[t.Y].ToUpper() + ")", (sl.dt[t.X] + sl.dt[t.Y]).ToString().ToUpper()); } } else if (d3.Length == 2) { Twoint t = new Twoint(-1, -1); Loop.For((j) => { if (sl.ds[j] == d3[0]) { t.X = j; } if (sl.ds[j] == d3[1]) { t.Y = j; } } , sl.ds.Count); if (t.X != -1 && t.Y != -1) { save.SaveLine("TIMECLICKSUB-{0}: {1}", "CE:ED(" + sl.ds[t.X].ToUpper() + " - " + sl.ds[t.Y].ToUpper() + ")", (sl.dt[t.X] - sl.dt[t.Y]).ToString().ToUpper()); } } } } save.SaveLine(""); save.SaveLine(""); #endregion #region Errors save.SaveLine("--ERRORS--"); save.SaveLine(""); if (kill != null) { save.SaveLine("TERMINATION_EXCEPTION: "); save.SaveLine(" EXCEPTION: {0}", kill.GetType().ToString().ToUpper()); save.SaveLine(" MESSAGE: {0}", kill.Message.ToUpper()); save.SaveLine(" STACK_TRACE: {0}", kill.StackTrace.ToUpper()); save.SaveLine(" HRESULT: {0}", kill.HResult.ToString().ToUpper()); if (kill.HelpLink != null) { save.SaveLine(" HELPLINK: {0}", kill.HelpLink.ToUpper()); } save.SaveLine(""); } if (TagDecoder.IsTag(dat, "ED")) { string[] edsec = TagDecoder.WTags(dat, "ED", true).Split('|'); Loop.For((i) => { string[] eind = edsec[i].Split(":+:"); if (eind.Length == 4) { save.SaveLine("HANDLED_EXCEPTION: "); save.SaveLine(" EXCEPTION: {0}", eind[0]); save.SaveLine(" MESSAGE: {0}", eind[1]); save.SaveLine(" STACK_TRACE: {0}", eind[2]); save.SaveLine(" HRESULT: {0}", eind[3]); } else if (eind.Length == 5) { save.SaveLine("HANDLED_EXCEPTION: "); save.SaveLine(" EXCEPTION: {0}", eind[0]); save.SaveLine(" MESSAGE: {0}", eind[1]); save.SaveLine(" STACK_TRACE: {0}", eind[2]); save.SaveLine(" HRESULT: {0}", eind[3]); save.SaveLine(" HELPLINK: {0}", eind[4]); } } , edsec.Length); } save.SaveLine(""); save.SaveLine(""); #endregion #region Results save.SaveLine("--RESULTS--"); save.SaveLine(""); save.DirectWrite(""); save.SaveWrite("EXCEPTIONS: "); System.Threading.Thread.Sleep(300); if (kill == null) { save.SaveWrite("PASS"); System.Threading.Thread.Sleep(800); save.SaveLine(""); } else { save.SaveWrite("FAIL"); System.Threading.Thread.Sleep(800); save.SaveLine(""); save.SaveLine("EXCEPTION={0}", kill.GetType().ToString().ToUpper()); save.SaveLine("MESSAGE={0}", kill.Message.ToUpper()); save.SaveLine("STACK_TRACE={0}", kill.StackTrace.ToUpper()); save.SaveLine("HRESULT={0}", kill.HResult.ToString().ToUpper()); if (kill.HelpLink != null) { save.SaveLine("HELPLINK={0}", kill.HelpLink.ToUpper()); } System.Threading.Thread.Sleep(800); save.SaveLine(""); } save.SaveWrite("TIME: "); System.Threading.Thread.Sleep(300); if (((sl.s.Elapsed - ignoredtime) - usertime) < maxtargettime) { save.SaveWrite("PASS"); System.Threading.Thread.Sleep(800); save.SaveLine(""); } else { save.SaveWrite("FAIL"); System.Threading.Thread.Sleep(800); save.SaveLine(""); save.SaveLine("TARGET_TIME={0}", maxtargettime); save.SaveLine("TOTAL_TIME_={0}", sl.s.Elapsed); save.SaveLine("USER_ADJUST={0}", sl.s.Elapsed - usertime); save.SaveLine("IGNRED_TIME={0}", ignoredtime); save.SaveLine("IGNR_ADJUST={0}", sl.s.Elapsed - ignoredtime); save.SaveLine("IGNR_TOTAL_={0}", (sl.s.Elapsed - ignoredtime) - usertime); System.Threading.Thread.Sleep(800); save.SaveLine(""); } //Report End save.ExclusiveWrite(""); save.SaveLine(""); #endregion save.SaveLine("--------END_OF_REPORT--------"); save.SaveLine(""); save.SaveLine(""); save.SaveLine(""); save.SaveAll(pth + "\\DiagReport-" + filename + ".log"); save.SaveLine(""); save.SaveLine("----PRESS_ANY_KEY_TO_EXIT----"); Console.ReadKey(); #endregion }
private void HandleDoctorsMessage(string packet) { string message = TagDecoder.GetValueByTag(Tag.DM, packet); this.BleConnect.doctorMessage = $"{message}"; }