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(h Main, @idProcess);
hProcess := OpenProcess(PROCESS_ALL_AC CESS, 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, 'SysTreeVi ew32',nil) ;
dnTreehWnd := FindWindowEx(dnstathwnd,0, 'SysTreeVi ew32',nil) ;
Form1.ListBox1.Items.Add(' Up Tree = ' + inttostr(uptreehwnd) + ', Down Tree = ' + inttostr(dntreehWnd));
//Tree Counts
utrCount := treeview_getcount(uptreehw nd);
dtrCount := treeview_getcount(dntreehw nd);
form1.listbox1.Items.add(' UpCount = ' + inttostr(utrCount) + ', DownCount = ' + inttostr(dtrCount));
//Try to get TreeItems
dnRt := treeview_getnextitem(dntre ehwnd,0,TV GN_FIRSTVI SIBLE);
dnRtN := treeview_getnextitem(dntre ehwnd,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(hProces s, 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
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(h
hProcess := OpenProcess(PROCESS_ALL_AC
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,
dnTreehWnd := FindWindowEx(dnstathwnd,0,
Form1.ListBox1.Items.Add('
//Tree Counts
utrCount := treeview_getcount(uptreehw
dtrCount := treeview_getcount(dntreehw
form1.listbox1.Items.add('
//Try to get TreeItems
dnRt := treeview_getnextitem(dntre
dnRtN := treeview_getnextitem(dntre
//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(hProces
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
listening
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
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
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
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
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
ASKER
Points increased...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This question is closed and dead... has been for ages, so I shall close it and award the points to PeterLarsen!