ProcessMemoryReaderLib.dll - C#

Узнай цену своей работы

Формулировка задачи:

Добрый день! Помогите, пожалуйста, найти данную библиотеку. Я нашел что-то вроде похожее:
Листинг программы
  1. using System;
  2. using System.Diagnostics;
  3. using System.Runtime.InteropServices;
  4. namespace ProcessMemoryReaderLib
  5. {
  6. /// <summary>
  7. /// ProcessMemoryReader is a class that enables direct reading a process memory
  8. /// </summary>
  9. class ProcessMemoryReaderApi
  10. {
  11. // constants information can be found in <winnt.h>
  12. [Flags]
  13. public enum ProcessAccessType
  14. {
  15. PROCESS_TERMINATE = (0x0001),
  16. PROCESS_CREATE_THREAD = (0x0002),
  17. PROCESS_SET_SESSIONID = (0x0004),
  18. PROCESS_VM_OPERATION = (0x0008),
  19. PROCESS_VM_READ = (0x0010),
  20. PROCESS_VM_WRITE = (0x0020),
  21. PROCESS_DUP_HANDLE = (0x0040),
  22. PROCESS_CREATE_PROCESS = (0x0080),
  23. PROCESS_SET_QUOTA = (0x0100),
  24. PROCESS_SET_INFORMATION = (0x0200),
  25. PROCESS_QUERY_INFORMATION = (0x0400)
  26. }
  27. // function declarations are found in the MSDN and in <winbase.h>
  28. // HANDLE OpenProcess(
  29. // DWORD dwDesiredAccess, // access flag
  30. // BOOL bInheritHandle, // handle inheritance option
  31. // DWORD dwProcessId // process identifier
  32. // );
  33. [DllImport("kernel32.dll")]
  34. public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
  35. // BOOL CloseHandle(
  36. // HANDLE hObject // handle to object
  37. // );
  38. [DllImport("kernel32.dll")]
  39. public static extern Int32 CloseHandle(IntPtr hObject);
  40. // BOOL ReadProcessMemory(
  41. // HANDLE hProcess, // handle to the process
  42. // LPCVOID lpBaseAddress, // base of memory area
  43. // LPVOID lpBuffer, // data buffer
  44. // SIZE_T nSize, // number of bytes to read
  45. // SIZE_T * lpNumberOfBytesRead // number of bytes read
  46. // );
  47. [DllImport("kernel32.dll")]
  48. public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
  49. // BOOL WriteProcessMemory(
  50. // HANDLE hProcess, // handle to process
  51. // LPVOID lpBaseAddress, // base of memory area
  52. // LPCVOID lpBuffer, // data buffer
  53. // SIZE_T nSize, // count of bytes to write
  54. // SIZE_T * lpNumberOfBytesWritten // count of bytes written
  55. // );
  56. [DllImport("kernel32.dll")]
  57. public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
  58. }
  59. public class ProcessMemoryReader
  60. {
  61. public ProcessMemoryReader()
  62. {
  63. }
  64. /// <summary>
  65. /// Process from which to read
  66. /// </summary>
  67. public Process ReadProcess
  68. {
  69. get
  70. {
  71. return m_ReadProcess;
  72. }
  73. set
  74. {
  75. m_ReadProcess = value;
  76. }
  77. }
  78. private Process m_ReadProcess = null;
  79. private IntPtr m_hProcess = IntPtr.Zero;
  80. public void OpenProcess()
  81. {
  82. // m_hProcess = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ, 1, (uint)m_ReadProcess.Id);
  83. ProcessMemoryReaderApi.ProcessAccessType access;
  84. access = ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_READ
  85. | ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_WRITE
  86. | ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_OPERATION;
  87. m_hProcess = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
  88. }
  89. public void CloseHandle()
  90. {
  91. int iRetValue;
  92. iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess);
  93. if (iRetValue == 0)
  94. throw new Exception("CloseHandle failed");
  95. }
  96. public byte[] ReadProcessMemory(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
  97. {
  98. byte[] buffer = new byte[bytesToRead];
  99. IntPtr ptrBytesRead;
  100. ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
  101. bytesRead = ptrBytesRead.ToInt32();
  102. return buffer;
  103. }
  104. public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)
  105. {
  106. IntPtr ptrBytesWritten;
  107. ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);
  108. bytesWritten = ptrBytesWritten.ToInt32();
  109. }
  110.  
  111. }
  112. }
Но здесь нет функций ReadInt, ReadFloat, ReadMultiLevelPointer Может у кого есть?

Решение задачи: «ProcessMemoryReaderLib.dll»

textual
Листинг программы
  1. public T ReadMulti<T>(IntPtr address, int[] offsets) where T : struct {

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

13   голосов , оценка 4.154 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут