ReactOS 0.4.15-dev-8145-ga541a46
InitOnce.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Win32 Base API
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: One-Time initialization API
5 * COPYRIGHT: Copyright 2023 Ratin Gao <ratin@knsoft.org>
6 */
7
8#include "k32_vista.h"
9
10BOOL
13 _Inout_ PINIT_ONCE InitOnce,
17{
18 return NT_SUCCESS(RtlRunOnceExecuteOnce(InitOnce,
21 Context));
22}
23
24BOOL
27 _Inout_ LPINIT_ONCE lpInitOnce,
29 _Out_ PBOOL fPending,
31{
33
34 Status = RtlRunOnceBeginInitialize(lpInitOnce, dwFlags, lpContext);
35 if (!NT_SUCCESS(Status))
36 {
38 return FALSE;
39 }
40
41 *fPending = (Status == STATUS_PENDING);
42 return TRUE;
43}
44
45BOOL
48 _Inout_ LPINIT_ONCE lpInitOnce,
50 _In_opt_ LPVOID lpContext)
51{
53
54 Status = RtlRunOnceComplete(lpInitOnce, dwFlags, lpContext);
55 if (!NT_SUCCESS(Status))
56 {
58 return FALSE;
59 }
60
61 return TRUE;
62}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
BOOL WINAPI InitOnceBeginInitialize(_Inout_ LPINIT_ONCE lpInitOnce, _In_ DWORD dwFlags, _Out_ PBOOL fPending, _Outptr_opt_result_maybenull_ LPVOID *lpContext)
Definition: InitOnce.c:26
BOOL WINAPI InitOnceComplete(_Inout_ LPINIT_ONCE lpInitOnce, _In_ DWORD dwFlags, _In_opt_ LPVOID lpContext)
Definition: InitOnce.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
#define _Inout_
Definition: ms_sal.h:378
#define _Outptr_opt_result_maybenull_
Definition: ms_sal.h:430
#define _Inout_opt_
Definition: ms_sal.h:379
#define __callback
Definition: ms_sal.h:2876
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define STATUS_PENDING
Definition: ntstatus.h:82
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
_Maybe_raises_SEH_exception_ NTSTATUS NTAPI RtlRunOnceExecuteOnce(_Inout_ PRTL_RUN_ONCE RunOnce, _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ PVOID *Context)
Definition: runonce.c:121
NTSTATUS NTAPI RtlRunOnceComplete(_Inout_ PRTL_RUN_ONCE RunOnce, _In_ ULONG Flags, _In_opt_ PVOID Context)
Definition: runonce.c:73
_Must_inspect_result_ NTSTATUS NTAPI RtlRunOnceBeginInitialize(_Inout_ PRTL_RUN_ONCE RunOnce, _In_ ULONG Flags, _Outptr_opt_result_maybenull_ PVOID *Context)
Definition: runonce.c:22
BOOL(WINAPI * PINIT_ONCE_FN)(_Inout_ PINIT_ONCE InitOnce, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ PVOID *Context)
Definition: winbase.h:3942
PRTL_RUN_ONCE PINIT_ONCE
Definition: winbase.h:3932
PRTL_RUN_ONCE LPINIT_ONCE
Definition: winbase.h:3933
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
BOOL * PBOOL
Definition: windef.h:161
#define WINAPI
Definition: msvc.h:6
_In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn
Definition: rtlfuncs.h:2533
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323
RTL_RUN_ONCE_INIT_FN * PRTL_RUN_ONCE_INIT_FN
Definition: rtltypes.h:325