Hello Boys and Girls.
Bubu-Boy need you help again.:rolleyes:
Hi, when I want to insert a item in a foreigner listview i can use WriteProcessMemory. Is that right?

I tryed some variation, but nothing works.

I would be happy, when someone would lead me on the right track.:stupid:

Greets your BBB
Posted on 2003-09-28 11:54:30 by Bubu-Boy

Hi, when I want to insert a item in a foreigner listview i can use WriteProcessMemory. Is that right?

I tryed some variation, but nothing works.

I would be happy, when someone would lead me on the right track.:stupid:
I think you can just send LVM_INSERTITEM message to hwnd of the listview, no need for WriteProcessMemory, but for SendMessage or PostMessage and FindWindow.

Edit: Just read your other post.

You still need to use SendMessage, but first you need to write the string to the target process's memory. Find a bit of space in target process and write the string there, then send the message.
Posted on 2003-09-29 07:34:59 by _js_
hey man, check this out:



LOCAL Col:LV_COLUMN

mov Col.imask,LVCF_FMT or LVCF_TEXT or LVCF_WIDTH
mov Col.lx,30
mov Col.pszText,offset buf
mov Col.cchTextMax,16
invoke SendMessage,Listview_hWnd,LVM_INSERTCOLUMN,0,addr Col

Posted on 2003-09-29 08:02:24 by optimus
Hello.

Sending the Message schould be clear. - I have problems with writing the string in the target process space.

"You still need to use SendMessage, but first you need to write the string to the target process's memory. Find a bit of space in target process and write the string there, then send the message"

Have someone an example to underline the theroy?

Greets BBB
Posted on 2003-09-29 10:20:00 by Bubu-Boy
your string is passed to the struct and thus to listview control by this code:



mov Col.pszText,offset buf


and that's all!
Posted on 2003-09-29 10:38:35 by optimus
Hi, the problem is, that the string offset is accesseble through diferent applications.
Or have zyou testet it ?

Greets.
Posted on 2003-09-29 10:57:36 by Bubu-Boy
i think the system should do this job for u.
Posted on 2003-09-29 11:21:03 by optimus
Hi, could you try to insert a item in a foreign application?
I think it will crashs.
Woulb be nice when you try it.


Greets BBB
Posted on 2003-09-29 11:29:45 by Bubu-Boy
Why don't you try it yourself? ^_^
Posted on 2003-09-29 11:32:27 by f0dder
hi, thanks for your answers.

I alredy said, that the other programm crashes. Sombody told me, that I have to use a hook or write the string in the process memory.
I tryed to write it in the process memory but i dont know how.

I can dlete all items from a foreign listview, but not add a item, because i hace fo overgive a parameter(offset).


Greets BBB
Posted on 2003-09-29 11:37:47 by Bubu-Boy
I just tryed the example with the column, and as I already said, it crashes.
Please teach me how write process memory work right.

Thanks again.

Greets!
Posted on 2003-09-29 11:43:11 by Bubu-Boy
VirtualAllocEx a block of memory in the target application (if you're on NT... I don't care about 9x), WriteProcessMemory your string there, and then send the message.
Posted on 2003-09-29 11:47:24 by f0dder
maybe using CreateFileMapping to create a shared mapping memory
Posted on 2003-09-29 11:49:48 by optimus
won't work as-is - the other process would have to cooperate and re-open the filemapping object, there's no such thing as globally shared memory (that works on all win32, anyway)
Posted on 2003-09-29 11:54:33 by f0dder
Hi flooder I know you are a grant coder - You have contribute a function in hte MASM32.lib..

I know about the solution t write it in the process space with WriteProcessMemory.
But I cant fugure out how it works correcly.

A little sample wuld be nice.


Greets!
Posted on 2003-09-29 13:33:17 by Bubu-Boy
Having code in masm32 says nothing about coder skill whatsoever... and the code I contributed is pretty silly iirc, just based around some old tricks.

I might have time to write some code or pseudocode tomorrow - but the steps are something like the following:

*) get process handle from window handle (GetWindowThreadProcessId)
*) allocate memory in process (VirtualAllocEx)
*) write string to allocated memory in process (WriteProcessMemory)

- this info _should_ be enough to get you started with code yourself - at least give it a try and post your attempt here.
Posted on 2003-09-29 13:45:28 by f0dder
Hi, thank you very much.

Step one should be very clear.

allocate memory in process (VirtualAllocEx) ?

I have the windows documentation, but i cant understant it. - Perhaps its why my englisch soo bad. :mad:

Greets!
Posted on 2003-09-29 13:50:07 by Bubu-Boy
address_of_memory = VirtualAllocEx(processhandle, 0, sizeofstring, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- passing 0 as lpaddress tells virtualalloc to "allocate memory wherever, I don't care, I just want the memory".
After that, you can use WriteProcessMemory to write to the allocated memory block - and yeah, you do have to
use WriteProcessMemory and not memcopy or whatever, as the memory is located in the other process.
Posted on 2003-09-29 13:55:44 by f0dder
INVOKE VirtualAllocEx, hProcess, 0, sizeof File , MEM_COMMIT,PAGE_EXECUTE_READWRITE
MOV memory, EAX
INVOKE WriteProcessMemory, hProcess, memory, ADDR File, sizeof File, ADDR written


mov Col.imask,LVCF_FMT or LVCF_TEXT or LVCF_WIDTH
mov Col.lx,30
mov Col.pszText,offset File
mov Col.cchTextMax,16
invoke SendMessage,hWnd,LVM_INSERTCOLUMN, 0,addr Col


the programm wich schould get a new header crahses to
Posted on 2003-10-02 05:11:10 by Bubu-Boy
Um... the structure must be accessible from the other program as well, not just the string.
Posted on 2003-10-02 13:01:22 by Sephiroth3