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 10 BOOL 11 WINAPI 12 InitOnceExecuteOnce( 13 _Inout_ PINIT_ONCE InitOnce, 14 _In_ __callback PINIT_ONCE_FN InitFn, 15 _Inout_opt_ PVOID Parameter, 16 _Outptr_opt_result_maybenull_ LPVOID *Context) 17 { 18 return NT_SUCCESS(RtlRunOnceExecuteOnce(InitOnce, 19 (PRTL_RUN_ONCE_INIT_FN)InitFn, 20 Parameter, 21 Context)); 22 } 23 24 BOOL 25 WINAPI 26 InitOnceBeginInitialize( 27 _Inout_ LPINIT_ONCE lpInitOnce, 28 _In_ DWORD dwFlags, 29 _Out_ PBOOL fPending, 30 _Outptr_opt_result_maybenull_ LPVOID *lpContext) 31 { 32 NTSTATUS Status; 33 34 Status = RtlRunOnceBeginInitialize(lpInitOnce, dwFlags, lpContext); 35 if (!NT_SUCCESS(Status)) 36 { 37 BaseSetLastNTError(Status); 38 return FALSE; 39 } 40 41 *fPending = (Status == STATUS_PENDING); 42 return TRUE; 43 } 44 45 BOOL 46 WINAPI 47 InitOnceComplete( 48 _Inout_ LPINIT_ONCE lpInitOnce, 49 _In_ DWORD dwFlags, 50 _In_opt_ LPVOID lpContext) 51 { 52 NTSTATUS Status; 53 54 Status = RtlRunOnceComplete(lpInitOnce, dwFlags, lpContext); 55 if (!NT_SUCCESS(Status)) 56 { 57 BaseSetLastNTError(Status); 58 return FALSE; 59 } 60 61 return TRUE; 62 } 63