PyMemoryEditor 1.5.6__tar.gz → 1.5.7__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.
Files changed (51) hide show
  1. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PKG-INFO +4 -4
  2. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/__init__.py +7 -3
  3. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/linux/ptrace/__init__.py +2 -2
  4. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/linux/ptrace/enums.py +1 -1
  5. pymemoryeditor-1.5.7/PyMemoryEditor/process/__init__.py +145 -0
  6. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/process/util.py +2 -4
  7. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/README.md +1 -1
  8. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/pyproject.toml +3 -2
  9. pymemoryeditor-1.5.7/requirements.txt +2 -0
  10. pymemoryeditor-1.5.6/PyMemoryEditor/process/__init__.py +0 -87
  11. pymemoryeditor-1.5.6/requirements.txt +0 -3
  12. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/.github/workflows/python-package.yml +0 -0
  13. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/.gitignore +0 -0
  14. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/LICENSE +0 -0
  15. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/enums.py +0 -0
  16. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/errors.py +0 -0
  17. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/linux/functions.py +0 -0
  18. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/linux/process.py +0 -0
  19. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/linux/types.py +0 -0
  20. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/process/errors.py +0 -0
  21. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/process/info.py +0 -0
  22. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/util/__init__.py +0 -0
  23. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/util/scan.py +0 -0
  24. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/util/search/abstract.py +0 -0
  25. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/util/search/kmp.py +0 -0
  26. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/__init__.py +0 -0
  27. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/memory_allocation_states.py +0 -0
  28. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/memory_protections.py +0 -0
  29. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/memory_types.py +0 -0
  30. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/process_operations.py +0 -0
  31. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/enums/standard_access_rights.py +0 -0
  32. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/functions.py +0 -0
  33. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/process.py +0 -0
  34. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/PyMemoryEditor/win32/types.py +0 -0
  35. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/__init__.py +0 -0
  36. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/open_process.py +0 -0
  37. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/process/__init__.py +0 -0
  38. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/process/errors.py +0 -0
  39. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/process/util.py +0 -0
  40. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/__init__.py +0 -0
  41. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/memory_allocation_states.py +0 -0
  42. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/memory_protections.py +0 -0
  43. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/memory_types.py +0 -0
  44. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/process_operations.py +0 -0
  45. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/scan_types.py +0 -0
  46. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/enums/standard_access_rights.py +0 -0
  47. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/functions.py +0 -0
  48. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/types.py +0 -0
  49. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/build/lib/PyMemoryEditor/win32/util.py +0 -0
  50. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/tests/package.py +0 -0
  51. {pymemoryeditor-1.5.6 → pymemoryeditor-1.5.7}/tests/test_editor.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyMemoryEditor
3
- Version: 1.5.6
4
- Summary: A Python library to edit and track memory of Windows and Linux processes (32 bits and 64 bits).
3
+ Version: 1.5.7
4
+ Summary: Multi-platform library developed with ctypes for reading, writing and searching process memory, in a simple and friendly way with Python 3. It supports Windows and Linux (32-bit and 64-bit).
5
5
  Project-URL: Homepage, https://github.com/JeanExtreme002/PyMemoryEditor
6
6
  Author-email: Jean Loui Bernard Silva de Jesus <jeanextreme002@gmail.com>
7
7
  License-Expression: MIT
@@ -20,12 +20,12 @@ Classifier: Programming Language :: Python :: 3.8
20
20
  Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
23
24
  Classifier: Topic :: Scientific/Engineering
24
25
  Classifier: Topic :: Security
25
26
  Classifier: Topic :: System :: Monitoring
26
27
  Requires-Python: >=3.6
27
28
  Requires-Dist: psutil
28
- Requires-Dist: pywin32; platform_system == 'Windows'
29
29
  Provides-Extra: tests
30
30
  Requires-Dist: pytest; extra == 'tests'
31
31
  Description-Content-Type: text/markdown
@@ -39,7 +39,7 @@ reading and writing values in the process memory.
39
39
  [![Pypi](https://img.shields.io/pypi/v/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
40
40
  [![License](https://img.shields.io/pypi/l/PyMemoryEditor)](https://pypi.org/project/PyMemoryEditor/)
41
41
  [![Platforms](https://img.shields.io/badge/platforms-Windows%20%7C%20Linux-8A2BE2)](https://pypi.org/project/PyMemoryEditor/)
42
- [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%20...%20%7C%203.10%20%7C%203.11-blue)](https://pypi.org/project/PyMemoryEditor/)
42
+ [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%20...%20%7C%203.11%20%7C%203.12-blue)](https://pypi.org/project/PyMemoryEditor/)
43
43
  [![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/)
44
44
 
45
45
  # Installing PyMemoryEditor:
@@ -1,12 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  """
4
- A Python library developed with ctypes to manipulate Windows and Linux processes (32 bits and 64 bits),
5
- reading and writing values in the process memory.
4
+ Multi-platform library developed with ctypes for reading, writing and
5
+ searching process memory, in a simple and friendly way with Python 3.
6
+
7
+ The package supports Windows and Linux (32-bit and 64-bit).
6
8
  """
7
9
 
8
10
  __author__ = "Jean Loui Bernard Silva de Jesus"
9
- __version__ = "1.5.6"
11
+ __version__ = "1.5.7"
10
12
 
11
13
 
12
14
  from .enums import ScanTypesEnum
@@ -21,4 +23,6 @@ if "win" in sys.platform:
21
23
  # For Linux.
22
24
  else:
23
25
  from .linux.process import LinuxProcess
26
+ from .linux.ptrace import ptrace
27
+ from .linux.ptrace.enums import PtraceCommandsEnum
24
28
  OpenProcess = LinuxProcess
@@ -5,7 +5,7 @@
5
5
  # https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/baselib-ptrace-1.html
6
6
  # ...
7
7
 
8
- from .enums import CommandsEnum
8
+ from .enums import PtraceCommandsEnum
9
9
 
10
10
  from ctypes.util import find_library
11
11
  import ctypes
@@ -15,7 +15,7 @@ libc.ptrace.argtypes = (ctypes.c_ulong,) * 4
15
15
  libc.ptrace.restype = ctypes.c_long
16
16
 
17
17
 
18
- def ptrace(command: CommandsEnum, pid: int, *args: int) -> int:
18
+ def ptrace(command: PtraceCommandsEnum, pid: int, *args: int) -> int:
19
19
  """
20
20
  Run ptrace() system call with the provided command, pid and arguments.
21
21
  """
@@ -3,7 +3,7 @@
3
3
  from enum import Enum
4
4
 
5
5
 
6
- class CommandsEnum(Enum):
6
+ class PtraceCommandsEnum(Enum):
7
7
  """
8
8
  Enum with commands for ptrace() system call.
9
9
 
@@ -0,0 +1,145 @@
1
+ # -*- coding: utf-8 -*-
2
+ from abc import ABC, abstractmethod
3
+ from typing import Generator, Optional, Tuple, Type, TypeVar, Union
4
+
5
+ from ..enums import ScanTypesEnum
6
+ from ..process.info import ProcessInfo
7
+
8
+
9
+ T = TypeVar("T")
10
+
11
+
12
+ class AbstractProcess(ABC):
13
+ """
14
+ Abstract class to represent a process.
15
+ """
16
+
17
+ @abstractmethod
18
+ def __init__(self, *, window_title: Optional[str] = None, process_name: Optional[str] = None, pid: Optional[int] = None):
19
+ """
20
+ :param window_title: window title of the target program.
21
+ :param process_name: name of the target process.
22
+ :param pid: process ID.
23
+ """
24
+ self._process_info = ProcessInfo()
25
+
26
+ # Set the attributes to the process.
27
+ if pid:
28
+ self._process_info.pid = pid
29
+
30
+ elif window_title:
31
+ self._process_info.window_title = window_title
32
+
33
+ elif process_name:
34
+ self._process_info.process_name = process_name
35
+
36
+ else:
37
+ raise TypeError("You must pass an argument to one of these parameters (window_title, process_name, pid).")
38
+
39
+ def __enter__(self):
40
+ return self
41
+
42
+ def __exit__(self, exc_type, exc_value, exc_traceback):
43
+ self.close()
44
+
45
+ @property
46
+ def pid(self) -> int:
47
+ return self._process_info.pid
48
+
49
+ @abstractmethod
50
+ def close(self) -> bool:
51
+ """
52
+ Close the process handle.
53
+ """
54
+ raise NotImplementedError()
55
+
56
+ @abstractmethod
57
+ def get_memory_regions(self) -> Generator[dict, None, None]:
58
+ """
59
+ Generates dictionaries with the address, size and other
60
+ information of each memory region used by the process.
61
+ """
62
+ raise NotImplementedError()
63
+
64
+ @abstractmethod
65
+ def search_by_value(
66
+ self,
67
+ pytype: Type[T],
68
+ bufflength: int,
69
+ value: Union[bool, int, float, str, bytes],
70
+ scan_type: ScanTypesEnum = ScanTypesEnum.EXACT_VALUE,
71
+ *,
72
+ progress_information: bool = False,
73
+ writeable_only: bool = False,
74
+ ) -> Generator[Union[int, Tuple[int, dict]], None, None]:
75
+ """
76
+ Search the whole memory space, accessible to the process,
77
+ for the provided value, returning the found addresses.
78
+
79
+ :param pytype: type of value to be queried (bool, int, float, str or bytes).
80
+ :param bufflength: value size in bytes (1, 2, 4, 8).
81
+ :param value: value to be queried (bool, int, float, str or bytes).
82
+ :param scan_type: the way to compare the values.
83
+ :param progress_information: if True, a dictionary with the progress information will be return.
84
+ :param writeable_only: if True, search only at writeable memory regions.
85
+ """
86
+ raise NotImplementedError()
87
+
88
+ def search_by_value_between(
89
+ self,
90
+ pytype: Type[T],
91
+ bufflength: int,
92
+ start: Union[bool, int, float, str, bytes],
93
+ end: Union[bool, int, float, str, bytes],
94
+ *,
95
+ not_between: bool = False,
96
+ progress_information: bool = False,
97
+ writeable_only: bool = False,
98
+ ) -> Generator[Union[int, Tuple[int, dict]], None, None]:
99
+ """
100
+ Search the whole memory space, accessible to the process,
101
+ for a value within the provided range, returning the found addresses.
102
+
103
+ :param pytype: type of value to be queried (bool, int, float, str or bytes).
104
+ :param bufflength: value size in bytes (1, 2, 4, 8).
105
+ :param start: minimum inclusive value to be queried (bool, int, float, str or bytes).
106
+ :param end: maximum inclusive value to be queried (bool, int, float, str or bytes).
107
+ :param not_between: if True, return only addresses of values that are NOT within the range.
108
+ :param progress_information: if True, a dictionary with the progress information will be return.
109
+ :param writeable_only: if True, search only at writeable memory regions.
110
+ """
111
+ raise NotImplementedError()
112
+
113
+ @abstractmethod
114
+ def read_process_memory(
115
+ self,
116
+ address: int,
117
+ pytype: Type[T],
118
+ bufflength: int
119
+ ) -> T:
120
+ """
121
+ Return a value from a memory address.
122
+
123
+ :param address: target memory address (ex: 0x006A9EC0).
124
+ :param pytype: type of the value to be received (bool, int, float, str or bytes).
125
+ :param bufflength: value size in bytes (1, 2, 4, 8).
126
+ """
127
+ raise NotImplementedError()
128
+
129
+ @abstractmethod
130
+ def write_process_memory(
131
+ self,
132
+ address: int,
133
+ pytype: Type[T],
134
+ bufflength: int,
135
+ value: Union[bool, int, float, str, bytes]
136
+ ) -> T:
137
+ """
138
+ Write a value to a memory address.
139
+
140
+ :param address: target memory address (ex: 0x006A9EC0).
141
+ :param pytype: type of value to be written into memory (bool, int, float, str or bytes).
142
+ :param bufflength: value size in bytes (1, 2, 4, 8).
143
+ :param value: value to be written (bool, int, float, str or bytes).
144
+ """
145
+ raise NotImplementedError()
@@ -4,8 +4,7 @@ import psutil
4
4
  import sys
5
5
 
6
6
  if "win" in sys.platform:
7
- from win32.win32gui import FindWindow
8
- from win32.win32process import GetWindowThreadProcessId
7
+ from ..win32.functions import GetProcessIdByWindowTitle
9
8
 
10
9
 
11
10
  def get_process_id_by_process_name(process_name: str) -> int:
@@ -24,8 +23,7 @@ def get_process_id_by_window_title(window_title: str) -> int:
24
23
  if "win" not in sys.platform:
25
24
  raise OSError("This function is compatible only with Windows OS.")
26
25
 
27
- hwnd = FindWindow(None, window_title)
28
- return GetWindowThreadProcessId(hwnd)[1] if hwnd else 0
26
+ return GetProcessIdByWindowTitle(window_title)
29
27
 
30
28
 
31
29
  def pid_exists(pid: int) -> bool:
@@ -7,7 +7,7 @@ reading and writing values in the process memory.
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
9
  [![Platforms](https://img.shields.io/badge/platforms-Windows%20%7C%20Linux-8A2BE2)](https://pypi.org/project/PyMemoryEditor/)
10
- [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%20...%20%7C%203.10%20%7C%203.11-blue)](https://pypi.org/project/PyMemoryEditor/)
10
+ [![Python Version](https://img.shields.io/badge/python-3.6%20%7C%20...%20%7C%203.11%20%7C%203.12-blue)](https://pypi.org/project/PyMemoryEditor/)
11
11
  [![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/)
12
12
 
13
13
  # Installing PyMemoryEditor:
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "PyMemoryEditor"
3
3
  dynamic = ["version"]
4
- description = "A Python library to edit and track memory of Windows and Linux processes (32 bits and 64 bits)."
4
+ description = "Multi-platform library developed with ctypes for reading, writing and searching process memory, in a simple and friendly way with Python 3. It supports Windows and Linux (32-bit and 64-bit)."
5
5
  authors = [
6
6
  { name = "Jean Loui Bernard Silva de Jesus", email = "jeanextreme002@gmail.com" },
7
7
  ]
@@ -36,13 +36,14 @@ classifiers = [
36
36
  "Programming Language :: Python :: 3.9",
37
37
  "Programming Language :: Python :: 3.10",
38
38
  "Programming Language :: Python :: 3.11",
39
+ "Programming Language :: Python :: 3.12",
39
40
  "Topic :: Scientific/Engineering",
40
41
  "Topic :: Security",
41
42
  "Topic :: System :: Monitoring"
42
43
  ]
43
44
  exclude = ["tests"]
44
45
  requires-python = ">=3.6"
45
- dependencies = ['pywin32 ; platform_system == "Windows"', "psutil"]
46
+ dependencies = ["psutil"]
46
47
 
47
48
  [project.optional-dependencies]
48
49
  tests = [
@@ -0,0 +1,2 @@
1
+ psutil
2
+ pytest
@@ -1,87 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from abc import ABC, abstractmethod
3
- from typing import Optional, Type, TypeVar, Union
4
-
5
- from ..process.info import ProcessInfo
6
-
7
-
8
- T = TypeVar("T")
9
-
10
-
11
- class AbstractProcess(ABC):
12
- """
13
- Abstract class to represent a process.
14
- """
15
-
16
- @abstractmethod
17
- def __init__(self, *, window_title: Optional[str] = None, process_name: Optional[str] = None, pid: Optional[int] = None):
18
- """
19
- :param window_title: window title of the target program.
20
- :param process_name: name of the target process.
21
- :param pid: process ID.
22
- """
23
- self._process_info = ProcessInfo()
24
-
25
- # Set the attributes to the process.
26
- if pid:
27
- self._process_info.pid = pid
28
-
29
- elif window_title:
30
- self._process_info.window_title = window_title
31
-
32
- elif process_name:
33
- self._process_info.process_name = process_name
34
-
35
- else:
36
- raise TypeError("You must pass an argument to one of these parameters (window_title, process_name, pid).")
37
-
38
- def __enter__(self):
39
- return self
40
-
41
- def __exit__(self, exc_type, exc_value, exc_traceback):
42
- self.close()
43
-
44
- @property
45
- def pid(self) -> int:
46
- return self._process_info.pid
47
-
48
- @abstractmethod
49
- def close(self) -> bool:
50
- """
51
- Close the process handle.
52
- """
53
- raise NotImplementedError()
54
-
55
- @abstractmethod
56
- def read_process_memory(
57
- self,
58
- address: int,
59
- pytype: Type[T],
60
- bufflength: int
61
- ) -> T:
62
- """
63
- Return a value from a memory address.
64
-
65
- :param address: target memory address (ex: 0x006A9EC0).
66
- :param pytype: type of the value to be received (bool, int, float, str or bytes).
67
- :param bufflength: value size in bytes (1, 2, 4, 8).
68
- """
69
- raise NotImplementedError()
70
-
71
- @abstractmethod
72
- def write_process_memory(
73
- self,
74
- address: int,
75
- pytype: Type[T],
76
- bufflength: int,
77
- value: Union[bool, int, float, str, bytes]
78
- ) -> T:
79
- """
80
- Write a value to a memory address.
81
-
82
- :param address: target memory address (ex: 0x006A9EC0).
83
- :param pytype: type of value to be written into memory (bool, int, float, str or bytes).
84
- :param bufflength: value size in bytes (1, 2, 4, 8).
85
- :param value: value to be written (bool, int, float, str or bytes).
86
- """
87
- raise NotImplementedError()
@@ -1,3 +0,0 @@
1
- pywin32 ; sys_platform == 'win32'
2
- psutil
3
- pytest
File without changes