コード例 #1
0
        public bool Set(MemoryHandler Memory)
        {
            this.Memory = Memory;
            Memory.RefreshMemory();
            var process = Memory.Process;

            Address = Memory.GetAddress(Pointer);
            if (Address == null)
            {
                return(false);
            }

            foreach (ProcessThread th in process.Threads)
            {
                if (AffectedThreads.ContainsKey(th.Id))
                {
                    continue;
                }

                var hThread = Kernel32.OpenThread(ThreadAccess.THREAD_ALL_ACCESS, false, th.Id);
                if (hThread == IntPtr.Zero)
                {
                    throw new BreakPointException("Can't open thread for access");
                }

                SetToThread(hThread, th.Id);

                if (!Kernel32.CloseHandle(hThread))
                {
                    throw new BreakPointException("Failed to close thread handle");
                }
            }

            return(true);
        }
コード例 #2
0
        public void UnSet(MemoryHandler Memory)
        {
            Memory.RefreshMemory();
            var process = Memory.Process;

            foreach (ProcessThread th in process.Threads)
            {
                if (!AffectedThreads.ContainsKey(th.Id))
                {
                    continue;
                }

                var hThread = Kernel32.OpenThread(ThreadAccess.THREAD_ALL_ACCESS, false, th.Id);
                if (hThread == IntPtr.Zero)
                {
                    throw new BreakPointException("Can't open thread for access");
                }

                UnsetFromThread(hThread, th.Id);

                if (!Kernel32.CloseHandle(hThread))
                {
                    throw new BreakPointException("Failed to close thread handle");
                }
            }

            AffectedThreads.Clear();
        }