How do you fix code that works on everything but the listview you need?
-
Hi all, I have a program that needs to pick up the contents of a SysListView in another process. As you are all aware this requires me allocating memory for my strings and the LVITEM structure in the other process, then writing to them and sending the message and then reading from them. My code works, this might seem like a strange post but wait the plot thickens.I tested this program on the task manager, It has four of these SysListViews hanging around so It seemed as good a candidate as any for my experiment. I watch the process locate the window (the title changes so I had to do an enumwindows to find it) then I did an enumchildwindows in order to find all the SyslistViews. Now I getting somewhere I think to my self. I call my home-grown C dll with my window handles and I get the thread and process responsible for these critters. I set my debug priveleges and and ask for my window handle "all access". I allocate my memory watch my lil pointers come back and send my message and readprocessmemory back into my address space, and gleefully see the pointers filled with strings from the task manager. This is where it gets interesting. I change my window title to the name of the the title to the part of the name of the MDI window that I am interested in. I get my handles, my process handle, and allocate my memory, The first call works great, then the problems start ;( The second call to virtualallocex succeeds but the pointes now have the "bad ptr" following the address that was allocated, "that wasn't there on the other window" I think to myself, and sure enough the strings come back empty. So I decide to google this one. Two days of googling and no cigar. While googling I also decided that virtualallocex wasn't to be trusted to find the base address in the other process, so I decided to walk the vad and find my own address, this worked as well, and I locate memory locations large enough to hold my memory , but still no cigar. It works for the task manager but not the target program ;( By this time I have almost read anything I could find on virtualallocex and by passing most of the other virtual memory functions, I fiddled with virtualqueryex and virtualprotectex, trying to find the problem. FormatMessage came to mind pretty quickly but "The operation completed successfully" isn't much help when trying to debug code that is anything but successful. At this point let me try to give you a description of my environment: Window XP PRO SP2 latest updates. VS.NET 2003,
-
Hi all, I have a program that needs to pick up the contents of a SysListView in another process. As you are all aware this requires me allocating memory for my strings and the LVITEM structure in the other process, then writing to them and sending the message and then reading from them. My code works, this might seem like a strange post but wait the plot thickens.I tested this program on the task manager, It has four of these SysListViews hanging around so It seemed as good a candidate as any for my experiment. I watch the process locate the window (the title changes so I had to do an enumwindows to find it) then I did an enumchildwindows in order to find all the SyslistViews. Now I getting somewhere I think to my self. I call my home-grown C dll with my window handles and I get the thread and process responsible for these critters. I set my debug priveleges and and ask for my window handle "all access". I allocate my memory watch my lil pointers come back and send my message and readprocessmemory back into my address space, and gleefully see the pointers filled with strings from the task manager. This is where it gets interesting. I change my window title to the name of the the title to the part of the name of the MDI window that I am interested in. I get my handles, my process handle, and allocate my memory, The first call works great, then the problems start ;( The second call to virtualallocex succeeds but the pointes now have the "bad ptr" following the address that was allocated, "that wasn't there on the other window" I think to myself, and sure enough the strings come back empty. So I decide to google this one. Two days of googling and no cigar. While googling I also decided that virtualallocex wasn't to be trusted to find the base address in the other process, so I decided to walk the vad and find my own address, this worked as well, and I locate memory locations large enough to hold my memory , but still no cigar. It works for the task manager but not the target program ;( By this time I have almost read anything I could find on virtualallocex and by passing most of the other virtual memory functions, I fiddled with virtualqueryex and virtualprotectex, trying to find the problem. FormatMessage came to mind pretty quickly but "The operation completed successfully" isn't much help when trying to debug code that is anything but successful. At this point let me try to give you a description of my environment: Window XP PRO SP2 latest updates. VS.NET 2003,
Is the following utility successful in getting the contents of the list view? FWIW, here is a clever utility that copies the text of another process's controls to the clipboard. The controls that are supported are Edit (including obscured password edits), Static, Headers, Listview, ComboBox and ListBox. Source code (GPL'd) is included: "Control Content Saver" by Jacquelin Potier at http://jacquelin.potier.free.fr/controlcontentsaver/[^] If the code at the above site works, whereas yours doesn't, then compare code. If the code at the site doesn't work either, then you might not be looking at an ordinary list view control. Are you 100% certain that the windows class is SysListView(32)? Double-check with Spy++. If it's definitely a SysListView, then also check the style flags. Maybe it's an owner-data (i.e., a virtual list view) or owner-drawn, or both. Mike