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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ntmemoryapi
3
- Version: 1.7.0
3
+ Version: 1.7.2
4
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ntmemoryapi"
3
- version = "1.7.0"
3
+ version = "1.7.2"
4
4
  description = "Simple library for Windows to manipulate process virtual memory with stelthy syscall wraps"
5
5
  authors = [
6
6
  {name = "Xenely"}
@@ -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 pid if type(name_or_pid) is int:
287
- self.handle, self.name, self.pid = self.__init_with_pid(pid, access)
286
+ case int():
287
+ self.handle, self.pid, self.name = self.__init_with_pid(name_or_pid, access)
288
288
 
289
- case name if type(name_or_pid) is str:
290
- self.handle, self.name, self.pid = self.__init_with_name(name, access)
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 `pid_or_name` argument value, have to be `int` or `str` type")
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, process_name: str | None = None) -> 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 if name not defined
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, process_name, pid
781
+ return handle.value, pid, process_name
782
782
 
783
- def __init_with_name(self, name: str, access: int, current_username_only: bool) -> 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, current_username_only, process["name"])
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