srounet / Pymem

A python library for windows, providing the needed functions to start working on your own with memory editing.
MIT License
307 stars 44 forks source link

Search for exact process name #70

Closed Spawnrad closed 1 year ago

Spawnrad commented 3 years ago

https://github.com/srounet/Pymem/issues/69#issue-972630632

srounet commented 2 years ago

Maybe you could add a strict argument so it won't break existing projects based on fuzzy process name matching ?

def process_from_name(name, strict=False):
    """Open a process given its name.
    :param name: The name of the process to be opened
    :param strict: Perform an exact process name match (as opposed to default fuzzy search)
    :type name: str
    :type strict: bool
    :return: The ProcessEntry32 structure of the given process.
    :rtype: ctypes.c_void_p
    """
    name = name.lower()
    processes = list_processes()
    for process in processes:
        process_name = process.szExeFile.decode(locale.getpreferredencoding()).lower()
        if strict and name == process_name:
            return process
        elif name in process_name:
            return process
StarrFox commented 1 year ago

closed by https://github.com/srounet/Pymem/commit/8e011e3ca76cefbc5ebb6d43cb4c3c8026dcd9c8