示例#1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                // all handles in the system
                var handles = SystemInformation.EnumHandles();
                Console.WriteLine($"Total handles: {handles.Length}");
                foreach (var handle in handles)
                {
                    Console.WriteLine($"H: 0x{handle.Handle:X4}\tPID: {handle.ProcessId}\tObject: 0x{handle.Object.ToUInt64():X}\tType: {handle.ObjectTypeIndex,2} Access: 0x{handle.AccessMask:X8}");
                }
            }
            else
            {
                int pid = int.Parse(args[0]);

                using (var process = NativeProcess.Open(ProcessAccessMask.QueryInformation, pid)) {
                    var handles = process.EnumHandles();
                    Console.WriteLine($"Total handles: {handles.Length}");
                    foreach (var handle in handles)
                    {
                        Console.WriteLine($"H: 0x{handle.Handle:X4}\t Count: {handle.HandleCount}\tType: {handle.ObjectTypeIndex,2}\tPointer Count: 0x{handle.PointerCount:X}");
                    }
                }
            }
        }
示例#2
0
        public void Update()
        {
            TabManager.IsBusy = true;

            _rawHandles = SystemInformation.EnumHandles() ?? throw new Exception("Failed to get system handles");
            _handles    = new ObservableCollection <HandleViewModel>(_rawHandles.Take(1000).Select(handle => new HandleViewModel(handle)));
            _handleMap  = _handles.ToDictionary(handle => handle.Info);
            RaisePropertyChanged(nameof(Handles));

            _timer.Tick += delegate {
                int count = _handles.Count;
                if (count == _rawHandles.Length)
                {
                    _timer.Stop();
                    TabManager.IsBusy = false;
                    return;
                }
                foreach (var item in _rawHandles.Skip(count).Take(Math.Min(5000, _rawHandles.Length - count)).Select(item => new HandleViewModel(item)))
                {
                    _handles.Add(item);
                    _handleMap.Add(item.Info, item);
                }
            };
            _timer.Start();

            //var deadHandles = _rawHandles.AsParallel().Except(handles.AsParallel(), HandleComparer.Instance);
        }
示例#3
0
        static void Main(string[] args)
        {
            var types = SystemInformation.EnumObjectTypes();
            var job   = types.First(t => t.Name == "Job").Index;
            var jobs  = SystemInformation.EnumHandles().Where(h => h.ObjectTypeIndex == job).Distinct(new HandleComparer());

            foreach (var handle in jobs)
            {
                Console.WriteLine($"0x{handle.Handle:X4} {handle.ProcessId,7} 0x{handle.Object:X}");
            }
        }
示例#4
0
        public HandlesViewModel()
        {
            Icon        = Helpers.ToPackUri(Assembly.GetExecutingAssembly(), "/icons/handles.ico").ToString();
            _rawHandles = SystemInformation.EnumHandles() ?? throw new Exception("Failed to get system handles");

            _handles   = new ObservableCollection <HandleViewModel>(_rawHandles.Take(1000).Select(handle => new HandleViewModel(handle)));
            _handleMap = _handles.ToDictionary(handle => handle.Info);

            _timer.Tick += delegate {
                int count = _handles.Count;
                if (count == _rawHandles.Length)
                {
                    _timer.Stop();
                    return;
                }
                foreach (var item in _rawHandles.Skip(count).Take(Math.Min(5000, _rawHandles.Length - count)).Select(item => new HandleViewModel(item)))
                {
                    _handles.Add(item);
                    _handleMap.Add(item.Info, item);
                }
            };
            _timer.Start();
        }
示例#5
0
 public void Update()
 {
     var handles     = SystemInformation.EnumHandles();
     var deadHandles = _rawHandles.AsParallel().Except(handles.AsParallel());
 }