C# Only part of a ReadProcessMemory or WriteProcessMemory request was completed during Process.Kill()

前端 未结 3 690
谎友^
谎友^ 2020-12-05 18:45

I have been researching this issue pretty extensively and cannot seem to find an answer.

I know that the Only part of a ReadProcessMemory or WriteProcessMemory

3条回答
  •  感动是毒
    2020-12-05 19:12

    There are only some issues regarding the handling of the processes and the locking that I would change:

    object lockObject = new object();
    List processesToRemove = new List();
    foreach (Process p in _runningProcesses)
    {
        foreach (ProcessModule module in p.Modules)
        {
            string[] strs = text.Split('\\');
    
            if (module.ModuleName.Equals(strs[strs.Length - 1]))
            {
                processesToRemove.Add(p);
                break;
            }
        }                    
    }                
    lock (lockObject)
    {
        foreach (Process p in processesToRemove)
        {                 
            p.Kill();
            _runningProcesses.Remove(p);
        }                
    }
    

    I'm not answering for the bounty, just wanted to give some ideas. This code isn't tested because I don't exactly know what you are trying to do there.

    Just consider not to lock the process-list and to keep the lock as short as possible.

提交回复
热议问题