public static Win32HardwareBreakpoint TrySet(SafeObjectHandle threadHandle, HardwareBreakpointType type, HardwareBreakpointSize size, IntPtr address) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || IntPtr.Size != 8) { throw new PlatformNotSupportedException("Only 64 bit Windows is supported"); } var breakpoint = new Win32HardwareBreakpoint { Address = address, Size = size, Type = type, ThreadHandle = threadHandle }; bool self = threadHandle.DangerousGetHandle() == Win32Thread.GetCurrentThread().DangerousGetHandle(); if (self) { int threadID = GetCurrentThreadId(); breakpoint.ThreadHandle = Win32Thread.OpenThread(ThreadAccess.All, inheritHandle: false, threadID: threadID); if (breakpoint.ThreadHandle.IsInvalid) { throw new Win32Exception(); } } breakpoint.CompletionEvent = Win32Event.CreateEvent(IntPtr.Zero, manualReset: false, initialState: false, name: null); breakpoint.Op = Operation.Set; Win32Thread.ThreadProc threadProc = Win32HardwareBreakpoint.th; var th = Marshal.GetFunctionPointerForDelegate(threadProc); var h = GCHandle.Alloc(breakpoint); if (Win32Thread.CreateThread(IntPtr.Zero, UIntPtr.Zero, th, parameter: (IntPtr)h, creationFlags: 0, out int _).IsInvalid) { throw new Win32Exception(); } WaitForSingleObject(breakpoint.CompletionEvent, dwMilliseconds: Constants.INFINITE); breakpoint.CompletionEvent.Dispose(); if (self) { breakpoint.ThreadHandle.Dispose(); } breakpoint.ThreadHandle = threadHandle; if (!breakpoint.SUCC) { h.Free(); return(null); } breakpoint.gcHandle = h; GC.KeepAlive(threadProc); return(breakpoint); }
public HardwareBreakpoint(IntPtr address, HardwareBreakpointRegister register, HardwareBreakpointTrigger trigger, HardwareBreakpointSize size, BreakpointHandler handler) { Contract.Requires(handler != null); if (register == HardwareBreakpointRegister.InvalidRegister) { throw new InvalidOperationException(); } Address = address; Register = register; Trigger = trigger; Size = size; this.handler = handler; }
public bool SetHardwareBreakpoint(IntPtr id, IntPtr address, HardwareBreakpointRegister register, HardwareBreakpointTrigger trigger, HardwareBreakpointSize size, bool set) { return(CurrentFunctions.SetHardwareBreakpoint(id, address, register, trigger, size, set)); }
public bool SetHardwareBreakpoint(IntPtr id, IntPtr address, HardwareBreakpointRegister register, HardwareBreakpointTrigger trigger, HardwareBreakpointSize size, bool set) { // Not supported. return(false); }
public bool SetHardwareBreakpoint(IntPtr id, IntPtr address, HardwareBreakpointRegister register, HardwareBreakpointTrigger trigger, HardwareBreakpointSize size, bool set) { return(setHardwareBreakpointDelegate(id, address, register, trigger, size, set)); }
public bool SetHardwareBreakpoint(IntPtr id, IntPtr address, HardwareBreakpointRegister register, HardwareBreakpointTrigger trigger, HardwareBreakpointSize size, bool set) { // Do nothing return(false); }