Sunday, 15 February 2015

javascript - How to read memory at pointer (local_tbb.dwData) to get window handle -



javascript - How to read memory at pointer (local_tbb.dwData) to get window handle -

i've been lacking sleep i'm super on killing one.

what i'm trying handle window task bar button. next tutorial here: http://www.codeproject.com/articles/10497/a-tool-to-order-the-window-buttons-in-your-taskbar. specific part:

getting window handle

this lucky part. thought myself: "where maintain window handle?". must maintain somewhere, enable activation of right window when button selected. obvious place maintain in construction each button, , obvious place maintain pointer construction in dwdata field of each tbbutton.

so had @ dwdata fields, , appeared pointers. ok far. had @ memory pointed to, , there were: first field stores window handle smiling | :) )) microsoft developers aren't different, after smiling | :)

so task bar button this:

anyways how local_tbb:

remote_tbb = ralloc_alloc(struct_tbbutton.size); var rez = sendmessage(htoolbar, tb_getbutton, i, ctypes.voidptr_t(remote_tbb)); if (!rez) { throw new error('failed on sendmessage of tb_getbutton'); } var local_tbb = new struct_tbbutton(); var retread = ralloc_read(remote_tbb, local_tbb.address()); var freed = ralloc_free(remote_tbb); console.log('freed', freed); (var n in local_tbb) { console.log(n, local_tbb[n]); seek { console.log('tostring', n, local_tbb[n].tostring()); } grab (ignore) {} }

and succesfully dwdata field populated. console.log when on dwdata:

"dwdata" uint64 { } "tostring" "dwdata" "1499288"

so want guy said , then had @ memory pointed to. i'm trying that.

so know have this, ipc command should go sendmessage (currently i'm using 0x004a /** wm_copydata **/ can't right) , should set in local_tbb.dwdata address?

var remote_hwnd = ralloc_alloc(ctypes.voidptr_t.size); var smhwndrez = sendmessage(htoolbar, 0x004a /** wm_copydata **/, local_tbb.idcommand, ctypes.voidptr_t(remote_hwnd)); console.log('smhwndrez=', smhwndrez); var local_hwnd = ctypes.voidptr_t; var retread = ralloc_read(remote_hwnd, local_hwnd.address()); console.log('retread=', retread); var freed = ralloc_free(remote_hwnd); console.log('freed=', freed); console.log('local_hwnd = ', local_hwnd, local_hwnd.tostring(), uneval(local_hwnd));

strictly speaking, not winapi, not part of api undocumented implementation details.

from can gather:

get tbbutton data. the .dwdata contains pointer multiple(?) handles (voidptr_ts) so reinterpret .dwdata voidptr_t, i.e. new ctypes.voidptr_t(.dwdata); use readprocessmemory read pointer location .dwdata points to. (supposed be) window handle.

so this:

var tbb = new tbbutton(); ... var dataptr = new ctypes.voidptr_t(tbb.dwdata); var handle = new ctypes.voidptr_t(); // important: pass address of |handle|, not |handle| itself. if (!readprocessmemory(process, dataptr, handle.address(), ctypes.voidptr_t.size, null)) { throw new error("failed read window handle"); }

javascript winapi firefox-addon jsctypes

No comments:

Post a Comment