You are enumerating all the modules of the current process, that is: your process, that is: javaw.exe
. That's because you feed the EnumProcessModules
API with the result of GetCurrentProcess()
If you want to enumerate the modules of another process, you need to use OpenProcess
with it's PID
.
You can get a PID with two methods: