Friday, 15 July 2011

javascript - Address to WCHAR_T to pass to ReadProcessMemory -



javascript - Address to WCHAR_T to pass to ReadProcessMemory -

i'm having problem passing wchar_t readprocessmemory

this how succesfully pass pointers address readprocessmemory, can structures:

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);

but need wchar_t, have:

var chars = sendmessage(htoolbar, tb_getbuttontextw, local_tbb.idcommand, ctypes.voidptr_t(0)); console.log('chars=', chars, chars.tostring(), uneval(chars)); if (chars && parseint(chars.tostring()) > 0) { var remote_buf = ralloc_alloc(parseint(chars.tostring())); var charsre = sendmessage(htoolbar, tb_getbuttontextw, local_tbb.idcommand, ctypes.voidptr_t(remote_buf)); console.log('charsre=', charsre); var local_buf = ctypes.jschar; //wchar_t var retread = ralloc_read(remote_buf, local_buf.address()); ///problem line console.log('retread=', retread); var freed = ralloc_free(remote_buf); console.log('freed=', freed); console.log('button text = ', local_buf, local_buf.tostring()); } else { console.log('button text = none'); }

so problem on line:

var retread = ralloc_read(remote_buf, local_buf.address());`

and on local_buf.address()

errors in experimenting thrown are:

expected type pointer, got ctypes.jschar local_buf.address not function

so how pass wchar_t reference?

edit: here ralloc_read implemetnation:

function ralloc_read(remote_address, local_buffer) { var found_addr; (var = 0; < buffers.length; i++) { if (buffers[i][0] == remote_address) { found_addr = buffers[i] break; } } if (!found_addr) { homecoming null; } /*using found remote address(found_addr[0]), *i read size bytes (found_addr[1]) local_buffer*/ //console.info('found_addr[0]', found_addr[0].tostring()); var rez = readprocessmemory(proc, found_addr[0], local_buffer, found_addr[1], 0); homecoming rez; }

if ralloc_read calls readprocessmemory, you'll need allocate jschar array receive result.

var local_buf = ctypes.jschar.array()(chars); ralloc_read(remote_buf, local_buf.address()); var str = local_buf.readstring();

edit however, allocation phone call wrong:

ralloc_alloc(parseint(chars.tostring()));

this allocate chars bytes, e.g. chars = 11, 11 bytes. wchar_t/jschar not 1 byte 2 bytes.

ctypes.jschar.size // 2

so you'll need allocate remote memory buffer larger:

ralloc_alloc(parseint(chars.tostring()) * ctypes.jschar.size); // ralloc_alloc(count * sizeof(wchar_t*)) in c/c++

the local_buf stuff correct, though js-ctypes arrays automatically calculate required storage if knows size of array element type, ctypes.jschar.array()(11) buffer have 11 elements of size 2 bytes, i.e. 11 items * 2 bytes/item == 22 bytes.

javascript firefox-addon jsctypes

No comments:

Post a Comment