ntdll: Load the locale.nls file at startup.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-03-22 10:30:01 +01:00
parent f161195859
commit 4b0f1163fa
3 changed files with 36 additions and 1 deletions

View File

@ -4129,6 +4129,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
RtlInitAnsiString( &func_name, "CtrlRoutine" );
LdrGetProcedureAddress( kernel32_handle, &func_name, 0, (void **)&pCtrlRoutine );
locale_init();
actctx_init();
if (wm->ldr.Flags & LDR_COR_ILONLY)
status = fixup_imports_ilonly( wm, NULL, entry );

View File

@ -100,9 +100,12 @@ struct norm_table
/* WORD[] composition character sequences */
};
static const WCHAR *locale_strings;
static NLSTABLEINFO nls_info;
static struct norm_table *norm_tables[16];
static const NLS_LOCALE_LCID_INDEX *lcids_index;
static const NLS_LOCALE_LCNAME_INDEX *lcnames_index;
static const NLS_LOCALE_HEADER *locale_table;
static NTSTATUS load_string( ULONG id, LANGID lang, WCHAR *buffer, ULONG len )
{
@ -235,6 +238,36 @@ invalid:
}
void locale_init(void)
{
LARGE_INTEGER unused;
LCID system_lcid;
NTSTATUS status;
struct
{
UINT ctypes;
UINT unknown1;
UINT unknown2;
UINT unknown3;
UINT locales;
UINT charmaps;
UINT geoids;
UINT scripts;
} *header;
status = RtlGetLocaleFileMappingAddress( (void **)&header, &system_lcid, &unused );
if (status)
{
ERR( "locale init failed %x\n", status );
return;
}
locale_table = (const NLS_LOCALE_HEADER *)((char *)header + header->locales);
lcids_index = (const NLS_LOCALE_LCID_INDEX *)((char *)locale_table + locale_table->lcids_offset);
lcnames_index = (const NLS_LOCALE_LCNAME_INDEX *)((char *)locale_table + locale_table->lcnames_offset);
locale_strings = (const WCHAR *)((char *)locale_table + locale_table->strings_offset);
}
static BYTE rol( BYTE val, BYTE count )
{
return (val << count) | (val >> (8 - count));

View File

@ -66,6 +66,7 @@ extern const char *debugstr_exception_code( DWORD code ) DECLSPEC_HIDDEN;
extern void version_init(void) DECLSPEC_HIDDEN;
extern void debug_init(void) DECLSPEC_HIDDEN;
extern void actctx_init(void) DECLSPEC_HIDDEN;
extern void locale_init(void) DECLSPEC_HIDDEN;
extern void init_user_process_params(void) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;