Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

86 строки
2.5 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using EasyHook;
  5. namespace RenderHookAPI.Hook
  6. {
  7. public class HookManager
  8. {
  9. static internal List<Int32> HookedProcesses = new List<Int32>();
  10. /*
  11. * Please note that we have obtained this information with system privileges.
  12. * So if you get client requests with a process ID don't try to open the process
  13. * as this will fail in some cases. Just search the ID in the following list and
  14. * extract information that is already there...
  15. *
  16. * Of course you can change the way this list is implemented and the information
  17. * it contains but you should keep the code semantic.
  18. */
  19. internal static List<ProcessInfo> ProcessList = new List<ProcessInfo>();
  20. private static List<Int32> ActivePIDList = new List<Int32>();
  21. public static void AddHookedProcess(Int32 processId)
  22. {
  23. lock (HookedProcesses)
  24. {
  25. HookedProcesses.Add(processId);
  26. }
  27. }
  28. public static void RemoveHookedProcess(Int32 processId)
  29. {
  30. lock (HookedProcesses)
  31. {
  32. HookedProcesses.Remove(processId);
  33. }
  34. }
  35. public static bool IsHooked(Int32 processId)
  36. {
  37. lock (HookedProcesses)
  38. {
  39. return HookedProcesses.Contains(processId);
  40. }
  41. }
  42. [Serializable]
  43. public class ProcessInfo
  44. {
  45. public String FileName;
  46. public Int32 Id;
  47. public Boolean Is64Bit;
  48. public String User;
  49. }
  50. public static ProcessInfo[] EnumProcesses()
  51. {
  52. List<ProcessInfo> result = new List<ProcessInfo>();
  53. Process[] procList = Process.GetProcesses();
  54. for (int i = 0; i < procList.Length; i++)
  55. {
  56. Process proc = procList[i];
  57. try
  58. {
  59. ProcessInfo info = new ProcessInfo();
  60. info.FileName = proc.MainModule.FileName;
  61. info.Id = proc.Id;
  62. info.Is64Bit = RemoteHooking.IsX64Process(proc.Id);
  63. info.User = RemoteHooking.GetProcessIdentity(proc.Id).Name;
  64. result.Add(info);
  65. }
  66. catch
  67. {
  68. }
  69. }
  70. return result.ToArray();
  71. }
  72. }
  73. }