From dcbf403aeeb35cbe06d9614dc935f00e45efb899 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 30 Aug 2012 10:12:55 +0000 Subject: [PATCH] [FREELDR/CRT] Freeldr size is currently limited to 448 KB. On MSVC it was already at 442 KB, before wine's wctype table was used. The new wctype table is itself 37 KB. This lead to freeldr overflowing into memory regions that were used for the filesystem buffer, causing bootfailures. Fix this by giving freeldr it's own using _isctype(), since freeldr casts WCHAR to CHAR anyway. svn path=/trunk/; revision=57205 --- reactos/boot/freeldr/freeldr/freeldr.c | 9 +++++++++ reactos/lib/sdk/crt/crt.cmake | 2 ++ reactos/lib/sdk/crt/libcntpr.cmake | 4 +++- reactos/lib/sdk/crt/string/ctype.c | 18 ------------------ reactos/lib/sdk/crt/string/is_wctype.c | 13 +++++++++++++ reactos/lib/sdk/crt/string/iswctype.c | 12 ++++++++++++ 6 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 reactos/lib/sdk/crt/string/is_wctype.c create mode 100644 reactos/lib/sdk/crt/string/iswctype.c diff --git a/reactos/boot/freeldr/freeldr/freeldr.c b/reactos/boot/freeldr/freeldr/freeldr.c index 77a164a374a..6d069b63573 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.c +++ b/reactos/boot/freeldr/freeldr/freeldr.c @@ -57,6 +57,8 @@ VOID BootMain(LPSTR CmdLine) } // We need to emulate these, because the original ones don't work in freeldr +// These functions are here, because they need to be in the main compilation unit +// and cannot be in a library. int __cdecl wctomb(char *mbchar, wchar_t wchar) { *mbchar = (char)wchar; @@ -68,3 +70,10 @@ int __cdecl mbtowc (wchar_t *wchar, const char *mbchar, size_t count) *wchar = (wchar_t)*mbchar; return 1; } + +// The wctype table is 144 KB, too much for poor freeldr +int iswctype(wint_t wc, wctype_t wctypeFlags) +{ + return _isctype((char)wc, wctypeFlags); +} + diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake index 05479fb94b5..01f11982cab 100644 --- a/reactos/lib/sdk/crt/crt.cmake +++ b/reactos/lib/sdk/crt/crt.cmake @@ -252,6 +252,8 @@ list(APPEND CRT_SOURCE string/atoi64.c string/atol.c string/ctype.c + string/iswctype.c + string/is_wctype.c string/itoa.c string/itow.c string/scanf.c diff --git a/reactos/lib/sdk/crt/libcntpr.cmake b/reactos/lib/sdk/crt/libcntpr.cmake index b69636ec764..5723d993344 100644 --- a/reactos/lib/sdk/crt/libcntpr.cmake +++ b/reactos/lib/sdk/crt/libcntpr.cmake @@ -27,6 +27,8 @@ list(APPEND LIBCNTPR_SOURCE search/lfind.c stdlib/qsort.c string/ctype.c + string/iswctype.c + string/is_wctype.c string/scanf.c string/strcspn.c string/stricmp.c @@ -182,7 +184,7 @@ else() endif() add_library(libcntpr ${LIBCNTPR_SOURCE}) -add_target_compile_definitions(libcntpr +add_target_compile_definitions(libcntpr NO_RTL_INLINES _NTSYSTEM_ _NTDLLBUILD_ diff --git a/reactos/lib/sdk/crt/string/ctype.c b/reactos/lib/sdk/crt/string/ctype.c index 7c5188570f9..a28fd2058f1 100644 --- a/reactos/lib/sdk/crt/string/ctype.c +++ b/reactos/lib/sdk/crt/string/ctype.c @@ -584,24 +584,6 @@ int _isctype (int c, int ctypeFlags) return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); } -/* - * @implemented - */ -int iswctype(wint_t wc, wctype_t wctypeFlags) -{ - return (wine_wctype_table[wine_wctype_table[wc >> 8] + (wc & 0xff)] & wctypeFlags); -} - -/* - * obsolete - * - * @implemented - */ -int is_wctype(wint_t wc, wctype_t wctypeFlags) -{ - return (wine_wctype_table[wine_wctype_table[wc >> 8] + (wc & 0xff)] & wctypeFlags); -} - /* * @implemented */ diff --git a/reactos/lib/sdk/crt/string/is_wctype.c b/reactos/lib/sdk/crt/string/is_wctype.c new file mode 100644 index 00000000000..030900010de --- /dev/null +++ b/reactos/lib/sdk/crt/string/is_wctype.c @@ -0,0 +1,13 @@ +#include + +extern const unsigned short wine_wctype_table[]; + +/* + * obsolete + * + * @implemented + */ +int is_wctype(wint_t wc, wctype_t wctypeFlags) +{ + return iswctype(wc, wctypeFlags); +} diff --git a/reactos/lib/sdk/crt/string/iswctype.c b/reactos/lib/sdk/crt/string/iswctype.c new file mode 100644 index 00000000000..94b59e6ba74 --- /dev/null +++ b/reactos/lib/sdk/crt/string/iswctype.c @@ -0,0 +1,12 @@ +#include + +extern const unsigned short wine_wctype_table[]; + +/* + * @implemented + */ +int iswctype(wint_t wc, wctype_t wctypeFlags) +{ + return (wine_wctype_table[wine_wctype_table[wc >> 8] + (wc & 0xff)] & wctypeFlags); +} +