diff --git a/modules/rostests/apitests/crt/_snprintf.c b/modules/rostests/apitests/crt/_snprintf.c index 29580d66adf..7d476b0f550 100644 --- a/modules/rostests/apitests/crt/_snprintf.c +++ b/modules/rostests/apitests/crt/_snprintf.c @@ -1,2 +1,5 @@ +#include #define func__sntprintf func__snprintf +typedef int (__cdecl *PFN_sntprintf)(char *_Dest, size_t _Count, const char *_Format, ...); +#define str_sntprintf "_snprintf" #include "_sntprintf.h" diff --git a/modules/rostests/apitests/crt/_sntprintf.h b/modules/rostests/apitests/crt/_sntprintf.h index 887fee7f665..48f49e66ed9 100644 --- a/modules/rostests/apitests/crt/_sntprintf.h +++ b/modules/rostests/apitests/crt/_sntprintf.h @@ -13,6 +13,23 @@ #include #include +#ifndef TEST_STATIC_CRT + +static PFN_sntprintf p_sntprintf; + +static BOOL Init(void) +{ + HMODULE hdll = LoadLibraryA(TEST_DLL_NAME); + p_sntprintf = (PFN_sntprintf)GetProcAddress(hdll, str_sntprintf); + ok(p_sntprintf != NULL, "Failed to load %s from %s\n", str_sntprintf, TEST_DLL_NAME); + return (p_sntprintf != NULL); +} + +#undef _sntprintf +#define _sntprintf p_sntprintf + +#endif // !TEST_STATIC_CRT + /* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ #undef broken #define broken(x) 0 @@ -23,6 +40,14 @@ START_TEST(_sntprintf) size_t BufferSize = sizeof(Buffer) / sizeof(Buffer[0]); int Result; +#ifndef TEST_STATIC_CRT + if (!Init()) + { + skip("Skipping tests, because %s is not available\n", str_sntprintf); + return; + } +#endif + StartSeh() Result = _sntprintf(NULL, 0, _T("Hello")); #ifdef TEST_CRTDLL @@ -35,7 +60,9 @@ START_TEST(_sntprintf) StartSeh() Result = _sntprintf(NULL, 1, _T("Hello")); ok_int(Result, (GetNTVersion() >= _WIN32_WINNT_VISTA) ? -1 : 5); -#if defined(_UNICODE) || defined(TEST_CRTDLL) +#if defined(TEST_CRTDLL) + EndSeh(STATUS_ACCESS_VIOLATION); +#elif defined(_UNICODE) EndSeh((GetNTVersion() >= _WIN32_WINNT_VISTA) ? 0 : STATUS_ACCESS_VIOLATION); #else EndSeh(STATUS_SUCCESS); diff --git a/modules/rostests/apitests/crt/_snwprintf.c b/modules/rostests/apitests/crt/_snwprintf.c index 0f891982c23..23e7e6726cb 100644 --- a/modules/rostests/apitests/crt/_snwprintf.c +++ b/modules/rostests/apitests/crt/_snwprintf.c @@ -1,3 +1,6 @@ #define _UNICODE +#include #define func__sntprintf func__snwprintf +typedef int (__cdecl *PFN_sntprintf)(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, ...); +#define str_sntprintf "_snwprintf" #include "_sntprintf.h" diff --git a/modules/rostests/apitests/crtdll/CMakeLists.txt b/modules/rostests/apitests/crtdll/CMakeLists.txt index b4c5356cfa9..4a4a012c374 100644 --- a/modules/rostests/apitests/crtdll/CMakeLists.txt +++ b/modules/rostests/apitests/crtdll/CMakeLists.txt @@ -30,7 +30,7 @@ elseif(ARCH STREQUAL "amd64") endif() add_executable(crtdll_apitest testlist.c ${SOURCE_CRTDLL} ${crtdll_apitest_asm}) -target_compile_definitions(crtdll_apitest PRIVATE TEST_CRTDLL) +target_compile_definitions(crtdll_apitest PRIVATE TEST_CRTDLL TEST_DLL_NAME="crtdll.dll") target_link_libraries(crtdll_apitest wine ${PSEH_LIB}) set_module_type(crtdll_apitest win32cui) add_importlibs(crtdll_apitest crtdll msvcrt kernel32 ntdll) diff --git a/modules/rostests/apitests/msvcrt/CMakeLists.txt b/modules/rostests/apitests/msvcrt/CMakeLists.txt index 015c8d23fca..e40bc6c6127 100644 --- a/modules/rostests/apitests/msvcrt/CMakeLists.txt +++ b/modules/rostests/apitests/msvcrt/CMakeLists.txt @@ -81,7 +81,7 @@ list(APPEND SOURCE add_executable(msvcrt_apitest ${SOURCE}) add_dependencies(msvcrt_apitest asm) -target_compile_definitions(msvcrt_apitest PRIVATE TEST_MSVCRT) +target_compile_definitions(msvcrt_apitest PRIVATE TEST_MSVCRT TEST_DLL_NAME="msvcrt.dll") target_link_libraries(msvcrt_apitest wine ${PSEH_LIB}) set_module_type(msvcrt_apitest win32cui) add_importlibs(msvcrt_apitest msvcrt kernel32 ntdll) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 848def9058b..10009e1f1f0 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -26,7 +26,7 @@ list(APPEND SOURCE_CRT_TESTS ) add_library(ntdll_crt_test_lib ${SOURCE_CRT_TESTS}) -target_compile_definitions(ntdll_crt_test_lib PRIVATE TEST_NTDLL) +target_compile_definitions(ntdll_crt_test_lib PRIVATE TEST_NTDLL TEST_DLL_NAME="ntdll.dll") target_link_libraries(ntdll_crt_test_lib ${PSEH_LIB}) add_dependencies(ntdll_crt_test_lib psdk)