コード例 #1
0
ファイル: ListViewItem1.cs プロジェクト: thienkimlove/lead
 public static string GetListViewItem(IntPtr hwnd, uint processId, int item, int subItem = 0)
 {
     unsafe
     {
         string stringUni;
         int    num    = 0;
         IntPtr zero   = IntPtr.Zero;
         IntPtr intPtr = IntPtr.Zero;
         IntPtr zero1  = IntPtr.Zero;
         try
         {
             LV_ITEM lVITEM = new LV_ITEM();
             zero1 = Marshal.AllocHGlobal(2048);
             zero  = ListViewItem1.OpenProcess(Win32ProcessAccessType.AllAccess, false, processId);
             if (zero == IntPtr.Zero)
             {
                 throw new ApplicationException("Failed to access process!");
             }
             intPtr = ListViewItem1.VirtualAllocEx(zero, IntPtr.Zero, 2048, Win32AllocationTypes.MEM_COMMIT, Win32MemoryProtection.PAGE_READWRITE);
             if (intPtr == IntPtr.Zero)
             {
                 throw new SystemException("Failed to allocate memory in remote process");
             }
             lVITEM.mask       = 1;
             lVITEM.iItem      = item;
             lVITEM.iSubItem   = subItem;
             lVITEM.pszText    = (char *)(intPtr.ToInt32() + Marshal.SizeOf(typeof(LV_ITEM)));
             lVITEM.cchTextMax = 500;
             if (!ListViewItem1.WriteProcessMemory(zero, intPtr, ref lVITEM, (uint)Marshal.SizeOf(typeof(LV_ITEM)), out num))
             {
                 throw new SystemException("Failed to write to process memory");
             }
             ListViewItem1.SendMessageTimeout(hwnd, 4171, IntPtr.Zero, intPtr, 2, 5000, IntPtr.Zero);
             if (!ListViewItem1.ReadProcessMemory(zero, intPtr, zero1, 2048, out num))
             {
                 throw new SystemException("Failed to read from process memory");
             }
             stringUni = Marshal.PtrToStringUni((IntPtr)(zero1.ToInt32() + Marshal.SizeOf(typeof(LV_ITEM))));
         }
         finally
         {
             if (zero1 != IntPtr.Zero)
             {
                 Marshal.FreeHGlobal(zero1);
             }
             if (intPtr != IntPtr.Zero)
             {
                 ListViewItem1.VirtualFreeEx(zero, intPtr, 0, Win32AllocationTypes.MEM_RELEASE);
             }
             if (zero != IntPtr.Zero)
             {
                 ListViewItem1.CloseHandle(zero);
             }
         }
         return(stringUni);
     }
 }
コード例 #2
0
        // Token: 0x06000577 RID: 1399 RVA: 0x00032FE4 File Offset: 0x000311E4
        public static void SelectListViewItem(IntPtr hwnd, uint processId, int item)
        {
            IntPtr  intPtr  = IntPtr.Zero;
            IntPtr  intPtr2 = IntPtr.Zero;
            IntPtr  intPtr3 = IntPtr.Zero;
            LV_ITEM lv_ITEM = default(LV_ITEM);

            intPtr3           = Marshal.AllocHGlobal(2048);
            intPtr            = ListViewItem1.OpenProcess(Win32ProcessAccessType.AllAccess, false, processId);
            intPtr2           = ListViewItem1.VirtualAllocEx(intPtr, IntPtr.Zero, 2048u, Win32AllocationTypes.MEM_COMMIT, Win32MemoryProtection.PAGE_READWRITE);
            lv_ITEM.state     = 3;
            lv_ITEM.stateMask = 3;
            IntPtr zero = IntPtr.Zero;
            int    num  = 0;

            ListViewItem1.WriteProcessMemory(intPtr, intPtr2, ref lv_ITEM, (uint)Marshal.SizeOf(typeof(LV_ITEM)), out num);
            ListViewItem1.SendMessageTimeout(hwnd, 4139, (IntPtr)item, intPtr2, 2, 5000, IntPtr.Zero);
            ListViewItem1.VirtualFreeEx(intPtr, intPtr2, 0, Win32AllocationTypes.MEM_RELEASE);
            ListViewItem1.CloseHandle(intPtr);
        }
コード例 #3
0
        // Token: 0x06000578 RID: 1400 RVA: 0x000330AC File Offset: 0x000312AC
        public static string GetListViewItem(IntPtr hwnd, uint processId, int item, int subItem = 0)
        {
            int    num     = 0;
            IntPtr intPtr  = IntPtr.Zero;
            IntPtr intPtr2 = IntPtr.Zero;
            IntPtr intPtr3 = IntPtr.Zero;
            string result;

            try
            {
                LV_ITEM lv_ITEM = default(LV_ITEM);
                intPtr3 = Marshal.AllocHGlobal(2048);
                intPtr  = ListViewItem1.OpenProcess(Win32ProcessAccessType.AllAccess, false, processId);
                bool flag = intPtr == IntPtr.Zero;
                if (flag)
                {
                    throw new ApplicationException("Failed to access process!");
                }
                intPtr2 = ListViewItem1.VirtualAllocEx(intPtr, IntPtr.Zero, 2048u, Win32AllocationTypes.MEM_COMMIT, Win32MemoryProtection.PAGE_READWRITE);
                bool flag2 = intPtr2 == IntPtr.Zero;
                if (flag2)
                {
                    throw new SystemException("Failed to allocate memory in remote process");
                }
                lv_ITEM.mask     = 1;
                lv_ITEM.iItem    = item;
                lv_ITEM.iSubItem = subItem;
                unsafe
                {
                    lv_ITEM.pszText = (char *)(intPtr2.ToInt32() + Marshal.SizeOf(typeof(LV_ITEM)));
                }

                lv_ITEM.cchTextMax = 500;
                bool flag3 = ListViewItem1.WriteProcessMemory(intPtr, intPtr2, ref lv_ITEM, (uint)Marshal.SizeOf(typeof(LV_ITEM)), out num);
                bool flag4 = !flag3;
                if (flag4)
                {
                    throw new SystemException("Failed to write to process memory");
                }
                ListViewItem1.SendMessageTimeout(hwnd, 4171, IntPtr.Zero, intPtr2, 2, 5000, IntPtr.Zero);
                flag3 = ListViewItem1.ReadProcessMemory(intPtr, intPtr2, intPtr3, 2048, out num);
                bool flag5 = !flag3;
                if (flag5)
                {
                    throw new SystemException("Failed to read from process memory");
                }
                result = Marshal.PtrToStringUni((IntPtr)(intPtr3.ToInt32() + Marshal.SizeOf(typeof(LV_ITEM))));
            }
            finally
            {
                bool flag6 = intPtr3 != IntPtr.Zero;
                if (flag6)
                {
                    Marshal.FreeHGlobal(intPtr3);
                }
                bool flag7 = intPtr2 != IntPtr.Zero;
                if (flag7)
                {
                    ListViewItem1.VirtualFreeEx(intPtr, intPtr2, 0, Win32AllocationTypes.MEM_RELEASE);
                }
                bool flag8 = intPtr != IntPtr.Zero;
                if (flag8)
                {
                    ListViewItem1.CloseHandle(intPtr);
                }
            }
            return(result);
        }