winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
December 2019
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
635 discussions
Start a n
N
ew thread
Alexandre Julliard : kernel32: Move some initialization code to ntdll.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 331947c993c06b63ccc3adbe5500b24fbf79e3ed URL:
https://source.winehq.org/git/wine.git/?a=commit;h=331947c993c06b63ccc3adbe…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 19:54:56 2019 +0100 kernel32: Move some initialization code to ntdll. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/process.c | 9 --------- dlls/ntdll/debugtools.c | 2 ++ dlls/ntdll/env.c | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 72a93a7fe7..779c13cb54 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -170,20 +170,11 @@ void * CDECL __wine_kernel_init(void) { static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0}; - PEB *peb = NtCurrentTeb()->Peb; - RTL_USER_PROCESS_PARAMETERS *params = peb->ProcessParameters; - - /* Initialize everything */ - - setbuf(stdout,NULL); - setbuf(stderr,NULL); kernel32_handle = GetModuleHandleW(kernel32W); RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter ); LOCALE_Init(); - if (!params->CurrentDirectory.Handle) chdir("/"); /* avoid locking removable devices */ - return start_process_wrapper; } diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c index 64355ab3b8..546d527323 100644 --- a/dlls/ntdll/debugtools.c +++ b/dlls/ntdll/debugtools.c @@ -284,6 +284,8 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_ */ void debug_init(void) { + setbuf( stdout, NULL ); + setbuf( stderr, NULL ); ntdll_get_thread_data()->debug_info = &initial_info; init_done = TRUE; } diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index ebeda01ff8..116a57a8e7 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -1546,5 +1546,6 @@ done: RtlInitUnicodeString( &curdir, windows_dir ); RtlSetCurrentDirectory_U( &curdir ); } + if (!params->CurrentDirectory.Handle) chdir("/"); /* avoid locking removable devices */ set_wow64_environment( ¶ms->Environment ); }
1
0
0
0
Alexandre Julliard : kernel32: Initialize argv from the dll entry point.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 74eaa34147c08b15cb439d78b924b138e7571d6c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=74eaa34147c08b15cb439d78…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 19:20:17 2019 +0100 kernel32: Initialize argv from the dll entry point. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/kernel_main.c | 32 ++++++++++++++++++++++++++++++++ dlls/kernel32/process.c | 34 ---------------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c index 954b08b523..1d61853d86 100644 --- a/dlls/kernel32/kernel_main.c +++ b/dlls/kernel32/kernel_main.c @@ -29,6 +29,7 @@ #include "windef.h" #include "winbase.h" +#include "winnls.h" #include "wincon.h" #include "winternl.h" @@ -76,6 +77,36 @@ static void set_entry_point( HMODULE module, const char *name, DWORD rva ) } +/*********************************************************************** + * set_library_argv + * + * Set the Wine library argv global variable. + */ +static void set_library_argv( WCHAR **wargv ) +{ + int argc; + char *p, **argv; + DWORD total = 0; + + /* convert argv back from Unicode since it has to be in the Ansi codepage not the Unix one */ + + for (argc = 0; wargv[argc]; argc++) + total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL ); + + argv = RtlAllocateHeap( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) ); + p = (char *)(argv + argc + 1); + for (argc = 0; wargv[argc]; argc++) + { + DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL ); + argv[argc] = p; + p += reslen; + total -= reslen; + } + argv[argc] = NULL; + __wine_main_argv = argv; +} + + /*********************************************************************** * KERNEL process initialisation routine */ @@ -83,6 +114,7 @@ static BOOL process_attach( HMODULE module ) { RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters; + set_library_argv( __wine_main_wargv ); NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL ); /* Setup registry timezone information */ diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 09c6bab3ce..72a93a7fe7 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -86,39 +86,6 @@ const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s', #define PDB32_WIN32S_PROC 0x8000 /* Win32s process */ -/*********************************************************************** - * set_library_argv - * - * Set the Wine library argv global variables. - */ -static void set_library_argv( WCHAR **wargv ) -{ - int argc; - char *p, **argv; - DWORD total = 0; - - /* convert argv back from Unicode since it has to be in the Ansi codepage not the Unix one */ - - for (argc = 0; wargv[argc]; argc++) - total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL ); - - argv = RtlAllocateHeap( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) ); - p = (char *)(argv + argc + 1); - for (argc = 0; wargv[argc]; argc++) - { - DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL ); - argv[argc] = p; - p += reslen; - total -= reslen; - } - argv[argc] = NULL; - - __wine_main_argc = argc; - __wine_main_argv = argv; - __wine_main_wargv = wargv; -} - - #ifdef __i386__ extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry ); __ASM_GLOBAL_FUNC( call_process_entry, @@ -214,7 +181,6 @@ void * CDECL __wine_kernel_init(void) RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter ); LOCALE_Init(); - set_library_argv( __wine_main_wargv ); if (!params->CurrentDirectory.Handle) chdir("/"); /* avoid locking removable devices */
1
0
0
0
Alexandre Julliard : kernel32: Use the Rtl UTF8 conversion functions.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: d33504b9bb2de873ffe15c1b4d0598fdfd414672 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d33504b9bb2de873ffe15c1b…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 12:34:00 2019 +0100 kernel32: Use the Rtl UTF8 conversion functions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/locale.c | 84 ++++++++++++++++++++++++++++++------------- dlls/msvcrt/tests/file.c | 4 +-- dlls/ntdll/tests/rtlstr.c | 90 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 141 insertions(+), 37 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=d33504b9bb2de873ffe1…
1
0
0
0
Alexandre Julliard : ntdll: Use the Rtl UTF8 conversion functions.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: f46fa9c92d08c6e656bc22b94e09aa9dbe7d3be9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f46fa9c92d08c6e656bc22b9…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 12:25:54 2019 +0100 ntdll: Use the Rtl UTF8 conversion functions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/actctx.c | 17 ++++++----------- dlls/ntdll/locale.c | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index d5f2f70273..9e7782c1ee 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -2834,20 +2834,15 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident } else { - /* let's assume utf-8 for now */ - int len = wine_utf8_mbstowcs( 0, buffer, size, NULL, 0 ); + DWORD len; WCHAR *new_buff; - if (len == -1) - { - FIXME( "utf-8 conversion failed\n" ); - return STATUS_SXS_CANT_GEN_ACTCTX; - } - if (!(new_buff = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) - return STATUS_NO_MEMORY; - wine_utf8_mbstowcs( 0, buffer, size, new_buff, len ); + /* let's assume utf-8 for now */ + RtlUTF8ToUnicodeN( NULL, 0, &len, buffer, size ); + if (!(new_buff = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY; + RtlUTF8ToUnicodeN( new_buff, len, &len, buffer, size ); xmlbuf.ptr = new_buff; - xmlbuf.end = xmlbuf.ptr + len; + xmlbuf.end = xmlbuf.ptr + len / sizeof(WCHAR); status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf ); RtlFreeHeap( GetProcessHeap(), 0, new_buff ); } diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index d7a6401560..f5faada578 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -636,13 +636,19 @@ void init_locale( HMODULE module ) */ int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int dstlen ) { -#ifdef __APPLE__ - /* work around broken Mac OS X filesystem that enforces decomposed Unicode */ - flags |= MB_COMPOSITE; + DWORD reslen; + NTSTATUS status; + + if (unix_table) return wine_cp_mbstowcs( unix_table, flags, src, srclen, dst, dstlen ); + + if (!dstlen) dst = NULL; + status = RtlUTF8ToUnicodeN( dst, dstlen * sizeof(WCHAR), &reslen, src, srclen ); + if (status && status != STATUS_SOME_NOT_MAPPED) return 0; + reslen /= sizeof(WCHAR); +#ifdef __APPLE__ /* work around broken Mac OS X filesystem that enforces decomposed Unicode */ + if (reslen && dst) RtlNormalizeString( NormalizationC, dst, reslen, dst, (int *)&reslen ); #endif - return unix_table ? - wine_cp_mbstowcs( unix_table, flags, src, srclen, dst, dstlen ) : - wine_utf8_mbstowcs( flags, src, srclen, dst, dstlen ); + return reslen; } @@ -652,10 +658,16 @@ int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int d int ntdll_wcstoumbs( DWORD flags, const WCHAR *src, int srclen, char *dst, int dstlen, const char *defchar, int *used ) { - if (unix_table) - return wine_cp_wcstombs( unix_table, flags, src, srclen, dst, dstlen, defchar, used ); + DWORD reslen; + NTSTATUS status; + + if (unix_table) return wine_cp_wcstombs( unix_table, flags, src, srclen, dst, dstlen, defchar, used ); + if (used) *used = 0; /* all chars are valid for UTF-8 */ - return wine_utf8_wcstombs( flags, src, srclen, dst, dstlen ); + if (!dstlen) dst = NULL; + status = RtlUnicodeToUTF8N( dst, dstlen, &reslen, src, srclen * sizeof(WCHAR) ); + if (status && status != STATUS_SOME_NOT_MAPPED) return 0; + return reslen; }
1
0
0
0
Alexandre Julliard : ntdll: Implement RtlUTF8ToUnicodeN.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 27f0426b6f3189ef20a6a2d5ef09688a0dd64c61 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=27f0426b6f3189ef20a6a2d5…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 10:10:47 2019 +0100 ntdll: Implement RtlUTF8ToUnicodeN. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/ntdll.spec | 1 + include/winternl.h | 1 + 3 files changed, 116 insertions(+) diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 09f64b8dad..d7a6401560 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -1307,6 +1307,120 @@ found: } +/* helper for the various utf8 mbstowcs functions */ +static unsigned int decode_utf8_char( unsigned char ch, const char **str, const char *strend ) +{ + /* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */ + static const char utf8_length[128] = + { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */ + 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */ + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */ + 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 /* 0xf0-0xff */ + }; + + /* first byte mask depending on UTF-8 sequence length */ + static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 }; + + unsigned int len = utf8_length[ch - 0x80]; + unsigned int res = ch & utf8_mask[len]; + const char *end = *str + len; + + if (end > strend) + { + *str = end; + return ~0; + } + switch (len) + { + case 3: + if ((ch = end[-3] ^ 0x80) >= 0x40) break; + res = (res << 6) | ch; + (*str)++; + if (res < 0x10) break; + case 2: + if ((ch = end[-2] ^ 0x80) >= 0x40) break; + res = (res << 6) | ch; + if (res >= 0x110000 >> 6) break; + (*str)++; + if (res < 0x20) break; + if (res >= 0xd800 >> 6 && res <= 0xdfff >> 6) break; + case 1: + if ((ch = end[-1] ^ 0x80) >= 0x40) break; + res = (res << 6) | ch; + (*str)++; + if (res < 0x80) break; + return res; + } + return ~0; +} + + +/************************************************************************** + * RtlUTF8ToUnicodeN (NTDLL.@) + */ +NTSTATUS WINAPI RtlUTF8ToUnicodeN( WCHAR *dst, DWORD dstlen, DWORD *reslen, const char *src, DWORD srclen ) +{ + unsigned int res, len; + NTSTATUS status = STATUS_SUCCESS; + const char *srcend = src + srclen; + WCHAR *dstend; + + if (!src) return STATUS_INVALID_PARAMETER_4; + if (!reslen) return STATUS_INVALID_PARAMETER; + + dstlen /= sizeof(WCHAR); + dstend = dst + dstlen; + if (!dst) + { + for (len = 0; src < srcend; len++) + { + unsigned char ch = *src++; + if (ch < 0x80) continue; + if ((res = decode_utf8_char( ch, &src, srcend )) > 0x10ffff) + status = STATUS_SOME_NOT_MAPPED; + else + if (res > 0xffff) len++; + } + *reslen = len * sizeof(WCHAR); + return status; + } + + while ((dst < dstend) && (src < srcend)) + { + unsigned char ch = *src++; + if (ch < 0x80) /* special fast case for 7-bit ASCII */ + { + *dst++ = ch; + continue; + } + if ((res = decode_utf8_char( ch, &src, srcend )) <= 0xffff) + { + *dst++ = res; + } + else if (res <= 0x10ffff) /* we need surrogates */ + { + res -= 0x10000; + *dst++ = 0xd800 | (res >> 10); + if (dst == dstend) break; + *dst++ = 0xdc00 | (res & 0x3ff); + } + else + { + *dst++ = 0xfffd; + status = STATUS_SOME_NOT_MAPPED; + } + } + if (src < srcend) status = STATUS_BUFFER_TOO_SMALL; /* overflow */ + *reslen = (dstlen - (dstend - dst)) * sizeof(WCHAR); + return status; +} + + /* get the next char value taking surrogates into account */ static inline unsigned int get_surrogate_value( const WCHAR *src, unsigned int srclen ) { diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 566f51c8d1..415a43ab53 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -981,6 +981,7 @@ @ stdcall RtlTryAcquireSRWLockExclusive(ptr) @ stdcall RtlTryAcquireSRWLockShared(ptr) @ stdcall RtlTryEnterCriticalSection(ptr) +@ stdcall RtlUTF8ToUnicodeN(ptr long ptr ptr long) @ cdecl -i386 -norelay RtlUlongByteSwap() NTDLL_RtlUlongByteSwap @ cdecl -ret64 RtlUlonglongByteSwap(int64) # @ stub RtlUnhandledExceptionFilter2 diff --git a/include/winternl.h b/include/winternl.h index ea46087aac..9e7e2bad93 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2902,6 +2902,7 @@ NTSYSAPI BOOLEAN WINAPI RtlTimeToSecondsSince1980(const LARGE_INTEGER *,LPDWOR NTSYSAPI BOOLEAN WINAPI RtlTryAcquireSRWLockExclusive(RTL_SRWLOCK *); NTSYSAPI BOOLEAN WINAPI RtlTryAcquireSRWLockShared(RTL_SRWLOCK *); NTSYSAPI BOOL WINAPI RtlTryEnterCriticalSection(RTL_CRITICAL_SECTION *); +NTSYSAPI NTSTATUS WINAPI RtlUTF8ToUnicodeN(WCHAR*,DWORD,DWORD*,const char*,DWORD); NTSYSAPI ULONGLONG __cdecl RtlUlonglongByteSwap(ULONGLONG); NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING*); NTSYSAPI NTSTATUS WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING,PCUNICODE_STRING,BOOLEAN);
1
0
0
0
Alexandre Julliard : ntdll: Reimplement RtlUnicodeToUTF8N.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 0b39344ef0b02a969e9755a891f7d7f1a2986d48 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0b39344ef0b02a969e9755a8…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Dec 3 10:10:39 2019 +0100 ntdll: Reimplement RtlUnicodeToUTF8N. This avoids relying on wine_utf8_wcstombs(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/rtlstr.c | 33 -------------- dlls/ntdll/tests/rtlstr.c | 16 ------- 3 files changed, 111 insertions(+), 49 deletions(-) diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 5ad32e4f1b..09f64b8dad 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -1307,6 +1307,117 @@ found: } +/* get the next char value taking surrogates into account */ +static inline unsigned int get_surrogate_value( const WCHAR *src, unsigned int srclen ) +{ + if (src[0] >= 0xd800 && src[0] <= 0xdfff) /* surrogate pair */ + { + if (src[0] > 0xdbff || /* invalid high surrogate */ + srclen <= 1 || /* missing low surrogate */ + src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */ + return 0; + return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff); + } + return src[0]; +} + + +/************************************************************************** + * RtlUnicodeToUTF8N (NTDLL.@) + */ +NTSTATUS WINAPI RtlUnicodeToUTF8N( char *dst, DWORD dstlen, DWORD *reslen, const WCHAR *src, DWORD srclen ) +{ + char *end; + unsigned int val, len; + NTSTATUS status = STATUS_SUCCESS; + + if (!src) return STATUS_INVALID_PARAMETER_4; + if (!reslen) return STATUS_INVALID_PARAMETER; + if (dst && (srclen & 1)) return STATUS_INVALID_PARAMETER_5; + + srclen /= sizeof(WCHAR); + + if (!dst) + { + for (len = 0; srclen; srclen--, src++) + { + if (*src < 0x80) len++; /* 0x00-0x7f: 1 byte */ + else if (*src < 0x800) len += 2; /* 0x80-0x7ff: 2 bytes */ + else + { + if (!(val = get_surrogate_value( src, srclen ))) + { + val = 0xfffd; + status = STATUS_SOME_NOT_MAPPED; + } + if (val < 0x10000) len += 3; /* 0x800-0xffff: 3 bytes */ + else /* 0x10000-0x10ffff: 4 bytes */ + { + len += 4; + src++; + srclen--; + } + } + } + *reslen = len; + return status; + } + + for (end = dst + dstlen; srclen; srclen--, src++) + { + WCHAR ch = *src; + + if (ch < 0x80) /* 0x00-0x7f: 1 byte */ + { + if (dst > end - 1) break; + *dst++ = ch; + continue; + } + if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */ + { + if (dst > end - 2) break; + dst[1] = 0x80 | (ch & 0x3f); + ch >>= 6; + dst[0] = 0xc0 | ch; + dst += 2; + continue; + } + if (!(val = get_surrogate_value( src, srclen ))) + { + val = 0xfffd; + status = STATUS_SOME_NOT_MAPPED; + } + if (val < 0x10000) /* 0x800-0xffff: 3 bytes */ + { + if (dst > end - 3) break; + dst[2] = 0x80 | (val & 0x3f); + val >>= 6; + dst[1] = 0x80 | (val & 0x3f); + val >>= 6; + dst[0] = 0xe0 | val; + dst += 3; + } + else /* 0x10000-0x10ffff: 4 bytes */ + { + if (dst > end - 4) break; + dst[3] = 0x80 | (val & 0x3f); + val >>= 6; + dst[2] = 0x80 | (val & 0x3f); + val >>= 6; + dst[1] = 0x80 | (val & 0x3f); + val >>= 6; + dst[0] = 0xf0 | val; + dst += 4; + src++; + srclen--; + } + } + if (srclen) status = STATUS_BUFFER_TOO_SMALL; + *reslen = dstlen - (end - dst); + return status; +} + + /****************************************************************************** * RtlIsNormalizedString (NTDLL.@) */ diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index 8196dd7178..c0d8ec6477 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -709,39 +709,6 @@ NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem, } -/************************************************************************** - * RtlUnicodeToUTF8N (NTDLL.@) - * - * Converts a Unicode string to a UTF-8 string. - * - * RETURNS - * NTSTATUS code - */ -NTSTATUS WINAPI RtlUnicodeToUTF8N( LPSTR dst, DWORD dstlen, LPDWORD reslen, - LPCWSTR src, DWORD srclen) -{ - int ret; - - if (!src) return STATUS_INVALID_PARAMETER_4; - if (!reslen) return STATUS_INVALID_PARAMETER; - if (dst && (srclen & 1)) return STATUS_INVALID_PARAMETER_5; - - if (!dstlen && dst) - { - char c; - dst = &c; - ret = wine_utf8_wcstombs( 0, src, srclen / sizeof(WCHAR), dst, 1 ); - if (ret > 0) ret--; - } - else - ret = wine_utf8_wcstombs( 0, src, srclen / sizeof(WCHAR), dst, dstlen ); - if (reslen) - *reslen = (ret >= 0) ? ret : dstlen; /* overflow -> we filled up to dstlen */ - if (ret < 0) return STATUS_BUFFER_TOO_SMALL; - return STATUS_SUCCESS; -} - - /* CASE CONVERSIONS */ diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c index 4583ddeb4b..6be036f406 100644 --- a/dlls/ntdll/tests/rtlstr.c +++ b/dlls/ntdll/tests/rtlstr.c @@ -2152,11 +2152,8 @@ static void test_RtlUnicodeToUTF8N(void) length_expect(0, 0, STATUS_SUCCESS); length_expect(1, 1, STATUS_SUCCESS); length_expect(2, 3, STATUS_SUCCESS); -todo_wine -{ length_expect(3, 6, STATUS_SOME_NOT_MAPPED); length_expect(4, 7, STATUS_SOME_NOT_MAPPED); -} #undef length_expect for (i = 0; i <= 6; i++) @@ -2164,20 +2161,14 @@ todo_wine memset(buffer, 0x55, sizeof(buffer)); bytes_out = 0xdeadbeef; status = pRtlUnicodeToUTF8N(buffer, i, &bytes_out, special_string, sizeof(special_string)); -todo_wine_if (i == 4 || i == 5 || i == 6) ok(status == STATUS_BUFFER_TOO_SMALL, "%d: status = 0x%x\n", i, status); -todo_wine_if (bytes_out != special_string_len[i]) ok(bytes_out == special_string_len[i], "%d: expected %u, got %u\n", i, special_string_len[i], bytes_out); -todo_wine_if (i == 6) ok(memcmp(buffer, special_expected, special_string_len[i]) == 0, "%d: bad conversion\n", i); } status = pRtlUnicodeToUTF8N(buffer, 7, &bytes_out, special_string, sizeof(special_string)); -todo_wine ok(status == STATUS_SOME_NOT_MAPPED, "status = 0x%x\n", status); -todo_wine ok(bytes_out == special_string_len[7], "expected %u, got %u\n", special_string_len[7], bytes_out); -todo_wine ok(memcmp(buffer, special_expected, 7) == 0, "bad conversion\n"); /* conversion behavior with varying input length */ @@ -2225,19 +2216,15 @@ todo_wine status = pRtlUnicodeToUTF8N( buffer, sizeof(buffer), &bytes_out, unicode_to_utf8[i].unicode, lstrlenW(unicode_to_utf8[i].unicode) * sizeof(WCHAR)); -todo_wine_if(unicode_to_utf8[i].status == STATUS_SOME_NOT_MAPPED) ok(status == unicode_to_utf8[i].status, "(test %d): status is 0x%x, expected 0x%x\n", i, status, unicode_to_utf8[i].status); -todo_wine_if(i == 9 || i == 10 || i == 11) -{ ok(bytes_out == strlen(unicode_to_utf8[i].expected), "(test %d): bytes_out is %u, expected %u\n", i, bytes_out, lstrlenA(unicode_to_utf8[i].expected)); ok(!memcmp(buffer, unicode_to_utf8[i].expected, bytes_out), "(test %d): got \"%.*s\", expected \"%s\"\n", i, bytes_out, buffer, unicode_to_utf8[i].expected); -} ok(buffer[bytes_out] == 0x55, "(test %d): behind string: 0x%x\n", i, buffer[bytes_out]); @@ -2247,8 +2234,6 @@ todo_wine_if(i == 9 || i == 10 || i == 11) status = pRtlUnicodeToUTF8N( buffer, sizeof(buffer), &bytes_out, unicode_to_utf8[i].unicode, (lstrlenW(unicode_to_utf8[i].unicode) + 1) * sizeof(WCHAR)); -todo_wine_if(i == 9 || i == 10 || i == 11) -{ ok(status == unicode_to_utf8[i].status, "(test %d): status is 0x%x, expected 0x%x\n", i, status, unicode_to_utf8[i].status); @@ -2258,7 +2243,6 @@ todo_wine_if(i == 9 || i == 10 || i == 11) ok(!memcmp(buffer, unicode_to_utf8[i].expected, bytes_out), "(test %d): got \"%.*s\", expected \"%s\"\n", i, bytes_out, buffer, unicode_to_utf8[i].expected); -} ok(buffer[bytes_out] == 0x55, "(test %d): behind string: 0x%x\n", i, buffer[bytes_out]); }
1
0
0
0
Alexandre Julliard : jscript: Always check for errors in UTF8 conversions.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 0d0b7a145112b251c417327b8d93396ce24ec445 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0d0b7a145112b251c417327b…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Dec 4 16:03:21 2019 +0100 jscript: Always check for errors in UTF8 conversions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/jscript/global.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 37b222beba..2f7dbcd53f 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -629,7 +629,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') { len++; }else { - i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3; + i = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, ptr, 1, NULL, 0, NULL, NULL)*3; if(!i) { jsstr_release(str); return throw_uri_error(ctx, JS_E_INVALID_URI_CHAR, NULL); @@ -649,7 +649,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') { *rptr++ = *ptr; }else { - len = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL); + len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, ptr, 1, buf, sizeof(buf), NULL, NULL); for(i=0; i<len; i++) { *rptr++ = '%'; *rptr++ = int_to_char((BYTE)buf[i] >> 4); @@ -703,7 +703,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags val += hex_to_int(ptr[i*3+1])<<4; buf[i] = val; - res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, &out, 1); + res = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buf, i+1, &out, 1); if(res) break; } @@ -734,7 +734,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags val += hex_to_int(ptr[i*3+1])<<4; buf[i] = val; - res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, ret, 1); + res = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buf, i+1, ret, 1); if(res) break; } @@ -780,7 +780,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W if(is_uri_unescaped(*ptr)) len++; else { - size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL); + size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, ptr, 1, NULL, 0, NULL, NULL); if(!size) { jsstr_release(str); return throw_uri_error(ctx, JS_E_INVALID_URI_CHAR, NULL); @@ -799,7 +799,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W if(is_uri_unescaped(*ptr)) { *ret++ = *ptr; }else { - size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL); + size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, ptr, 1, buf, sizeof(buf), NULL, NULL); for(i=0; i<size; i++) { *ret++ = '%'; *ret++ = int_to_char((BYTE)buf[i] >> 4);
1
0
0
0
Alexandre Julliard : kernelbase: Verify that the file can be opened when looking for an executable.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: b82842461215f25c6d0819104cd06ab5cc7bf28a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b82842461215f25c6d081910…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Dec 4 10:07:03 2019 +0100 kernelbase: Verify that the file can be opened when looking for an executable. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=48211
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/process.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 51b75470c8..90ea299416 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -57,6 +57,13 @@ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, DWORD buflen ) ret = (SearchPathW( load_path, name, L".exe", buflen, buffer, NULL ) || /* not found, try without extension in case it is a Unix app */ SearchPathW( load_path, name, NULL, buflen, buffer, NULL )); + + if (ret) /* make sure it can be opened, SearchPathW also returns directories */ + { + HANDLE handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, + NULL, OPEN_EXISTING, 0, 0 ); + if ((ret = (handle != INVALID_HANDLE_VALUE))) CloseHandle( handle ); + } RtlReleasePath( load_path ); return ret; }
1
0
0
0
João Diogo Ferreira : kernelbase: Update GeoID when locale has changed.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: 7b1b0ce506be6871e8c3c5f6b837e0dc2c02b88c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7b1b0ce506be6871e8c3c5f6…
Author: João Diogo Ferreira <devilj(a)outlook.pt> Date: Mon Dec 2 21:39:54 2019 +0000 kernelbase: Update GeoID when locale has changed. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46196
Signed-off-by: João Diogo Craveiro Ferreira <devilj(a)outlook.pt> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 9bc3cfe80e..d81da5195f 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -239,7 +239,8 @@ void init_locale(void) USHORT *ansi_ptr, *oem_ptr, *casemap_ptr; LCID lcid = GetUserDefaultLCID(); WCHAR bufferW[80]; - DWORD count, i; + GEOID geoid = GEOID_NOT_AVAILABLE; + DWORD count, dispos, i; SIZE_T size; HKEY hkey; @@ -268,6 +269,17 @@ void init_locale(void) RegCreateKeyExW( HKEY_CURRENT_USER, L"Control Panel\\International", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &intl_key, NULL ); + if (!RegCreateKeyExW( intl_key, L"Geo", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, &dispos )) + { + if (dispos == REG_CREATED_NEW_KEY) + { + GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IGEOID | LOCALE_RETURN_NUMBER, + (WCHAR *)&geoid, sizeof(geoid) / sizeof(WCHAR) ); + SetUserGeoID( geoid ); + } + RegCloseKey( hkey ); + } + /* Update registry contents if the user locale has changed. * This simulates the action of the Windows control panel. */ @@ -290,6 +302,13 @@ void init_locale(void) (BYTE *)bufferW, (lstrlenW(bufferW) + 1) * sizeof(WCHAR) ); } + if (geoid == GEOID_NOT_AVAILABLE) + { + GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_IGEOID | LOCALE_RETURN_NUMBER, + (WCHAR *)&geoid, sizeof(geoid) / sizeof(WCHAR) ); + SetUserGeoID( geoid ); + } + if (!RegCreateKeyExW( nls_key, L"Codepage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) {
1
0
0
0
João Diogo Ferreira : kernel32: Make GetUserGeoID() always succeed if geoclass is valid.
by Alexandre Julliard
04 Dec '19
04 Dec '19
Module: wine Branch: master Commit: a31dec5fa9cf148d6ac6aed4c3afc2882170a8e4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a31dec5fa9cf148d6ac6aed4…
Author: João Diogo Ferreira <devilj(a)outlook.pt> Date: Mon Dec 2 21:39:52 2019 +0000 kernel32: Make GetUserGeoID() always succeed if geoclass is valid. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46196
Signed-off-by: João Diogo Craveiro Ferreira <devilj(a)outlook.pt> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/locale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index 5b196be2d5..cd9f7fac2f 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -2810,7 +2810,7 @@ static const struct geoinfo_t *get_geoinfo_dataptr(GEOID geoid) */ GEOID WINAPI GetUserGeoID(GEOCLASS geoclass) { - GEOID ret = GEOID_NOT_AVAILABLE; + GEOID ret = 39070; static const WCHAR geoW[] = {'G','e','o',0}; static const WCHAR nationW[] = {'N','a','t','i','o','n',0}; static const WCHAR regionW[] = {'R','e','g','i','o','n',0}; @@ -2831,7 +2831,7 @@ GEOID WINAPI GetUserGeoID(GEOCLASS geoclass) break; default: WARN("Unknown geoclass %d\n", geoclass); - return ret; + return GEOID_NOT_AVAILABLE; } if (!(hkey = create_registry_key())) return ret;
1
0
0
0
← Newer
1
...
51
52
53
54
55
56
57
...
64
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Results per page:
10
25
50
100
200