ReactOS.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
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
List overview
Download
Ros-diffs
May 2021
----- 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
ros-diffs@reactos.org
21 participants
183 discussions
Start a n
N
ew thread
[reactos] 07/11: [RTL] Properly truncate 8dot3 names when using a MultiByte OEM code page
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30f2ad79498910848aacd…
commit 30f2ad79498910848aacdf2b03de88372f21556e Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon May 17 17:40:26 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [RTL] Properly truncate 8dot3 names when using a MultiByte OEM code page CORE-17571 --- sdk/lib/rtl/dos8dot3.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sdk/lib/rtl/dos8dot3.c b/sdk/lib/rtl/dos8dot3.c index 05301fd444f..1f9ead5e832 100644 --- a/sdk/lib/rtl/dos8dot3.c +++ b/sdk/lib/rtl/dos8dot3.c @@ -102,8 +102,9 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name, DotPos = Index; } - /* Copy name (6 valid characters max) */ - for (Index = 0; Index < DotPos && Context->NameLength < 6; Index++) + /* Copy name. OEM string length can't exceed 6. */ + UCHAR OemSizeLeft = 6; + for (Index = 0; (Index < DotPos) && OemSizeLeft; Index++) { Char = Name->Buffer[Index]; @@ -115,8 +116,17 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name, else if (Char >= L'a' && Char <= L'z') Char = RtlpUpcaseUnicodeChar(Char); + /* Beware of MB OEM codepage */ + if (NlsMbOemCodePageTag && HIBYTE(NlsUnicodeToMbOemTable[Char])) + { + if (OemSizeLeft < 2) + break; + OemSizeLeft--; + } + Context->NameBuffer[Context->NameLength] = Char; - ++Context->NameLength; + Context->NameLength++; + OemSizeLeft--; } }
3 years, 7 months
1
0
0
0
[reactos] 06/11: [RTL] Fix RtlIsValidOemCharacter implementation for Multibyte code pages
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=49fcbe7cd8531178970ff…
commit 49fcbe7cd8531178970ffe48f91f3dc4d68022d1 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon May 17 16:14:26 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [RTL] Fix RtlIsValidOemCharacter implementation for Multibyte code pages CORE-17571 --- sdk/lib/rtl/unicode.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c index 7f045401326..e1896497ce6 100644 --- a/sdk/lib/rtl/unicode.c +++ b/sdk/lib/rtl/unicode.c @@ -519,16 +519,24 @@ RtlIsValidOemCharacter(IN PWCHAR Char) /* If multi-byte code page present */ if (NlsMbOemCodePageTag) { - USHORT Offset = 0; + USHORT Offset; OemChar = NlsUnicodeToMbOemTable[*Char]; /* If character has Lead Byte */ - if (NlsOemLeadByteInfo[HIBYTE(OemChar)]) - Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)]; + Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)]; + if (Offset) + { + /* Use DBCS table */ + UnicodeChar = NlsOemLeadByteInfo[Offset + LOBYTE(OemChar)]; + } + else + { + UnicodeChar = NlsOemToUnicodeTable[OemChar]; + } - /* Receive Unicode character from the table */ - UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]); + /* Upcase */ + UnicodeChar = RtlpUpcaseUnicodeChar(UnicodeChar); /* Receive OEM character from the table */ OemChar = NlsUnicodeToMbOemTable[UnicodeChar]; @@ -544,7 +552,10 @@ RtlIsValidOemCharacter(IN PWCHAR Char) /* Not valid character, failed */ if (OemChar == NlsOemDefaultChar) + { + DPRINT1("\\u%04x is not valid for OEM\n", *Char); return FALSE; + } *Char = UnicodeChar;
3 years, 7 months
1
0
0
0
[reactos] 05/11: [RTL] Properly implement RtlUnicodeToOemN
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1b08836338a25d96c9fd1…
commit 1b08836338a25d96c9fd11e57d1cc07f5de44bda Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon May 17 16:10:48 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [RTL] Properly implement RtlUnicodeToOemN CORE-17571 --- sdk/lib/rtl/nls.c | 72 +++++++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/sdk/lib/rtl/nls.c b/sdk/lib/rtl/nls.c index fc4e8440460..a875379ca15 100644 --- a/sdk/lib/rtl/nls.c +++ b/sdk/lib/rtl/nls.c @@ -634,9 +634,10 @@ RtlUnicodeToMultiByteSize(OUT PULONG MbSize, } /* - * @unimplemented + * @implemented */ -NTSTATUS NTAPI +NTSTATUS +NTAPI RtlUnicodeToOemN(OUT PCHAR OemString, IN ULONG OemSize, OUT PULONG ResultSize OPTIONAL, @@ -644,68 +645,45 @@ RtlUnicodeToOemN(OUT PCHAR OemString, IN ULONG UnicodeSize) { ULONG Size = 0; - ULONG i; PAGED_CODE_RTL(); + /* Bytes -> chars */ + UnicodeSize /= sizeof(WCHAR); + if (!NlsMbOemCodePageTag) { - /* single-byte code page */ - if (UnicodeSize > (OemSize * sizeof(WCHAR))) - Size = OemSize; - else - Size = UnicodeSize / sizeof(WCHAR); - - if (ResultSize) - *ResultSize = Size; - - for (i = 0; i < Size; i++) + while (OemSize && UnicodeSize) { - *OemString = NlsUnicodeToOemTable[*UnicodeString]; - OemString++; - UnicodeString++; + OemString[Size] = NlsUnicodeToOemTable[*UnicodeString++]; + Size++; + OemSize--; + UnicodeSize--; } } else { - /* multi-byte code page */ - /* FIXME */ - - USHORT WideChar; - USHORT OemChar; - - for (i = OemSize, Size = UnicodeSize / sizeof(WCHAR); i && Size; i--, Size--) + while (OemSize && UnicodeSize) { - WideChar = *UnicodeString++; + USHORT OemChar = NlsUnicodeToMbOemTable[*UnicodeString++]; - if (WideChar < 0x80) + if (HIBYTE(OemChar)) { - *OemString++ = LOBYTE(WideChar); - continue; + if (OemSize < 2) + break; + OemString[Size++] = HIBYTE(OemChar); + OemSize--; } - - OemChar = NlsUnicodeToMbOemTable[WideChar]; - - if (!HIBYTE(OemChar)) - { - *OemString++ = LOBYTE(OemChar); - continue; - } - - if (i >= 2) - { - *OemString++ = HIBYTE(OemChar); - *OemString++ = LOBYTE(OemChar); - i--; - } - else break; + OemString[Size++] = LOBYTE(OemChar); + OemSize--; + UnicodeSize--; } - - if (ResultSize) - *ResultSize = OemSize - i; } - return STATUS_SUCCESS; + if (ResultSize) + *ResultSize = Size; + + return UnicodeSize ? STATUS_BUFFER_OVERFLOW : STATUS_SUCCESS; } /*
3 years, 7 months
1
0
0
0
[reactos] 04/11: [NTDLL_APITEST] Add some tests for RtlUnicodeToOemN
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4e0ce779d777901c082d9…
commit 4e0ce779d777901c082d9501f43aabdfa3502451 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon May 17 12:07:26 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [NTDLL_APITEST] Add some tests for RtlUnicodeToOemN CORE-17571 --- modules/rostests/apitests/ntdll/CMakeLists.txt | 1 + modules/rostests/apitests/ntdll/RtlUnicodeToOemN.c | 237 +++++++++++++++++++++ modules/rostests/apitests/ntdll/testlist.c | 2 + 3 files changed, 240 insertions(+) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 684990e2df5..ef5f6a61302 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -81,6 +81,7 @@ list(APPEND SOURCE RtlReAllocateHeap.c RtlUnicodeStringToAnsiString.c RtlUnicodeStringToCountedOemString.c + RtlUnicodeToOemN.c RtlUpcaseUnicodeStringToCountedOemString.c RtlValidateUnicodeString.c RtlxUnicodeStringToAnsiSize.c diff --git a/modules/rostests/apitests/ntdll/RtlUnicodeToOemN.c b/modules/rostests/apitests/ntdll/RtlUnicodeToOemN.c new file mode 100644 index 00000000000..ff20e9a7b82 --- /dev/null +++ b/modules/rostests/apitests/ntdll/RtlUnicodeToOemN.c @@ -0,0 +1,237 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: 0BSD (
https://spdx.org/licenses/0BSD.html
) + * PURPOSE: Test for RtlUnicodeToOemN + * COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include "precomp.h" + +static const struct +{ + ULONG AnsiCp; + ULONG OemCp; + struct + { + LPCWSTR StrW; + NTSTATUS Status; + ULONG ReturnedSize; + LPCSTR StrOem; + } Test[10]; +} TestData[] = +{ + { + 1252, 1252, /* Western SBCS */ + { + { + L"ABCDEF", + STATUS_SUCCESS, + 6, + "ABCDEF" + }, + { + L"ABCDEF", + STATUS_SUCCESS, + 6, + "ABCDEF\xAA\xAA\xAA" + }, + { + L"ABCDEF", + STATUS_BUFFER_OVERFLOW, + 3, + "ABC" + }, + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_SUCCESS, + 6, + "??????" + }, + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_BUFFER_OVERFLOW, + 3, + "???" + }, + } + }, + { + 1252, 932, /* Western SBCS - Modified SJIS */ + { + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_SUCCESS, + 12, + "\x83\x66\x83\x58\x83\x4e\x83\x67\x83\x62\x83\x76" + }, + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_SUCCESS, + 12, + "\x83\x66\x83\x58\x83\x4e\x83\x67\x83\x62\x83\x76\xAA\xAA\xAA" + }, + } + }, + { + 932, 1252, /* Modified SJIS - Western SBCS */ + { + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_SUCCESS, + 6, + "??????" + }, + { + L"\u30c7\u30b9\u30afABC", + STATUS_SUCCESS, + 6, + "???ABC" + }, + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_BUFFER_OVERFLOW, + 3, + "???" + }, + } + }, + { + 932, 932, /* Modified SJIS - Modified SJIS */ + { + { + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", + STATUS_SUCCESS, + 12, + "\x83\x66\x83\x58\x83\x4e\x83\x67\x83\x62\x83\x76" + } + } + }, +}; + +START_TEST(RtlUnicodeToOemN) +{ + ULONG Length; + LPSTR StrOem; + ULONG ResultSize; + NTSTATUS Status; + CHAR OemBuffer[4]; + + /* Basic things */ + Status = RtlUnicodeToOemN(NULL, 0, NULL, NULL, 0); + ok_ntstatus(Status, STATUS_SUCCESS); + + Status = RtlUnicodeToOemN(NULL, 0, NULL, L"ABCDEF", 0); + ok_ntstatus(Status, STATUS_SUCCESS); + + Status = RtlUnicodeToOemN(NULL, 0, NULL, NULL, 2); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + + Status = RtlUnicodeToOemN(NULL, 0, NULL, L"A", 2); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + + Status = RtlUnicodeToOemN(NULL, 0, NULL, L"A", 2); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + + StartSeh() + Status = RtlUnicodeToOemN(NULL, 1, NULL, L"A", 2); + EndSeh(STATUS_ACCESS_VIOLATION) + + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"A", 2); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], (CHAR)0xAA); + + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"AB", 4); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], (CHAR)0xAA); + + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 2, NULL, L"A", 4); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], '\0'); + + /* RtlUnicodeToOemN doesn't care about string termination */ + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"A", 4); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], (CHAR)0xAA); + + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + OemBuffer[2] = 0xAA; + OemBuffer[3] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 4, NULL, L"A\0B", 8); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], '\0'); + ok_char(OemBuffer[2], 'B'); + ok_char(OemBuffer[3], '\0'); + + /* Odd Unicode buffer size */ + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + OemBuffer[2] = 0xAA; + OemBuffer[3] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 2, NULL, L"AB", 5); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], 'B'); + ok_char(OemBuffer[2], (CHAR)0xAA); + ok_char(OemBuffer[3], (CHAR)0xAA); + + /* Odd Unicode buffer size */ + OemBuffer[0] = 0xAA; + OemBuffer[1] = 0xAA; + OemBuffer[2] = 0xAA; + OemBuffer[3] = 0xAA; + Status = RtlUnicodeToOemN(OemBuffer, 3, NULL, L"AB", 5); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_char(OemBuffer[0], 'A'); + ok_char(OemBuffer[1], 'B'); + ok_char(OemBuffer[2], (CHAR)0xAA); + ok_char(OemBuffer[3], (CHAR)0xAA); + + for (int i = 0; i < _countof(TestData); i++) + { + SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1); + + for (int j = 0; TestData[i].Test[j].StrW != NULL; j++) + { + Length = strlen(TestData[i].Test[j].StrOem); + StrOem = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length + 1); + + memset(StrOem, 0xAA, Length + 1); + ResultSize = 0x0BADF00D; + + Status = RtlUnicodeToOemN(StrOem, + Length, + &ResultSize, + TestData[i].Test[j].StrW, + wcslen(TestData[i].Test[j].StrW) * sizeof(WCHAR)); + + ok_ntstatus(Status, TestData[i].Test[j].Status); + ok_long(ResultSize, TestData[i].Test[j].ReturnedSize); + for (int k = 0; k < ResultSize; k++) + { + ok(StrOem[k] == TestData[i].Test[j].StrOem[k], + "Wrong char \\x%02x, expected TestData[%u].Test[%u].StrOem[%u] (\\x%02x)\n", + StrOem[k], i, j, k, TestData[i].Test[j].StrOem[k]); + } + for (int k = ResultSize; k < (Length + 1); k++) + { + ok_char(StrOem[k], (CHAR)0xAA); + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, StrOem); + } + } +} diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index 5d4b00b0cce..5a56ec6e987 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -77,6 +77,7 @@ extern void func_RtlQueryTimeZoneInformation(void); extern void func_RtlReAllocateHeap(void); extern void func_RtlUnicodeStringToAnsiString(void); extern void func_RtlUnicodeStringToCountedOemString(void); +extern void func_RtlUnicodeToOemN(void); extern void func_RtlUpcaseUnicodeStringToCountedOemString(void); extern void func_RtlValidateUnicodeString(void); extern void func_RtlxUnicodeStringToAnsiSize(void); @@ -162,6 +163,7 @@ const struct test winetest_testlist[] = { "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString }, { "RtlUnicodeStringToCountedOemString", func_RtlUnicodeStringToCountedOemString }, { "RtlUnicodeStringToOemSize", func_RtlxUnicodeStringToOemSize }, + { "RtlUnicodeToOemN", func_RtlUnicodeToOemN }, { "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString }, { "RtlValidateUnicodeString", func_RtlValidateUnicodeString }, { "StackOverflow", func_StackOverflow },
3 years, 7 months
1
0
0
0
[reactos] 03/11: [NTDLL_APITEST] Add some tests for RtlUnicodeStringToCountedOemString
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=53a6c44f74efc7576e47e…
commit 53a6c44f74efc7576e47e7da11bbfc5483e9e788 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed May 12 23:31:20 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [NTDLL_APITEST] Add some tests for RtlUnicodeStringToCountedOemString CORE-17571 --- modules/rostests/apitests/ntdll/CMakeLists.txt | 1 + .../ntdll/RtlUnicodeStringToCountedOemString.c | 136 +++++++++++++++++++++ modules/rostests/apitests/ntdll/testlist.c | 2 + sdk/include/ndk/rtlfuncs.h | 8 ++ 4 files changed, 147 insertions(+) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index d1e4499fb68..684990e2df5 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -80,6 +80,7 @@ list(APPEND SOURCE RtlQueryTimeZoneInfo.c RtlReAllocateHeap.c RtlUnicodeStringToAnsiString.c + RtlUnicodeStringToCountedOemString.c RtlUpcaseUnicodeStringToCountedOemString.c RtlValidateUnicodeString.c RtlxUnicodeStringToAnsiSize.c diff --git a/modules/rostests/apitests/ntdll/RtlUnicodeStringToCountedOemString.c b/modules/rostests/apitests/ntdll/RtlUnicodeStringToCountedOemString.c new file mode 100644 index 00000000000..30393fc0ea6 --- /dev/null +++ b/modules/rostests/apitests/ntdll/RtlUnicodeStringToCountedOemString.c @@ -0,0 +1,136 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later.html
) + * PURPOSE: Test for RtlUnicodeStringToCountedOemString + * COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include "precomp.h" + +static const struct +{ + ULONG AnsiCp; + ULONG OemCp; + const UNICODE_STRING StrU; + NTSTATUS Status; + const OEM_STRING StrOem; +} TestData[] = +{ + { + 1252, 932, /* Western SBCS - Modified SJIS */ + RTL_CONSTANT_STRING(L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7"), + STATUS_BUFFER_OVERFLOW, + RTL_CONSTANT_STRING("\x83\x66\x83\x58\x83\x4e") + }, + { + 932, 1252, /* Modified SJIS - Western SBCS */ + RTL_CONSTANT_STRING(L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7"), + STATUS_UNMAPPABLE_CHARACTER, + RTL_CONSTANT_STRING("??????") + }, + { + 932, 932, /* Modified SJIS - Modified SJIS */ + RTL_CONSTANT_STRING(L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7"), + STATUS_SUCCESS, + RTL_CONSTANT_STRING("\x83\x66\x83\x58\x83\x4e\x83\x67\x83\x62\x83\x76") + }, + { + 1252, 1252, /* Western SBCS */ + RTL_CONSTANT_STRING(L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7"), /* Some japanese characters */ + STATUS_UNMAPPABLE_CHARACTER, + RTL_CONSTANT_STRING("??????") + }, +}; + +START_TEST(RtlUnicodeStringToCountedOemString) +{ + WCHAR BufferU[10]; + CHAR BufferOem[10]; + UNICODE_STRING StringU; + OEM_STRING StringOem; + NTSTATUS Status; + int i; + + memset(BufferU, 0xAA, sizeof(BufferU)); + memset(BufferOem, 0xAA, sizeof(BufferOem)); + + BufferU[0] = L'A'; + BufferU[1] = UNICODE_NULL; + + StringU.Buffer = BufferU; + StringU.MaximumLength = 10 * sizeof(WCHAR); + + RtlInitUnicodeString(&StringU, BufferU); + ok(StringU.Length == 1 * sizeof(WCHAR), "Invalid size: %d\n", StringU.Length); + ok(StringU.MaximumLength == 2 * sizeof(WCHAR), "Invalid size: %d\n", StringU.MaximumLength); + ok(StringU.Buffer == BufferU, "Invalid buffer: %p\n", StringU.Buffer); + + StringOem.Buffer = BufferOem; + StringOem.Length = 0; + StringOem.MaximumLength = 10 * sizeof(CHAR); + + Status = RtlUnicodeStringToCountedOemString(&StringOem, &StringU, FALSE); + ok(NT_SUCCESS(Status), "RtlUnicodeStringToCountedOemString failed: %lx\n", Status); + ok(StringOem.Length == 1 * sizeof(CHAR), "Invalid size: %d\n", StringOem.Length); + ok(StringOem.MaximumLength == 10 * sizeof(CHAR), "Invalid size: %d\n", StringOem.MaximumLength); + ok(StringOem.Buffer == BufferOem, "Invalid buffer: %p\n", StringOem.Buffer); + + ok(BufferOem[0] == 'A', "Unexpected first char 0x%02x for OEM string.\n", BufferOem[0]); + for (i = 1; i < 10; ++i) + { + ok(BufferOem[i] == (CHAR)0xAA, "Unexpected char 0x%02x at position %d.\n", BufferOem[i], i); + } + + ok(i == 10, "String was not null terminated!\n"); + + /* Test buffer overflow */ + wcsncpy(BufferU, L"Test", _countof(BufferU)); + RtlInitUnicodeString(&StringU, BufferU); + StringU.MaximumLength = sizeof(BufferU); + StringOem.Buffer = BufferOem; + StringOem.MaximumLength = 1 * sizeof(CHAR); + StringOem.Length = 0; + memset(BufferOem, 0xAA, sizeof(BufferOem)); + + Status = RtlUnicodeStringToCountedOemString(&StringOem, &StringU, FALSE); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + ok(StringOem.Length == 4 * sizeof(CHAR), "Invalid size: %d\n", StringOem.Length); + ok(StringOem.MaximumLength == 1 * sizeof(CHAR), "Invalid size: %d\n", StringOem.MaximumLength); + ok(StringOem.Buffer == BufferOem, "Invalid buffer: %p\n", StringOem.Buffer); + + for (i = 0; i < 10; ++i) + { + ok(BufferOem[i] == (CHAR)0xAA, "Unexpected char 0x%02x at position %d.\n", BufferOem[i], i); + } + + for (i = 0; i < _countof(TestData); i++) + { + SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1); + + trace("Testing locale %u. ANSI: %u, OEM %u\n", i, (UINT)TestData[i].AnsiCp, (UINT)TestData[i].OemCp); + + /* Get the right length */ + StringOem.Buffer = NULL; + StringOem.Length = 0; + StringOem.MaximumLength = 0; + + Status = RtlUnicodeStringToCountedOemString(&StringOem, &TestData[i].StrU, FALSE); + ok_ntstatus(Status, STATUS_BUFFER_OVERFLOW); + ok_long(StringOem.Length, TestData[i].StrOem.Length); + ok_long(StringOem.MaximumLength, 0); + + StringOem.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, StringOem.Length); + StringOem.MaximumLength = StringOem.Length; + StringOem.Length = 0; + + Status = RtlUnicodeStringToCountedOemString(&StringOem, &TestData[i].StrU, FALSE); + ok_ntstatus(Status, TestData[i].Status); + + ok_long(StringOem.Length, TestData[i].StrOem.Length); + ok_long(StringOem.MaximumLength, TestData[i].StrOem.Length); /* Untouched */ + ok_long(memcmp(StringOem.Buffer, TestData[i].StrOem.Buffer, min(StringOem.Length, TestData[i].StrOem.Length)), 0); + + RtlFreeHeap(RtlGetProcessHeap(), 0, StringOem.Buffer); + } +} + diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index 78a8af20a05..5d4b00b0cce 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -76,6 +76,7 @@ extern void func_RtlpEnsureBufferSize(void); extern void func_RtlQueryTimeZoneInformation(void); extern void func_RtlReAllocateHeap(void); extern void func_RtlUnicodeStringToAnsiString(void); +extern void func_RtlUnicodeStringToCountedOemString(void); extern void func_RtlUpcaseUnicodeStringToCountedOemString(void); extern void func_RtlValidateUnicodeString(void); extern void func_RtlxUnicodeStringToAnsiSize(void); @@ -159,6 +160,7 @@ const struct test winetest_testlist[] = { "RtlReAllocateHeap", func_RtlReAllocateHeap }, { "RtlUnicodeStringToAnsiSize", func_RtlxUnicodeStringToAnsiSize }, /* For some reason, starting test name with Rtlx hides it */ { "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString }, + { "RtlUnicodeStringToCountedOemString", func_RtlUnicodeStringToCountedOemString }, { "RtlUnicodeStringToOemSize", func_RtlxUnicodeStringToOemSize }, { "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString }, { "RtlValidateUnicodeString", func_RtlValidateUnicodeString }, diff --git a/sdk/include/ndk/rtlfuncs.h b/sdk/include/ndk/rtlfuncs.h index 513fc195b5f..60e1308b964 100644 --- a/sdk/include/ndk/rtlfuncs.h +++ b/sdk/include/ndk/rtlfuncs.h @@ -1879,6 +1879,14 @@ RtlUnicodeStringToOemString( BOOLEAN AllocateDestinationString ); +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToCountedOemString( + _Inout_ POEM_STRING OemDest, + _In_ PCUNICODE_STRING UniSource, + _In_ BOOLEAN AllocateDestinationString); + NTSYSAPI NTSTATUS NTAPI
3 years, 7 months
1
0
0
0
[reactos] 02/11: [NTDLL_APITEST] Add tests for RtlxUnicodeStringToAnsiSize & RtlxUnicodeStringToOemSize
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a8b51da8044cd84a41a6…
commit 0a8b51da8044cd84a41a647407848d74690e9467 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue May 18 23:00:58 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [NTDLL_APITEST] Add tests for RtlxUnicodeStringToAnsiSize & RtlxUnicodeStringToOemSize CORE-17571 --- modules/rostests/apitests/ntdll/CMakeLists.txt | 3 ++ .../apitests/ntdll/RtlxUnicodeStringToAnsiSize.c | 33 ++++++++++++++++++++++ .../apitests/ntdll/RtlxUnicodeStringToOemSize.c | 33 ++++++++++++++++++++++ modules/rostests/apitests/ntdll/testlist.c | 4 +++ 4 files changed, 73 insertions(+) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 85dba02c31d..d1e4499fb68 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -8,6 +8,7 @@ spec2def(ntdll_apitest.exe ntdll_apitest.spec) list(APPEND SOURCE LdrEnumResources.c load_notifications.c + locale.c NtAcceptConnectPort.c NtAllocateVirtualMemory.c NtApphelpCacheControl.c @@ -81,6 +82,8 @@ list(APPEND SOURCE RtlUnicodeStringToAnsiString.c RtlUpcaseUnicodeStringToCountedOemString.c RtlValidateUnicodeString.c + RtlxUnicodeStringToAnsiSize.c + RtlxUnicodeStringToOemSize.c StackOverflow.c SystemInfo.c Timer.c) diff --git a/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c new file mode 100644 index 00000000000..5caeea2346c --- /dev/null +++ b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToAnsiSize.c @@ -0,0 +1,33 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: 0BSD (
https://spdx.org/licenses/0BSD.html
) + * PURPOSE: Test for RtlxUnicodeStringToAnsiSize + * COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include "precomp.h" + +static const struct +{ + ULONG AnsiCp; + ULONG OemCp; + PCWSTR Str; + ULONG OemLength; +} TestData[] = +{ + { 1252, 932, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 7 }, /* "Desktop" in Japanese */ + { 932, 1252, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 13 }, /* "Desktop" in Japanese */ +}; + +START_TEST(RtlxUnicodeStringToAnsiSize) +{ + for (int i = 0; i < _countof(TestData); i++) + { + SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1); + UNICODE_STRING Ustr; + RtlInitUnicodeString(&Ustr, TestData[i].Str); + ULONG Length = RtlxUnicodeStringToAnsiSize(&Ustr); + ok(Length == TestData[i].OemLength, "Wrong OEM length for test %u, expected %u, got %u\n", + i, (UINT)TestData[i].OemLength, (UINT)Length); + } +} diff --git a/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c new file mode 100644 index 00000000000..354b64562fd --- /dev/null +++ b/modules/rostests/apitests/ntdll/RtlxUnicodeStringToOemSize.c @@ -0,0 +1,33 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: 0BSD (
https://spdx.org/licenses/0BSD.html
) + * PURPOSE: Test for RtlxUnicodeStringToOemSize + * COPYRIGHT: Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include "precomp.h" + +static const struct +{ + ULONG AnsiCp; + ULONG OemCp; + PCWSTR Str; + ULONG OemLength; +} TestData[] = +{ + { 1252, 932, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 7 }, /* "Desktop" in Japanese */ + { 932, 1252, L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7", 13 }, /* "Desktop" in Japanese */ +}; + +START_TEST(RtlxUnicodeStringToOemSize) +{ + for (int i = 0; i < _countof(TestData); i++) + { + SetupLocale(TestData[i].AnsiCp, TestData[i].OemCp, -1); + UNICODE_STRING Ustr; + RtlInitUnicodeString(&Ustr, TestData[i].Str); + ULONG Length = RtlxUnicodeStringToOemSize(&Ustr); + ok(Length == TestData[i].OemLength, "Wrong OEM length for test %u, expected %u, got %u\n", + i, (UINT)TestData[i].OemLength, (UINT)Length); + } +} diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index 141a1305f61..78a8af20a05 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -78,6 +78,8 @@ extern void func_RtlReAllocateHeap(void); extern void func_RtlUnicodeStringToAnsiString(void); extern void func_RtlUpcaseUnicodeStringToCountedOemString(void); extern void func_RtlValidateUnicodeString(void); +extern void func_RtlxUnicodeStringToAnsiSize(void); +extern void func_RtlxUnicodeStringToOemSize(void); extern void func_StackOverflow(void); extern void func_TimerResolution(void); @@ -155,7 +157,9 @@ const struct test winetest_testlist[] = { "RtlpEnsureBufferSize", func_RtlpEnsureBufferSize }, { "RtlQueryTimeZoneInformation", func_RtlQueryTimeZoneInformation }, { "RtlReAllocateHeap", func_RtlReAllocateHeap }, + { "RtlUnicodeStringToAnsiSize", func_RtlxUnicodeStringToAnsiSize }, /* For some reason, starting test name with Rtlx hides it */ { "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString }, + { "RtlUnicodeStringToOemSize", func_RtlxUnicodeStringToOemSize }, { "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString }, { "RtlValidateUnicodeString", func_RtlValidateUnicodeString }, { "StackOverflow", func_StackOverflow },
3 years, 7 months
1
0
0
0
[reactos] 01/11: [NTDLL_APITEST] Add some Japanese to RtlGenerate8dot3Name test case
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=50e0b006e7814aaf95035…
commit 50e0b006e7814aaf950358832fd8af88255ba93a Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue May 18 23:00:38 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 22:50:29 2021 +0200 [NTDLL_APITEST] Add some Japanese to RtlGenerate8dot3Name test case CORE-17571 --- .../rostests/apitests/ntdll/RtlGenerate8dot3Name.c | 145 ++++++++++----------- modules/rostests/apitests/ntdll/locale.c | 78 +++++++++++ modules/rostests/apitests/ntdll/precomp.h | 6 + 3 files changed, 156 insertions(+), 73 deletions(-) diff --git a/modules/rostests/apitests/ntdll/RtlGenerate8dot3Name.c b/modules/rostests/apitests/ntdll/RtlGenerate8dot3Name.c index 9b606526c9a..fa8ded244ea 100644 --- a/modules/rostests/apitests/ntdll/RtlGenerate8dot3Name.c +++ b/modules/rostests/apitests/ntdll/RtlGenerate8dot3Name.c @@ -2,10 +2,11 @@ // code7bit:
https://github.com/katahiromz/code7bit
// To revert conversion, please execute "code7bit -r <file>". /* - * PROJECT: ReactOS api tests - * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Test for RtlGenerate8dot3Name - * PROGRAMMER: Pierre Schweitzer <pierre(a)reactos.org> + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later.html
) + * PURPOSE: Test for RtlGenerate8dot3Name + * COPYRIGHT: Copyright 2015-2016 Pierre Schweitzer <pierre(a)reactos.org> + * Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> */ #include "precomp.h" @@ -19,40 +20,71 @@ RtlGenerate8dot3Name( _Inout_ PGENERATE_NAME_CONTEXT Context, _Inout_ PUNICODE_STRING Name8dot3); -#define NAMES_COUNT 14 -#define LOCALES_COUNT 3 +ULONG Locales[][2] = +{ + {1252, 850}, // Most used for latin langs + {1252, 437}, // Used for English US (not only) + {1252, 775}, // Used for Estonian + {1252, 932}, // Western SBCS, Japanese + {932, 1252}, // Japanese, Western SBCS + {932, 932}, // Japanese, Japanese +}; +#define LOCALES_COUNT _countof(Locales) + +PWSTR Names[] = { + L"Menu D\u00E9marrer", + L"S\u00E9lecteur de configuration clavier.lnk", + L"\u00E9\u00E8\u00E0\u00F9\u00E7.txt", + L"\u00E7\u00F9\u00E0\u00E8\u00E9.txt", + L"\u00E9\u00E8\u00E0\u00F9.txt", + L"\u00E7\u00F9\u00E0\u00E8.txt", + L"\u00E9\u00E8\u00E0\u00F9\u00E7eeauc.txt", + L"\u00E9e\u00E8\u00E9\u00E7c\u00F9u.txt", + L"test.\u00E9x\u00E8", + L"t\u00A3$t\u00A4.txt", + L"Long file name.txt", + L"Long file name", + L"Longfilename.txt", + L"Longfilename", + L"\u30c7\u30b9\u30af\u30c8\u30c3\u30d7" /* Desktop in Japanese */ +}; +#define NAMES_COUNT _countof(Names) -PWSTR Names[NAMES_COUNT] = { L"Menu D\u00E9marrer", L"S\u00E9lecteur de configuration clavier.lnk", L"\u00E9\u00E8\u00E0\u00F9\u00E7.txt", L"\u00E7\u00F9\u00E0\u00E8\u00E9.txt", L"\u00E9\u00E8\u00E0\u00F9.txt", L"\u00E7\u00F9\u00E0\u00E8.txt", L"\u00E9\u00E8\u00E0\u00F9\u00E7eeauc.txt", L"\u00E9e\u00E8\u00E9\u00E7c\u00F9u.txt", L"test.\u00E9x\u00E8", L"t\u00A3$t\u00A4.txt", L"Long file name.txt", L"Long file name", L"Longfilename.txt", L"Longfilename" }; PWSTR ShortNames1[LOCALES_COUNT][NAMES_COUNT] = { - { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, - { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, - { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDM~1", L"SLECTE~1.LNK", L"5C2D~1.TXT", L"423C~1.TXT", L"925E~1.TXT", L"7E4C~1.TXT", L"EEAUC~1.TXT", L"ECU~1.TXT", L"TEST~1.X", L"T$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, }; PWSTR ShortNames2[LOCALES_COUNT][NAMES_COUNT] = { - { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, - { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, - { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDM~2", L"SLECTE~2.LNK", L"5C2D~2.TXT", L"423C~2.TXT", L"925E~2.TXT", L"7E4C~2.TXT", L"EEAUC~2.TXT", L"ECU~2.TXT", L"TEST~2.X", L"T$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, }; PWSTR ExShortNames1[LOCALES_COUNT][NAMES_COUNT] = { - { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~1.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~1.TXT", L"\u00C9\u00C8\u00C0\u00D9~1.TXT", L"\u00C7\u00D9\u00C0\u00C8~1.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~1.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~1.TXT", L"TEST~1.\u00C9X\u00C8", L"T\u00A3$T\u00A4~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, - { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~1.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~1.TXT", L"\u00C9\u00C8\u00C0\u00D9~1.TXT", L"\u00C7\u00D9\u00C0\u00C8~1.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~1.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~1.TXT", L"TEST~1.\u00C9X\u00C8", L"T\u00A3$T_~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, - { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9CAU~1.TXT", L"UAC\u00C9~1.TXT", L"\u00C9CAU~1.TXT", L"UAC~1.TXT", L"\u00C9CAUEE~1.TXT", L"\u00C9EC\u00C9CU~1.TXT", L"TEST~1.\u00C9XC", L"T\u00A3$T\u00A4~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1" }, + { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~1.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~1.TXT", L"\u00C9\u00C8\u00C0\u00D9~1.TXT", L"\u00C7\u00D9\u00C0\u00C8~1.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~1.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~1.TXT", L"TEST~1.\u00C9X\u00C8", L"T\u00A3$T\u00A4~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~1.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~1.TXT", L"\u00C9\u00C8\u00C0\u00D9~1.TXT", L"\u00C7\u00D9\u00C0\u00C8~1.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~1.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~1.TXT", L"TEST~1.\u00C9X\u00C8", L"T\u00A3$T_~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9CAU~1.TXT", L"UAC\u00C9~1.TXT", L"\u00C9CAU~1.TXT", L"UAC~1.TXT", L"\u00C9CAUEE~1.TXT", L"\u00C9EC\u00C9CU~1.TXT", L"TEST~1.\u00C9XC", L"T\u00A3$T\u00A4~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDE~1", L"SELECT~1.LNK", L"EEAUC~1.TXT", L"CUAEE~1.TXT", L"EEAU~1.TXT", L"CUAE~1.TXT", L"EEAUCE~1.TXT", L"EEEECC~1.TXT", L"TEST~1.EXE", L"T\uFFE1$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"\u30c7\u30b9\u30af~1" }, + { L"MENUD\u00C9~1", L"S\u00C9LECT~1.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~1.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~1.TXT", L"\u00C9\u00C8\u00C0\u00D9~1.TXT", L"\u00C7\u00D9\u00C0\u00C8~1.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~1.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~1.TXT", L"TEST~1.\u00C9X\u00C8", L"T\u00A3$T\u00A4~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"9A16~1" }, + { L"MENUDE~1", L"SELECT~1.LNK", L"EEAUC~1.TXT", L"CUAEE~1.TXT", L"EEAU~1.TXT", L"CUAE~1.TXT", L"EEAUCE~1.TXT", L"EEEECC~1.TXT", L"TEST~1.EXE", L"T\uFFE1$T~1.TXT", L"LONGFI~1.TXT", L"LONGFI~1", L"LONGFI~1.TXT", L"LONGFI~1", L"\u30c7\u30b9\u30af~1" }, }; PWSTR ExShortNames2[LOCALES_COUNT][NAMES_COUNT] = { - { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~2.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~2.TXT", L"\u00C9\u00C8\u00C0\u00D9~2.TXT", L"\u00C7\u00D9\u00C0\u00C8~2.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~2.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~2.TXT", L"TEST~2.\u00C9X\u00C8", L"T\u00A3$T\u00A4~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, - { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~2.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~2.TXT", L"\u00C9\u00C8\u00C0\u00D9~2.TXT", L"\u00C7\u00D9\u00C0\u00C8~2.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~2.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~2.TXT", L"TEST~2.\u00C9X\u00C8", L"T\u00A3$T_~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, - { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9CAU~2.TXT", L"UAC\u00C9~2.TXT", L"\u00C9CAU~2.TXT", L"UAC~2.TXT", L"\u00C9CAUEE~2.TXT", L"\u00C9EC\u00C9CU~2.TXT", L"TEST~2.\u00C9XC", L"T\u00A3$T\u00A4~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2" }, -}; - -ULONG Locales[LOCALES_COUNT][2] = -{ - {1252, 850}, // Most used for latin langs - {1252, 437}, // Used for English US (not only) - {1252, 775}, // Used for Estonian + { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~2.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~2.TXT", L"\u00C9\u00C8\u00C0\u00D9~2.TXT", L"\u00C7\u00D9\u00C0\u00C8~2.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~2.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~2.TXT", L"TEST~2.\u00C9X\u00C8", L"T\u00A3$T\u00A4~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~2.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~2.TXT", L"\u00C9\u00C8\u00C0\u00D9~2.TXT", L"\u00C7\u00D9\u00C0\u00C8~2.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~2.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~2.TXT", L"TEST~2.\u00C9X\u00C8", L"T\u00A3$T_~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9CAU~2.TXT", L"UAC\u00C9~2.TXT", L"\u00C9CAU~2.TXT", L"UAC~2.TXT", L"\u00C9CAUEE~2.TXT", L"\u00C9EC\u00C9CU~2.TXT", L"TEST~2.\u00C9XC", L"T\u00A3$T\u00A4~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDE~2", L"SELECT~2.LNK", L"EEAUC~2.TXT", L"CUAEE~2.TXT", L"EEAU~2.TXT", L"CUAE~2.TXT", L"EEAUCE~2.TXT", L"EEEECC~2.TXT", L"TEST~2.EXE", L"T\uFFE1$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"\u30c7\u30b9\u30af~2" }, + { L"MENUD\u00C9~2", L"S\u00C9LECT~2.LNK", L"\u00C9\u00C8\u00C0\u00D9\u00C7~2.TXT", L"\u00C7\u00D9\u00C0\u00C8\u00C9~2.TXT", L"\u00C9\u00C8\u00C0\u00D9~2.TXT", L"\u00C7\u00D9\u00C0\u00C8~2.TXT", L"\u00C9\u00C8\u00C0\u00D9\u00C7E~2.TXT", L"\u00C9E\u00C8\u00C9\u00C7C~2.TXT", L"TEST~2.\u00C9X\u00C8", L"T\u00A3$T\u00A4~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"9A16~2" }, + { L"MENUDE~2", L"SELECT~2.LNK", L"EEAUC~2.TXT", L"CUAEE~2.TXT", L"EEAU~2.TXT", L"CUAE~2.TXT", L"EEAUCE~2.TXT", L"EEEECC~2.TXT", L"TEST~2.EXE", L"T\uFFE1$T~2.TXT", L"LONGFI~2.TXT", L"LONGFI~2", L"LONGFI~2.TXT", L"LONGFI~2", L"\u30c7\u30b9\u30af~2" }, }; #define LONG_NAMES_COUNT 12 @@ -68,49 +100,6 @@ PWSTR LongShortNames[LONG_NAMES_COUNT] = L"VERYLO~1.TXT", L"VERYLO~2.TXT", L"VERYLO~3.TXT", L"VERYLO~4.TXT", L"VED051~1.TXT", L"VED051~2.TXT", }; -PVOID LoadCodePageData(ULONG Code) -{ - char filename[MAX_PATH], sysdir[MAX_PATH]; - HANDLE hFile; - PVOID Data = NULL; - GetSystemDirectoryA(sysdir, MAX_PATH); - - if (Code != -1) - StringCbPrintfA(filename, sizeof(filename), "%s\\c_%lu.nls", sysdir, Code); - else - StringCbPrintfA(filename, sizeof(filename), "%s\\l_intl.nls", sysdir); - - hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - DWORD dwRead; - DWORD dwFileSize = GetFileSize(hFile, NULL); - Data = malloc(dwFileSize); - ReadFile(hFile, Data, dwFileSize, &dwRead, NULL); - CloseHandle(hFile); - } - return Data; -} - -/*
https://www.microsoft.com/resources/msdn/goglobal/default.mspx
*/ -void SetupLocale(ULONG AnsiCode, ULONG OemCode, ULONG Unicode) -{ - NLSTABLEINFO NlsTable; - PVOID AnsiCodePageData; - PVOID OemCodePageData; - PVOID UnicodeCaseTableData; - - AnsiCodePageData = LoadCodePageData(AnsiCode); - OemCodePageData = LoadCodePageData(OemCode); - UnicodeCaseTableData = LoadCodePageData(Unicode); - - RtlInitNlsTables(AnsiCodePageData, OemCodePageData, UnicodeCaseTableData, &NlsTable); - RtlResetRtlTranslations(&NlsTable); - /* Do NOT free the buffers here, they are directly used! - Yes, we leak the old buffers, but this is a test anyway... */ - -} - START_TEST(RtlGenerate8dot3Name) { USHORT i, j; @@ -134,23 +123,33 @@ START_TEST(RtlGenerate8dot3Name) RtlGenerate8dot3Name(&LongName, FALSE, &Context, &ShortName); RtlInitUnicodeString(&Expected, ShortNames1[j][i]); - ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", j, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u,%u:: Generated: %.*S. Expected: %.*S\n", j, i, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); ShortName.Length = 0; RtlGenerate8dot3Name(&LongName, FALSE, &Context, &ShortName); RtlInitUnicodeString(&Expected, ShortNames2[j][i]); - ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", j, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u,%u:: Generated: %.*S. Expected: %.*S\n", j, i, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); RtlZeroMemory(&Context, sizeof(GENERATE_NAME_CONTEXT)); ShortName.Length = 0; RtlGenerate8dot3Name(&LongName, TRUE, &Context, &ShortName); RtlInitUnicodeString(&Expected, ExShortNames1[j][i]); - ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", j, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u,%u:: Generated: %.*S. Expected: %.*S\n", j, i, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + if (!RtlEqualUnicodeString(&Expected, &ShortName, FALSE)) + { + for (int k = 0; k < (ShortName.Length / sizeof(WCHAR)); k++) + trace("Got \\u%04x at %d\n", ShortName.Buffer[k], k); + } ShortName.Length = 0; RtlGenerate8dot3Name(&LongName, TRUE, &Context, &ShortName); RtlInitUnicodeString(&Expected, ExShortNames2[j][i]); - ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u:: Generated: %.*S. Expected: %.*S\n", j, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + ok(RtlEqualUnicodeString(&Expected, &ShortName, FALSE), "%u,%u:: Generated: %.*S. Expected: %.*S\n", j, i, ShortName.Length / sizeof(WCHAR), ShortName.Buffer, Expected.Length / sizeof(WCHAR), Expected.Buffer); + if (!RtlEqualUnicodeString(&Expected, &ShortName, FALSE)) + { + for (int k = 0; k < (ShortName.Length / sizeof(WCHAR)); k++) + trace("Got \\u%04x at %d\n", ShortName.Buffer[k], k); + } } } diff --git a/modules/rostests/apitests/ntdll/locale.c b/modules/rostests/apitests/ntdll/locale.c new file mode 100644 index 00000000000..281d3b8b2ba --- /dev/null +++ b/modules/rostests/apitests/ntdll/locale.c @@ -0,0 +1,78 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later.html
) + * PURPOSE: RTL locale support + * COPYRIGHT: Copyright 2016 Mark Jansen <mark.jansen(a)reactos.org> + * Copyright 2021 Jérôme Gardou <jerome.gardou(a)reactos.org> + */ + +#include "precomp.h" + +static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(PVOID *); +static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(PVOID); +HANDLE hKernel32; + +static PVOID LoadCodePageData(_In_ ULONG Code) +{ + char filename[MAX_PATH], sysdir[MAX_PATH]; + HANDLE hFile; + PVOID Data = NULL; + PVOID FsRedir; + + if (!hKernel32) + { + hKernel32 = GetModuleHandleA("kernel32.dll"); + + pWow64DisableWow64FsRedirection = (void*)GetProcAddress(hKernel32, "Wow64DisableWow64FsRedirection"); + pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hKernel32, "Wow64RevertWow64FsRedirection"); + } + + if (pWow64DisableWow64FsRedirection) + pWow64DisableWow64FsRedirection(&FsRedir); + + GetSystemDirectoryA(sysdir, MAX_PATH); + + if (Code != -1) + StringCbPrintfA(filename, sizeof(filename), "%s\\c_%lu.nls", sysdir, Code); + else + StringCbPrintfA(filename, sizeof(filename), "%s\\l_intl.nls", sysdir); + + hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", filename, (UINT)GetLastError()); + if (hFile != INVALID_HANDLE_VALUE) + { + DWORD dwRead; + DWORD dwFileSize = GetFileSize(hFile, NULL); + Data = malloc(dwFileSize); + ReadFile(hFile, Data, dwFileSize, &dwRead, NULL); + CloseHandle(hFile); + } + + if (pWow64RevertWow64FsRedirection) + pWow64RevertWow64FsRedirection(FsRedir); + + return Data; +} + +/*
https://www.microsoft.com/resources/msdn/goglobal/default.mspx
*/ +void SetupLocale( + _In_ ULONG AnsiCode, + _In_ ULONG OemCode, + _In_ ULONG Unicode) +{ + NLSTABLEINFO NlsTable; + PVOID AnsiCodePageData; + PVOID OemCodePageData; + PVOID UnicodeCaseTableData; + + AnsiCodePageData = LoadCodePageData(AnsiCode); + OemCodePageData = LoadCodePageData(OemCode); + UnicodeCaseTableData = LoadCodePageData(Unicode); + + RtlInitNlsTables(AnsiCodePageData, OemCodePageData, UnicodeCaseTableData, &NlsTable); + RtlResetRtlTranslations(&NlsTable); + /* + * Do NOT free the buffers here, they are directly used! + * Yes, we leak the old buffers, but this is a test anyway... + */ +} diff --git a/modules/rostests/apitests/ntdll/precomp.h b/modules/rostests/apitests/ntdll/precomp.h index d476f1cc958..4871076a873 100644 --- a/modules/rostests/apitests/ntdll/precomp.h +++ b/modules/rostests/apitests/ntdll/precomp.h @@ -35,4 +35,10 @@ QuerySetThreadValidator( _In_ ULONG InfoLength, _In_ NTSTATUS ExpectedStatus); +void +SetupLocale( + _In_ ULONG AnsiCode, + _In_ ULONG OemCode, + _In_ ULONG Unicode); + #endif /* _NTDLL_APITEST_PRECOMP_H_ */
3 years, 7 months
1
0
0
0
[reactos] 02/02: [XDK] Update the prototype of IO_COMPLETION_ROUTINE
by Dmitry Borisov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=999345a4feaae1e74533c…
commit 999345a4feaae1e74533c96fa2cdfa1bce50ec5f Author: Dmitry Borisov <di.sean(a)protonmail.com> AuthorDate: Wed May 12 20:15:42 2021 +0600 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 20:14:29 2021 +0200 [XDK] Update the prototype of IO_COMPLETION_ROUTINE --- sdk/include/xdk/iotypes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/include/xdk/iotypes.h b/sdk/include/xdk/iotypes.h index a8a2d8d601e..4a00f1137cf 100644 --- a/sdk/include/xdk/iotypes.h +++ b/sdk/include/xdk/iotypes.h @@ -2826,11 +2826,12 @@ typedef enum _IO_PAGING_PRIORITY { _Function_class_(IO_COMPLETION_ROUTINE) _IRQL_requires_same_ +_IRQL_requires_max_(DISPATCH_LEVEL) typedef NTSTATUS (NTAPI IO_COMPLETION_ROUTINE)( _In_ struct _DEVICE_OBJECT *DeviceObject, _In_ struct _IRP *Irp, - _In_opt_ PVOID Context); + _In_reads_opt_(_Inexpressible_("varies")) PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; _Function_class_(IO_DPC_ROUTINE)
3 years, 7 months
1
0
0
0
[reactos] 01/02: [NTOS:PO] Check for optional parameter in the completion routine
by Dmitry Borisov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2193031133ed7c3c4e383…
commit 2193031133ed7c3c4e3835202ced9afd6b0b9800 Author: Dmitry Borisov <di.sean(a)protonmail.com> AuthorDate: Tue May 11 01:45:01 2021 +0600 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Wed May 19 20:14:29 2021 +0200 [NTOS:PO] Check for optional parameter in the completion routine The CompletionFunction parameter is really optional. This fixes a bugcheck caused by shutdown with IDE driver stack. CORE-17401 --- ntoskrnl/po/power.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ntoskrnl/po/power.c b/ntoskrnl/po/power.c index 125edbc11df..5f100d7a8d5 100644 --- a/ntoskrnl/po/power.c +++ b/ntoskrnl/po/power.c @@ -124,12 +124,15 @@ PopPresentIrp( return Status; } +static IO_COMPLETION_ROUTINE PopRequestPowerIrpCompletion; + static NTSTATUS NTAPI -PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PVOID Context) +PopRequestPowerIrpCompletion( + _In_ PDEVICE_OBJECT DeviceObject, + _In_ PIRP Irp, + _In_reads_opt_(_Inexpressible_("varies")) PVOID Context) { PIO_STACK_LOCATION Stack; PREQUEST_POWER_COMPLETE CompletionRoutine; @@ -139,11 +142,15 @@ PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, CompletionRoutine = Context; PowerState.DeviceState = (ULONG_PTR)Stack->Parameters.Others.Argument3; - CompletionRoutine(Stack->Parameters.Others.Argument1, - (UCHAR)(ULONG_PTR)Stack->Parameters.Others.Argument2, - PowerState, - Stack->Parameters.Others.Argument4, - &Irp->IoStatus); + + if (CompletionRoutine) + { + CompletionRoutine(Stack->Parameters.Others.Argument1, + (UCHAR)(ULONG_PTR)Stack->Parameters.Others.Argument2, + PowerState, + Stack->Parameters.Others.Argument4, + &Irp->IoStatus); + } IoSkipCurrentIrpStackLocation(Irp); IoFreeIrp(Irp); @@ -636,12 +643,13 @@ PoRegisterSystemState(IN PVOID StateHandle, */ NTSTATUS NTAPI -PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject, - IN UCHAR MinorFunction, - IN POWER_STATE PowerState, - IN PREQUEST_POWER_COMPLETE CompletionFunction, - IN PVOID Context, - OUT PIRP *pIrp OPTIONAL) +PoRequestPowerIrp( + _In_ PDEVICE_OBJECT DeviceObject, + _In_ UCHAR MinorFunction, + _In_ POWER_STATE PowerState, + _In_opt_ PREQUEST_POWER_COMPLETE CompletionFunction, + _In_opt_ __drv_aliasesMem PVOID Context, + _Outptr_opt_ PIRP *pIrp) { PDEVICE_OBJECT TopDeviceObject; PIO_STACK_LOCATION Stack;
3 years, 7 months
1
0
0
0
[reactos] 01/01: [CMAKE] Allow compiling amd64 port with GCC on Windows
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0f723105c69c2cfd912fe…
commit 0f723105c69c2cfd912fe0ea82b585a4addc0d0e Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed May 19 14:13:51 2021 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed May 19 14:13:51 2021 +0200 [CMAKE] Allow compiling amd64 port with GCC on Windows Dedicated to Daniel --- sdk/cmake/host-tools.cmake | 3 +++ sdk/lib/pseh/CMakeLists.txt | 8 +++++++- sdk/tools/gcc_plugin_seh/CMakeLists.txt | 8 ++++++++ sdk/tools/gcc_plugin_seh/main.cpp | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sdk/cmake/host-tools.cmake b/sdk/cmake/host-tools.cmake index fe9b449fa84..8e9158227c8 100644 --- a/sdk/cmake/host-tools.cmake +++ b/sdk/cmake/host-tools.cmake @@ -13,6 +13,9 @@ function(setup_host_tools) string(STRIP ${GCC_PLUGIN_DIR} GCC_PLUGIN_DIR) list(APPEND CMAKE_HOST_TOOLS_EXTRA_ARGS -DGCC_PLUGIN_DIR=${GCC_PLUGIN_DIR}) list(APPEND HOST_MODULES gcc_plugin_seh) + if (CMAKE_HOST_WIN32) + list(APPEND HOST_MODULES g++_plugin_seh) + endif() endif() list(TRANSFORM HOST_TOOLS PREPEND "${REACTOS_BINARY_DIR}/host-tools/bin/" OUTPUT_VARIABLE HOST_TOOLS_OUTPUT) if (CMAKE_HOST_WIN32) diff --git a/sdk/lib/pseh/CMakeLists.txt b/sdk/lib/pseh/CMakeLists.txt index 604e56614ed..9777f55c930 100644 --- a/sdk/lib/pseh/CMakeLists.txt +++ b/sdk/lib/pseh/CMakeLists.txt @@ -20,7 +20,13 @@ if(MSVC OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (ARCH STREQUAL "amd64"))) elseif((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (ARCH STREQUAL "amd64")) # for GCC amd64 this is just an interface library, with our home-made plugin add_library(pseh INTERFACE) - target_compile_options(pseh INTERFACE -fplugin=$<TARGET_FILE:native-gcc_plugin_seh>) + if (CMAKE_HOST_WIN32) + target_compile_options(pseh INTERFACE + $<$<COMPILE_LANGUAGE:C>:-fplugin=$<TARGET_FILE:native-gcc_plugin_seh>> + $<$<COMPILE_LANGUAGE:CXX>:-fplugin=$<TARGET_FILE:native-g++_plugin_seh>>) + else() + target_compile_options(pseh INTERFACE $<$<COMPILE_LANGUAGE:C,CXX>:-fplugin=$<TARGET_FILE:native-gcc_plugin_seh>>) + endif() else() if(USE_PSEH3) diff --git a/sdk/tools/gcc_plugin_seh/CMakeLists.txt b/sdk/tools/gcc_plugin_seh/CMakeLists.txt index b96571f7fbe..d2d56ee5a8b 100644 --- a/sdk/tools/gcc_plugin_seh/CMakeLists.txt +++ b/sdk/tools/gcc_plugin_seh/CMakeLists.txt @@ -2,3 +2,11 @@ add_host_module(gcc_plugin_seh main.cpp) target_include_directories(gcc_plugin_seh PRIVATE ${GCC_PLUGIN_DIR}/include) set_target_properties(gcc_plugin_seh PROPERTIES POSITION_INDEPENDENT_CODE ON) + +if (CMAKE_HOST_SYSTEM MATCHES "Windows") + # On windows, GCC plugins need to be linked to the main executable + # This means that there must be a plugin for both GCC & G++ + target_link_libraries(gcc_plugin_seh PRIVATE ${GCC_PLUGIN_DIR}/cc1.exe.a) + add_host_module(g++_plugin_seh $<TARGET_OBJECTS:gcc_plugin_seh>) + target_link_libraries(g++_plugin_seh PRIVATE ${GCC_PLUGIN_DIR}/cc1plus.exe.a) +endif() diff --git a/sdk/tools/gcc_plugin_seh/main.cpp b/sdk/tools/gcc_plugin_seh/main.cpp index 22df978e0c6..7383192da71 100644 --- a/sdk/tools/gcc_plugin_seh/main.cpp +++ b/sdk/tools/gcc_plugin_seh/main.cpp @@ -20,7 +20,7 @@ #define is_alpha(c) (((c)>64 && (c)<91) || ((c)>96 && (c)<123)) #if defined(_WIN32) || defined(WIN32) -#define VISIBLE __decspec(dllexport) +#define VISIBLE __declspec(dllexport) #else #define VISIBLE __attribute__((__visibility__("default"))) #endif
3 years, 7 months
1
0
0
0
← Newer
1
...
4
5
6
7
8
9
10
...
19
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Results per page:
10
25
50
100
200