0

Itrying to get a out of a string sysListView32 from another process. The list is a tree. And for the first column returns an empty string. Tell me where is the problem?

Image of tree: tree Code:

vProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ |
    PROCESS_VM_WRITE, False, vProcessId);
 vPointer = VirtualAllocEx(vProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT,
    PAGE_READWRITE);
 vItem.mask = LVIF_TEXT;
 vItem.iItem = I;
 vItem.iSubItem = J;
 vItem.cchTextMax = sizeof(vBuffer);
 vItem.pszText = (wchar_t*)vPointer +sizeof(TLVItem);
 WriteProcessMemory(vProcess, vPointer, &vItem, sizeof(TLVItem),
            &vNumberOfBytesRead);
 SendMessageW(mHandle, LVM_GETITEMW, I, (LPARAM)vPointer);
 ReadProcessMemory(vProcess, (wchar_t*)vPointer +sizeof(TLVItem),
            vBuffer, sizeof(vBuffer), &vNumberOfBytesRead);
 RESULT = UnicodeString(vBuffer);

 VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE); // free mem
 CloseHandle(vProcess);
AlexGu
  • 133
  • 1
  • 6

1 Answers1

0

You didn't VirtualAlloc the memory block in the target process, so it isn't there.

Instead of using extreme hackery to try to get this, why not use one of the accessibility APIs to get this info cross-process. UIA, for example, goes down to XP and supports this:

http://msdn.microsoft.com/en-us/library/ms726294(VS.85).aspx

Martyn

Martyn Lovell
  • 2,086
  • 11
  • 13
  • Is it not the memory allocation in another process? vProcess = OpenProcess (PROCESS_VM_OPERATION.... vPointer = VirtualAllocEx (vProcess, .... – AlexGu Jul 14 '11 at 12:09
  • You are right, I missed that. But then you are sending vPointer to SendMessage when vPointer isn't a valid address in the source process. I renew my belief that you should use UIA. – Martyn Lovell Jul 14 '11 at 19:22
  • I ran a utility named UISpy.ehe, and it is unable to obtain a text of the first column, just like my code. The second column normally reads my code...Empty strings... http://i.piccy.info/i5/26/21/1742126/Snymok5.png – AlexGu Jul 15 '11 at 12:55