Esempio n. 1
0
        private bool RenameCallback(IntPtr hwnd, IntPtr lParam)
        {
            var itemCount = User32.SendMessage(hwnd,
                                               MSG.LVM_GETITEMCOUNT, 0, 0);

            for (var n = 0; n < itemCount; ++n)
            {
                var item = new LVITEMA
                {
                    mask      = LVIF.LVIF_STATE,
                    iItem     = n,
                    stateMask = LVIS.LVIS_SELECTED
                };
                User32.SendMessage(hwnd, MSG.LVM_GETITEMA,
                                   0, ref item);

                if (item.state == 0)
                {
                    continue;
                }
                User32.SendMessage(hwnd, MSG.LVM_EDITLABEL, n, 0);
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public void SelectAll()
        {
            LVITEMA item = new LVITEMA();

            item.mask      = LVIF.LVIF_STATE;
            item.stateMask = LVIS.LVIS_SELECTED;
            item.state     = LVIS.LVIS_SELECTED;
            User32.SendMessage(this.LVHandle, MSG.LVM_SETITEMSTATE, -1, ref item);
        }
Esempio n. 3
0
        public static List <string> GetDesktopItemTextList()
        {
            List <string> lstItems       = new List <string>();
            int           MaxChar        = 0x100;
            IntPtr        handleListView = GetSysListView32();
            int           itemCount      = GetDesktopItemCount(handleListView);

            GetWindowThreadProcessId(handleListView, out uint pid);
            IntPtr handleX = OpenProcess(ProcessAccessFlags.All, false, pid);

            if (handleX == IntPtr.Zero)
            {
                LogText("*** OpenProcess failed ***");
                return(lstItems);
            }

            IntPtr  memLoc = VirtualAllocEx(handleX, IntPtr.Zero, 0x1000, AllocationType.Commit, MemoryProtection.ReadWrite);
            LVITEMA lvItem = new LVITEMA()
            {
                mask = LVIF_TEXT, iSubItem = 0, cchTextMax = MaxChar
            };
            int lvItemSize = Marshal.SizeOf(lvItem);

            byte[] itemBuffer = new byte[lvItemSize];

            for (int i = 0; i < itemCount; i++)
            {
                lvItem.iItem   = i;
                lvItem.pszText = memLoc + 0x300;

                // alloc mem for unmanaged obj
                var lvItemLocalPtr = Marshal.AllocHGlobal(lvItemSize);
                // copy struct to unmanaged space
                Marshal.StructureToPtr(lvItem, lvItemLocalPtr, false);
                // copy unmanaged struct to the target process
                WriteProcessMemory(handleX, memLoc, lvItemLocalPtr, (uint)lvItemSize, IntPtr.Zero);

                SendMessage(handleListView, LVM_GETITEMW, i, memLoc);

                // read updated item from target processs
                ReadProcessMemory(handleX, memLoc, Marshal.UnsafeAddrOfPinnedArrayElement(itemBuffer, 0), (uint)lvItemSize, IntPtr.Zero);
                lvItem = (LVITEMA)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(itemBuffer, 0), typeof(LVITEMA));
                //LogText(String.Format("Response #{0} : {1} | {2} {3}", i + 1, response, strBuffer.ToString("X8"), lvItem.pszText.ToString("X8")));
                string str = ReadString(handleX, lvItem.pszText, MaxChar);
                lstItems.Add(str);

                Marshal.FreeHGlobal(lvItemLocalPtr);
            }

            VirtualFreeEx(handleX, memLoc, 0, AllocationType.Release);
            CloseHandle(handleX);
            return(lstItems);
        }
Esempio n. 4
0
        bool RenameCallback(IntPtr hwnd, IntPtr lParam)
        {
            int itemCount = User32.SendMessage(hwnd,
                                               MSG.LVM_GETITEMCOUNT, 0, 0);

            for (int n = 0; n < itemCount; ++n)
            {
                LVITEMA item = new LVITEMA();
                item.mask      = LVIF.LVIF_STATE;
                item.iItem     = n;
                item.stateMask = LVIS.LVIS_SELECTED;
                User32.SendMessage(hwnd, MSG.LVM_GETITEMA,
                                   0, ref item);

                if (item.state != 0)
                {
                    User32.SendMessage(hwnd, MSG.LVM_EDITLABEL, n, 0);
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 5
0
 public static extern int SendMessage(IntPtr hWnd, MSG Msg,
     int wParam, ref LVITEMA lParam);