RtlRunOnceExecuteOnce - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#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
    );

#endif

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 reference

NtDoc

This function is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (nf-ntddk-rtlrunonceexecuteonce)

RtlRunOnceExecuteOnce function

Description

The RtlRunOnceExecuteOnce performs a one-time initialization.

Parameters

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.

Return value

RtlRunOnceExecuteOnce returns STATUS_SUCCESS if the operation succeeds, or the appropriate NTSTATUS error code if the operation fails.

Syntax

NTSYSAPI NTSTATUS RtlRunOnceExecuteOnce(
  PRTL_RUN_ONCE         RunOnce,
  PRTL_RUN_ONCE_INIT_FN InitFn,
  PVOID                 Parameter,
  PVOID                 *Context
);

Remarks

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.

See also

RTL_RUN_ONCE

RtlRunOnceBeginInitialize

RtlRunOnceComplete

RtlRunOnceInitialize

RunOnceInitialization