public void Run(MemoryReader reader, IpcChannel channel) { var o1 = reader.FindOffset(_pattern1).Cast <int?>().FirstOrDefault(); var o2 = reader.FindOffset(_pattern2).Cast <int?>().FirstOrDefault(); if (o1 == null || o2 == null) { channel.LogError("Could not find version reporting function"); return; } var ver1 = ReadVersion(reader, (int)o1 + 5); var ver2 = ReadVersion(reader, (int)o2 + 6); if (ver1 == null || ver2 == null) { channel.LogError("Could not read version values"); return; } channel.LogBasic("Found client versions: {0}, {1}", ver1, ver2); channel.WriteVersions((uint)ver1, (uint)ver2); }
#pragma warning disable IDE0060 // Remove unused parameter public EntryPoint(RemoteHooking.IContext context, string channelName) #pragma warning restore IDE0060 // Remove unused parameter { _channel = IpcChannel.Connect(channelName); }
public static int Run(string[] args) { try { if (!HandleArguments(ref args)) { return(0); } } catch (OptionException e) { Console.Error.WriteLine(e.Message); return(1); } Log.Level = LogLevel.Debug; Log.TimestampFormat = "HH:mm:ss:fff"; var color = Console.ForegroundColor; Log.Loggers.Add(new ConsoleLogger(false, color, color, color, color, color)); if (!Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += UnhandledException; } var procs = Process.GetProcessesByName("TERA"); if (procs.Length == 0) { _log.Error("Could not find the TERA process"); return(1); } if (procs.Length != 1) { _log.Error("Found multiple TERA processes; please run only one"); return(1); } var proc = procs[0]; var fileName = Path.GetFileName(proc.MainModule.FileName); if (fileName != "TERA.exe") { _log.Error("Process {0} ({1}) has unexpected file name: {2}", proc.ProcessName, proc.Id, fileName); return(1); } _log.Basic("Injecting process {0} ({1})", proc.ProcessName, proc.Id); var chanName = IpcChannel.Create(); var loc = Assembly.GetExecutingAssembly().Location; RemoteHooking.Inject(proc.Id, InjectionOptions.DoNotRequireStrongName, loc, loc, chanName); var chan = IpcChannel.Connect(chanName); chan.Wait(); Directory.CreateDirectory(_output); if (chan.Version1 != null && chan.Version2 != null) { var verPath = Path.Combine(_output, "ver.txt"); File.WriteAllLines(verPath, new[] { chan.Version1.ToString(), chan.Version2.ToString(), }); _log.Basic("Wrote client versions to {0}", verPath); } if (chan.DataCenterKey != null) { var keyPath = Path.Combine(_output, "key.txt"); File.WriteAllLines(keyPath, new[] { string.Join(" ", chan.DataCenterKey.Select(x => x.ToString("X2"))), }); _log.Basic("Wrote data center key to {0}", keyPath); } if (chan.DataCenterIV != null) { var ivPath = Path.Combine(_output, "iv.txt"); File.WriteAllLines(ivPath, new[] { string.Join(" ", chan.DataCenterIV.Select(x => x.ToString("X2"))), }); _log.Basic("Wrote data center IV to {0}", ivPath); } if (chan.GameMessages != null) { var opcPath = Path.Combine(_output, "opc.txt"); File.WriteAllLines(opcPath, chan.GameMessages .Select(x => $"{x.Item2} = {x.Item1}") .ToArray()); _log.Basic("Wrote opcodes to {0}", opcPath); } if (chan.SystemMessages != null) { var smtPath = Path.Combine(_output, "smt.txt"); File.WriteAllLines(smtPath, chan.SystemMessages .Select(x => $"{x.Item2} = {x.Item1}") .ToArray()); _log.Basic("Wrote system messages to {0}", smtPath); } return(0); }
public EntryPoint(RemoteHooking.IContext context, string channelName) { _channel = IpcChannel.Connect(channelName); }