public TransactionHandle( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, Guid unitOfWorkGuid, TmHandle tmHandle, TransactionAccess access ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtOpenTransaction( out handle, access, ref oa, ref unitOfWorkGuid, tmHandle ?? IntPtr.Zero )) >= NtStatus.Error) { Win32.ThrowLastError(status); } } finally { oa.Dispose(); } this.Handle = handle; }
public ResourceManagerHandle( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmHandle tmHandle, Guid guid, ResourceManagerAccess access ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtOpenResourceManager( out handle, access, tmHandle, ref guid, ref oa )) >= NtStatus.Error) { Win32.ThrowLastError(status); } } finally { oa.Dispose(); } this.Handle = handle; }
public EnlistmentHandle( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, ResourceManagerHandle resourceManagerHandle, Guid guid, EnlistmentAccess access ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtOpenEnlistment( out handle, access, resourceManagerHandle, ref guid, ref oa ).ThrowIf(); } finally { oa.Dispose(); } this.Handle = handle; }
public static PortHandle Create( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int maxConnectionInfoLength, int maxMessageLength, int maxPoolUsage ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreatePort( out handle, ref oa, maxConnectionInfoLength, maxMessageLength, maxPoolUsage ).ThrowIf(); } finally { oa.Dispose(); } return(new PortHandle(handle, true)); }
public static PortHandle CreateWaitable( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int maxConnectionInfoLength, int maxMessageLength, int maxPoolUsage ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtCreateWaitablePort( out handle, ref oa, maxConnectionInfoLength, maxMessageLength, maxPoolUsage )) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } return(new PortHandle(handle, true)); }
public static EnlistmentHandle Create( EnlistmentAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, ResourceManagerHandle resourceManagerHandle, TransactionHandle transactionHandle, EnlistmentOptions createOptions, NotificationMask notificationMask, IntPtr enlistmentKey ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateEnlistment( out handle, access, resourceManagerHandle, transactionHandle, ref oa, createOptions, notificationMask, enlistmentKey ).ThrowIf(); } finally { oa.Dispose(); } return(new EnlistmentHandle(handle, true)); }
public static TmHandle Create( TmAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, string logFileName, TmOptions createOptions ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); UnicodeString logFileNameStr = new UnicodeString(logFileName); IntPtr handle; try { Win32.NtCreateTransactionManager( out handle, access, ref oa, ref logFileNameStr, createOptions, 0 ).ThrowIf(); } finally { logFileNameStr.Dispose(); oa.Dispose(); } return(new TmHandle(handle, true)); }
public static ThreadHandle Create( ThreadAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, ProcessHandle processHandle, out ClientId clientId, ref Context threadContext, ref InitialTeb initialTeb, bool createSuspended ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateThread( out handle, access, ref oa, processHandle, out clientId, ref threadContext, ref initialTeb, createSuspended ).ThrowIf(); } finally { oa.Dispose(); } return(new ThreadHandle(handle, true)); }
public TmHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmAccess access) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtOpenTransactionManager( out handle, access, ref oa, IntPtr.Zero, IntPtr.Zero, 0 )) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } this.Handle = handle; }
public TransactionHandle( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, Guid unitOfWorkGuid, TmHandle tmHandle, TransactionAccess access ) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtOpenTransaction( out handle, access, ref oa, ref unitOfWorkGuid, tmHandle ?? IntPtr.Zero ).ThrowIf(); } finally { oa.Dispose(); } this.Handle = handle; }
public DirectoryHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DirectoryAccess access) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if (KProcessHacker.Instance != null) { handle = KProcessHacker.Instance.KphOpenDirectoryObject(access, oa).ToIntPtr(); } else { if ((status = Win32.NtOpenDirectoryObject(out handle, access, ref oa)) >= NtStatus.Error) { Win32.Throw(status); } } } finally { oa.Dispose(); } this.Handle = handle; }
public static TokenHandle Create( TokenAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TokenType tokenType, Luid authenticationId, long expirationTime, Sid user, Sid[] groups, PrivilegeSet privileges, Sid owner, Sid primaryGroup, Acl defaultDacl, TokenSource source ) { NtStatus status; TokenUser tokenUser = new TokenUser(user); TokenGroups tokenGroups = new TokenGroups(groups); TokenPrivileges tokenPrivileges = new TokenPrivileges(privileges); TokenOwner tokenOwner = new TokenOwner(owner); TokenPrimaryGroup tokenPrimaryGroup = new TokenPrimaryGroup(primaryGroup); TokenDefaultDacl tokenDefaultDacl = new TokenDefaultDacl(defaultDacl); ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtCreateToken( out handle, access, ref oa, tokenType, ref authenticationId, ref expirationTime, ref tokenUser, ref tokenGroups, ref tokenPrivileges, ref tokenOwner, ref tokenPrimaryGroup, ref tokenDefaultDacl, ref source )) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } return(new TokenHandle(handle, true)); }
public static SectionHandle Create( SectionAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, long maximumSize, SectionAttributes sectionAttributes, MemoryProtection pageAttributes, FileHandle fileHandle ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if (maximumSize != 0) { if ((status = Win32.NtCreateSection( out handle, access, ref oa, ref maximumSize, pageAttributes, sectionAttributes, fileHandle ?? IntPtr.Zero )) >= NtStatus.Error) { Win32.Throw(status); } } else { if ((status = Win32.NtCreateSection( out handle, access, ref oa, IntPtr.Zero, pageAttributes, sectionAttributes, fileHandle ?? IntPtr.Zero )) >= NtStatus.Error) { Win32.Throw(status); } } } finally { oa.Dispose(); } return(new SectionHandle(handle, true)); }
public static TransactionHandle Create( TransactionAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, Guid unitOfWorkGuid, TmHandle tmHandle, TransactionOptions createOptions, long timeout, string description ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; if (unitOfWorkGuid == Guid.Empty) { unitOfWorkGuid = Guid.NewGuid(); } try { UnicodeString descriptionStr = new UnicodeString(description); try { if ((status = Win32.NtCreateTransaction( out handle, access, ref oa, ref unitOfWorkGuid, tmHandle ?? IntPtr.Zero, createOptions, 0, 0, ref timeout, ref descriptionStr )) >= NtStatus.Error) { Win32.Throw(status); } } finally { descriptionStr.Dispose(); } } finally { oa.Dispose(); } return(new TransactionHandle(handle, true)); }
public DriverHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); try { this.Handle = KProcessHacker.Instance.KphOpenDriver(oa).ToIntPtr(); } finally { oa.Dispose(); } }
public static PortHandle CreateWaitable( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory ) { return(CreateWaitable( name, objectFlags, rootDirectory, Win32.PortMessageMaxDataLength, Win32.PortMessageMaxLength, 0 )); }
public KeyedEventHandle(string name, DirectoryHandle rootDirectory, ObjectFlags objectFlags, KeyedEventAccess access) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtOpenKeyedEvent(out handle, access, ref oa).ThrowIf(); } finally { oa.Dispose(); } this.Handle = handle; }
public SemaphoreHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, SemaphoreAccess access) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtOpenSemaphore(out handle, access, ref oa).ThrowIf(); } finally { oa.Dispose(); } this.Handle = handle; }
public ThreadHandle( string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, ClientId clientId, ThreadAccess access ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if (clientId.ProcessId == 0 && clientId.ThreadId == 0) { if ((status = Win32.NtOpenThread( out handle, access, ref oa, IntPtr.Zero )) >= NtStatus.Error) { Win32.Throw(status); } } else { if ((status = Win32.NtOpenThread( out handle, access, ref oa, ref clientId )) >= NtStatus.Error) { Win32.Throw(status); } } } finally { oa.Dispose(); } this.Handle = handle; }
public static ResourceManagerHandle Create( ResourceManagerAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmHandle tmHandle, Guid guid, ResourceManagerOptions createOptions, string description ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { UnicodeString descriptionStr = new UnicodeString(description); try { if ((status = Win32.NtCreateResourceManager( out handle, access, tmHandle, ref guid, ref oa, createOptions, ref descriptionStr )) >= NtStatus.Error) { Win32.ThrowLastError(status); } } finally { descriptionStr.Dispose(); } } finally { oa.Dispose(); } return(new ResourceManagerHandle(handle, true)); }
public static TmHandle Create( TmAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, string logFileName, TmOptions createOptions ) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { UnicodeString logFileNameStr = new UnicodeString(logFileName); try { if ((status = Win32.NtCreateTransactionManager( out handle, access, ref oa, ref logFileNameStr, createOptions, 0 )) >= NtStatus.Error) { Win32.ThrowLastError(status); } } finally { logFileNameStr.Dispose(); } } finally { oa.Dispose(); } return(new TmHandle(handle, true)); }
public SectionHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, SectionAccess access) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtOpenSection(out handle, access, ref oa)) >= NtStatus.Error) { Win32.ThrowLastError(status); } } finally { oa.Dispose(); } this.Handle = handle; }
public TmHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmAccess access) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtOpenTransactionManager( out handle, access, ref oa, IntPtr.Zero, IntPtr.Zero, 0 ).ThrowIf(); } finally { oa.Dispose(); } this.Handle = handle; }
public static SemaphoreHandle Create(SemaphoreAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int initialCount, int maximumCount) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateSemaphore( out handle, access, ref oa, initialCount, maximumCount ).ThrowIf(); } finally { oa.Dispose(); } return(new SemaphoreHandle(handle, true)); }
public static DebugObjectHandle Create(DebugObjectAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DebugObjectFlags flags) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtCreateDebugObject( out handle, access, ref oa, flags )) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } return(new DebugObjectHandle(handle, true)); }
public static IoCompletionHandle Create(IoCompletionAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int count) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateIoCompletion(out handle, access, ref oa, count).ThrowIf(); } finally { oa.Dispose(); } return(new IoCompletionHandle(handle, true)); }
public static DebugObjectHandle Create(DebugObjectAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DebugObjectFlags flags) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { Win32.NtCreateDebugObject( out handle, access, ref oa, flags ).ThrowIf(); } finally { oa.Dispose(); } return new DebugObjectHandle(handle, true); }
public static MutantHandle Create(MutantAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, bool initialOwner) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtCreateMutant(out handle, access, ref oa, initialOwner)) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } return(new MutantHandle(handle, true)); }
public static SymbolicLinkHandle Create(SymbolicLinkAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, string linkTarget) { ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { UnicodeString linkTargetString = new UnicodeString(linkTarget); try { Win32.NtCreateSymbolicLinkObject( out handle, access, ref oa, ref linkTargetString ).ThrowIf(); } finally { linkTargetString.Dispose(); } } finally { oa.Dispose(); } return(new SymbolicLinkHandle(handle, true)); }
/// <summary> /// Creates a timer. /// </summary> /// <param name="access">The desired access to the timer.</param> /// <param name="name">A name for the timer in the object manager namespace.</param> /// <param name="objectFlags">The flags to use when creating the object.</param> /// <param name="rootDirectory">The directory in which to place the timer. This can be null.</param> /// <param name="type"> /// The type of timer; synchronization timers will be reset once waiting threads are released. /// </param> /// <returns>A handle to the timer.</returns> public static TimerHandle Create(TimerAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TimerType type) { NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { if ((status = Win32.NtCreateTimer(out handle, access, ref oa, type)) >= NtStatus.Error) { Win32.Throw(status); } } finally { oa.Dispose(); } return(new TimerHandle(handle, true)); }