-
Notifications
You must be signed in to change notification settings - Fork 535
Prototype generic process functions #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Prototype generic process functions #1000
Conversation
…ericProcess class
… which does not exist
@ikelos - I'd love your thoughts on this. The idea to have a simple to use way to get key information about a process for plugins. That way there can be a central way to do these lookups within plugins so that they're consistent and if an update needs to be done it only needs to happen in one place. It could be bulked out to include extra bits for a process like getting memory regions etc. It should hopefully mean that we'd be able to make non-OS specific plugins - assuming it's done in the right way. Given it's above intel process that might be a good place for it given the arm work at the moment? Thanks again. |
Yep, sorry, it is on my list, just a bit lower down at the moment, sorry! 5:S |
Hey @eve-mem ! It's a great idea to ensure better consistency across the framework. I think this is also related to your other ticket Unify Linux plugins representation of pids which we should take a decision at some point. |
Thanks both. I completely understand not having time to look at this given how little time i seem to have at the moment. Thanks for those pointers @gcmoreira - that's almost exactly why I'd pike something like this PR to exist. Just a single place to have the 'right' answer so we can do it once for all plugins. Not necessarily this version in particular, but the idea at least. |
…t is readable and remove unneeded source code
Hey @ikelos and @gcmoreira, I was working on the PR for #981 and it just felt to me that doing this first might make it all a bit easier. Assuming that you both think that this is a good idea of course! What do you think? I also tried to add an explanation of tgid/pid/tid into the readme docs. Not sure what you both make of that? @gcmoreira thanks for the comments - I think I've got them all now. I'm a little unsure I got the datetime part correct in the mac side - could you check that a little closer? Thanks both. |
Hey @eve-mem good job! I think it's a solid idea, but we should keep refining the implementation. There are a few areas that could be improved, and some issues that still need fixing.
- user_pid = task.get_pid()
- user_tid = task.pid # Note that pid is user_tid in Linux
- user_ppid = task.get_parent_pid()
+ user_pid = task.get_user_pid()
+ user_tid = task.get_user_tid()
+ user_ppid = task.get_user_ppid()
# or get_parent_user_pid()
|
Thanks @gcmoreira - makes sense I'll work on it. Particularly the pid filtering, it makes sense to me now. I was hoping that the functions would be the same across the different OSes, I'll change the get_pid to get_user_pid for all of them. |
Hey @gcmoreira - I was updating the linux side of the generic processes as per your suggestion. e.g. - user_pid = task.get_pid()
- user_tid = task.pid # Note that pid is user_tid in Linux
- user_ppid = task.get_parent_pid()
+ user_pid = task.get_user_pid()
+ user_tid = task.get_user_tid()
+ user_ppid = task.get_user_ppid()
# or get_parent_user_pid() It means that then the linux side will have slightly different functions to the other OSes - meaning it's less generic again. I'm hoping it means a plugin could run on both linux/windows/macos without any changes. What do you think about having the linux side having It means there's still only one place for the actual logic for Would love to hear your thoughts on whether this simplifies things or adds unnecessary layers! |
I think an interface should be generic, with the common usage (so whilst there may be non-user pids and tids and ppids, we kind of all have an intuition of what we mean, and the docstring can explain precisely what's returned, and we can overrload OS specific ones with other OS specific functions if we really need (so people don't have to jump into and out of the handlers to do different things, but the only ones they can rely on across multiplatform methods are the ones on the generic interface. This will mean choosing what we expect to be "common" carefully, because changing it later will be nigh on impossible... |
|
||
PIDs, TIDs, and TGID | ||
-------------------- | ||
Typically processes are a collection of threads that are working together for a single program to run. On Windows `notepad.exe` would be a process that might contain multiple threads, in task manager you would only see the single process. In Linux you will also see processes split into multiple threads working together, however Linux uses a single `task` structure to represent processes and the threads that make them up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux doesn't use a single task struct, threads have their own. The code reflects this but this part of the documentation is off:
"uses a single task
structure to represent processes and the threads"
return ( | ||
self.real_parent.get_pid() | ||
if self.real_parent and self.real_parent.is_readable() | ||
else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a renderer unavailable instance as 0 is misleading
Hello,
This draft PR is to add some experimental features to provide a generic way of getting basic information from processes regardless of operating system. The idea was discussed in the comments of this issue: #981
The idea being to provide a set of functions that can be used in plugins to make them easier to make (or volshell), and be consistent across the different operating systems so it's easier to switch between them.
It is very basic, just adding the following functions. Mostly just be shifting code out of various pslist plugins to the extensions so they can used from anywhere.
(This is what I mean with the colours if it's not clear - 🟢: Added in this PR, ⚫: Function already existed, 🔴: Not added in this PR)
It was interesting to work on this. I noticed after that the linux module class also inherits from
GenericIntelProcess
and already has aget_name
function.Also that the windows EPROCESS already had the
get_create_time
andget_exit_time
functions so I used those names in the generic part.I've then modified the pslist plugins for windows/linux/mac to show how this could be used. If this is useful I'm happy to modify the existing plugins to use this, it shouldn't affect how they work - but might make them easier to read.
I'm not sure if this is the best (or even a good) way of doing this - so I'd be very interested in your thoughts.
Thanks!