> For the complete documentation index, see [llms.txt](https://docs.vezel.dev/ruptura/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vezel.dev/ruptura/tasks/system-access.md).

# System Access

The **Vezel.Ruptura.System** library provides convenient managed wrappers for native Win32 APIs and kernel objects. The focus is primarily on functionality that is not readily available in .NET, but there is still some overlap.

For example, you could enumerate all threads in a process like so:

```csharp
using var snapshot = SnapshotObject.Create(SnapshotFlags.Threads, ProcessObject.CurrentId);

foreach (ThreadSnapshot threadSnapshot in snapshot.EnumerateThreads())
{
    using var thread = ThreadObject.OpenId(threadSnapshot.Id, ThreadAccess.GetLimitedInfo);

    Console.WriteLine($"{thread.Id}: {thread.Description}");
}
```

Instances of classes derived from `KernelObject` (such as the `SnapshotObject` and `ThreadObject` instances in the above code) are thin wrappers around [`SafeHandle`](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) objects, with a few niceties on top, such as a settable `IsInheritable` property and equality operators based on [`CompareObjectHandles`](https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-compareobjecthandles). `KernelObject` inherits from [`CriticalFinalizerObject`](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject), so like `SafeHandle`, you can rely on `KernelObject` instances being usable in finalizers. On top of that, they expose a bunch of relevant Win32 APIs for the particular object type.

Some kernel objects are waitable. This is the case for `ProcessObject` and `ThreadObject`, for example. They derive from `SynchronizationObject` (which derives from `KernelObject`). You could wait for a thread to exit like this:

```csharp
using var thread = ThreadObject.OpenId(id, ThreadAccess.Synchronize);

if (thread.Wait(TimeSpan.FromSeconds(5), alertable: false) == WaitResult.TimedOut)
    throw new TimeoutException();
```

(`WaitResult.Alerted` can only occur if `alertable` is set to `true`. Also, `WaitResult.Abandoned` is only relevant when waiting on a mutex.)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.vezel.dev/ruptura/tasks/system-access.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
