From 79d850f2d7624a941ee395815d1d0d60427dcc30 Mon Sep 17 00:00:00 2001 From: Juergen Schmied Date: Mon, 12 Jun 2000 21:56:02 +0000 Subject: [PATCH] - implemented Get/SetThreadLocale - added comment about OleErrorInfo field in TEB --- dlls/ole32/errorinfo.c | 3 +++ include/thread.h | 4 ++-- scheduler/process.c | 9 --------- scheduler/thread.c | 30 ++++++++++++++++++++++++++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/dlls/ole32/errorinfo.c b/dlls/ole32/errorinfo.c index e5733ab721e..ce6ab81be25 100644 --- a/dlls/ole32/errorinfo.c +++ b/dlls/ole32/errorinfo.c @@ -3,6 +3,9 @@ * * Copyright 2000 Patrik Stridvall * + * + * The errorinfo is a per-thread object. The reference is stored in the + * TEB at offset 0xf80 */ #include "debugtools.h" diff --git a/include/thread.h b/include/thread.h index e58b95d6cc7..f04068646bf 100644 --- a/include/thread.h +++ b/include/thread.h @@ -75,7 +75,7 @@ typedef struct _TEB WORD thunk_ss; /* --n 84 Yet another 16-bit stack selector */ WORD pad3; /* --n 86 */ DWORD pad4[15]; /* --n 88 */ - ULONG CurrentLocale; /* -2n C4 */ + ULONG CurrentLocale; /* -2- C4 */ DWORD pad5[48]; /* --n C8 */ DWORD delta_priority; /* 1-n 188 Priority delta */ DWORD unknown4[7]; /* d-n 18c Unknown */ @@ -107,7 +107,7 @@ typedef struct _TEB DWORD pad8[3]; /* --n f10 */ PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */ DWORD pad9[24]; /* --n f20 */ - PVOID ReservedForOle; /* -2- f80 used by ole32 */ + PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */ } TEB; /* Thread exception flags */ diff --git a/scheduler/process.c b/scheduler/process.c index 0c4aedd1c12..0e30571083b 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -1006,15 +1006,6 @@ DWORD WINAPI MapProcessHandle( HANDLE handle ) return ret; } -/*********************************************************************** - * GetThreadLocale (KERNEL32.295) - */ -LCID WINAPI GetThreadLocale(void) -{ - return PROCESS_Current()->locale; -} - - /*********************************************************************** * SetPriorityClass (KERNEL32.503) */ diff --git a/scheduler/thread.c b/scheduler/thread.c index 839e4663291..031fcc5eda5 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -30,6 +30,7 @@ #include "debugtools.h" #include "queue.h" #include "hook.h" +#include "winnls.h" DEFAULT_DEBUG_CHANNEL(thread); @@ -296,6 +297,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack, teb->entry_arg = param; teb->startup = THREAD_Start; teb->htask16 = GetCurrentTask(); + teb->CurrentLocale = GetUserDefaultLCID(); /* for threads in user context */ if (id) *id = (DWORD)tid; if (SYSDEPS_SpawnThread( teb ) == -1) { @@ -810,6 +812,16 @@ VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost ) FIXME("(0x%08lx,%d): stub\n", threadId, boost); } + +/*********************************************************************** + * GetThreadLocale (KERNEL32.295) + */ +LCID WINAPI GetThreadLocale(void) +{ + return NtCurrentTeb()->CurrentLocale; +} + + /********************************************************************** * SetThreadLocale [KERNEL32.671] Sets the calling threads current locale. * @@ -817,14 +829,24 @@ VOID WINAPI VWin32_BoostThreadStatic( DWORD threadId, INT boost ) * Success: TRUE * Failure: FALSE * - * NOTES - * Implemented in NT only (3.1 and above according to MS + * FIXME + * check if lcid is a valid cp */ BOOL WINAPI SetThreadLocale( LCID lcid) /* [in] Locale identifier */ { - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + switch (lcid) + { + case LOCALE_SYSTEM_DEFAULT: + lcid = GetSystemDefaultLCID(); + break; + case LOCALE_USER_DEFAULT: + case LOCALE_NEUTRAL: + lcid = GetUserDefaultLCID(); + break; + } + NtCurrentTeb()->CurrentLocale = lcid; + return TRUE; }