2

I'm running ruby on my Windows 7 machine. How can I do the following with Ruby(1.9.3):

  1. Get all the processes details (like PID, Image Name, Memory Usage) running on the machine &

  2. Get the memory contents in plain text format for each of the above processes so that I will be able to parse it..

For first task should I use windows tasklist command and parse it for the required information or some better alternative exists.

And for second I have read a lot and still confused, whether I should create a ruby extension or use FFI or use some kind of WinAPI function ReadProcessMemory..

This stack overflow question resembles my situation How can I read the memory of another process in Python in Windows?

Community
  • 1
  • 1

1 Answers1

0

If you 're on Linux please read this previous post

https://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux

about

/proc/<id>/maps
/proc/<id>/pagemap
/proc/<id>/mem

This could be easily ported in Ruby

list processes is like list /proc folder For processes who is not a child of your process, you have to look to :

http://www.ruby-doc.org/gems/docs/p/Ptrace-0.9.3/Ptrace/MemArea.html

Community
  • 1
  • 1
Romain
  • 451
  • 4
  • 13