Exemplo n.º 1
0
        private KernelResult GetProcessList(ulong address, int maxCount, out int count)
        {
            count = 0;

            if ((maxCount >> 28) != 0)
            {
                return(KernelResult.MaximumExceeded);
            }

            if (maxCount != 0)
            {
                KProcess currentProcess = _system.Scheduler.GetCurrentProcess();

                ulong copySize = (ulong)maxCount * 8;

                if (address + copySize <= address)
                {
                    return(KernelResult.InvalidMemState);
                }

                if (currentProcess.MemoryManager.OutsideAddrSpace(address, copySize))
                {
                    return(KernelResult.InvalidMemState);
                }
            }

            int copyCount = 0;

            lock (_system.Processes)
            {
                foreach (KProcess process in _system.Processes.Values)
                {
                    if (copyCount < maxCount)
                    {
                        if (!KernelTransfer.KernelToUserInt64(_system, (long)address + copyCount * 8, process.Pid))
                        {
                            return(KernelResult.UserCopyFailed);
                        }
                    }

                    copyCount++;
                }
            }

            count = copyCount;

            return(KernelResult.Success);
        }
Exemplo n.º 2
0
        private KernelResult GetProcessList(ulong Address, int MaxCount, out int Count)
        {
            Count = 0;

            if ((MaxCount >> 28) != 0)
            {
                return(KernelResult.MaximumExceeded);
            }

            if (MaxCount != 0)
            {
                KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();

                ulong CopySize = (ulong)MaxCount * 8;

                if (Address + CopySize <= Address)
                {
                    return(KernelResult.InvalidMemState);
                }

                if (CurrentProcess.MemoryManager.OutsideAddrSpace(Address, CopySize))
                {
                    return(KernelResult.InvalidMemState);
                }
            }

            int CopyCount = 0;

            lock (System.Processes)
            {
                foreach (KProcess Process in System.Processes.Values)
                {
                    if (CopyCount < MaxCount)
                    {
                        if (!KernelTransfer.KernelToUserInt64(System, (long)Address + CopyCount * 8, Process.Pid))
                        {
                            return(KernelResult.UserCopyFailed);
                        }
                    }

                    CopyCount++;
                }
            }

            Count = CopyCount;

            return(KernelResult.Success);
        }