ntmemoryapi 1.7.0__tar.gz → 1.7.2__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.
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/PKG-INFO +1 -1
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/pyproject.toml +1 -1
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/src/ntmemoryapi/__init__.py +12 -12
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/README.md +0 -0
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/src/ntmemoryapi/embed.py +0 -0
- {ntmemoryapi-1.7.0 → ntmemoryapi-1.7.2}/src/ntmemoryapi/misc.py +0 -0
|
@@ -283,14 +283,14 @@ class Process:
|
|
|
283
283
|
# Open process by it's ID or it's name
|
|
284
284
|
match name_or_pid:
|
|
285
285
|
|
|
286
|
-
case
|
|
287
|
-
self.handle, self.
|
|
286
|
+
case int():
|
|
287
|
+
self.handle, self.pid, self.name = self.__init_with_pid(name_or_pid, access)
|
|
288
288
|
|
|
289
|
-
case
|
|
290
|
-
self.handle, self.
|
|
289
|
+
case str():
|
|
290
|
+
self.handle, self.pid, self.name = self.__init_with_name(name_or_pid, access)
|
|
291
291
|
|
|
292
292
|
case _:
|
|
293
|
-
raise Exception("Invalid `
|
|
293
|
+
raise Exception("Invalid `name_or_pid` argument value, have to be `int` or `str` type")
|
|
294
294
|
|
|
295
295
|
# Try create file at temp directory to load SIMD KMP .dll (Module to blazingly fast pattern scaning)
|
|
296
296
|
try:
|
|
@@ -746,11 +746,11 @@ class Process:
|
|
|
746
746
|
# ==-------------------------------------------------------------------== #
|
|
747
747
|
# Private methods #
|
|
748
748
|
# ==-------------------------------------------------------------------== #
|
|
749
|
-
def __init_with_pid(self, pid: int, access: int,
|
|
749
|
+
def __init_with_pid(self, pid: int, access: int, listed_processes: list[dict[str, int | str]] | None = None) -> tuple[int, int, str]:
|
|
750
750
|
"""Open process handle by it's ID with desired access."""
|
|
751
751
|
|
|
752
|
-
# Iterate all of the processes
|
|
753
|
-
for process in list_processes():
|
|
752
|
+
# Iterate all of the processes
|
|
753
|
+
for process in listed_processes if listed_processes is not None else list_processes():
|
|
754
754
|
|
|
755
755
|
# If process have a reqired name
|
|
756
756
|
if process["id"] == pid:
|
|
@@ -778,16 +778,16 @@ class Process:
|
|
|
778
778
|
else:
|
|
779
779
|
raise Exception("NtOpenProcess failed with status: 0x%s" % hex(result)[2:].upper())
|
|
780
780
|
|
|
781
|
-
return handle.value,
|
|
781
|
+
return handle.value, pid, process_name
|
|
782
782
|
|
|
783
|
-
def __init_with_name(self, name: str, access: int
|
|
783
|
+
def __init_with_name(self, name: str, access: int) -> tuple[int, int, str]:
|
|
784
784
|
"""Open process hanle by it's name with desired access."""
|
|
785
785
|
|
|
786
786
|
# Iterate all of the processes using snapshot
|
|
787
|
-
for process in list_processes():
|
|
787
|
+
for process in (listed_processes := list_processes()):
|
|
788
788
|
|
|
789
789
|
# If process have a reqired name
|
|
790
790
|
if process["name"].lower() == name.strip().lower():
|
|
791
|
-
return self.__init_with_pid(process["id"], access,
|
|
791
|
+
return self.__init_with_pid(process["id"], access, listed_processes)
|
|
792
792
|
|
|
793
793
|
raise Exception("Process with `%s` name not found" % name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|