How would I keep a index of Window handles so I can destroy or edit any of the windows? (there can be as many as 100+ windows @ a time)? - handle=hWnd001 name=W001 handle=hWnd002 name=W002 - ex. - .WHILE Index>0 push SW_HIDE push hWnd+Index call ShowWindow dec Index .ENDW -
You can allocate memory from a heap.You can store the handles as a simple array if the exact element number can be determined. If not, store them in a linked list.
Listen to Iczelion on that one.....he's tha fuckin shit! Although, from your code, it looks like you're playin with all the windows. If this is true, why not just play with tha "Desktop Window"??? ________________________________________________________________ .data? ... hDesk dd ? .code ... invoke GetDesktopWindow mov hDesk, EAX _________________________________________________________________
isn't the desktop handle suppose to be always 0 ? (s)
I see you mentioned that linked lists can be used for an unknown number of handles. Can you explain what a linked list is or point me to a tutorial, reference or something? Thnx!
How would I do a linked list or heapalloc?
Linked lists in a nutshell: A linked list is a series of little heap structures that point to the next item in the list. Say you global var pList and have this struct: MyListElement STRUCT pNext DWORD ? hWnd DWORD ? MyListElement ENDS Here is the list with 3 data items in it: pList --> pNext --> pNext --> pNext=0 hWnd hWnd hWnd pList holds a pointer to the first element. The first element.pNext holds a pointer to the 2nd element, and so on till the last element.pNext holds a NULL to indicate the end of the list. You need a few methods to manage the list, such as AddElement to end of list DeleteElement from list FindElement in list based on item DeleteList rolls it all back up and away Your specific application requirements will define what methods you need. Note the list is a type of array that grows each tme you add a single element to it, it can be of any size.Items may be addded or deleted anywhere in the list as long as the pointers are adjusted. Your Add method would do the alloc. HeapAlloc works like this: invoke GetProcessHeap mov hHeap, eax ... ... invoke HeapAlloc hHeap, NULL, SIZEOF MyListElement ; now have a pointer to a fresh element in eax
How can you hold an undetermined number of handles, if you need to change the size of the string that contains the pointers? This seems to be similar to the FAT tables.
"String" size doesn't matter as long as the linking pointers, and the data you are storing, are in the same place in every STRUCT in the chain. Each STRUCT (as in the above example) holds exactly one handle. The big hassle is ensuring the space used is available for reuse, when you no longer need it. Windows already provides several linked lists of your windows. They are used to maintain the window hierarchy. You can navigate the hierarchy with GetParent and GetNextWindow, and maybe with GetWindowLong. Or you could step through a list of windows with the Enum???Windows functions.