コード例 #1
0
        public override void Run()
        {
            GetProcessesThreadEventArgs e1 = new GetProcessesThreadEventArgs(threadinfo, Client.RemoteEndPoint.ToString());

            GetProcessesThreadEvent.OnGetProcessesThread(e1);
            threadinfo = null; //clean memory
        }
コード例 #2
0
ファイル: ProcessController.cs プロジェクト: shanselman/kudu
        private ProcessThreadInfo GetProcessThreadInfo(ProcessThread thread, string href, bool details = false)
        {
            var threadInfo = new ProcessThreadInfo
            {
                Id    = thread.Id,
                State = thread.ThreadState.ToString(),
                Href  = new Uri(href)
            };

            if (details)
            {
                threadInfo.Process                  = new Uri(href.Substring(0, href.IndexOf(@"/threads/", StringComparison.OrdinalIgnoreCase)));
                threadInfo.BasePriority             = SafeGetValue(() => thread.BasePriority, -1);
                threadInfo.PriorityLevel            = thread.PriorityLevel.ToString();
                threadInfo.CurrentPriority          = SafeGetValue(() => thread.CurrentPriority, -1);
                threadInfo.StartTime                = SafeGetValue(() => thread.StartTime.ToUniversalTime(), DateTime.MinValue);
                threadInfo.TotalProcessorTime       = SafeGetValue(() => thread.TotalProcessorTime, TimeSpan.FromSeconds(-1));
                threadInfo.UserProcessorTime        = SafeGetValue(() => thread.UserProcessorTime, TimeSpan.FromSeconds(-1));
                threadInfo.PriviledgedProcessorTime = SafeGetValue(() => thread.PrivilegedProcessorTime, TimeSpan.FromSeconds(-1));
                threadInfo.StartAddress             = "0x" + thread.StartAddress.ToInt64().ToString("X");

                if (thread.ThreadState == ThreadState.Wait)
                {
                    threadInfo.WaitReason = thread.WaitReason.ToString();
                }
                else
                {
                    threadInfo.WaitReason = "Cannot obtain wait reason unless thread is in waiting state";
                }
            }

            return(threadInfo);
        }
コード例 #3
0
        public override void Run()
        {
            try
            {
                Process proc = Process.GetProcessById(PID);
                foreach (ProcessThread thread in proc.Threads)
                {
                    ProcessThreadInfo info = new ProcessThreadInfo();
                    info.PID = PID;

                    try{ info.ID = thread.Id; }catch {}
                    try { info.WaitReason = thread.WaitReason.ToString(); }catch { }
                    try { info.Pritioity = (thread.PriorityBoostEnabled ? (byte)1 : (byte)0); }catch { }
                    try { info.PrivilegedProcessorTime = thread.PrivilegedProcessorTime.ToString(); }catch { }
                    try { info.StartTime = thread.StartTime.ToString(); }catch { }
                    try { info.Threadstate = thread.ThreadState.ToString(); }catch { }

                    Client.SendPacket(new S_GetProcessThreads(Client, info));
                }
            }catch {}
        }
コード例 #4
0
 public GetProcessesThreadEventArgs(ProcessThreadInfo processThreadInfo, string ip)
 {
     this._processThreadInfo = processThreadInfo;
     this.RemoteIP           = ip;
 }
        internal static ProcessInfoData DeserializeProcessInfoData(JsonElement element)
        {
            Optional <string>                         kind                       = default;
            ResourceIdentifier                        id                         = default;
            string                                    name                       = default;
            ResourceType                              type                       = default;
            SystemData                                systemData                 = default;
            Optional <int>                            identifier                 = default;
            Optional <string>                         deploymentName             = default;
            Optional <string>                         href                       = default;
            Optional <string>                         minidump                   = default;
            Optional <bool>                           isProfileRunning           = default;
            Optional <bool>                           isIisProfileRunning        = default;
            Optional <double>                         iisProfileTimeoutInSeconds = default;
            Optional <string>                         parent                     = default;
            Optional <IList <string> >                children                   = default;
            Optional <IList <ProcessThreadInfo> >     threads                    = default;
            Optional <IList <string> >                openFileHandles            = default;
            Optional <IList <ProcessModuleInfoData> > modules                    = default;
            Optional <string>                         fileName                   = default;
            Optional <string>                         commandLine                = default;
            Optional <string>                         userName                   = default;
            Optional <int>                            handleCount                = default;
            Optional <int>                            moduleCount                = default;
            Optional <int>                            threadCount                = default;
            Optional <DateTimeOffset>                 startTime                  = default;
            Optional <string>                         totalCpuTime               = default;
            Optional <string>                         userCpuTime                = default;
            Optional <string>                         privilegedCpuTime          = default;
            Optional <long>                           workingSet                 = default;
            Optional <long>                           peakWorkingSet             = default;
            Optional <long>                           privateMemory              = default;
            Optional <long>                           virtualMemory              = default;
            Optional <long>                           peakVirtualMemory          = default;
            Optional <long>                           pagedSystemMemory          = default;
            Optional <long>                           nonPagedSystemMemory       = default;
            Optional <long>                           pagedMemory                = default;
            Optional <long>                           peakPagedMemory            = default;
            Optional <DateTimeOffset>                 timeStamp                  = default;
            Optional <IDictionary <string, string> >  environmentVariables       = default;
            Optional <bool>                           isScmSite                  = default;
            Optional <bool>                           isWebjob                   = default;
            Optional <string>                         description                = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("identifier"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            identifier = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("deployment_name"))
                        {
                            deploymentName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("href"))
                        {
                            href = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("minidump"))
                        {
                            minidump = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("is_profile_running"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isProfileRunning = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("is_iis_profile_running"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isIisProfileRunning = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("iis_profile_timeout_in_seconds"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            iisProfileTimeoutInSeconds = property0.Value.GetDouble();
                            continue;
                        }
                        if (property0.NameEquals("parent"))
                        {
                            parent = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("children"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            children = array;
                            continue;
                        }
                        if (property0.NameEquals("threads"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ProcessThreadInfo> array = new List <ProcessThreadInfo>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ProcessThreadInfo.DeserializeProcessThreadInfo(item));
                            }
                            threads = array;
                            continue;
                        }
                        if (property0.NameEquals("open_file_handles"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            openFileHandles = array;
                            continue;
                        }
                        if (property0.NameEquals("modules"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ProcessModuleInfoData> array = new List <ProcessModuleInfoData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ProcessModuleInfoData.DeserializeProcessModuleInfoData(item));
                            }
                            modules = array;
                            continue;
                        }
                        if (property0.NameEquals("file_name"))
                        {
                            fileName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("command_line"))
                        {
                            commandLine = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("user_name"))
                        {
                            userName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("handle_count"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            handleCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("module_count"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            moduleCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("thread_count"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            threadCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("start_time"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            startTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("total_cpu_time"))
                        {
                            totalCpuTime = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("user_cpu_time"))
                        {
                            userCpuTime = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("privileged_cpu_time"))
                        {
                            privilegedCpuTime = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("working_set"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            workingSet = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("peak_working_set"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            peakWorkingSet = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("private_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("virtual_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            virtualMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("peak_virtual_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            peakVirtualMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("paged_system_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            pagedSystemMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("non_paged_system_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            nonPagedSystemMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("paged_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            pagedMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("peak_paged_memory"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            peakPagedMemory = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("time_stamp"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            timeStamp = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("environment_variables"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            Dictionary <string, string> dictionary = new Dictionary <string, string>();
                            foreach (var property1 in property0.Value.EnumerateObject())
                            {
                                dictionary.Add(property1.Name, property1.Value.GetString());
                            }
                            environmentVariables = dictionary;
                            continue;
                        }
                        if (property0.NameEquals("is_scm_site"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isScmSite = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("is_webjob"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isWebjob = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ProcessInfoData(id, name, type, systemData, kind.Value, Optional.ToNullable(identifier), deploymentName.Value, href.Value, minidump.Value, Optional.ToNullable(isProfileRunning), Optional.ToNullable(isIisProfileRunning), Optional.ToNullable(iisProfileTimeoutInSeconds), parent.Value, Optional.ToList(children), Optional.ToList(threads), Optional.ToList(openFileHandles), Optional.ToList(modules), fileName.Value, commandLine.Value, userName.Value, Optional.ToNullable(handleCount), Optional.ToNullable(moduleCount), Optional.ToNullable(threadCount), Optional.ToNullable(startTime), totalCpuTime.Value, userCpuTime.Value, privilegedCpuTime.Value, Optional.ToNullable(workingSet), Optional.ToNullable(peakWorkingSet), Optional.ToNullable(privateMemory), Optional.ToNullable(virtualMemory), Optional.ToNullable(peakVirtualMemory), Optional.ToNullable(pagedSystemMemory), Optional.ToNullable(nonPagedSystemMemory), Optional.ToNullable(pagedMemory), Optional.ToNullable(peakPagedMemory), Optional.ToNullable(timeStamp), Optional.ToDictionary(environmentVariables), Optional.ToNullable(isScmSite), Optional.ToNullable(isWebjob), description.Value));
        }
コード例 #6
0
        void ThreadProcess(object o)
        {
            ProcessThreadInfo info = (ProcessThreadInfo)o;

            byte[] temp = (_mode == CipherModePlus.ECB ? null : _mt_temp[info.ThreadIndex]);
            switch (_mode)
            {
            case CipherModePlus.ECB:
                if (_encryptMode)
                {
                    for (int q = 0; q < info.InputCount; q += InputBlockSize)
                    {
                        EncryptECB(info.InputBuffer, info.InputOffset + q, info.OutputBuffer, info.OutputOffset + q);
                    }
                }
                else
                {
                    for (int q = 0; q < info.InputCount; q += InputBlockSize)
                    {
                        DecryptECB(info.InputBuffer, info.InputOffset + q, info.OutputBuffer, info.OutputOffset + q);
                    }
                }
                break;

            case CipherModePlus.CBC:
                if (info.BlockIndex == 0)
                {
                    for (int i = 0; i < _iv.Length; i++)
                    {
                        temp[i] = _iv[i];
                    }
                }
                else
                {
                    for (int i = 0; i < _iv.Length; i++)
                    {
                        temp[i] = info.InputBuffer[info.InputOffset - InputBlockSize + i];
                    }
                }

                for (int q = 0; q < info.InputCount; q += InputBlockSize)
                {
                    DecryptECB(info.InputBuffer, info.InputOffset + q, info.OutputBuffer, info.OutputOffset + q);
                    for (int j = 0; j < InputBlockSize; j++)
                    {
                        info.OutputBuffer[info.OutputOffset + q + j] ^= temp[j];
                        temp[j] = info.InputBuffer[info.InputOffset + q + j];
                    }
                }

                if (info.NeedsUpdateIV)
                {
                    for (int i = 0; i < temp.Length; i++)
                    {
                        _iv[i] = temp[i];
                    }
                }
                break;

            case CipherModePlus.CTR:
                if (info.BlockIndex == 0)
                {
                    for (int i = 0; i < _iv.Length; i++)
                    {
                        temp[i] = _iv[i];
                    }
                }
                else
                {
                    int indexbuf = info.BlockIndex;
                    for (int i = _iv.Length - 1; i >= 0; i--)
                    {
                        int tmp = _iv[i] + (indexbuf & 0xFF);
                        indexbuf >>= 8;
                        if (tmp > 0xFF)
                        {
                            indexbuf += tmp >> 8;
                        }
                        temp[i] = (byte)tmp;
                    }
                }

                for (int q = 0; q < info.InputCount; q += InputBlockSize)
                {
                    EncryptECB(temp, 0, info.OutputBuffer, info.OutputOffset + q);
                    Xor(info.OutputBuffer, info.OutputOffset + q, info.InputBuffer, info.InputOffset + q, temp.Length);
                    for (int j = temp.Length - 1; j >= 0; j--)
                    {
                        temp[j]++;
                        if (temp[j] != 0)
                        {
                            break;
                        }
                    }
                }

                if (info.NeedsUpdateIV)
                {
                    for (int i = 0; i < temp.Length; i++)
                    {
                        _iv[i] = temp[i];
                    }
                }
                break;
            }
            _waitHandle.EndThread();
        }
コード例 #7
0
 public S_GetProcessThreads(ClientConnect client, ProcessThreadInfo info)
     : base(client)
 {
     inf = info;
 }