Пример #1
0
        /// <summary>
        ///     A subitem (a column value) of an item of this list view.
        /// </summary>
        public SystemListViewItem this[int index, int subIndex] {
            get {
                LVITEM lvi = new();
                lvi.cchTextMax = 300;
                lvi.iItem      = index;
                lvi.iSubItem   = subIndex;
                lvi.stateMask  = 0xffffffff;
                lvi.mask       = LVIF_IMAGE | LVIF_STATE | LVIF_TEXT;
                ProcessMemoryChunk tc = ProcessMemoryChunk.Alloc(sw.Process, 301);
                lvi.pszText = tc.Location;
                ProcessMemoryChunk lc = ProcessMemoryChunk.AllocStruct(sw.Process, lvi);
                ApiHelper.FailIfZero(SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), LVM_GETITEM, IntPtr.Zero,
                                                              lc.Location));
                lvi = (LVITEM)lc.ReadToStructure(0, typeof(LVITEM));
                lc.Dispose();
                if (lvi.pszText != tc.Location)
                {
                    tc.Dispose();
                    tc = new ProcessMemoryChunk(sw.Process, lvi.pszText, lvi.cchTextMax);
                }

                byte[] tmp   = tc.Read();
                string title = Encoding.Default.GetString(tmp);
                if (title.IndexOf('\0') != -1)
                {
                    title = title.Substring(0, title.IndexOf('\0'));
                }
                int  image = lvi.iImage;
                uint state = lvi.state;
                tc.Dispose();
                return(new SystemListViewItem(sw, index, title, state, image));
            }
        }
Пример #2
0
        /// <summary>
        /// Sets the selected-state of the item.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="selected">if set to <c>true</c> the item will be selected.</param>
        public void SetItemSelectedState(int rowIndex, bool selected)
        {
            LVITEM lvi = new LVITEM();

            lvi.stateMask = (uint)(ListViewItemState.LVIS_SELECTED);
            lvi.state     = selected ? (uint)(ListViewItemState.LVIS_SELECTED) : 0;
            ProcessMemoryChunk lc = ProcessMemoryChunk.AllocStruct(sw.Process, lvi);

            SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), LVM_SETITEMSTATE, new IntPtr(rowIndex), lc.Location);
            lc.Dispose();
        }
Пример #3
0
        private static long GetMemoryAddressOfString(byte[] searchedBytes, Process p)
        {
            //List<int> addrList = new List<int>();
            long addr  = 0;
            int  speed = 1024 * 64;

            for (long j = HumStartAddress; j < HumEndAddress; j += speed)
            {
                ManagedWinapi.ProcessMemoryChunk mem = new ProcessMemoryChunk(p, (IntPtr)j, speed + searchedBytes.Length);

                byte[] bigMem = mem.Read();

                for (int k = 0; k < bigMem.Length - searchedBytes.Length; k++)
                {
                    bool found = true;
                    for (int l = 0; l < searchedBytes.Length; l++)
                    {
                        if (bigMem[k + l] != searchedBytes[l])
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        addr = k + j;
                        break;
                    }
                }
                if (addr != 0)
                {
                    //addrList.Add(addr);
                    //addr = 0;
                    break;
                }
            }
            //return addrList;
            return(addr);
        }
Пример #4
0
 /// <summary>
 /// A subitem (a column value) of an item of this list view.
 /// </summary>
 public SystemListViewItem this[int index, int subIndex]
 {
     get
     {
         LVITEM lvi = new LVITEM();
         lvi.cchTextMax = 300;
         lvi.iItem = index;
         lvi.iSubItem = subIndex;
         lvi.stateMask = 0xffffffff;
         lvi.mask = LVIF_IMAGE | LVIF_STATE | LVIF_TEXT;
         ProcessMemoryChunk tc = ProcessMemoryChunk.Alloc(sw.Process, 301);
         lvi.pszText = tc.Location;
         ProcessMemoryChunk lc = ProcessMemoryChunk.AllocStruct(sw.Process, lvi);
         ApiHelper.FailIfZero(SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), SystemListView.LVM_GETITEM, IntPtr.Zero, lc.Location));
         lvi = (LVITEM)lc.ReadToStructure(0, typeof(LVITEM));
         lc.Dispose();
         if (lvi.pszText != tc.Location)
         {
             tc.Dispose();
             tc = new ProcessMemoryChunk(sw.Process, lvi.pszText, lvi.cchTextMax);
         }
         byte[] tmp = tc.Read();
         string title = Encoding.Default.GetString(tmp);
         if (title.IndexOf('\0') != -1) title = title.Substring(0, title.IndexOf('\0'));
         int image = lvi.iImage;
         uint state = lvi.state;
         tc.Dispose();
         return new SystemListViewItem(sw, index, title, state, image);
     }
 }