ReactOS 0.4.16-dev-732-g2d1144a
winapi_thunks.cpp File Reference
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <ntsecapi.h>
#include <corecrt_internal.h>
#include <appmodel.h>
#include <roapi.h>
Include dependency graph for winapi_thunks.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{winapi_thunks.cpp}
 

Macros

#define _ACRT_APPLY_TO_LATE_BOUND_MODULES_0
 
#define _ACRT_APPLY_TO_LATE_BOUND_MODULES_1    _APPLY(api_ms_win_core_fibers_l1_1_0, "api-ms-win-core-fibers-l1-1-0" )
 
#define _ACRT_APPLY_TO_LATE_BOUND_MODULES
 
#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_0
 
#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_1
 
#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS
 
#define _APPLY(_SYMBOL, _NAME)   _SYMBOL,
 
#define _APPLY(_SYMBOL, _NAME)   _CRT_WIDE(_NAME),
 
#define _APPLY(_FUNCTION, _MODULES)   _CRT_CONCATENATE(_FUNCTION, _id),
 
#define _APPLY(_FUNCTION, _MODULES)    using _CRT_CONCATENATE(_FUNCTION, _pft) = decltype(_FUNCTION)*;
 
#define _APPLY(_FUNCTION, _MODULES)
 

Enumerations

enum  anonymous_namespace{winapi_thunks.cpp}::module_id : unsigned { anonymous_namespace{winapi_thunks.cpp}::module_id_count }
 
enum  anonymous_namespace{winapi_thunks.cpp}::function_id : unsigned { anonymous_namespace{winapi_thunks.cpp}::function_id_count }
 

Functions

WINBASEAPI _Success_ (return > 0 &&return< BufferLength) DWORD WINAPI GetTempPath2W(_In_ DWORD BufferLength
 Deletes the virtual mapping and optionally gives back the page & dirty bit.
 
WINBASEAPI _Out_writes_to_opt_ (BufferLength, return+1) LPWSTR Buffer)
 
WINBASEAPI DWORD64 WINAPI GetEnabledXStateFeatures ()
 
_Must_inspect_result_ WINBASEAPI BOOL WINAPI GetXStateFeaturesMask (_In_ PCONTEXT context, _Out_ PDWORD64 feature_mask)
 
 _Success_ (return !=NULL) extern "C" WINBASEAPI PVOID WINAPI LocateXStateFeature(_In_ PCONTEXT context
 
bool __cdecl __acrt_initialize_winapi_thunks ()
 
bool __cdecl __acrt_uninitialize_winapi_thunks (bool const terminating)
 
static __forceinline void *__cdecl invalid_function_sentinel () throw ()
 
static HMODULE __cdecl try_load_library_from_system_directory (wchar_t const *const name) throw ()
 
static HMODULE __cdecl try_get_module (module_id const id) throw ()
 
static HMODULE __cdecl try_get_first_available_module (module_id const *const first, module_id const *const last) throw ()
 
static __forceinline void *__cdecl try_get_proc_address_from_first_available_module (char const *const name, module_id const *const first_module_id, module_id const *const last_module_id) throw ()
 
static void *__cdecl try_get_function (function_id const id, char const *const name, module_id const *const first_module_id, module_id const *const last_module_id) throw ()
 
_ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS BOOL WINAPI __acrt_AreFileApisANSI ()
 
int WINAPI __acrt_CompareStringEx (LPCWSTR const locale_name, DWORD const flags, LPCWCH const string1, int const string1_count, LPCWCH const string2, int const string2_count, LPNLSVERSIONINFO const version, LPVOID const reserved, LPARAM const param)
 
static BOOL enum_system_locales_ex_nolock (LOCALE_ENUMPROCEX const enum_proc) throw ()
 
BOOL WINAPI __acrt_EnumSystemLocalesEx (LOCALE_ENUMPROCEX const enum_proc, DWORD const flags, LPARAM const param, LPVOID const reserved)
 
DWORD WINAPI __acrt_FlsAlloc (PFLS_CALLBACK_FUNCTION const callback)
 
BOOL WINAPI __acrt_FlsFree (DWORD const fls_index)
 
PVOID WINAPI __acrt_FlsGetValue (DWORD const fls_index)
 
BOOL WINAPI __acrt_FlsSetValue (DWORD const fls_index, PVOID const fls_data)
 
int WINAPI __acrt_GetDateFormatEx (LPCWSTR const locale_name, DWORD const flags, SYSTEMTIME CONST *const date, LPCWSTR const format, LPWSTR const buffer, int const buffer_count, LPCWSTR const calendar)
 
int WINAPI __acrt_GetTempPath2W (DWORD nBufferLength, LPWSTR lpBuffer)
 
DWORD64 WINAPI __acrt_GetEnabledXStateFeatures ()
 
int WINAPI __acrt_GetLocaleInfoEx (LPCWSTR const locale_name, LCTYPE const lc_type, LPWSTR const data, int const data_count)
 
VOID WINAPI __acrt_GetSystemTimePreciseAsFileTime (LPFILETIME const system_time)
 
int WINAPI __acrt_GetTimeFormatEx (LPCWSTR const locale_name, DWORD const flags, SYSTEMTIME CONST *const time, LPCWSTR const format, LPWSTR const buffer, int const buffer_count)
 
int WINAPI __acrt_GetUserDefaultLocaleName (LPWSTR const locale_name, int const locale_name_count)
 
BOOL WINAPI __acrt_GetXStateFeaturesMask (PCONTEXT const context, PDWORD64 const feature_mask)
 
BOOL WINAPI __acrt_InitializeCriticalSectionEx (LPCRITICAL_SECTION const critical_section, DWORD const spin_count, DWORD const flags)
 
BOOL WINAPI __acrt_IsValidLocaleName (LPCWSTR const locale_name)
 
int WINAPI __acrt_LCMapStringEx (LPCWSTR const locale_name, DWORD const flags, LPCWSTR const source, int const source_count, LPWSTR const destination, int const destination_count, LPNLSVERSIONINFO const version, LPVOID const reserved, LPARAM const sort_handle)
 
int WINAPI __acrt_LCIDToLocaleName (LCID const locale, LPWSTR const name, int const name_count, DWORD const flags)
 
LCID WINAPI __acrt_LocaleNameToLCID (LPCWSTR const name, DWORD const flags)
 
PVOID WINAPI __acrt_LocateXStateFeature (PCONTEXT const content, DWORD const feature_id, PDWORD const length)
 
int WINAPI __acrt_MessageBoxA (HWND const hwnd, LPCSTR const text, LPCSTR const caption, UINT const type)
 
int WINAPI __acrt_MessageBoxW (HWND const hwnd, LPCWSTR const text, LPCWSTR const caption, UINT const type)
 
BOOLEAN WINAPI __acrt_RtlGenRandom (PVOID const buffer, ULONG const buffer_count)
 
HRESULT WINAPI __acrt_RoInitialize (RO_INIT_TYPE const init_type)
 
void WINAPI __acrt_RoUninitialize ()
 
LONG WINAPI __acrt_AppPolicyGetProcessTerminationMethodInternal (_Out_ AppPolicyProcessTerminationMethod *policy)
 
LONG WINAPI __acrt_AppPolicyGetThreadInitializationTypeInternal (_Out_ AppPolicyThreadInitializationType *policy)
 
LONG WINAPI __acrt_AppPolicyGetShowDeveloperDiagnosticInternal (_Out_ AppPolicyShowDeveloperDiagnostic *policy)
 
LONG WINAPI __acrt_AppPolicyGetWindowingModelInternal (_Out_ AppPolicyWindowingModel *policy)
 
BOOL WINAPI __acrt_SetThreadStackGuarantee (PULONG const stack_size_in_bytes)
 
bool __cdecl __acrt_can_show_message_box ()
 
bool __cdecl __acrt_can_use_vista_locale_apis ()
 
void __cdecl __acrt_eagerly_load_locale_apis ()
 
bool __cdecl __acrt_can_use_xstate_apis ()
 
HWND __cdecl __acrt_get_parent_window ()
 
bool __cdecl __acrt_is_interactive ()
 

Variables

_In_ DWORD feature_id
 
_In_ DWORD _Out_opt_ PDWORD length
 
static wchar_t const *const anonymous_namespace{winapi_thunks.cpp}::module_names [module_id_count]
 
static HMODULE module_handles [module_id_count]
 
static voidencoded_function_pointers [function_id_count]
 

Macro Definition Documentation

◆ _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS

#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS
Value:
_ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_0 \
_ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_1 \

Definition at line 136 of file winapi_thunks.cpp.

◆ _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_0

#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_0

Definition at line 89 of file winapi_thunks.cpp.

◆ _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_1

#define _ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS_1
Value:
_APPLY(FlsAlloc, ({ api_ms_win_core_fibers_l1_1_0, kernel32 })) \
_APPLY(FlsFree, ({ api_ms_win_core_fibers_l1_1_0, kernel32 })) \
_APPLY(FlsGetValue, ({ api_ms_win_core_fibers_l1_1_0, kernel32 })) \
_APPLY(FlsSetValue, ({ api_ms_win_core_fibers_l1_1_0, kernel32 }))
PVOID WINAPI FlsGetValue(DWORD dwFlsIndex)
Definition: fiber.c:460
BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
Definition: fiber.c:481
BOOL WINAPI FlsFree(DWORD dwFlsIndex)
Definition: fiber.c:400
DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
Definition: fiber.c:341
#define _APPLY(_SYMBOL, _NAME)

Definition at line 128 of file winapi_thunks.cpp.

◆ _ACRT_APPLY_TO_LATE_BOUND_MODULES

#define _ACRT_APPLY_TO_LATE_BOUND_MODULES
Value:
_ACRT_APPLY_TO_LATE_BOUND_MODULES_0 \
_ACRT_APPLY_TO_LATE_BOUND_MODULES_1 \

Definition at line 85 of file winapi_thunks.cpp.

◆ _ACRT_APPLY_TO_LATE_BOUND_MODULES_0

#define _ACRT_APPLY_TO_LATE_BOUND_MODULES_0
Value:
_APPLY(api_ms_win_core_datetime_l1_1_1, "api-ms-win-core-datetime-l1-1-1" ) \
_APPLY(api_ms_win_core_file_l1_2_4, "api-ms-win-core-file-l1-2-4" ) \
_APPLY(api_ms_win_core_file_l1_2_2, "api-ms-win-core-file-l1-2-2" ) \
_APPLY(api_ms_win_core_localization_l1_2_1, "api-ms-win-core-localization-l1-2-1" ) \
_APPLY(api_ms_win_core_localization_obsolete_l1_2_0, "api-ms-win-core-localization-obsolete-l1-2-0") \
_APPLY(api_ms_win_core_processthreads_l1_1_2, "api-ms-win-core-processthreads-l1-1-2" ) \
_APPLY(api_ms_win_core_string_l1_1_0, "api-ms-win-core-string-l1-1-0" ) \
_APPLY(api_ms_win_core_synch_l1_2_0, "api-ms-win-core-synch-l1-2-0" ) \
_APPLY(api_ms_win_core_sysinfo_l1_2_1, "api-ms-win-core-sysinfo-l1-2-1" ) \
_APPLY(api_ms_win_core_winrt_l1_1_0, "api-ms-win-core-winrt-l1-1-0" ) \
_APPLY(api_ms_win_core_xstate_l2_1_0, "api-ms-win-core-xstate-l2-1-0" ) \
_APPLY(api_ms_win_rtcore_ntuser_window_l1_1_0, "api-ms-win-rtcore-ntuser-window-l1-1-0" ) \
_APPLY(api_ms_win_security_systemfunctions_l1_1_0, "api-ms-win-security-systemfunctions-l1-1-0" ) \
_APPLY(ext_ms_win_ntuser_dialogbox_l1_1_0, "ext-ms-win-ntuser-dialogbox-l1-1-0" ) \
_APPLY(ext_ms_win_ntuser_windowstation_l1_1_0, "ext-ms-win-ntuser-windowstation-l1-1-0" ) \
_APPLY(advapi32, "advapi32" ) \
_APPLY(kernel32, "kernel32" ) \
_APPLY(kernelbase, "kernelbase" ) \
_APPLY(ntdll, "ntdll" ) \
_APPLY(api_ms_win_appmodel_runtime_l1_1_2, "api-ms-win-appmodel-runtime-l1-1-2" ) \
_APPLY(user32, "user32" )

Definition at line 51 of file winapi_thunks.cpp.

◆ _ACRT_APPLY_TO_LATE_BOUND_MODULES_1

#define _ACRT_APPLY_TO_LATE_BOUND_MODULES_1    _APPLY(api_ms_win_core_fibers_l1_1_0, "api-ms-win-core-fibers-l1-1-0" )

Definition at line 80 of file winapi_thunks.cpp.

◆ _APPLY [1/5]

#define _APPLY (   _FUNCTION,
  _MODULES 
)    _CRT_CONCATENATE(_FUNCTION, _id),

Definition at line 391 of file winapi_thunks.cpp.

◆ _APPLY [2/5]

#define _APPLY (   _FUNCTION,
  _MODULES 
)     using _CRT_CONCATENATE(_FUNCTION, _pft) = decltype(_FUNCTION)*;

Definition at line 391 of file winapi_thunks.cpp.

◆ _APPLY [3/5]

#define _APPLY (   _FUNCTION,
  _MODULES 
)
Value:
static _CRT_CONCATENATE(_FUNCTION, _pft) __cdecl _CRT_CONCATENATE(try_get_, _FUNCTION)() throw() \
{ \
static module_id const candidate_modules[] = _CRT_UNPARENTHESIZE(_MODULES); \
\
return reinterpret_cast<_CRT_CONCATENATE(_FUNCTION, _pft)>(try_get_function( \
_CRT_CONCATENATE(_FUNCTION, _id), \
_CRT_STRINGIZE(_FUNCTION), \
candidate_modules, \
candidate_modules + _countof(candidate_modules))); \
}
#define __cdecl
Definition: accygwin.h:79
#define _countof(array)
Definition: sndvol32.h:70
#define _CRT_CONCATENATE(a, b)
Definition: vcruntime.h:23
#define _CRT_UNPARENTHESIZE(...)
Definition: vcruntime.h:26
#define _CRT_STRINGIZE(_Value)
Definition: vcruntime.h:17
static void *__cdecl try_get_function(function_id const id, char const *const name, module_id const *const first_module_id, module_id const *const last_module_id)

Definition at line 391 of file winapi_thunks.cpp.

◆ _APPLY [4/5]

#define _APPLY (   _SYMBOL,
  _NAME 
)    _SYMBOL,

Definition at line 391 of file winapi_thunks.cpp.

◆ _APPLY [5/5]

#define _APPLY (   _SYMBOL,
  _NAME 
)    _CRT_WIDE(_NAME),

Definition at line 391 of file winapi_thunks.cpp.

Function Documentation

◆ __acrt_AppPolicyGetProcessTerminationMethodInternal()

LONG WINAPI __acrt_AppPolicyGetProcessTerminationMethodInternal ( _Out_ AppPolicyProcessTerminationMethod policy)

Definition at line 808 of file winapi_thunks.cpp.

809{
810 if (auto const app_policy_get_process_terminaton_method_claims = try_get_AppPolicyGetProcessTerminationMethod())
811 {
812 return app_policy_get_process_terminaton_method_claims(GetCurrentThreadEffectiveToken(), policy);
813 }
814
815 return STATUS_NOT_FOUND;
816}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:47
#define GetCurrentThreadEffectiveToken()
Definition: security.c:42
#define STATUS_NOT_FOUND
Definition: shellext.h:72

Referenced by __acrt_get_process_end_policy().

◆ __acrt_AppPolicyGetShowDeveloperDiagnosticInternal()

LONG WINAPI __acrt_AppPolicyGetShowDeveloperDiagnosticInternal ( _Out_ AppPolicyShowDeveloperDiagnostic policy)

Definition at line 828 of file winapi_thunks.cpp.

829{
830 if (auto const app_policy_get_show_developer_diagnostic_claims = try_get_AppPolicyGetShowDeveloperDiagnostic())
831 {
832 return app_policy_get_show_developer_diagnostic_claims(GetCurrentThreadEffectiveToken(), policy);
833 }
834
835 return STATUS_NOT_FOUND;
836}

Referenced by __acrt_get_developer_information_policy().

◆ __acrt_AppPolicyGetThreadInitializationTypeInternal()

LONG WINAPI __acrt_AppPolicyGetThreadInitializationTypeInternal ( _Out_ AppPolicyThreadInitializationType policy)

Definition at line 818 of file winapi_thunks.cpp.

819{
820 if (auto const app_policy_get_thread_initialization_type_claims = try_get_AppPolicyGetThreadInitializationType())
821 {
822 return app_policy_get_thread_initialization_type_claims(GetCurrentThreadEffectiveToken(), policy);
823 }
824
825 return STATUS_NOT_FOUND;
826}

Referenced by __acrt_get_begin_thread_init_policy().

◆ __acrt_AppPolicyGetWindowingModelInternal()

LONG WINAPI __acrt_AppPolicyGetWindowingModelInternal ( _Out_ AppPolicyWindowingModel policy)

Definition at line 838 of file winapi_thunks.cpp.

839{
840 if (auto const app_policy_get_windowing_model_claims = try_get_AppPolicyGetWindowingModel())
841 {
842 return app_policy_get_windowing_model_claims(GetCurrentThreadEffectiveToken(), policy);
843 }
844
845 return STATUS_NOT_FOUND;
846}

Referenced by __acrt_get_windowing_model_policy().

◆ __acrt_AreFileApisANSI()

_ACRT_APPLY_TO_LATE_BOUND_FUNCTIONS BOOL WINAPI __acrt_AreFileApisANSI ( void  )

Definition at line 405 of file winapi_thunks.cpp.

406{
407 if (auto const are_file_apis_ansi = try_get_AreFileApisANSI())
408 {
409 return are_file_apis_ansi();
410 }
411
412 // If we were unable to get the AreFileApisANSI function, we can safely
413 // assume that the file APIs are, in fact, ANSI:
414 return TRUE;
415}
#define TRUE
Definition: types.h:120

Referenced by __acrt_get_utf8_acp_compatibility_codepage(), and __acrt_GetTempPath2A().

◆ __acrt_can_show_message_box()

bool __cdecl __acrt_can_show_message_box ( void  )

Definition at line 858 of file winapi_thunks.cpp.

859{
860 bool can_show_message_box = false;
862 && try_get_MessageBoxA() != nullptr
863 && try_get_MessageBoxW() != nullptr)
864 {
865 can_show_message_box = true;
866 }
867 return can_show_message_box;
868}
@ windowing_model_policy_hwnd
windowing_model_policy __cdecl __acrt_get_windowing_model_policy(void)

Referenced by common_show_message_box().

◆ __acrt_can_use_vista_locale_apis()

bool __cdecl __acrt_can_use_vista_locale_apis ( void  )

Definition at line 870 of file winapi_thunks.cpp.

871{
872 return try_get_CompareStringEx() != nullptr;
873}

Referenced by _expandlocale().

◆ __acrt_can_use_xstate_apis()

bool __cdecl __acrt_can_use_xstate_apis ( void  )

Definition at line 894 of file winapi_thunks.cpp.

895{
896 return try_get_LocateXStateFeature() != nullptr;
897}

◆ __acrt_CompareStringEx()

int WINAPI __acrt_CompareStringEx ( LPCWSTR const  locale_name,
DWORD const  flags,
LPCWCH const  string1,
int const  string1_count,
LPCWCH const  string2,
int const  string2_count,
LPNLSVERSIONINFO const  version,
LPVOID const  reserved,
LPARAM const  param 
)

Definition at line 417 of file winapi_thunks.cpp.

428{
429 if (auto const compare_string_ex = try_get_CompareStringEx())
430 {
431 // On WCOS devices, CompareStringEx may calls into icu.dll which is an OS component using the UCRT.
432 // If icu.dll calls any UCRT export under OS mode (ex: malloc), then CompareStringEx will return under Prog Mode even if
433 // we started in OS mode. To prevent this, an OS mode guard is in place.
434 __crt_state_management::scoped_global_state_reset os_mode_guard;
435 return compare_string_ex(locale_name, flags, string1, string1_count, string2, string2_count, version, reserved, param);
436 }
437
438 return CompareStringW(__acrt_LocaleNameToLCID(locale_name, 0), flags, string1, string1_count, string2, string2_count);
439}
static const WCHAR version[]
Definition: asmname.c:66
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4014
r reserved
Definition: btrfs.c:3006
GLbitfield flags
Definition: glext.h:7161
GLfloat param
Definition: glext.h:5796
static CHAR string1[MAX_PATH]
Definition: asmname.c:32
static CHAR string2[MAX_PATH]
Definition: automation.c:345
LCID WINAPI __acrt_LocaleNameToLCID(LPCWSTR const name, DWORD const flags)

◆ __acrt_eagerly_load_locale_apis()

void __cdecl __acrt_eagerly_load_locale_apis ( void  )

Definition at line 879 of file winapi_thunks.cpp.

880{
881 try_get_AreFileApisANSI();
882 try_get_CompareStringEx();
883 try_get_EnumSystemLocalesEx();
884 try_get_GetDateFormatEx();
885 try_get_GetLocaleInfoEx();
886 try_get_GetTimeFormatEx();
887 try_get_GetUserDefaultLocaleName();
888 try_get_IsValidLocaleName();
889 try_get_LCMapStringEx();
890 try_get_LCIDToLocaleName();
891 try_get_LocaleNameToLCID();
892}

Referenced by _lock_locales(), _wsetlocale(), and setlocale().

◆ __acrt_EnumSystemLocalesEx()

BOOL WINAPI __acrt_EnumSystemLocalesEx ( LOCALE_ENUMPROCEX const  enum_proc,
DWORD const  flags,
LPARAM const  param,
LPVOID const  reserved 
)

Definition at line 477 of file winapi_thunks.cpp.

483{
484 if (auto const enum_system_locales_ex = try_get_EnumSystemLocalesEx())
485 {
486 return enum_system_locales_ex(enum_proc, flags, param, reserved);
487 }
488
489 return __acrt_lock_and_call(__acrt_locale_lock, [&]() -> BOOL
490 {
492 });
493}
@ __acrt_locale_lock
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL CALLBACK enum_proc(HWND hwnd, LPARAM lParam)
Definition: win.c:671
static BOOL enum_system_locales_ex_nolock(LOCALE_ENUMPROCEX const enum_proc)

◆ __acrt_FlsAlloc()

DWORD WINAPI __acrt_FlsAlloc ( PFLS_CALLBACK_FUNCTION const  callback)

Definition at line 495 of file winapi_thunks.cpp.

496{
497#if FLS_ALWAYS_AVAILABLE
498 return FlsAlloc(callback);
499#else
500 if (auto const fls_alloc = try_get_FlsAlloc())
501 {
502 return fls_alloc(callback);
503 }
504
505 return TlsAlloc();
506#endif
507}
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
static IPrintDialogCallback callback
Definition: printdlg.c:326

◆ __acrt_FlsFree()

BOOL WINAPI __acrt_FlsFree ( DWORD const  fls_index)

Definition at line 509 of file winapi_thunks.cpp.

510{
511#if FLS_ALWAYS_AVAILABLE
512 return FlsFree(fls_index);
513#else
514 if (auto const fls_free = try_get_FlsFree())
515 {
516 return fls_free(fls_index);
517 }
518
519 return TlsFree(fls_index);
520#endif
521}
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166

◆ __acrt_FlsGetValue()

PVOID WINAPI __acrt_FlsGetValue ( DWORD const  fls_index)

Definition at line 523 of file winapi_thunks.cpp.

524{
525#if FLS_ALWAYS_AVAILABLE
526 return FlsGetValue(fls_index);
527#else
528 if (auto const fls_get_value = try_get_FlsGetValue())
529 {
530 return fls_get_value(fls_index);
531 }
532
533 return TlsGetValue(fls_index);
534#endif
535}
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240

◆ __acrt_FlsSetValue()

BOOL WINAPI __acrt_FlsSetValue ( DWORD const  fls_index,
PVOID const  fls_data 
)

Definition at line 537 of file winapi_thunks.cpp.

538{
539#if FLS_ALWAYS_AVAILABLE
540 return FlsSetValue(fls_index, fls_data);
541#else
542 if (auto const fls_set_value = try_get_FlsSetValue())
543 {
544 return fls_set_value(fls_index, fls_data);
545 }
546
547 return TlsSetValue(fls_index, fls_data);
548#endif
549}
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276

◆ __acrt_get_parent_window()

HWND __cdecl __acrt_get_parent_window ( void  )

Definition at line 899 of file winapi_thunks.cpp.

900{
901 auto const get_active_window = try_get_GetActiveWindow();
902 if (!get_active_window)
903 {
904 return nullptr;
905 }
906
907 HWND const active_window = get_active_window();
908 if (!active_window)
909 {
910 return nullptr;
911 }
912
913 auto const get_last_active_popup = try_get_GetLastActivePopup();
914 if (!get_last_active_popup)
915 {
916 return active_window;
917 }
918
919 return get_last_active_popup(active_window);
920}

Referenced by common_show_message_box().

◆ __acrt_GetDateFormatEx()

int WINAPI __acrt_GetDateFormatEx ( LPCWSTR const  locale_name,
DWORD const  flags,
SYSTEMTIME CONST *const  date,
LPCWSTR const  format,
LPWSTR const  buffer,
int const  buffer_count,
LPCWSTR const  calendar 
)

Definition at line 551 of file winapi_thunks.cpp.

560{
561 if (auto const get_date_format_ex = try_get_GetDateFormatEx())
562 {
563 return get_date_format_ex(locale_name, flags, date, format, buffer, buffer_count, calendar);
564 }
565
567}
GLuint buffer
Definition: glext.h:5915
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
__u16 date
Definition: mkdosfs.c:8
Definition: format.c:58
size_t const buffer_count
Definition: xtoa.cpp:36

◆ __acrt_GetEnabledXStateFeatures()

DWORD64 WINAPI __acrt_GetEnabledXStateFeatures ( void  )

Definition at line 581 of file winapi_thunks.cpp.

582{
583 if (auto const get_enabled_xstate_features = try_get_GetEnabledXStateFeatures())
584 {
585 return get_enabled_xstate_features();
586 }
587
588 abort(); // No fallback; callers should check availablility before calling
589}
#define abort()
Definition: i386-dis.c:34

◆ __acrt_GetLocaleInfoEx()

int WINAPI __acrt_GetLocaleInfoEx ( LPCWSTR const  locale_name,
LCTYPE const  lc_type,
LPWSTR const  data,
int const  data_count 
)

Definition at line 591 of file winapi_thunks.cpp.

597{
598 if (auto const get_locale_info_ex = try_get_GetLocaleInfoEx())
599 {
600 return get_locale_info_ex(locale_name, lc_type, data, data_count);
601 }
602
603 return GetLocaleInfoW(__acrt_LocaleNameToLCID(locale_name, 0), lc_type, data, data_count);
604}
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ __acrt_GetSystemTimePreciseAsFileTime()

VOID WINAPI __acrt_GetSystemTimePreciseAsFileTime ( LPFILETIME const  system_time)

Definition at line 606 of file winapi_thunks.cpp.

607{
608 if (auto const get_system_time_precise_as_file_time = try_get_GetSystemTimePreciseAsFileTime())
609 {
610 return get_system_time_precise_as_file_time(system_time);
611 }
612
613 return GetSystemTimeAsFileTime(system_time);
614}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128

◆ __acrt_GetTempPath2W()

int WINAPI __acrt_GetTempPath2W ( DWORD  nBufferLength,
LPWSTR  lpBuffer 
)

Definition at line 569 of file winapi_thunks.cpp.

573{
574 if (auto const get_temp_path2w = try_get_GetTempPath2W())
575 {
576 return get_temp_path2w(nBufferLength, lpBuffer);
577 }
579}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3098

◆ __acrt_GetTimeFormatEx()

int WINAPI __acrt_GetTimeFormatEx ( LPCWSTR const  locale_name,
DWORD const  flags,
SYSTEMTIME CONST *const  time,
LPCWSTR const  format,
LPWSTR const  buffer,
int const  buffer_count 
)

Definition at line 616 of file winapi_thunks.cpp.

624{
625 if (auto const get_time_format_ex = try_get_GetTimeFormatEx())
626 {
627 return get_time_format_ex(locale_name, flags, time, format, buffer, buffer_count);
628 }
629
631}
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
__u16 time
Definition: mkdosfs.c:8

◆ __acrt_GetUserDefaultLocaleName()

int WINAPI __acrt_GetUserDefaultLocaleName ( LPWSTR const  locale_name,
int const  locale_name_count 
)

Definition at line 633 of file winapi_thunks.cpp.

637{
638 if (auto const get_user_default_locale_name = try_get_GetUserDefaultLocaleName())
639 {
640 return get_user_default_locale_name(locale_name, locale_name_count);
641 }
642
643 return __acrt_LCIDToLocaleName(GetUserDefaultLCID(), locale_name, locale_name_count, 0);
644}
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1211
int WINAPI __acrt_LCIDToLocaleName(LCID const locale, LPWSTR const name, int const name_count, DWORD const flags)

◆ __acrt_GetXStateFeaturesMask()

BOOL WINAPI __acrt_GetXStateFeaturesMask ( PCONTEXT const  context,
PDWORD64 const  feature_mask 
)

Definition at line 646 of file winapi_thunks.cpp.

650{
651 if (auto const get_xstate_features_mask = try_get_GetXStateFeaturesMask())
652 {
653 return get_xstate_features_mask(context, feature_mask);
654 }
655
656 abort(); // No fallback; callers should check availablility before calling
657}
Definition: http.c:7252

◆ __acrt_initialize_winapi_thunks()

bool __cdecl __acrt_initialize_winapi_thunks ( void  )

Definition at line 191 of file winapi_thunks.cpp.

192{
193 void* const encoded_nullptr = __crt_fast_encode_pointer(nullptr);
194
195 for (void*& p : encoded_function_pointers)
196 {
197 p = encoded_nullptr;
198 }
199
200 return true;
201}
GLfloat GLfloat p
Definition: glext.h:8902
static void * encoded_function_pointers[function_id_count]

◆ __acrt_InitializeCriticalSectionEx()

BOOL WINAPI __acrt_InitializeCriticalSectionEx ( LPCRITICAL_SECTION const  critical_section,
DWORD const  spin_count,
DWORD const  flags 
)

Definition at line 659 of file winapi_thunks.cpp.

664{
665 if (auto const initialize_critical_section_ex = try_get_InitializeCriticalSectionEx())
666 {
667 return initialize_critical_section_ex(critical_section, spin_count, flags);
668 }
669
671}
CRITICAL_SECTION critical_section
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765

◆ __acrt_is_interactive()

bool __cdecl __acrt_is_interactive ( void  )

Definition at line 922 of file winapi_thunks.cpp.

923{
924 auto const get_process_window_station = try_get_GetProcessWindowStation();
925 if (!get_process_window_station)
926 {
927 return true;
928 }
929
930 auto const get_user_object_information = try_get_GetUserObjectInformationW();
931 if (!get_user_object_information)
932 {
933 return true;
934 }
935
936 HWINSTA const hwinsta = get_process_window_station();
937 if (!hwinsta)
938 {
939 return false;
940 }
941
942 USEROBJECTFLAGS uof{};
943 if (!get_user_object_information(hwinsta, UOI_FLAGS, &uof, sizeof(uof), nullptr))
944 {
945 return false;
946 }
947
948 if ((uof.dwFlags & WSF_VISIBLE) == 0)
949 {
950 return false;
951 }
952
953 return true;
954}
#define WSF_VISIBLE
Definition: winuser.h:2455
#define UOI_FLAGS
Definition: winuser.h:1086

Referenced by common_show_message_box().

◆ __acrt_IsValidLocaleName()

BOOL WINAPI __acrt_IsValidLocaleName ( LPCWSTR const  locale_name)

Definition at line 673 of file winapi_thunks.cpp.

674{
675 if (auto const is_valid_locale_name = try_get_IsValidLocaleName())
676 {
677 return is_valid_locale_name(locale_name);
678 }
679
681}
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: locale.c:2923
#define LCID_INSTALLED
Definition: winnls.h:203

◆ __acrt_LCIDToLocaleName()

int WINAPI __acrt_LCIDToLocaleName ( LCID const  locale,
LPWSTR const  name,
int const  name_count,
DWORD const  flags 
)

Definition at line 703 of file winapi_thunks.cpp.

709{
710 if (auto const lcid_to_locale_name = try_get_LCIDToLocaleName())
711 {
712 return lcid_to_locale_name(locale, name, name_count, flags);
713 }
714
715 return __acrt_DownlevelLCIDToLocaleName(locale, name, name_count);
716}
Definition: _locale.h:75
int __cdecl __acrt_DownlevelLCIDToLocaleName(LCID lcid, LPWSTR outLocaleName, int cchLocaleName)
Definition: name.c:39

Referenced by __acrt_GetUserDefaultLocaleName().

◆ __acrt_LCMapStringEx()

int WINAPI __acrt_LCMapStringEx ( LPCWSTR const  locale_name,
DWORD const  flags,
LPCWSTR const  source,
int const  source_count,
LPWSTR const  destination,
int const  destination_count,
LPNLSVERSIONINFO const  version,
LPVOID const  reserved,
LPARAM const  sort_handle 
)

Definition at line 683 of file winapi_thunks.cpp.

694{
695 if (auto const lc_map_string_ex = try_get_LCMapStringEx())
696 {
697 return lc_map_string_ex(locale_name, flags, source, source_count, destination, destination_count, version, reserved, sort_handle);
698 }
699#pragma warning(disable:__WARNING_PRECONDITION_NULLTERMINATION_VIOLATION) // 26035 LCMapStringW annotation is presently incorrect 11/26/2014 Jaykrell
701}
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3805
size_t const source_count
Definition: read.cpp:240
size_t const destination_count
Definition: wcrtomb.cpp:52

◆ __acrt_LocaleNameToLCID()

LCID WINAPI __acrt_LocaleNameToLCID ( LPCWSTR const  name,
DWORD const  flags 
)

Definition at line 718 of file winapi_thunks.cpp.

722{
723 if (auto const locale_name_to_lcid = try_get_LocaleNameToLCID())
724 {
725 return locale_name_to_lcid(name, flags);
726 }
727
729}
LCID __cdecl __acrt_DownlevelLocaleNameToLCID(_In_opt_ LPCWSTR localeName)

Referenced by __acrt_CompareStringEx(), __acrt_GetDateFormatEx(), __acrt_GetLocaleInfoEx(), __acrt_GetTimeFormatEx(), __acrt_IsValidLocaleName(), and __acrt_LCMapStringEx().

◆ __acrt_LocateXStateFeature()

PVOID WINAPI __acrt_LocateXStateFeature ( PCONTEXT const  content,
DWORD const  feature_id,
PDWORD const  length 
)

Definition at line 731 of file winapi_thunks.cpp.

736{
737 if (auto const locate_xstate_feature = try_get_LocateXStateFeature())
738 {
739 return locate_xstate_feature(content, feature_id, length);
740 }
741
742 abort(); // No fallback; callers should check availablility before calling
743}
content
Definition: atl_ax.c:994
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
_In_ DWORD feature_id

◆ __acrt_MessageBoxA()

int WINAPI __acrt_MessageBoxA ( HWND const  hwnd,
LPCSTR const  text,
LPCSTR const  caption,
UINT const  type 
)

Definition at line 745 of file winapi_thunks.cpp.

751{
752 if (auto const message_box_a = try_get_MessageBoxA())
753 {
754 return message_box_a(hwnd, text, caption, type);
755 }
756
757 abort(); // No fallback; callers should check availablility before calling
758}
const WCHAR * text
Definition: package.c:1794
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ __acrt_MessageBoxW()

int WINAPI __acrt_MessageBoxW ( HWND const  hwnd,
LPCWSTR const  text,
LPCWSTR const  caption,
UINT const  type 
)

Definition at line 760 of file winapi_thunks.cpp.

766{
767 if (auto const message_box_w = try_get_MessageBoxW())
768 {
769 return message_box_w(hwnd, text, caption, type);
770 }
771
772 abort(); // No fallback; callers should check availablility before calling
773}

◆ __acrt_RoInitialize()

HRESULT WINAPI __acrt_RoInitialize ( RO_INIT_TYPE const  init_type)

Definition at line 788 of file winapi_thunks.cpp.

789{
790 if (auto const ro_initialize = try_get_RoInitialize())
791 {
792 return ro_initialize(init_type);
793 }
794
795 return S_OK; // No fallback (this is a best-effort wrapper)
796}
#define S_OK
Definition: intsafe.h:52

Referenced by thread_start().

◆ __acrt_RoUninitialize()

void WINAPI __acrt_RoUninitialize ( void  )

Definition at line 798 of file winapi_thunks.cpp.

799{
800 if (auto const ro_uninitialize = try_get_RoUninitialize())
801 {
802 return ro_uninitialize();
803 }
804
805 // No fallback (this is a best-effort wrapper)
806}

Referenced by common_end_thread().

◆ __acrt_RtlGenRandom()

BOOLEAN WINAPI __acrt_RtlGenRandom ( PVOID const  buffer,
ULONG const  buffer_count 
)

Definition at line 775 of file winapi_thunks.cpp.

779{
780 if (auto const rtl_gen_random = try_get_SystemFunction036())
781 {
782 return rtl_gen_random(buffer, buffer_count);
783 }
784
785 abort(); // No fallback (this function should exist)
786}

Referenced by rand_s().

◆ __acrt_SetThreadStackGuarantee()

BOOL WINAPI __acrt_SetThreadStackGuarantee ( PULONG const  stack_size_in_bytes)

Definition at line 848 of file winapi_thunks.cpp.

849{
850 if (auto const set_thread_stack_guarantee = try_get_SetThreadStackGuarantee())
851 {
852 return set_thread_stack_guarantee(stack_size_in_bytes);
853 }
854
855 return FALSE;
856}
#define FALSE
Definition: types.h:117

◆ __acrt_uninitialize_winapi_thunks()

bool __cdecl __acrt_uninitialize_winapi_thunks ( bool const  terminating)

Definition at line 203 of file winapi_thunks.cpp.

204{
205 // If the process is terminating, there's no need to free any module handles
206 if (terminating)
207 {
208 return true;
209 }
210
212 {
213 if (module)
214 {
216 {
218 }
219
220 module = nullptr;
221 }
222 }
223
224 return true;
225}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
static HMODULE module_handles[module_id_count]

◆ _Out_writes_to_opt_()

WINBASEAPI _Out_writes_to_opt_ ( BufferLength  ,
return 1 
)

◆ _Success_() [1/2]

_Success_ ( return = NULL)

Definition at line 1028 of file fsctrl.c.

3189{
3191
3192 PVPB Vpb = Vcb->Vpb;
3193 PVPB OldVpb;
3194
3195 BOOLEAN Remount = FALSE;
3196
3197 PAGED_CODE();
3198
3199 UNREFERENCED_PARAMETER( IrpContext );
3200
3201 //
3202 // Check whether we are looking for a device only Mvcb.
3203 //
3204
3205 for (Link = CdData.VcbQueue.Flink;
3206 Link != &CdData.VcbQueue;
3207 Link = Link->Flink) {
3208
3209 *OldVcb = CONTAINING_RECORD( Link, VCB, VcbLinks );
3210
3211 //
3212 // Skip ourselves.
3213 //
3214
3215 if (Vcb == *OldVcb) { continue; }
3216
3217 //
3218 // Look at the Vpb and state of the previous Vcb.
3219 //
3220
3221 OldVpb = (*OldVcb)->Vpb;
3222
3223 if ((OldVpb != Vpb) &&
3224 (OldVpb->RealDevice == Vpb->RealDevice) &&
3225 ((*OldVcb)->VcbCondition == VcbNotMounted)) {
3226
3227 //
3228 // If the current disk is a raw disk then it can match a previous music or
3229 // raw disk.
3230 //
3231
3232 if (FlagOn( Vcb->VcbState, VCB_STATE_AUDIO_DISK)) {
3233
3234 if (FlagOn( (*OldVcb)->VcbState, VCB_STATE_AUDIO_DISK )) {
3235
3236 //
3237 // If we have both TOC then fail the remount if the lengths
3238 // are different or they don't match.
3239 //
3240
3241 if ((Vcb->TocLength != (*OldVcb)->TocLength) ||
3242 ((Vcb->TocLength != 0) &&
3243 !RtlEqualMemory( Vcb->CdromToc,
3244 (*OldVcb)->CdromToc,
3245 Vcb->TocLength ))) {
3246
3247 continue;
3248 }
3249
3250 Remount = TRUE;
3251 break;
3252 }
3253
3254 //
3255 // The current disk is not a raw disk. Go ahead and compare
3256 // serial numbers, volume label and TOC.
3257 //
3258
3259 }
3260 else if ((OldVpb->SerialNumber == Vpb->SerialNumber) &&
3261 (Vcb->TocLength == (*OldVcb)->TocLength) &&
3262 ((Vcb->TocLength == 0) || RtlEqualMemory( Vcb->CdromToc,
3263 (*OldVcb)->CdromToc,
3264 Vcb->TocLength )) &&
3265 (Vpb->VolumeLabelLength == OldVpb->VolumeLabelLength) &&
3266 (RtlEqualMemory( OldVpb->VolumeLabel,
3267 Vpb->VolumeLabel,
3268 Vpb->VolumeLabelLength ))) {
3269 //
3270 // Remember the old Vcb. Then set the return value to
3271 // TRUE and break.
3272 //
3273
3274 Remount = TRUE;
3275 break;
3276 }
3277 }
3278 }
3279
3280 return Remount;
3281}
#define PAGED_CODE()
unsigned char BOOLEAN
CD_DATA CdData
Definition: cddata.c:42
#define VCB_STATE_AUDIO_DISK
Definition: cdstruc.h:712
@ VcbNotMounted
Definition: cdstruc.h:490
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1676
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define Vcb
Definition: cdprocs.h:1415
LIST_ENTRY VcbQueue
Definition: cdstruc.h:334
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: cdstruc.h:498
Definition: iotypes.h:189
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH/sizeof(WCHAR)]
Definition: iotypes.h:198
USHORT VolumeLabelLength
Definition: iotypes.h:193
ULONG SerialNumber
Definition: iotypes.h:196
struct _DEVICE_OBJECT * RealDevice
Definition: iotypes.h:195
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static int Link(const char **args)
Definition: vfdcmd.c:2414

◆ _Success_() [2/2]

WINBASEAPI _Success_ ( return  )

Deletes the virtual mapping and optionally gives back the page & dirty bit.

Parameters
Process- The process this address belongs to, or NULL if system address.
Address- The address to unmap.
WasDirty- Optional param receiving the dirty bit of the PTE.
Page- Optional param receiving the page number previously mapped to this address.
Returns
Whether there was actually a page mapped at the given address.

Definition at line 57 of file firmware.c.

207{
210
211 /* Check input parameters */
212 if (FirmwareType == NULL)
213 {
215 return FALSE;
216 }
217
218 /* Query firmware type */
220 &BootInfo,
221 sizeof(BootInfo),
222 0);
223 if (!NT_SUCCESS(Status))
224 {
226 return FALSE;
227 }
228
229 *FirmwareType = BootInfo.FirmwareType;
230 return TRUE;
231}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
Status
Definition: gdiplustypes.h:25
@ SystemBootEnvironmentInformation
Definition: extypes.h:307
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)

◆ enum_system_locales_ex_nolock()

static BOOL enum_system_locales_ex_nolock ( LOCALE_ENUMPROCEX const  enum_proc)
throw (
)
static

Definition at line 452 of file winapi_thunks.cpp.

455{
456#ifndef __clang__
457 static LOCALE_ENUMPROCEX static_enum_proc;
458#endif
459
460 static_enum_proc = __crt_fast_encode_pointer(enum_proc);
462#ifdef __clang__
463 LocaleEnumProcW,
464#else
465 [](LPWSTR locale_string)
466 #if defined(__GNUC__) && !defined(__clang__)
468 #endif // __GNUC__
469 { return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0); },
470#endif
472 static_enum_proc = __crt_fast_encode_pointer(nullptr);
473
474 return result;
475}
#define __GNUC__
Definition: _icc.h:38
BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
Definition: locale.c:2999
GLuint64EXT * result
Definition: glext.h:11304
#define __stdcall
Definition: typedefs.h:25
BOOL(CALLBACK * LOCALE_ENUMPROCEX)(LPWSTR, DWORD, LPARAM)
Definition: winnls.h:541
BOOL(CALLBACK * LOCALE_ENUMPROCW)(LPWSTR)
Definition: winnls.h:540
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by __acrt_EnumSystemLocalesEx().

◆ GetEnabledXStateFeatures()

WINBASEAPI DWORD64 WINAPI GetEnabledXStateFeatures ( )

◆ GetXStateFeaturesMask()

_Must_inspect_result_ WINBASEAPI BOOL WINAPI GetXStateFeaturesMask ( _In_ PCONTEXT  context,
_Out_ PDWORD64  feature_mask 
)

◆ invalid_function_sentinel()

static __forceinline void *__cdecl invalid_function_sentinel ( )
throw (
)
static

Definition at line 227 of file winapi_thunks.cpp.

228{
229 return reinterpret_cast<void*>(static_cast<uintptr_t>(-1));
230}
unsigned int uintptr_t
Definition: intrin.h:47

Referenced by try_get_function().

◆ try_get_first_available_module()

static HMODULE __cdecl try_get_first_available_module ( module_id const *const  first,
module_id const *const  last 
)
throw (
)
static

Definition at line 295 of file winapi_thunks.cpp.

299{
300 for (module_id const* it = first; it != last; ++it)
301 {
302 HMODULE const handle = try_get_module(*it);
303 if (handle)
304 {
305 return handle;
306 }
307 }
308
309 return nullptr;
310}
const GLint * first
Definition: glext.h:5794
static UINT UINT last
Definition: font.c:45
static HMODULE __cdecl try_get_module(module_id const id)

Referenced by try_get_proc_address_from_first_available_module().

◆ try_get_function()

static void *__cdecl try_get_function ( function_id const  id,
char const *const  name,
module_id const *const  first_module_id,
module_id const *const  last_module_id 
)
throw (
)
static

Definition at line 327 of file winapi_thunks.cpp.

333{
334 // First check to see if we've cached the function pointer:
335 {
336 void* const cached_fp = __crt_fast_decode_pointer(
337 __crt_interlocked_read_pointer(encoded_function_pointers + id));
338
339 if (cached_fp == invalid_function_sentinel())
340 {
341 return nullptr;
342 }
343
344 if (cached_fp)
345 {
346 return cached_fp;
347 }
348 }
349
350 // If we haven't yet cached the function pointer, try to import it from any
351 // of the modules in which it might be defined. If this fails, cache the
352 // sentinel pointer so that we don't attempt to load this function again:
353 void* const new_fp = try_get_proc_address_from_first_available_module(name, first_module_id, last_module_id);
354 if (!new_fp)
355 {
356 void* const cached_fp = __crt_fast_decode_pointer(
357 __crt_interlocked_exchange_pointer(
359 __crt_fast_encode_pointer(invalid_function_sentinel())));
360
361 if (cached_fp)
362 {
363 _ASSERTE(cached_fp == invalid_function_sentinel());
364 }
365
366 return nullptr;
367 }
368
369 // Swap the newly obtained function pointer into the cache. The cache may
370 // no longer contain an encoded null pointer if another thread obtained the
371 // function address while we were doing the same (both threads should have
372 // gotten the same function pointer):
373 {
374 void* const cached_fp = __crt_fast_decode_pointer(
375 __crt_interlocked_exchange_pointer(
377 __crt_fast_encode_pointer(new_fp)));
378
379 if (cached_fp)
380 {
381 _ASSERTE(cached_fp == new_fp);
382 }
383 }
384
385 return new_fp;
386}
#define _ASSERTE(expr)
Definition: crtdbg.h:114
static __forceinline void *__cdecl try_get_proc_address_from_first_available_module(char const *const name, module_id const *const first_module_id, module_id const *const last_module_id)
static __forceinline void *__cdecl invalid_function_sentinel()

◆ try_get_module()

static HMODULE __cdecl try_get_module ( module_id const  id)
throw (
)
static

Definition at line 255 of file winapi_thunks.cpp.

256{
257 // First check to see if we've cached the module handle:
258 if (HMODULE const cached_handle = __crt_interlocked_read_pointer(module_handles + id))
259 {
260 if (cached_handle == INVALID_HANDLE_VALUE)
261 {
262 return nullptr;
263 }
264
265 return cached_handle;
266 }
267
268 // If we haven't yet cached the module handle, try to load the library. If
269 // this fails, cache the sentinel handle value INVALID_HANDLE_VALUE so that
270 // we don't attempt to load the module again:
272 if (!new_handle)
273 {
274 if (HMODULE const cached_handle = __crt_interlocked_exchange_pointer(module_handles + id, INVALID_HANDLE_VALUE))
275 {
276 _ASSERTE(cached_handle == INVALID_HANDLE_VALUE);
277 }
278
279 return nullptr;
280 }
281
282 // Swap the new handle into the cache. If the cache no longer contained a
283 // null handle, then some other thread loaded the module and cached the
284 // handle while we were doing the same. In that case, we free the handle
285 // once to maintain the reference count:
286 if (HMODULE const cached_handle = __crt_interlocked_exchange_pointer(module_handles + id, new_handle))
287 {
288 _ASSERTE(cached_handle == new_handle);
289 FreeLibrary(new_handle);
290 }
291
292 return new_handle;
293}
static wchar_t const *const module_names[module_id_count]
static HMODULE __cdecl try_load_library_from_system_directory(wchar_t const *const name)

Referenced by try_get_first_available_module().

◆ try_get_proc_address_from_first_available_module()

static __forceinline void *__cdecl try_get_proc_address_from_first_available_module ( char const *const  name,
module_id const *const  first_module_id,
module_id const *const  last_module_id 
)
throw (
)
static

Definition at line 312 of file winapi_thunks.cpp.

317{
318 HMODULE const module_handle = try_get_first_available_module(first_module_id, last_module_id);
319 if (!module_handle)
320 {
321 return nullptr;
322 }
323
324 return reinterpret_cast<void*>(GetProcAddress(module_handle, name));
325}
#define GetProcAddress(x, y)
Definition: compat.h:753
static HMODULE __cdecl try_get_first_available_module(module_id const *const first, module_id const *const last)

Referenced by try_get_function().

◆ try_load_library_from_system_directory()

static HMODULE __cdecl try_load_library_from_system_directory ( wchar_t const *const  name)
throw (
)
static

Definition at line 232 of file winapi_thunks.cpp.

233{
235 if (handle)
236 {
237 return handle;
238 }
239
240 // LOAD_LIBRARY_SEARCH_SYSTEM32 is only supported by Windows 7 and above; if
241 // the OS does not support this flag, try again without it. On these OSes,
242 // all APISets will be forwarders. To prevent DLL hijacking, do not attempt
243 // to load the APISet forwarders dynamically. This will cause our caller to
244 // fall back to the real DLL (e.g. kernel32). All of those are known DLLs.
246 wcsncmp(name, L"api-ms-", 7) != 0 &&
247 wcsncmp(name, L"ext-ms-", 7) != 0)
248 {
249 return LoadLibraryExW(name, nullptr, 0);
250 }
251
252 return nullptr;
253}
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_SEARCH_SYSTEM32
Definition: winbase.h:379

Referenced by try_get_module().

Variable Documentation

◆ encoded_function_pointers

void* encoded_function_pointers[function_id_count]
static

Definition at line 189 of file winapi_thunks.cpp.

Referenced by __acrt_initialize_winapi_thunks(), and try_get_function().

◆ feature_id

_In_ DWORD feature_id

Definition at line 47 of file winapi_thunks.cpp.

Referenced by __acrt_LocateXStateFeature().

◆ length

Definition at line 48 of file winapi_thunks.cpp.

◆ module_handles

HMODULE module_handles[module_id_count]
static

Definition at line 182 of file winapi_thunks.cpp.

Referenced by __acrt_uninitialize_winapi_thunks(), and try_get_module().