Link to home
Start Free TrialLog in
Avatar of Javen
Javen

asked on

Obtain data from an external Treeview

Hi Guys,

First question... hope one of you can help! I am attemtping to retrieve data from a TreeView in an external process. I have successfully connected to the Handle of the Window the TreeView is in, and stepped down to have the handle of the TreeView itself.

I have also successfully retrieved the textual parts of a StatusBar, using VirtualAllocEx in the external process.

// Get process handle
GetWindowThreadProcessID(hMain, @idProcess);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, idProcess);
if hProcess = 0 then RaiseLastWin32Error;

// Allocate buffer in process
pBuf := VirtualAllocEx(hProcess, nil, cBuf, MEM_COMMIT, PAGE_READWRITE);
if pBuf = nil then RaiseLastWin32Error;

//Get the Tree Handles
upTreehWnd := FindWindowEx(upstathwnd,0,'SysTreeView32',nil);
dnTreehWnd := FindWindowEx(dnstathwnd,0,'SysTreeView32',nil);
Form1.ListBox1.Items.Add('Up Tree = ' + inttostr(uptreehwnd) + ', Down Tree = ' + inttostr(dntreehWnd));

//Tree Counts
utrCount := treeview_getcount(uptreehwnd);
dtrCount := treeview_getcount(dntreehwnd);
form1.listbox1.Items.add('UpCount = ' + inttostr(utrCount) + ', DownCount = ' + inttostr(dtrCount));

//Try to get TreeItems
dnRt := treeview_getnextitem(dntreehwnd,0,TVGN_FIRSTVISIBLE);
dnRtN := treeview_getnextitem(dntreehwnd,dnrt, TVGN_NEXTVISIBLE);

//Create a TV_ITEM
dnRtItem.mask := TVIF_HANDLE and TVIF_TEXT;
dnRtItem.pszText := @s;
dnRtItem.cchTextMax := 1024;
dnRtItem.hItem := dnRT;

WHAT I need to do now I believe (from another subject https://www.experts-exchange.com/questions/20096218/Getting-text-from-treeview-from-outside.html) is that I need to write the empty TV_ITEM using WriteProcessItem to the virtual memory in the other process, then call the TreeView_GetItem to populate that item, using the Memory of the other process, and then read it back into the local environment.

//Write the TV_ITEM to the Remote Process
rBln := WriteProcessMemory(hProcess, pointer(pTreeBuf), @pTreeBuf,sizeof(pTreeBuf), nil);

I believe that my problems are in the correct set-up of the local Pointers/Objects and their usage within the WriteProcessMemory function. However I may be wring... I've been using delphi for about 15 days so far...!

Ideally, an Expert will be able to provide me with details of how to set-up the TV_ITEM locally to receive information, how to write the blank TV_ITEM to the external process, how to retrieve the TV_ITEM back to the local process, and then perhaps help get access to the TV_ITEM textual content.

I am a total newbie at this, and I have no idea whether the number of points I have posted is acceptable or not. I'm hoping someone can help regardless.

Javen
Avatar of PeterLarsen
PeterLarsen

listening
Avatar of Javen

ASKER

Hi Peter,

What does listening mean? Is this som3 sort of eXe jargon?

If the question does not have enought points attached, can someone just say so!

Cheers,

Javen
It's just a way to say that i'm listening to this, and i want everybody else to know that i'm here :-)

If you raise the points you will probably get more attention - dont know for sure.
I think the question is to long. Maybe thats the problem.

/Peter
Avatar of Javen

ASKER

Cheers Peter,

I followed the instructions of the eXe Question posting guide, but perhaps I went a bit overboard!

I will endeavour to raise the points...

Javen
Avatar of Javen

ASKER

Points increased...
ASKER CERTIFIED SOLUTION
Avatar of PeterLarsen
PeterLarsen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Javen

ASKER

This question is closed and dead... has been for ages, so I shall close it and award the points to PeterLarsen!