Repository navigation
Add flag for getting command line arguments of processes - #17
Conversation
|
Rachel Macfarlane (@RMacfarlane) could you gauge how fast it is now to just query for args? (no memory/cpu) |
| DWORD pid; | ||
| DWORD ppid; | ||
| DWORD memory; // Reported in bytes | ||
| TCHAR arguments[512]; |
There was a problem hiding this comment.
I notice below you trim if the command line goes over, is there a actual maximum value we could use here?
There was a problem hiding this comment.
The actual maximum is 8191 (at least for processes run from cmd line), but increasing it beyond ~720 causes the JS tests to error out without any message. I tried switching to allocating the ProcessInfo array on the heap, but that causes a heap out of memory exception when running the tests with the current size.
Earlier I thought I was seeing nondeterministic failures when it was set to 720, so I'm wary of increasing it close to that. My guess is that it failed because it wasn't able to find a piece of contiguous memory large enough, even though its not a particularly large array, ~54k.
| None = 0, | ||
| Memory = 1 | ||
| Memory = 1, | ||
| Arguments = 2 |
There was a problem hiding this comment.
Thinking about this again we should probably name this "CommandLine" instead of Arguments as that's the Windows terminology for the exe+args.
| ppid: number; | ||
| name: string; | ||
| memory?: number; | ||
| arguments?: string; |
|
On my machine, calling getProcessList with only the args flag is under 20ms. |
Daniel Imms (Tyriar)
left a comment
There was a problem hiding this comment.
Looks great. Good to merge after the few comment related changes.
|
|
||
| /** | ||
| * Returns a tree of processes with the rootPid process as the root. | ||
| * @param {number} rootPid - The pid of the process that will be the root of the tree. |
There was a problem hiding this comment.
You should omit the types here as they are redundant and could succumb to bit rot
| ppid: number; | ||
| name: string; | ||
| memory?: number; | ||
| commandLine?: string; |
There was a problem hiding this comment.
Let's add a note here about the 512 maximum, you don't need to explain it, just state that it's cut off.
| pid: number; | ||
| ppid: number; | ||
| name: string; | ||
| memory?: number; |
There was a problem hiding this comment.
jsdoc explaining the unit would be good
Use NtQueryInformationProcess to get the command line arguments of a process