|
3 | 3 | import functools |
4 | 4 | import typing |
5 | 5 | from pathlib import Path |
6 | | -from typing import Self, Union |
| 6 | +from typing import Self |
7 | 7 |
|
8 | 8 | import regex |
9 | 9 |
|
10 | 10 | from memobj.allocation import Allocator |
11 | 11 | from memobj.process import Process |
12 | 12 | from memobj.process.windows.module import WindowsModule |
13 | | -from memobj.process.windows.utils import \ |
14 | | - WindowsMemoryProtection # TODO: what was this going to be used for? |
15 | | -from memobj.process.windows.utils import (LUID, LUID_AND_ATTRIBUTES, |
16 | | - PROCESSENTRY32, TOKEN_PRIVILEGES, |
17 | | - CheckWindowsOsError, |
18 | | - SingleLUIDAndAttributes, |
19 | | - WindowsMemoryBasicInformation, |
20 | | - WindowsModuleInfo) |
| 13 | +from memobj.process.windows.utils import ( |
| 14 | + WindowsMemoryProtection, |
| 15 | +) # TODO: what was this going to be used for? |
| 16 | +from memobj.process.windows.utils import ( |
| 17 | + LUID, |
| 18 | + LUID_AND_ATTRIBUTES, |
| 19 | + PROCESSENTRY32, |
| 20 | + TOKEN_PRIVILEGES, |
| 21 | + CheckWindowsOsError, |
| 22 | + SingleLUIDAndAttributes, |
| 23 | + WindowsMemoryBasicInformation, |
| 24 | +) |
21 | 25 |
|
22 | 26 |
|
23 | | -# TODO: update everything that uses modules to use the new WindowsModule |
24 | 27 | class WindowsProcess(Process): |
25 | 28 | def __init__(self, process_handle: int): |
26 | 29 | self.process_handle = process_handle |
27 | 30 |
|
28 | | - # TODO: why are we getting debug privileges for our own process? |
29 | 31 | @staticmethod |
30 | 32 | def _get_debug_privileges(): |
31 | 33 | with CheckWindowsOsError(): |
@@ -411,25 +413,6 @@ def get_modules( |
411 | 413 | else: |
412 | 414 | return WindowsModule.get_all_modules(self) |
413 | 415 |
|
414 | | - # def get_module_name(self, module: WindowsModuleInfo) -> str: |
415 | | - # with CheckWindowsOsError(): |
416 | | - # # https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getmodulebasenamew |
417 | | - # # I just assume MAX_PATH is good enough |
418 | | - # name_buffer = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH) |
419 | | - |
420 | | - # success = ctypes.windll.psapi.GetModuleBaseNameW( |
421 | | - # self.process_handle, |
422 | | - # ctypes.c_void_p(module.lpBaseOfDll), |
423 | | - # ctypes.byref(name_buffer), |
424 | | - # ctypes.wintypes.MAX_PATH, |
425 | | - # ) |
426 | | - |
427 | | - # if success == 0: |
428 | | - # raise ValueError(f"GetModuleBaseNameW failed for {module}") |
429 | | - |
430 | | - # return name_buffer.value |
431 | | - |
432 | | - # TODO: return module here |
433 | 416 | def get_module_named(self, name: str) -> WindowsModule: |
434 | 417 | return WindowsModule.from_name(self, name) |
435 | 418 |
|
|
0 commit comments