mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:12:57 +00:00
[UCRTBASE] Fix broken imports from ntdll
Previously sprintf and _vsnprintf were imported from ntdll. These functions are defined as inline functions in ucrt headers, but linked directly by legacy CRT code.
This commit is contained in:
parent
c37af4cfca
commit
ad50a00020
2 changed files with 64 additions and 0 deletions
|
@ -1,7 +1,22 @@
|
||||||
|
|
||||||
spec2def(ucrtbase.dll ucrtbase.spec ADD_IMPORTLIB)
|
spec2def(ucrtbase.dll ucrtbase.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
|
# Hack to replace the old CRT include directory with the UCRT include directory
|
||||||
|
get_property(INCLUDE_DIRS DIRECTORY . PROPERTY INCLUDE_DIRECTORIES)
|
||||||
|
list(REMOVE_ITEM INCLUDE_DIRS "${REACTOS_SOURCE_DIR}/sdk/include/crt")
|
||||||
|
set_property(DIRECTORY . PROPERTY INCLUDE_DIRECTORIES ${INCLUDE_DIRS})
|
||||||
|
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/ucrt)
|
||||||
|
|
||||||
|
remove_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS)
|
||||||
|
|
||||||
|
add_compile_definitions(
|
||||||
|
_UCRT
|
||||||
|
_CORECRT_BUILD
|
||||||
|
CRTDLL
|
||||||
|
)
|
||||||
|
|
||||||
add_library(ucrtbase SHARED
|
add_library(ucrtbase SHARED
|
||||||
|
printf.c
|
||||||
stubs.c
|
stubs.c
|
||||||
ucrtbase_stubs.c
|
ucrtbase_stubs.c
|
||||||
ucrtbase.def
|
ucrtbase.def
|
||||||
|
|
49
dll/win32/ucrtbase/printf.c
Normal file
49
dll/win32/ucrtbase/printf.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS CRT
|
||||||
|
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||||
|
* PURPOSE: Instantiation of CRT stdio inline functions
|
||||||
|
* COPYRIGHT: Copyright 2023-2024 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _NO_CRT_STDIO_INLINE
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// These 2 functions are inlined in UCRT headers, but they are referenced by
|
||||||
|
// external code in the legacy CRT, so we need to provide them as non-inline
|
||||||
|
// functions here.
|
||||||
|
|
||||||
|
_Success_(return >= 0)
|
||||||
|
_Check_return_opt_
|
||||||
|
int __CRTDECL sprintf(
|
||||||
|
_Pre_notnull_ _Always_(_Post_z_) char* const _Buffer,
|
||||||
|
_In_z_ _Printf_format_string_ char const* const _Format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
int _Result;
|
||||||
|
va_list _ArgList;
|
||||||
|
|
||||||
|
__crt_va_start(_ArgList, _Format);
|
||||||
|
|
||||||
|
_Result = __stdio_common_vsprintf(
|
||||||
|
_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
|
||||||
|
_Buffer, (size_t)-1, _Format, NULL, _ArgList);
|
||||||
|
|
||||||
|
__crt_va_end(_ArgList);
|
||||||
|
return _Result < 0 ? -1 : _Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Success_(return >= 0)
|
||||||
|
_Check_return_opt_
|
||||||
|
int __CRTDECL _vsnprintf(
|
||||||
|
_Out_writes_opt_(_BufferCount) _Post_maybez_ char* const _Buffer,
|
||||||
|
_In_ size_t const _BufferCount,
|
||||||
|
_In_z_ _Printf_format_string_ char const* const _Format,
|
||||||
|
va_list _ArgList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int _Result = __stdio_common_vsprintf(
|
||||||
|
_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
|
||||||
|
_Buffer, _BufferCount, _Format, NULL, _ArgList);
|
||||||
|
|
||||||
|
return _Result < 0 ? -1 : _Result;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue