PyMemoryEditor 1.0.1__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Jean Loui Bernard Silva de Jesus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyMemoryEditor
3
+ Version: 1.0.3
4
+ Summary: Process memory reader and writer.
5
+ Home-page: https://github.com/JeanExtreme002/PyMemoryEditor
6
+ Author: Jean Loui Bernard Silva de Jesus
7
+ License: MIT
8
+ Keywords: memory writer reader
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Environment :: Win32 (MS Windows)
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # PyMemoryEditor
21
+
22
+ A Python library developed with [ctypes](https://docs.python.org/3/library/ctypes.html) to manipulate Windows processes (32 bits and 64 bits), <br>
23
+ reading and writing values in the process memory.
24
+
25
+ [![Python Package](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml/badge.svg)](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml)
26
+ [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
27
+ [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
28
+ [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://pypi.org/project/PyMemoryEditor/)
29
+ [![Downloads](https://static.pepy.tech/personalized-badge/pymemoryeditor?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/PyMemoryEditor/)
30
+
31
+ # Installing PyMemoryEditor:
32
+ ```
33
+ pip3 install PyMemoryEditor
34
+ ```
35
+
36
+ # Basic Usage:
37
+
38
+ Import `PyMemoryEditor` and open a process using the `OpenProcess` class, passing a window title, process name <br>
39
+ or PID as an argument. You can use the context manager to do this.
40
+
41
+ ```
42
+ from PyMemoryEditor import OpenProcess
43
+
44
+ with OpenProcess(process_name = "example.exe") as process:
45
+ # Do something...
46
+ ```
47
+
48
+ After that, use the methods `read_process_memory` and `write_process_memory` to manipulate the process <br>
49
+ memory, passing in the function call the memory address, data type and its size. See the example below:
50
+
51
+ ```
52
+ from PyMemoryEditor import OpenProcess
53
+
54
+ title = "Window title of an example program"
55
+ address = 0x0005000C
56
+
57
+ with OpenProcess(window_title = title) as process:
58
+
59
+ # Getting value from the process memory.
60
+ value = process.read_process_memory(address, int, 4)
61
+
62
+ # Writing to the process memory.
63
+ process.write_process_memory(address, int, 4, value + 7)
64
+ ```
@@ -6,22 +6,46 @@ reading and writing values in the process memory.
6
6
  """
7
7
 
8
8
  __author__ = "Jean Loui Bernard Silva de Jesus"
9
- __version__ = "1.0.1"
9
+ __version__ = "1.0.3"
10
10
 
11
11
  from .process import Process
12
12
  from .win32.constants import PROCESS_ALL_ACCESS, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE
13
13
  from .win32.functions import CloseHandle, GetProcessHandle, ReadProcessMemory, WriteProcessMemory
14
14
 
15
- __all__ = ("OpenProcess", "PROCESS_ALL_ACCESS", "PROCESS_VM_OPERATION", "PROCESS_VM_READ", "PROCESS_VM_WRITE")
15
+ from typing import Optional, Type, Union
16
16
 
17
- class OpenProcess(object):
18
-
19
- def __enter__(self): return self
20
-
21
- def __exit__(self, exc_type, exc_value, exc_traceback): self.close()
17
+ __all__ = (
18
+ "OpenProcess",
19
+ "PROCESS_ALL_ACCESS",
20
+ "PROCESS_VM_OPERATION",
21
+ "PROCESS_VM_READ",
22
+ "PROCESS_VM_WRITE"
23
+ )
22
24
 
23
- def __init__(self, window_title = None, process_name = None, pid = None, permission = PROCESS_ALL_ACCESS):
24
25
 
26
+ class OpenProcess(object):
27
+ """
28
+ Class to open a process for reading or writing memory.
29
+ """
30
+ def __enter__(self):
31
+ return self
32
+
33
+ def __exit__(self, exc_type, exc_value, exc_traceback):
34
+ self.close()
35
+
36
+ def __init__(
37
+ self,
38
+ window_title: Optional[str] = None,
39
+ process_name: Optional[str] = None,
40
+ pid: Optional[int] = None,
41
+ permission: int = PROCESS_ALL_ACCESS
42
+ ):
43
+ """
44
+ :param window_title: window title of the target program.
45
+ :param process_name: name of the target process.
46
+ :param pid: process ID.
47
+ :param permission: access mode to the process.
48
+ """
25
49
  # Instantiate the permission argument.
26
50
  self.__permission = permission
27
51
 
@@ -45,40 +69,45 @@ class OpenProcess(object):
45
69
  self.__process_handle = GetProcessHandle(permission, False, self.__process.pid)
46
70
 
47
71
  def close(self):
48
-
49
72
  """
50
73
  Close the process handle.
51
74
  """
52
-
53
75
  return CloseHandle(self.__process_handle)
54
76
 
55
- def read_process_memory(self, address, pytype, bufflength):
56
-
77
+ def read_process_memory(
78
+ self,
79
+ address: int,
80
+ pytype: Type,
81
+ bufflength: int
82
+ ) -> Union[str, int, float]:
57
83
  """
58
84
  Return a value from a memory address.
59
85
 
60
- @param address: Target memory address (ex: 0x006A9EC0).
61
- @param type_: Type of the value to be received (str, int or float).
62
- @param bufflength: Value size in bytes (1, 2, 4, 8).
86
+ :param address: target memory address (ex: 0x006A9EC0).
87
+ :param pytype: type of the value to be received (str, int or float).
88
+ :param bufflength: value size in bytes (1, 2, 4, 8).
63
89
  """
64
-
65
- if not self.__permission in [PROCESS_ALL_ACCESS, PROCESS_VM_READ]:
90
+ if self.__permission not in [PROCESS_ALL_ACCESS, PROCESS_VM_READ]:
66
91
  raise PermissionError("The handle does not have permission to read the process memory.")
67
92
 
68
93
  return win32.functions.ReadProcessMemory(self.__process_handle, address, pytype, bufflength)
69
94
 
70
- def write_process_memory(self, address, pytype, bufflength, value):
71
-
95
+ def write_process_memory(
96
+ self,
97
+ address: int,
98
+ pytype: Type,
99
+ bufflength: int,
100
+ value: Union[str, int, float]
101
+ ) -> Union[str, int, float]:
72
102
  """
73
103
  Write a value to a memory address.
74
104
 
75
- @param address: Target memory address (ex: 0x006A9EC0).
76
- @param pytype: Type of value to be written into memory (str, int or float).
77
- @param bufflength: Value size in bytes (1, 2, 4, 8).
78
- @param value: Value to be written (str, int or float).
105
+ :param address: target memory address (ex: 0x006A9EC0).
106
+ :param pytype: type of value to be written into memory (str, int or float).
107
+ :param bufflength: value size in bytes (1, 2, 4, 8).
108
+ :param value: value to be written (str, int or float).
79
109
  """
80
-
81
- if not self.__permission in [PROCESS_ALL_ACCESS, PROCESS_VM_OPERATION | PROCESS_VM_WRITE]:
110
+ if self.__permission not in [PROCESS_ALL_ACCESS, PROCESS_VM_OPERATION | PROCESS_VM_WRITE]:
82
111
  raise PermissionError("The handle does not have permission to write to the process memory.")
83
112
 
84
113
  return WriteProcessMemory(self.__process_handle, address, pytype, bufflength, value)
@@ -3,18 +3,22 @@
3
3
  from .errors import ProcessIDNotExistsError, ProcessNotFoundError, WindowNotFoundError
4
4
  from .util import get_process_id_by_process_name, get_process_id_by_window_title, pid_exists
5
5
 
6
+
6
7
  class Process(object):
8
+ """
9
+ Class representing a process.
10
+ """
7
11
 
8
12
  __pid = 0
9
13
  __process_name = ""
10
14
  __window_title = ""
11
15
 
12
16
  @property
13
- def pid(self):
17
+ def pid(self) -> int:
14
18
  return self.__pid
15
19
 
16
20
  @pid.setter
17
- def pid(self, pid):
21
+ def pid(self, pid: int) -> None:
18
22
 
19
23
  # Check if the value is an integer.
20
24
  if not isinstance(pid, int):
@@ -25,11 +29,11 @@ class Process(object):
25
29
  else: raise ProcessIDNotExistsError(pid)
26
30
 
27
31
  @property
28
- def process_name(self):
32
+ def process_name(self) -> str:
29
33
  return self.__process_name
30
34
 
31
35
  @process_name.setter
32
- def process_name(self, process_name):
36
+ def process_name(self, process_name: str) -> None:
33
37
 
34
38
  # Get the process ID.
35
39
  pid = get_process_id_by_process_name(process_name)
@@ -40,11 +44,11 @@ class Process(object):
40
44
  self.__process_name = process_name
41
45
 
42
46
  @property
43
- def window_title(self):
47
+ def window_title(self) -> str:
44
48
  return self.__window_title
45
49
 
46
50
  @window_title.setter
47
- def window_title(self, window_title):
51
+ def window_title(self, window_title: str) -> None:
48
52
 
49
53
  # Get the process ID.
50
54
  pid = get_process_id_by_window_title(window_title)
@@ -2,24 +2,26 @@
2
2
 
3
3
  class ProcessIDNotExistsError(Exception):
4
4
 
5
- def __init__(self, pid):
5
+ def __init__(self, pid: int):
6
6
  self.__pid = pid
7
7
 
8
- def __str__(self):
8
+ def __str__(self) -> str:
9
9
  return "The process ID \"%i\" does not exist." % self.__pid
10
10
 
11
+
11
12
  class ProcessNotFoundError(Exception):
12
13
 
13
- def __init__(self, process_name):
14
+ def __init__(self, process_name: str):
14
15
  self.__process_name = process_name
15
16
 
16
- def __str__(self):
17
+ def __str__(self) -> str:
17
18
  return "Could not find the process \"%s\"." % self.__process_name
18
19
 
20
+
19
21
  class WindowNotFoundError(Exception):
20
22
 
21
- def __init__(self, window_title):
23
+ def __init__(self, window_title: str):
22
24
  self.__window_title = window_title
23
25
 
24
- def __str__(self):
26
+ def __str__(self) -> str:
25
27
  return "Could not find the window \"%s\"." % self.__window_title
@@ -4,28 +4,24 @@ from win32gui import FindWindow
4
4
  from win32process import GetWindowThreadProcessId
5
5
  import psutil
6
6
 
7
- def get_process_id_by_process_name(process_name) -> int:
8
7
 
8
+ def get_process_id_by_process_name(process_name: str) -> int:
9
9
  """
10
10
  Get a process name and return its process ID.
11
11
  """
12
-
13
12
  for process in psutil.process_iter():
14
- if process.name() == process_name: return process.pid
15
-
16
- def get_process_id_by_window_title(window_title) -> int:
13
+ if process.name() == process_name:
14
+ return process.pid
17
15
 
16
+ def get_process_id_by_window_title(window_title: str) -> int:
18
17
  """
19
18
  Get a window title and return its process ID.
20
19
  """
21
-
22
20
  hwnd = FindWindow(None, window_title)
23
21
  return GetWindowThreadProcessId(hwnd)[1] if hwnd else 0
24
22
 
25
- def pid_exists(pid) -> bool:
26
-
23
+ def pid_exists(pid: int) -> bool:
27
24
  """
28
25
  Check if the process ID exists.
29
26
  """
30
-
31
27
  return psutil.pid_exists(pid)
@@ -5,28 +5,25 @@ from ctypes import byref, windll, c_void_p
5
5
 
6
6
  kernel32 = windll.LoadLibrary("kernel32.dll")
7
7
 
8
- def CloseHandle(handle) -> int:
9
8
 
9
+ def CloseHandle(handle) -> int:
10
10
  """
11
11
  Close the process handle.
12
12
  """
13
-
14
13
  return kernel32.CloseHandle(handle)
15
14
 
16
- def GetProcessHandle(access_right, inherit, pid) -> int:
17
15
 
16
+ def GetProcessHandle(access_right, inherit, pid) -> int:
18
17
  """
19
18
  Get a process ID and return its process handle.
20
19
  """
21
-
22
20
  return kernel32.OpenProcess(access_right, inherit, pid)
23
21
 
24
- def ReadProcessMemory(process_handle, address, pytype, bufflength):
25
22
 
23
+ def ReadProcessMemory(process_handle, address, pytype, bufflength):
26
24
  """
27
25
  Return a value from a memory address.
28
26
  """
29
-
30
27
  if not pytype in [str, int, float]: raise ValueError("The type must be string, int or float.")
31
28
 
32
29
  data = get_c_type_of(pytype, int(bufflength))
@@ -34,12 +31,11 @@ def ReadProcessMemory(process_handle, address, pytype, bufflength):
34
31
 
35
32
  return data.value
36
33
 
37
- def WriteProcessMemory(process_handle, address, pytype, bufflength, value):
38
34
 
35
+ def WriteProcessMemory(process_handle, address, pytype, bufflength, value):
39
36
  """
40
37
  Write a value to a memory address.
41
38
  """
42
-
43
39
  if not pytype in [str, int, float]: raise ValueError("The type must be string, int or float.")
44
40
 
45
41
  data = get_c_type_of(pytype, int(bufflength))
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from typing import Type
4
+ import ctypes
5
+
6
+
7
+ def get_c_type_of(pytype: Type, length: int = 1) -> ctypes._SimpleCData:
8
+ """
9
+ Return a C type of a primitive type of the Python language.
10
+ """
11
+ if pytype is str: return ctypes.create_string_buffer(length)
12
+
13
+ elif pytype is int:
14
+
15
+ if length == 1: return ctypes.c_int8() # 1 Byte
16
+ if length == 2: return ctypes.c_int16() # 2 Bytes
17
+ if length <= 4: return ctypes.c_int32() # 4 Bytes
18
+ return ctypes.c_int64() # 8 Bytes
19
+
20
+ # Float values lose their precision when converted to c_float. For that reason,
21
+ # any float value will be converted to double.
22
+ elif pytype is float: return ctypes.c_double() # 8 Bytes
23
+
24
+ elif pytype is bool: return ctypes.c_bool()
25
+
26
+ else: raise ValueError("The type must be string, int, float or bool.")
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyMemoryEditor
3
+ Version: 1.0.3
4
+ Summary: Process memory reader and writer.
5
+ Home-page: https://github.com/JeanExtreme002/PyMemoryEditor
6
+ Author: Jean Loui Bernard Silva de Jesus
7
+ License: MIT
8
+ Keywords: memory writer reader
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Environment :: Win32 (MS Windows)
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # PyMemoryEditor
21
+
22
+ A Python library developed with [ctypes](https://docs.python.org/3/library/ctypes.html) to manipulate Windows processes (32 bits and 64 bits), <br>
23
+ reading and writing values in the process memory.
24
+
25
+ [![Python Package](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml/badge.svg)](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml)
26
+ [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
27
+ [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
28
+ [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://pypi.org/project/PyMemoryEditor/)
29
+ [![Downloads](https://static.pepy.tech/personalized-badge/pymemoryeditor?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/PyMemoryEditor/)
30
+
31
+ # Installing PyMemoryEditor:
32
+ ```
33
+ pip3 install PyMemoryEditor
34
+ ```
35
+
36
+ # Basic Usage:
37
+
38
+ Import `PyMemoryEditor` and open a process using the `OpenProcess` class, passing a window title, process name <br>
39
+ or PID as an argument. You can use the context manager to do this.
40
+
41
+ ```
42
+ from PyMemoryEditor import OpenProcess
43
+
44
+ with OpenProcess(process_name = "example.exe") as process:
45
+ # Do something...
46
+ ```
47
+
48
+ After that, use the methods `read_process_memory` and `write_process_memory` to manipulate the process <br>
49
+ memory, passing in the function call the memory address, data type and its size. See the example below:
50
+
51
+ ```
52
+ from PyMemoryEditor import OpenProcess
53
+
54
+ title = "Window title of an example program"
55
+ address = 0x0005000C
56
+
57
+ with OpenProcess(window_title = title) as process:
58
+
59
+ # Getting value from the process memory.
60
+ value = process.read_process_memory(address, int, 4)
61
+
62
+ # Writing to the process memory.
63
+ process.write_process_memory(address, int, 4, value + 7)
64
+ ```
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  setup.py
3
4
  PyMemoryEditor/__init__.py
@@ -6,7 +6,8 @@ reading and writing values in the process memory.
6
6
  [![Python Package](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml/badge.svg)](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml)
7
7
  [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
8
8
  [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
9
- [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue)](https://pypi.org/project/PyMemoryEditor/)
9
+ [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://pypi.org/project/PyMemoryEditor/)
10
+ [![Downloads](https://static.pepy.tech/personalized-badge/pymemoryeditor?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/PyMemoryEditor/)
10
11
 
11
12
  # Installing PyMemoryEditor:
12
13
  ```
@@ -25,7 +26,7 @@ with OpenProcess(process_name = "example.exe") as process:
25
26
  # Do something...
26
27
  ```
27
28
 
28
- After that, use the functions `read_process_memory` and `write_process_memory` to manipulate the process <br>
29
+ After that, use the methods `read_process_memory` and `write_process_memory` to manipulate the process <br>
29
30
  memory, passing in the function call the memory address, data type and its size. See the example below:
30
31
 
31
32
  ```
@@ -1,63 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyMemoryEditor
3
- Version: 1.0.1
4
- Summary: Process memory reader and writer.
5
- Home-page: https://github.com/JeanExtreme002/PyMemoryEditor
6
- Author: Jean Loui Bernard Silva de Jesus
7
- License: MIT
8
- Description: # PyMemoryEditor
9
-
10
- A Python library developed with [ctypes](https://docs.python.org/3/library/ctypes.html) to manipulate Windows processes (32 bits and 64 bits), <br>
11
- reading and writing values in the process memory.
12
-
13
- [![Python Package](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml/badge.svg)](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml)
14
- [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
15
- [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
16
- [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue)](https://pypi.org/project/PyMemoryEditor/)
17
-
18
- # Installing PyMemoryEditor:
19
- ```
20
- pip3 install PyMemoryEditor
21
- ```
22
-
23
- # Basic Usage:
24
-
25
- Import `PyMemoryEditor` and open a process using the `OpenProcess` class, passing a window title, process name <br>
26
- or PID as an argument. You can use the context manager to do this.
27
-
28
- ```
29
- from PyMemoryEditor import OpenProcess
30
-
31
- with OpenProcess(process_name = "example.exe") as process:
32
- # Do something...
33
- ```
34
-
35
- After that, use the functions `read_process_memory` and `write_process_memory` to manipulate the process <br>
36
- memory, passing in the function call the memory address, data type and its size. See the example below:
37
-
38
- ```
39
- from PyMemoryEditor import OpenProcess
40
-
41
- title = "Window title of an example program"
42
- address = 0x0005000C
43
-
44
- with OpenProcess(window_title = title) as process:
45
-
46
- # Getting value from the process memory.
47
- value = process.read_process_memory(address, int, 4)
48
-
49
- # Writing to the process memory.
50
- process.write_process_memory(address, int, 4, value + 7)
51
- ```
52
-
53
- Keywords: memory writer reader
54
- Platform: UNKNOWN
55
- Classifier: License :: OSI Approved :: MIT License
56
- Classifier: Intended Audience :: Developers
57
- Classifier: Environment :: Win32 (MS Windows)
58
- Classifier: Operating System :: Microsoft :: Windows
59
- Classifier: Programming Language :: Python :: 3 :: Only
60
- Classifier: Programming Language :: Python :: 3.6
61
- Classifier: Programming Language :: Python :: 3.7
62
- Classifier: Programming Language :: Python :: 3.8
63
- Description-Content-Type: text/markdown
@@ -1,26 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import ctypes
4
-
5
- def get_c_type_of(pytype, length = 1) -> ctypes._SimpleCData:
6
-
7
- """
8
- Return a C type of a primitive type of the Python language.
9
- """
10
-
11
- if pytype is str: return ctypes.create_string_buffer(length)
12
-
13
- elif pytype is int:
14
-
15
- if length == 1: return ctypes.c_int8() # 1 Byte
16
- if length == 2: return ctypes.c_int16() # 2 Bytes
17
- if length <= 4: return ctypes.c_int32() # 4 Bytes
18
- return ctypes.c_int64() # 8 Bytes
19
-
20
- # Float values ​​lose their precision when converted to c_float. For that reason,
21
- # any float value will be converted to double.
22
- elif pytype is float: return ctypes.c_double() # 8 Bytes
23
-
24
- elif pytype is bool: return ctypes.c_bool()
25
-
26
- else: raise ValueError("The type must be string, int, float or bool.")
@@ -1,63 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyMemoryEditor
3
- Version: 1.0.1
4
- Summary: Process memory reader and writer.
5
- Home-page: https://github.com/JeanExtreme002/PyMemoryEditor
6
- Author: Jean Loui Bernard Silva de Jesus
7
- License: MIT
8
- Description: # PyMemoryEditor
9
-
10
- A Python library developed with [ctypes](https://docs.python.org/3/library/ctypes.html) to manipulate Windows processes (32 bits and 64 bits), <br>
11
- reading and writing values in the process memory.
12
-
13
- [![Python Package](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml/badge.svg)](https://github.com/JeanExtreme002/PyMemoryEditor/actions/workflows/python-package.yml)
14
- [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
15
- [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
16
- [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue)](https://pypi.org/project/PyMemoryEditor/)
17
-
18
- # Installing PyMemoryEditor:
19
- ```
20
- pip3 install PyMemoryEditor
21
- ```
22
-
23
- # Basic Usage:
24
-
25
- Import `PyMemoryEditor` and open a process using the `OpenProcess` class, passing a window title, process name <br>
26
- or PID as an argument. You can use the context manager to do this.
27
-
28
- ```
29
- from PyMemoryEditor import OpenProcess
30
-
31
- with OpenProcess(process_name = "example.exe") as process:
32
- # Do something...
33
- ```
34
-
35
- After that, use the functions `read_process_memory` and `write_process_memory` to manipulate the process <br>
36
- memory, passing in the function call the memory address, data type and its size. See the example below:
37
-
38
- ```
39
- from PyMemoryEditor import OpenProcess
40
-
41
- title = "Window title of an example program"
42
- address = 0x0005000C
43
-
44
- with OpenProcess(window_title = title) as process:
45
-
46
- # Getting value from the process memory.
47
- value = process.read_process_memory(address, int, 4)
48
-
49
- # Writing to the process memory.
50
- process.write_process_memory(address, int, 4, value + 7)
51
- ```
52
-
53
- Keywords: memory writer reader
54
- Platform: UNKNOWN
55
- Classifier: License :: OSI Approved :: MIT License
56
- Classifier: Intended Audience :: Developers
57
- Classifier: Environment :: Win32 (MS Windows)
58
- Classifier: Operating System :: Microsoft :: Windows
59
- Classifier: Programming Language :: Python :: 3 :: Only
60
- Classifier: Programming Language :: Python :: 3.6
61
- Classifier: Programming Language :: Python :: 3.7
62
- Classifier: Programming Language :: Python :: 3.8
63
- Description-Content-Type: text/markdown
File without changes
File without changes