// outbound public XConnection(XRemote remote, IPAddress ip, ushort tcpPort) { Remote = remote; Bandwidth = new BandwidthLog(5); Outbound = true; RemoteIP = ip; TcpPort = tcpPort; try { IPEndPoint endpoint = new IPEndPoint(RemoteIP, TcpPort); TcpSocket = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp); TcpSocket.BeginConnect((EndPoint)endpoint, new AsyncCallback(Socket_Connect), TcpSocket); } catch (Exception ex) { Log("TcpSocket", ex.Message); Disconnect(); } }
// called from re-compiled app's entrypoint public static void Init(string datPath, bool trackFlow, bool trackInstances, bool remoteViewer) { AppDir = Path.GetDirectoryName(datPath); DatPath = datPath; LogError("Entry point Init"); if (InitComplete) { LogError("Init already called"); return; } InitComplete = true; RemoteViewer = remoteViewer; if (remoteViewer) TargetFps = 10; StartTime = DateTime.Now; Watch.Start(); // read compiled settings if (trackFlow) { FlowTracking = true; ThreadTracking = true; ClassTracking = true; } InstanceTracking = trackInstances; //System.Windows.Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); //Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //AppDomain.CurrentDomain.FirstChanceException +=new EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs>(CurrentDomain_FirstChanceException); try { // reset path to root path if not found (user moved exe folder, or distributing demo if (!File.Exists(DatPath)) DatPath = "XRay.dat"; // data file with node info should be along side ext DatHash = Utilities.MD5HashFile(DatPath); DatSize = new FileInfo(DatPath).Length; LoadNodeMap(); ApplySettings(); // init tracking structures CoveredNodes = new BitArray(FunctionCount); TrackMethodExit = (ThreadTracking && FlowTracking && TrackFunctionHits && Nodes != null); // nodes initd InitCoreThread(); if (!remoteViewer) { if(EnableIpcServer) StartIpcServer(); if (EnableTcpServer) { Remote = new XRemote(); Remote.StartListening(TcpListenPort, EncryptionKey); } if (EnableLocalViewer && ShowViewerOnStart) StartGui(); } } catch (Exception ex) { File.WriteAllText(Path.Combine(AppDir, "XRayError.txt"), "XRay::Init - " + ex.Message + ":\r\n" + ex.StackTrace); } }
// inbound public XConnection(XRemote remote) { Remote = remote; Bandwidth = new BandwidthLog(5); }