Created
November 29, 2020 01:06
-
-
Save Jongy/4a8739351beac654dbcc6be5cb386e4d to your computer and use it in GitHub Desktop.
Linux Kernel MicroPython ps() & task_struct.comm modification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from struct_access import container_of, partial_struct | |
from kernel_ffi import current | |
task_struct = partial_struct("task_struct") | |
p = task_struct(current()) | |
# p.<TAB> | |
from struct_access import dump_struct | |
dump_struct(p) | |
while p.pid != 2: | |
print("i'm at pid {} comm {!r}".format(p.pid, p.comm.read())) | |
p = container_of(p.tasks.next, "task_struct", "tasks") | |
print(p.comm.read()) # kthreadd | |
p.comm = "this is very long!!" # ValueError | |
p.comm = "this is very lon" # ValueError | |
print(p.comm.read()) # this is very lon | |
# ps -ef | head -n 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment