I want to get the process ID by supplying the window handle to
the following API.
DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId);
However I am failing to understand how can I pass the Pointer to
DWORD to DL call object.
I tried passing PtrData object, but it does not seem to be returning
the PID value as I had expected. Following is my irb session:
irb(main):001:0> require ‘dl’
irb(main):002:0> rpid = 0
irb(main):004:0> ptr = DL::PtrData.new(rpid)
=> #<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>
irb(main):006:0> getpid = user32[‘GetWindowThreadProcessId’, ‘LLP’]
=> #<DL::Symbol:0x2a0d070 func=0x77d48a58 ‘long
GetWindowThreadProcessId(long, void *);’>
irb(main):007:0> getpid.call(0x00120464, ptr)
=> [4032, [1180772, #<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>]]
irb(main):008:0> p ptr
#<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>
I was expecting to ptr data to change to the pid of my process, however
it has not changed at all.
Am I missing something obvious. Is there any other way I can do this.
Thanks and Regards,