public ClientProcess PeekNewClient() { ClientProcess process = null; newClients.TryPeek(out process); return(process); }
public ClientProcess DequeueDeadClient() { ClientProcess process = null; deadClients.TryDequeue(out process); return(process); }
public ClientProcess DequeueNewClient() { ClientProcess process = null; newClients.TryDequeue(out process); return(process); }
public ClientProcess PeekDeadClient() { ClientProcess process = null; deadClients.TryPeek(out process); return(process); }
void OnProcessTerminated(ClientProcess process) { if (process == null) { throw new ArgumentNullException("process"); } ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process)); }
public Player(ClientProcess process) { this.process = process; accessor = new ProcessMemoryAccessor(process.ProcessId, ProcessAccess.Read); inventory = new Inventory(this); equipment = new EquipmentSet(this); skillbook = new Skillbook(this); spellbook = new Spellbook(this); stats = new PlayerStats(this); modifiers = new PlayerModifiers(this); location = new MapLocation(this); gameClient = new ClientState(this); }
public void AddNewClient(ClientProcess process, ClientVersion version = null) { var player = new Player(process) { Version = version }; player.PropertyChanged += Player_PropertyChanged; if (player.Version == null) { player.Version = ClientVersionManager.Instance.Versions.First(v => v.Key != "Auto-Detect"); } AddPlayer(player); player.Update(); }
public ClientProcessEventArgs(ClientProcess process) { this.process = process; }
void OnProcessTerminated(ClientProcess process) { if (process == null) throw new ArgumentNullException("process"); ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process)); }
public void ScanForProcesses(Action<ClientProcess> enumProcessCallback = null) { var foundClients = new Dictionary<int, ClientProcess>(); var deadClients = new Dictionary<int, ClientProcess>(); var newClients = new Dictionary<int, ClientProcess>(); NativeMethods.EnumWindows((windowHandle, lParam) => { // Get Process & Thread Id var processId = 0; var threadId = NativeMethods.GetWindowThreadProcessId(windowHandle, out processId); // Get Window Class Name var classNameBuffer = new StringBuilder(256); var classNameLength = NativeMethods.GetClassName(windowHandle, classNameBuffer, classNameBuffer.Capacity); var className = classNameBuffer.ToString(); // Check Class Name (DA) if (!string.Equals("DarkAges", className, StringComparison.OrdinalIgnoreCase)) return true; // Get Window Title var windowTextLength = NativeMethods.GetWindowTextLength(windowHandle); var windowTextBuffer = new StringBuilder(windowTextLength + 1); windowTextLength = NativeMethods.GetWindowText(windowHandle, windowTextBuffer, windowTextBuffer.Capacity); var windowText = windowTextBuffer.ToString(); // Get Window Rectangle Rect windowRect; NativeMethods.GetWindowRect(windowHandle, out windowRect); var process = new ClientProcess { ProcessId = processId, WindowHandle = windowHandle, WindowClassName = className, WindowTitle = windowText, WindowWidth = windowRect.Width, WindowHeight = windowRect.Height }; // Add to found clients foundClients[processId] = process; // Callback enumProcessCallback?.Invoke(process); return true; }, IntPtr.Zero); // Find Dead Clients foreach (var client in clientProcesses.Values.ToArray()) { ClientProcess process; if (!foundClients.ContainsKey(client.ProcessId)) { clientProcesses.TryRemove(client.ProcessId, out process); EnqueueDeadClient(client); } } // Find New Clients foreach (var client in foundClients.Values) { if (!clientProcesses.ContainsKey(client.ProcessId)) { clientProcesses[client.ProcessId] = client; EnqueueNewClient(client); } } }
public void EnqueueNewClient(ClientProcess process) { newClients.Enqueue(process); OnProcessCreated(process); }
public void EnqueueDeadClient(ClientProcess process) { deadClients.Enqueue(process); OnProcessTerminated(process); }
public void ScanForProcesses(Action <ClientProcess> enumProcessCallback = null) { var foundClients = new Dictionary <int, ClientProcess>(); var deadClients = new Dictionary <int, ClientProcess>(); var newClients = new Dictionary <int, ClientProcess>(); NativeMethods.EnumWindows((windowHandle, lParam) => { // Get Process & Thread Id var processId = 0; var threadId = NativeMethods.GetWindowThreadProcessId(windowHandle, out processId); // Get Window Class Name var classNameBuffer = new StringBuilder(256); var classNameLength = NativeMethods.GetClassName(windowHandle, classNameBuffer, classNameBuffer.Capacity); var className = classNameBuffer.ToString(); // Check Class Name (DA) if (!string.Equals("DarkAges", className, StringComparison.OrdinalIgnoreCase)) { return(true); } // Get Window Title var windowTextLength = NativeMethods.GetWindowTextLength(windowHandle); var windowTextBuffer = new StringBuilder(windowTextLength + 1); windowTextLength = NativeMethods.GetWindowText(windowHandle, windowTextBuffer, windowTextBuffer.Capacity); var windowText = windowTextBuffer.ToString(); // Get Window Rectangle Rect windowRect; NativeMethods.GetWindowRect(windowHandle, out windowRect); var process = new ClientProcess { ProcessId = processId, WindowHandle = windowHandle, WindowClassName = className, WindowTitle = windowText, WindowWidth = windowRect.Width, WindowHeight = windowRect.Height }; // Add to found clients foundClients[processId] = process; // Callback enumProcessCallback?.Invoke(process); return(true); }, IntPtr.Zero); // Find Dead Clients foreach (var client in clientProcesses.Values.ToArray()) { ClientProcess process; if (!foundClients.ContainsKey(client.ProcessId)) { clientProcesses.TryRemove(client.ProcessId, out process); EnqueueDeadClient(client); } } // Find New Clients foreach (var client in foundClients.Values) { if (!clientProcesses.ContainsKey(client.ProcessId)) { clientProcesses[client.ProcessId] = client; EnqueueNewClient(client); } } }