Respect the codepage stored in .LNK files in conhost (#15111)

Making Conhost pick up codepage from .lnk files.

Because of the wrong assignment order, the Conhost was not picking up
the codepage stored in .lnk shortcut files. This change fixes this issue
by changing the order of the assignment to the correct one.

This is a potential backward compatibility issue.

Since this issue has been present in the codebase for years, this change
runs a high risk of breaking backward compatibility with software that
depends on incorrect behavior.

## Validation Steps Performed
Tested fix manually (using chcp command, making sure each .lnk codepage
was picked up.) against Debug/Release x64 builds with 5 different .lnk
files:

1. Arabic codepage 1256
2. Greek 869
3. Latin2 852
4. Thai 874
5. Traditional Chinese 50229

Ran TAEF tests against Debug/Release x64/x86 with identical results as
main branch.

Tested against invalid codepage numbers by manually manipulating .lnk
file binary. In case of an invalid codepage number, Conhost defaults to
a valid default one, which I assume is expected behavior.

Closes #14942
This commit is contained in:
michalnpl
2023-04-06 08:51:57 -07:00
committed by GitHub
parent a98a0cf2c6
commit e73362d45b

View File

@@ -165,7 +165,7 @@ void ShortcutSerialization::s_SetLinkPropertyDwordValue(_Inout_ IPropertyStore*
NT_FE_CONSOLE_PROPS* pNtFEConsoleProps;
if (SUCCEEDED(pConsoleLnkDataList->CopyDataBlock(NT_FE_CONSOLE_PROPS_SIG, reinterpret_cast<void**>(&pNtFEConsoleProps))))
{
pNtFEConsoleProps->uCodePage = pStateInfo->CodePage;
pStateInfo->CodePage = pNtFEConsoleProps->uCodePage;
LocalFree(pNtFEConsoleProps);
}
}