#ifndef _NTRTL_H
_Maybe_raises_SEH_exception_
NTSYSAPI
NTSTATUS
NTAPI
RtlRunOnceExecuteOnce(
_Inout_ PRTL_RUN_ONCE RunOnce,
_In_ __callback PRTL_RUN_ONCE_INIT_FN InitFn,
_Inout_opt_ PVOID Parameter,
_Outptr_opt_result_maybenull_ PVOID *Context
);
View code on GitHub// ntddk.h
NTSYSAPI NTSTATUS RtlRunOnceExecuteOnce(
PRTL_RUN_ONCE RunOnce,
PRTL_RUN_ONCE_INIT_FN InitFn,
PVOID Parameter,
PVOID *Context
);
View the official Windows Driver Kit DDI referenceThis function is documented in Windows Driver Kit.
The RtlRunOnceExecuteOnce performs a one-time initialization.
RunOnce [in, out]A pointer to the RTL_RUN_ONCE one-time initialization structure.
InitFn [in]A pointer to a RunOnceInitialization routine.
Parameter [in, out]The value to pass as the Parameter parameter to the RunOnceInitialization routine.
Context [out]A pointer to a PVOID variable that receives the initialized data.
RtlRunOnceExecuteOnce returns STATUS_SUCCESS if the operation succeeds, or the appropriate NTSTATUS error code if the operation fails.
NTSYSAPI NTSTATUS RtlRunOnceExecuteOnce(
PRTL_RUN_ONCE RunOnce,
PRTL_RUN_ONCE_INIT_FN InitFn,
PVOID Parameter,
PVOID *Context
);
For the first call to RtlRunOnceExecuteOnce for a particular RTL_RUN_ONCE structure, RtlRunOnceExecuteOnce calls the RunOnceInitialization routine to initialize the data. Every subsequent call to RtlRunOnceExecuteOnce for that structure supplies the same initialized data. The RunOnceInitialization routine will not be called twice for the same RTL_RUN_ONCE structure.
RtlRunOnceExecuteOnce runs with normal kernel APCs disabled. The routine should not be called within a special kernel APC unless all calls occur at APC_LEVEL.