ntmemoryapi 2.1.3__tar.gz → 2.1.5__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ntmemoryapi
3
- Version: 2.1.3
4
- Summary: Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps
3
+ Version: 2.1.5
4
+ Summary: Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps.
5
5
  Author: Xenely
6
6
  Requires-Dist: psutil>=7.1.3
7
7
  Requires-Python: >=3.10
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "ntmemoryapi"
3
- version = "2.1.3"
4
- description = "Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps"
3
+ version = "2.1.5"
4
+ description = "Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps."
5
5
  authors = [
6
6
  {name = "Xenely"}
7
7
  ]
@@ -5,8 +5,11 @@
5
5
  # | Discord: xenely |
6
6
  # +-------------------------------------+
7
7
 
8
+ import typing
9
+
10
+
8
11
  # ==-------------------------------------------------------------------== #
9
- # Classes #
12
+ # Base errors classes #
10
13
  # ==-------------------------------------------------------------------== #
11
14
  class NtError(Exception):
12
15
  """Exception that raises on `nt` functions calls fails."""
@@ -40,6 +43,30 @@ class NtError(Exception):
40
43
  return "%s%08x" % (hex_prefix if hex_prefix is not None else "", self.status)
41
44
 
42
45
 
46
+ class MemoryError(NtError):
47
+ """Exception that raises on virtual memory read fail."""
48
+
49
+ # ==--------------------------------== #
50
+ # Public methods #
51
+ # ==--------------------------------== #
52
+ def __init__(self, status: int, address: int, operation: typing.Literal["read", "write"]):
53
+
54
+ # Save initializer arguments as an attributes
55
+ self.address = address
56
+ self.operation = operation
57
+
58
+ # Call initializer of parrent class
59
+ super().__init__(None, status)
60
+
61
+ def __str__(self) -> str:
62
+ """Overload triggered on `str` cast calls"""
63
+
64
+ return "Unalble to %s memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.operation, self.address, self.get_hex_status())
65
+
66
+
67
+ # ==-------------------------------------------------------------------== #
68
+ # Errors classes #
69
+ # ==-------------------------------------------------------------------== #
43
70
  class OpenProcessError(NtError):
44
71
  """Exception that raises on process open fail."""
45
72
 
@@ -63,7 +90,7 @@ class OpenProcessError(NtError):
63
90
  return "Unable to open process: %s" % self.message
64
91
 
65
92
 
66
- class MemoryReadError(NtError):
93
+ class MemoryReadError(MemoryError):
67
94
  """Exception that raises on virtual memory read fail."""
68
95
 
69
96
  # ==--------------------------------== #
@@ -71,19 +98,11 @@ class MemoryReadError(NtError):
71
98
  # ==--------------------------------== #
72
99
  def __init__(self, status: int, address: int):
73
100
 
74
- # Save initializer arguments as an attributes
75
- self.address = address
76
-
77
101
  # Call initializer of parrent class
78
- super().__init__(None, status)
79
-
80
- def __str__(self) -> str:
81
- """Overload triggered on `str` cast calls"""
102
+ super().__init__(status, address, "read")
82
103
 
83
- return "Unalble to read memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.address, self.get_hex_status())
84
104
 
85
-
86
- class MemoryWriteError(NtError):
105
+ class MemoryWriteError(MemoryError):
87
106
  """Exception that raises on virtual memory read fail."""
88
107
 
89
108
  # ==--------------------------------== #
@@ -91,13 +110,5 @@ class MemoryWriteError(NtError):
91
110
  # ==--------------------------------== #
92
111
  def __init__(self, status: int, address: int):
93
112
 
94
- # Save initializer arguments as an attributes
95
- self.address = address
96
-
97
113
  # Call initializer of parrent class
98
- super().__init__(None, status)
99
-
100
- def __str__(self) -> str:
101
- """Overload triggered on `str` cast calls"""
102
-
103
- return "Unalble to write memory at `0x%08x` address, `nt` function failed with `%s` status" % (self.address, self.get_hex_status())
114
+ super().__init__(status, address, "write")
File without changes