public void KphDuplicateObject( int sourceProcessHandle, int sourceHandle, int targetProcessHandle, int targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { byte[] data = new byte[7 * sizeof(int)]; fixed(byte *dataPtr = data) { *(int *)(dataPtr + 0x0) = sourceProcessHandle; *(int *)(dataPtr + 0x4) = sourceHandle; *(int *)(dataPtr + 0x8) = targetProcessHandle; *(int *)(dataPtr + 0xc) = targetHandle; *(int *)(dataPtr + 0x10) = desiredAccess; *(int *)(dataPtr + 0x14) = (int)handleAttributes; *(int *)(dataPtr + 0x18) = (int)options; _fileHandle.IoControl(CtlCode(Control.KphDuplicateObject), data, null); } }
public static void SetHandleInformation(SafeHandle handle, HandleFlags mask, HandleFlags flags) { if (!NativeSetHandleInformation(handle, mask, flags)) { throw new Win32Exception(); } }
public void SetHandleAttributes(ProcessHandle processHandle, IntPtr handle, HandleFlags flags) { byte *inData = stackalloc byte[12]; *(int *)inData = processHandle; *(int *)(inData + 4) = handle.ToInt32(); *(int *)(inData + 8) = (int)flags; _fileHandle.IoControl(CtlCode(Control.SetHandleAttributes), inData, 12, null, 0); }
public static unsafe void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { IntPtr dummy; DuplicateObject( sourceProcessHandle, sourceHandle, IntPtr.Zero, out dummy, desiredAccess, handleAttributes, options ); }
public unsafe static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { IntPtr dummy; DuplicateObject( sourceProcessHandle, sourceHandle, IntPtr.Zero, out dummy, desiredAccess, handleAttributes, options ); }
public static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, IntPtr targetProcessHandle, out IntPtr targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { NtDuplicateObject( sourceProcessHandle, sourceHandle, targetProcessHandle, out targetHandle, desiredAccess, handleAttributes, options ).ThrowIf(); }
public unsafe static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, IntPtr targetProcessHandle, out IntPtr targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { if (KProcessHacker.Instance != null) { int target; KProcessHacker.Instance.KphDuplicateObject( sourceProcessHandle.ToInt32(), sourceHandle.ToInt32(), targetProcessHandle.ToInt32(), out target, desiredAccess, handleAttributes, options); targetHandle = new IntPtr(target); } else { NtStatus status; if ((status = NtDuplicateObject( sourceProcessHandle, sourceHandle, targetProcessHandle, out targetHandle, desiredAccess, handleAttributes, options)) >= NtStatus.Error) { Throw(status); } } }
protected override void BeginProcessing() { if (Inherit) { _flags |= HandleFlags.Inherit; } if (ProtectFromClose) { _flags |= HandleFlags.ProtectFromClose; } if (Clear) { _mask = HandleFlags.Inherit | HandleFlags.ProtectFromClose; } else { _mask = _flags; } }
public void KphDuplicateObject( int sourceProcessHandle, int sourceHandle, int targetProcessHandle, out int targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { int handle; KphDuplicateObject( sourceProcessHandle, sourceHandle, targetProcessHandle, (int)&handle, desiredAccess, handleAttributes, options ); targetHandle = handle; }
private void inheritMenuItem_Click(object sender, EventArgs e) { HandleItem item = (HandleItem)listHandles.SelectedItems[0].Tag; HandleFlags flags = item.Handle.Flags; if ((flags & HandleFlags.Inherit) != 0) { flags &= ~HandleFlags.Inherit; } else { flags |= HandleFlags.Inherit; } try { //using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) //KProcessHacker.Instance.SetHandleAttributes(phandle, new IntPtr(item.Handle.Handle), flags); } catch (Exception ex) { PhUtils.ShowException("Unable to set handle attributes", ex); } }
public static extern bool SetHandleInformation(SafeHandle handle, HandleFlags dwMask, HandleFlags dwFlags);
private static extern bool SetHandleInformation(SafeFileHandle hObject, HandleFlags dwMask, HandleFlags dwFlags);
internal static extern bool SetHandleInformation(IntPtr handle, HandleFlags dwMask, HandleFlags dwFlags);
public void KphDuplicateObject( int sourceProcessHandle, int sourceHandle, int targetProcessHandle, int targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { byte[] data = new byte[7 * sizeof(int)]; fixed (byte* dataPtr = data) { *(int*)(dataPtr + 0x0) = sourceProcessHandle; *(int*)(dataPtr + 0x4) = sourceHandle; *(int*)(dataPtr + 0x8) = targetProcessHandle; *(int*)(dataPtr + 0xc) = targetHandle; *(int*)(dataPtr + 0x10) = desiredAccess; *(int*)(dataPtr + 0x14) = (int)handleAttributes; *(int*)(dataPtr + 0x18) = (int)options; _fileHandle.IoControl(CtlCode(Control.KphDuplicateObject), data, null); } }
public unsafe static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, IntPtr targetProcessHandle, out IntPtr targetHandle, int desiredAccess, HandleFlags handleAttributes, DuplicateOptions options ) { if (KProcessHacker.Instance != null) { int target; KProcessHacker.Instance.KphDuplicateObject( sourceProcessHandle.ToInt32(), sourceHandle.ToInt32(), targetProcessHandle.ToInt32(), out target, desiredAccess, handleAttributes, options); targetHandle = new IntPtr(target); } else { NtStatus status; if ((status = NtDuplicateObject( sourceProcessHandle, sourceHandle, targetProcessHandle, out targetHandle, desiredAccess, handleAttributes, options)) >= NtStatus.Error) ThrowLastError(status); } }
public static extern Bool SetHandleInformation(IntPtr handle, HandleFlags change, HandleFlags value);
static extern bool SetHandleInformation(IntPtr hObject, HandleFlags dwMask, HandleFlags dwFlags);
private static extern bool SetHandleInformation(IntPtr hObject, HandleFlags dwMask, HandleFlags dwFlags);
internal static partial bool SetHandleInformation(SafeHandle hObject, HandleFlags dwMask, HandleFlags dwFlags);
private static extern bool NativeGetHandleInformation( SafeHandle hObject, out HandleFlags lpdwFlags );
public static extern bool GetHandleInformation(SafeHandle handle, out HandleFlags lpdwFlags);
void SetFlags(HandleFlags mask, HandleFlags value) { UnsafeNativeMethods.SetHandleInformation(m_handle, (uint)mask, (uint)value).EnsureNoWin32Error(); }
public static extern bool SetHandleInformation(IntPtr handle, HandleFlags dwMask, HandleFlags dwFlags);
public void SetHandleAttributes(ProcessHandle processHandle, IntPtr handle, HandleFlags flags) { byte* inData = stackalloc byte[12]; *(int*)inData = processHandle; *(int*)(inData + 4) = handle.ToInt32(); *(int*)(inData + 8) = (int)flags; _fileHandle.IoControl(CtlCode(Control.SetHandleAttributes), inData, 12, null, 0); }
public static extern bool GetHandleInformation(IntPtr handle, out HandleFlags lpdwFlags);