ntdll: Store the codepage data addresses in both PEBs.

Spotted by Jactry Zeng.
This commit is contained in:
Huw Davies 2023-09-08 12:33:22 +01:00 committed by Alexandre Julliard
parent 3c2e980d8d
commit 152924c9e4
2 changed files with 20 additions and 0 deletions

View file

@ -89,6 +89,13 @@ invalid:
return STATUS_INVALID_PARAMETER;
}
static PEB64 *get_peb64( void )
{
TEB64 *teb64 = NtCurrentTeb64();
if (!teb64) return NULL;
return (PEB64 *)(UINT_PTR)teb64->Peb;
}
void locale_init(void)
{
@ -101,6 +108,7 @@ void locale_init(void)
void *ansi_ptr = utf8, *oem_ptr = utf8, *case_ptr;
NTSTATUS status;
const struct locale_nls_header *header;
PEB64 *peb64 = get_peb64();
status = RtlGetLocaleFileMappingAddress( (void **)&header, &system_lcid, &unused );
if (status)
@ -158,15 +166,18 @@ void locale_init(void)
NtGetNlsSectionPtr( 10, 0, NULL, &case_ptr, &size );
NtCurrentTeb()->Peb->UnicodeCaseTableData = case_ptr;
if (peb64) peb64->UnicodeCaseTableData = PtrToUlong( case_ptr );
if (ansi_cp != CP_UTF8)
{
NtGetNlsSectionPtr( 11, ansi_cp, NULL, &ansi_ptr, &size );
NtCurrentTeb()->Peb->AnsiCodePageData = ansi_ptr;
if (peb64) peb64->AnsiCodePageData = PtrToUlong( ansi_ptr );
}
if (oem_cp != CP_UTF8)
{
NtGetNlsSectionPtr( 11, oem_cp, NULL, &oem_ptr, &size );
NtCurrentTeb()->Peb->OemCodePageData = oem_ptr;
if (peb64) peb64->OemCodePageData = PtrToUlong( oem_ptr );
}
RtlInitNlsTables( ansi_ptr, oem_ptr, case_ptr, &nls_info );
NlsAnsiCodePage = nls_info.AnsiTableInfo.CodePage;

View file

@ -875,6 +875,15 @@ static void test_peb_teb(void)
peb64->OSBuildNumber, NtCurrentTeb()->Peb->OSBuildNumber );
ok( peb64->OSPlatformId == NtCurrentTeb()->Peb->OSPlatformId, "wrong OSPlatformId %lx / %lx\n",
peb64->OSPlatformId, NtCurrentTeb()->Peb->OSPlatformId );
ok( peb64->AnsiCodePageData == PtrToUlong( NtCurrentTeb()->Peb->AnsiCodePageData ),
"wrong AnsiCodePageData %I64x / %p\n",
peb64->AnsiCodePageData, NtCurrentTeb()->Peb->AnsiCodePageData );
ok( peb64->OemCodePageData == PtrToUlong( NtCurrentTeb()->Peb->OemCodePageData ),
"wrong OemCodePageData %I64x / %p\n",
peb64->OemCodePageData, NtCurrentTeb()->Peb->OemCodePageData );
ok( peb64->UnicodeCaseTableData == PtrToUlong( NtCurrentTeb()->Peb->UnicodeCaseTableData ),
"wrong UnicodeCaseTableData %I64x / %p\n",
peb64->UnicodeCaseTableData, NtCurrentTeb()->Peb->UnicodeCaseTableData );
return;
}
#endif