Inheritance: ObservableObject
Beispiel #1
0
        public ClientProcess PeekNewClient()
        {
            ClientProcess process = null;

            newClients.TryPeek(out process);

            return(process);
        }
Beispiel #2
0
        public ClientProcess DequeueDeadClient()
        {
            ClientProcess process = null;

            deadClients.TryDequeue(out process);

            return(process);
        }
Beispiel #3
0
        public ClientProcess DequeueNewClient()
        {
            ClientProcess process = null;

            newClients.TryDequeue(out process);

            return(process);
        }
Beispiel #4
0
        public ClientProcess PeekDeadClient()
        {
            ClientProcess process = null;

            deadClients.TryPeek(out process);

            return(process);
        }
Beispiel #5
0
        void OnProcessTerminated(ClientProcess process)
        {
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }

            ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process));
        }
Beispiel #6
0
 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);
 }
Beispiel #7
0
        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();
        }
Beispiel #8
0
 public ClientProcessEventArgs(ClientProcess process)
 {
     this.process = process;
 }
        void OnProcessTerminated(ClientProcess process)
        {
            if (process == null)
            throw new ArgumentNullException("process");

              ProcessTerminated?.Invoke(this, new ClientProcessEventArgs(process));
        }
Beispiel #10
0
        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);
            }
              }
        }
Beispiel #11
0
 public void EnqueueNewClient(ClientProcess process)
 {
     newClients.Enqueue(process);
       OnProcessCreated(process);
 }
Beispiel #12
0
 public void EnqueueDeadClient(ClientProcess process)
 {
     deadClients.Enqueue(process);
       OnProcessTerminated(process);
 }
 public ClientProcessEventArgs(ClientProcess process)
 {
     this.process = process;
 }
Beispiel #14
0
 public void EnqueueNewClient(ClientProcess process)
 {
     newClients.Enqueue(process);
     OnProcessCreated(process);
 }
Beispiel #15
0
 public void EnqueueDeadClient(ClientProcess process)
 {
     deadClients.Enqueue(process);
     OnProcessTerminated(process);
 }
Beispiel #16
0
        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);
                }
            }
        }