#ifndef _NTRTL_H
_Must_inspect_result_
NTSYSAPI
NTSTATUS
NTAPI
RtlRunOnceBeginInitialize(
_Inout_ PRTL_RUN_ONCE RunOnce,
_In_ ULONG Flags,
_Outptr_opt_result_maybenull_ PVOID *Context
);
View code on GitHub// ntddk.h
NTSYSAPI NTSTATUS RtlRunOnceBeginInitialize(
[in, out] PRTL_RUN_ONCE RunOnce,
[in] ULONG Flags,
[out] PVOID *Context
);
View the official Windows Driver Kit DDI referenceThis function is documented in Windows Driver Kit.
The RtlRunOnceBeginInitialize routine begins a one-time initialization.
RunOnce [in, out]Pointer to the RTL_RUN_ONCE one-time initialization structure.
Flags [in]Drivers can optionally specify one or more of the following flags:
Perform initialization asynchronously. The driver can perform multiple completion attempts in parallel. If this flag is used, subsequent calls to this routine will fail unless this flag is also specified.
Do not begin initialization, but check to determine if initialization has already occurred. If RtlRunOnceBeginInitialize returns STATUS_SUCCESS, the initialization succeeded, and *Context contains the initialized data.
Context [out]Specifies a pointer to a PVOID variable that receives the initialized data. The value of *Context is valid only when the routine returns STATUS_SUCCESS.
RtlRunOnceBeginInitialize returns one of the following NTSTATUS values:
| Return code | Description |
|---|---|
| STATUS_SUCCESS | The one-time initialization has already completed. The initialized data is stored in the memory location that Context points to. |
| STATUS_PENDING | The caller has successfully begun one-time initialization. The caller now performs the driver-specific initialization steps and then calls RtlRunOnceComplete to complete the initialization. |
Drivers can alternatively perform one-time initialization by calling RtlRunOnceExecuteOnce and supplying a RunOnceInitialization routine.