Alexandre Julliard : ntdll: Load the locale.nls file at startup.

Alexandre Julliard julliard at winehq.org
Tue Mar 22 16:46:29 CDT 2022


Module: wine
Branch: master
Commit: 4b0f1163fae90e0852e97c07043c85b975f2cede
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4b0f1163fae90e0852e97c07043c85b975f2cede

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar 22 10:30:01 2022 +0100

ntdll: Load the locale.nls file at startup.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/loader.c     |  1 +
 dlls/ntdll/locale.c     | 35 ++++++++++++++++++++++++++++++++++-
 dlls/ntdll/ntdll_misc.h |  1 +
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index d3b63dc7ada..f84746b7f1b 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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 );
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index 360496dd7e1..c60e6f2cf3e 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -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));
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index d7c5ade5bc1..571b49e844c 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -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;
 




More information about the wine-cvs mailing list