Some ctypes stuff for processes
pip install randomandroidphone
Tested against Windows 10 / Python 3.11 / Anaconda
from ctypesprocstuff import (
get_kids_dict,
get_all_procs_with_children,
iter_process,
wmic_process_active,
is_process_user_an_admin,
kill_process_and_children,
suspend_subprocess,
resume_subprocess,
)
import subprocess
import time
qq = get_kids_dict(pid=23336, bi_rl_lr="lr")
print(qq)
allprocschild = get_all_procs_with_children()
for i in iter_process():
di = wmic_process_active(i.th32ProcessID)
try:
print(is_process_user_an_admin(i.th32ProcessID))
except Exception as e:
print(e)
if di.get("Caption", "") == "uc_driver.exe":
print(i.th32ProcessID)
kill_process_and_children(i.th32ProcessID, taskkillargs=("/f",))
print(di)
p = subprocess.Popen("notepad.exe")
time.sleep(5)
suspend_subprocess(p)
time.sleep(15)
resume_subprocess(p)
# kill_process_and_children(pid=15300, taskkillargs=("/f",))
get_all_procs_with_children() -> 'list[dict]'
A function to get all processes with their children.
Returns a list of dictionaries containing information about processes and their children (except pid 0 and pid 4).
get_kids_dict(pid: 'int', bi_rl_lr: "Literal['rl', 'lr', 'bi']" = 'lr') -> 'dict'
A function that constructs a dictionary of processes and their children based on the provided process ID.
Args:
pid (int): The process ID for which to build the dictionary.
bi_rl_lr (Literal["rl", "lr", "bi"], optional): The direction of the process hierarchy. Defaults to "lr" (left to right).
Returns:
dict: A dictionary mapping the processes and their children along with module information.
is_process_user_an_admin(pid: 'int') -> 'bool'
Checks if the process user identified by the given process ID is an administrator.
Args:
pid (int): The process ID to check for administrator privileges.
Returns:
bool: True if the process user is an administrator, False otherwise.
iter_module(pid: 'int') -> 'Generator'
A function that iterates over the modules of a specified process.
Args:
pid (int): The process ID for which to iterate over the modules.
Yields:
Generator: Yields the module information obtained from the snapshot.
iter_process() -> 'Generator'
A function that iterates over the processes from a snapshot and yields them.
iter_threads() -> 'Generator'
A function that iterates over the threads from a snapshot and yields them.
kill_process_and_children(pid: 'int', taskkillargs: 'tuple' = ('/f',)) -> 'list[list[bytes, bytes, int]]'
A function to kill a process and its children based on the given process ID (starting from the deepest child).
Args:
pid (int): The process ID of the parent process to be killed.
taskkillargs (tuple, optional): Additional arguments for the taskkill command. Defaults to ("/f",).
Returns:
list[list[bytes, bytes, int]]: A list containing information about the executed kill process and its children after termination.
resume_subprocess(proc: 'subprocess.Popen') -> 'None'
Resumes a subprocess based on the given process handle.
Args:
proc (subprocess.Popen): The subprocess to be resumed.
Returns:
None
suspend_subprocess(proc: 'subprocess.Popen') -> 'None'
Suspend a subprocess by calling NtSuspendProcess with the handle of the provided subprocess.
Parameters:
proc (subprocess.Popen): The subprocess to be suspended.
Returns:
None
wmic_process_active(pid: 'int') -> 'dict'
Retrieves information about an active process based on the provided process ID.
Args:
pid (int): The process ID for which to retrieve information.
Returns:
dict: A dictionary containing information about the active process, including CommandLine, Caption, and ProcessId.
Metadata
Release files for ctypesprocstuff 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ctypesprocstuff-0.10.tar.gz | 13.6 kB | Without provenance | Details for ctypesprocstuff-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctypesprocstuff-0.10-py3-none-any.whl | Python 3 | none | any | Details for ctypesprocstuff-0.10-py3-none-any.whl |
Total release size: 28.0 kB
Release files / ctypesprocstuff-0.10.tar.gz
| Download URL | ctypesprocstuff-0.10.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84c6acc6ede0fc38f0146f7d03b8c19e9e1aacf259781c1be30355f8043278f7
|
|
BLAKE2b-256 checksum How to use checksums |
fd02a60ea7e0729ba80cd4832fadcd70662d909fbca52adf83f6a4c4ead29871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / ctypesprocstuff-0.10-py3-none-any.whl
| Download URL | ctypesprocstuff-0.10-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c1efffd9fc04938eb1fc027365518d90868a71098d466d56bd2e50faee6ebb8
|
|
BLAKE2b-256 checksum How to use checksums |
8f2a70396df688fe48f241292dee102a48065cf20ff765b1627b6283a6bbcf6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for ctypesprocstuff 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.