mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Moved interlocked and locale functions.
Implemented basic locale support. Added some missing interlocked functions. svn path=/trunk/; revision=2056
This commit is contained in:
parent
b03d2d1155
commit
6d64efee46
14 changed files with 470 additions and 99 deletions
|
@ -713,6 +713,52 @@ ExInitializePagedLookasideList (
|
|||
);
|
||||
|
||||
|
||||
ULONG
|
||||
FASTCALL
|
||||
ExfInterlockedAddUlong (
|
||||
IN PULONG Addend,
|
||||
IN ULONG Increment,
|
||||
IN PKSPIN_LOCK Lock
|
||||
);
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
FASTCALL
|
||||
Exfi386InterlockedIncrementLong (
|
||||
IN PLONG Addend
|
||||
);
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
FASTCALL
|
||||
Exfi386InterlockedDecrementLong (
|
||||
IN PLONG Addend
|
||||
);
|
||||
|
||||
ULONG
|
||||
FASTCALL
|
||||
Exfi386InterlockedExchangeUlong (
|
||||
IN PULONG Target,
|
||||
IN ULONG Value
|
||||
);
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
STDCALL
|
||||
Exi386InterlockedIncrementLong (
|
||||
IN PLONG Addend
|
||||
);
|
||||
|
||||
INTERLOCKED_RESULT
|
||||
STDCALL
|
||||
Exi386InterlockedDecrementLong (
|
||||
IN PLONG Addend
|
||||
);
|
||||
|
||||
ULONG
|
||||
STDCALL
|
||||
Exi386InterlockedExchangeUlong (
|
||||
IN PULONG Target,
|
||||
IN ULONG Value
|
||||
);
|
||||
|
||||
/*
|
||||
LONG
|
||||
FASTCALL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.45 2001/07/04 20:40:20 chorns Exp $
|
||||
# $Id: Makefile,v 1.46 2001/07/12 17:17:06 ekohl Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -55,7 +55,7 @@ TARGETNAME := ntoskrnl
|
|||
OBJECTS_PATH = objects
|
||||
|
||||
ASFLAGS = -Iinclude
|
||||
CFLAGS = -Iinclude -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror
|
||||
CFLAGS = -Iinclude -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
@ -96,7 +96,6 @@ OBJECTS_RTL = \
|
|||
rtl/ctype.o \
|
||||
rtl/error.o \
|
||||
rtl/handle.o \
|
||||
rtl/interlck.o \
|
||||
rtl/largeint.o \
|
||||
rtl/mem.o \
|
||||
rtl/memchr.o \
|
||||
|
@ -216,6 +215,7 @@ OBJECTS_PS = \
|
|||
ps/create.o \
|
||||
ps/idle.o \
|
||||
ps/kill.o \
|
||||
ps/locale.o \
|
||||
ps/process.o \
|
||||
ps/psmgr.o \
|
||||
ps/thread.o \
|
||||
|
@ -230,7 +230,6 @@ OBJECTS_EX = \
|
|||
ex/init.o \
|
||||
ex/interlck.o \
|
||||
ex/list.o \
|
||||
ex/locale.o \
|
||||
ex/lookas.o \
|
||||
ex/napi.o \
|
||||
ex/power.o \
|
||||
|
|
|
@ -7,6 +7,9 @@ include hal/x86/sources
|
|||
|
||||
OBJECTS_BOOT := ke/i386/multiboot.o
|
||||
|
||||
OBJECTS_EX_I386 := \
|
||||
ex/i386/interlck.o
|
||||
|
||||
OBJECTS_KE_I386 := \
|
||||
ke/i386/exp.o \
|
||||
ke/i386/irq.o \
|
||||
|
@ -20,7 +23,7 @@ OBJECTS_KE_I386 := \
|
|||
ke/i386/v86m.o \
|
||||
ke/i386/v86m_sup.o \
|
||||
ke/i386/bios.o \
|
||||
ke/i386/i386-mcount.o \
|
||||
ke/i386/i386-mcount.o \
|
||||
ke/i386/gdt.o \
|
||||
ke/i386/idt.o \
|
||||
ke/i386/ldt.o \
|
||||
|
@ -34,4 +37,4 @@ OBJECTS_MM_I386 := \
|
|||
mm/i386/page.o \
|
||||
mm/i386/pfault.o
|
||||
|
||||
OBJECTS_ARCH = $(OBJECTS_BOOT) $(OBJECTS_KE_I386) $(OBJECTS_MM_I386)
|
||||
OBJECTS_ARCH = $(OBJECTS_BOOT) $(OBJECTS_EX_I386) $(OBJECTS_KE_I386) $(OBJECTS_MM_I386)
|
||||
|
|
1
reactos/ntoskrnl/ex/i386/.cvsignore
Normal file
1
reactos/ntoskrnl/ex/i386/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
*.d
|
|
@ -1,13 +1,80 @@
|
|||
/* $Id: interlck.c,v 1.9 2001/07/06 21:30:33 ekohl Exp $
|
||||
/* $Id: interlck.c,v 1.1 2001/07/12 17:17:56 ekohl Exp $
|
||||
*
|
||||
* reactos/ntoskrnl/rtl/interlck.c
|
||||
* reactos/ntoskrnl/ex/i386/interlck.c
|
||||
*
|
||||
*/
|
||||
#include <reactos/config.h>
|
||||
#include <ntos.h>
|
||||
#include <internal/debug.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
|
||||
INTERLOCKED_RESULT FASTCALL
|
||||
Exfi386InterlockedIncrementLong(IN PLONG Addend);
|
||||
|
||||
__asm__("\n\t.global @Exfi386InterlockedIncrementLong@4\n\t"
|
||||
"@Exfi386InterlockedIncrementLong@4:\n\t"
|
||||
"addl $1,(%ecx)\n\t"
|
||||
"lahf\n\t"
|
||||
"andl $0xC000, %eax\n\t"
|
||||
"ret\n\t");
|
||||
|
||||
|
||||
INTERLOCKED_RESULT FASTCALL
|
||||
Exfi386InterlockedDecrementLong(IN PLONG Addend);
|
||||
|
||||
__asm__("\n\t.global @Exfi386InterlockedDecrementLong@4\n\t"
|
||||
"@Exfi386InterlockedDecrementLong@4:\n\t"
|
||||
"subl $1,(%ecx)\n\t"
|
||||
"lahf\n\t"
|
||||
"andl $0xC000, %eax\n\t"
|
||||
"ret\n\t");
|
||||
|
||||
|
||||
ULONG FASTCALL
|
||||
Exfi386InterlockedExchangeUlong(IN PULONG Target,
|
||||
IN ULONG Value);
|
||||
|
||||
__asm__("\n\t.global @Exfi386InterlockedExchangeUlong@8\n\t"
|
||||
"@Exfi386InterlockedExchangeUlong@8:\n\t"
|
||||
"movl (%ecx),%eax\n"
|
||||
"xchgl %edx,(%ecx)\n\t"
|
||||
"ret\n\t");
|
||||
|
||||
|
||||
|
||||
INTERLOCKED_RESULT STDCALL
|
||||
Exi386InterlockedIncrementLong(IN PLONG Addend);
|
||||
|
||||
__asm__("\n\t.global _Exi386InterlockedIncrementLong@4\n\t"
|
||||
"_Exi386InterlockedIncrementLong@4:\n\t"
|
||||
"movl 4(%esp),%eax\n\t"
|
||||
"addl $1,(%eax)\n\t"
|
||||
"lahf\n\t"
|
||||
"andl $0xC000, %eax\n\t"
|
||||
"ret $4\n\t");
|
||||
|
||||
|
||||
INTERLOCKED_RESULT STDCALL
|
||||
Exi386InterlockedDecrementLong(IN PLONG Addend);
|
||||
|
||||
__asm__("\n\t.global _Exi386InterlockedDecrementLong@4\n\t"
|
||||
"_Exi386InterlockedDecrementLong@4:\n\t"
|
||||
"movl 4(%esp),%eax\n\t"
|
||||
"subl $1,(%eax)\n\t"
|
||||
"lahf\n\t"
|
||||
"andl $0xC000, %eax\n\t"
|
||||
"ret $4\n\t");
|
||||
|
||||
|
||||
ULONG STDCALL
|
||||
Exi386InterlockedExchangeUlong(IN PULONG Target,
|
||||
IN ULONG Value);
|
||||
|
||||
__asm__("\n\t.global _Exi386InterlockedExchangeUlong@8\n\t"
|
||||
"_Exi386InterlockedExchangeUlong@8:\n\t"
|
||||
"movl 4(%esp),%edx\n\t"
|
||||
"movl 8(%esp),%eax\n\t"
|
||||
"xchgl %eax,(%edx)\n\t"
|
||||
"ret $8\n\t");
|
||||
|
||||
#define USE_FASTCALL
|
||||
|
||||
/**********************************************************************
|
||||
* FASTCALL: @InterlockedIncrement@4
|
||||
|
@ -18,7 +85,7 @@ InterlockedIncrement(PLONG Addend);
|
|||
/*
|
||||
* FUNCTION: Increments a caller supplied variable of type LONG as an
|
||||
* atomic operation
|
||||
* ARGUMENTS;
|
||||
* ARGUMENTS:
|
||||
* Addend = Points to a variable whose value is to be increment
|
||||
* RETURNS: The incremented value
|
||||
*/
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: interlck.c,v 1.6 2000/12/23 02:37:39 dwelch Exp $
|
||||
/* $Id: interlck.c,v 1.7 2001/07/12 17:18:49 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -180,5 +180,37 @@ ExInterlockedCompareExchange64 (IN OUT PLONGLONG Destination,
|
|||
return oldval;
|
||||
}
|
||||
|
||||
ULONG FASTCALL
|
||||
ExfInterlockedAddUlong(PULONG Addend,
|
||||
ULONG Increment,
|
||||
PKSPIN_LOCK Lock)
|
||||
/*
|
||||
* ExInterlockedAddUlong adds an unsigned long value to a given unsigned
|
||||
* integer as an atomic operation.
|
||||
*
|
||||
* ADDEND = Points to an unsigned long integer whose value is to be adjusted
|
||||
* by the Increment value.
|
||||
*
|
||||
* INCREMENT = Is an unsigned long integer to be added.
|
||||
*
|
||||
* LOCK = Points to a spinlock to be used to synchronize access to ADDEND.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* The original value of the unsigned integer pointed to by ADDEND.
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
ULONG oldval;
|
||||
|
||||
KeAcquireSpinLock (Lock, &oldlvl);
|
||||
|
||||
oldval = *Addend;
|
||||
*Addend += Increment;
|
||||
|
||||
KeReleaseSpinLock (Lock, oldlvl);
|
||||
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/* $Id: locale.c,v 1.4 2000/12/23 02:37:39 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ex/locale.c
|
||||
* PURPOSE: Locale support
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
OUT PLCID DefaultLocaleId)
|
||||
/*
|
||||
* Returns the default locale.
|
||||
*
|
||||
* THREADORSYSTEM = If TRUE then the locale for this thread is returned,
|
||||
* otherwise the locale for the system is returned.
|
||||
*
|
||||
* DEFAUTLOCALEID = Points to a variable that receives the locale id.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* Status.
|
||||
*/
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
IN LCID DefaultLocaleId)
|
||||
/*
|
||||
* Sets the default locale.
|
||||
*
|
||||
* THREADORSYSTEM = If TRUE then the thread's locale is set, otherwise the
|
||||
* sytem locale is set.
|
||||
*
|
||||
* DEFAUTLOCALEID = The locale id to be set
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* Status
|
||||
*/
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -95,6 +95,10 @@ static inline PKPCR KeGetCurrentKPCR(VOID)
|
|||
|
||||
extern HANDLE SystemProcessHandle;
|
||||
|
||||
extern LCID PsDefaultThreadLocaleId;
|
||||
extern LCID PsDefaultSystemLocaleId;
|
||||
|
||||
|
||||
typedef struct _KAPC_STATE
|
||||
{
|
||||
LIST_ENTRY ApcListHead[2];
|
||||
|
@ -118,7 +122,7 @@ typedef struct _KTHREAD
|
|||
NT_TEB* Teb; /* 20 */
|
||||
|
||||
/* Pointer to the thread's TLS array */
|
||||
PVOID TlsArray; /* 24 */
|
||||
PVOID TlsArray; /* 24 */
|
||||
PVOID KernelStack; /* 28 */
|
||||
UCHAR DebugActive; /* 2C */
|
||||
|
||||
|
@ -443,7 +447,7 @@ struct _EPROCESS
|
|||
PVOID SectionBaseAddress;
|
||||
PVOID QuotaBlock;
|
||||
NTSTATUS LastThreadExitStatus;
|
||||
PVOID WorkingSetWatch;
|
||||
PVOID WorkingSetWatch;
|
||||
HANDLE InheritedFromUniqueProcessId;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
ULONG DefaultHardErrorProcessing;
|
||||
|
@ -471,12 +475,13 @@ struct _EPROCESS
|
|||
/*
|
||||
* Added by Philip Susi for list of threads in process
|
||||
*/
|
||||
LIST_ENTRY ThreadListHead;
|
||||
LIST_ENTRY ThreadListHead;
|
||||
};
|
||||
|
||||
#define PROCESS_STATE_TERMINATED (1)
|
||||
#define PROCESS_STATE_ACTIVE (2)
|
||||
|
||||
VOID PiInitDefaultLocale(VOID);
|
||||
VOID PiInitProcessManager(VOID);
|
||||
VOID PiShutdownProcessManager(VOID);
|
||||
VOID PsInitThreadManagment(VOID);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: main.c,v 1.99 2001/06/29 21:08:50 ea Exp $
|
||||
/* $Id: main.c,v 1.100 2001/07/12 17:23:42 ekohl Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/main.c
|
||||
|
@ -646,6 +646,8 @@ ExpInitializeExecutive(VOID)
|
|||
|
||||
CmInitializeRegistry2();
|
||||
|
||||
PiInitDefaultLocale();
|
||||
|
||||
/*
|
||||
* Start the motherboard enumerator (the HAL)
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.110 2001/07/06 21:30:59 ekohl Exp $
|
||||
; $Id: ntoskrnl.def,v 1.111 2001/07/12 17:17:07 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -86,18 +86,18 @@ ExSystemTimeToLocalTime@8
|
|||
ExTryToAcquireResourceExclusiveLite@4
|
||||
ExUnregisterCallback@4
|
||||
ExWindowStationObjectType DATA
|
||||
;@ExfInterlockedAddUlong
|
||||
@ExfInterlockedAddUlong@12
|
||||
;@ExfInterlockedInsertHeadList
|
||||
;@ExfInterlockedInsertTailList
|
||||
;@ExfInterlockedPopEntryList
|
||||
;@ExfInterlockedPushEntryList
|
||||
;@ExfInterlockedRemoveHeadList
|
||||
;@Exfi386InterlockedDecrementLong
|
||||
;@Exfi386InterlockedExchangeUlong
|
||||
;@Exfi386InterlockedIncrementLong
|
||||
;Exi386InterlockedDecrementLong
|
||||
;Exi386InterlockedExchangeUlong
|
||||
;Exi386InterlockedIncrementLong
|
||||
@Exfi386InterlockedDecrementLong@4
|
||||
@Exfi386InterlockedExchangeUlong@8
|
||||
@Exfi386InterlockedIncrementLong@4
|
||||
Exi386InterlockedDecrementLong@4
|
||||
Exi386InterlockedExchangeUlong@8
|
||||
Exi386InterlockedIncrementLong@4
|
||||
FsRtlAddLargeMcbEntry@28
|
||||
FsRtlAddMcbEntry@16
|
||||
FsRtlAddToTunnelCache@32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.96 2001/07/06 21:30:59 ekohl Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.97 2001/07/12 17:17:07 ekohl Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -86,18 +86,18 @@ ExSystemTimeToLocalTime=ExSystemTimeToLocalTime@8
|
|||
ExTryToAcquireResourceExclusiveLite=ExTryToAcquireResourceExclusiveLite@4
|
||||
ExUnregisterCallback=ExUnregisterCallback@4
|
||||
ExWindowStationObjectType DATA
|
||||
;ExfInterlockedAddUlong
|
||||
ExfInterlockedAddUlong=@ExfInterlockedAddUlong@12
|
||||
;ExfInterlockedInsertHeadList
|
||||
;ExfInterlockedInsertTailList
|
||||
;ExfInterlockedPopEntryList
|
||||
;ExfInterlockedPushEntryList
|
||||
;ExfInterlockedRemoveHeadList
|
||||
;Exfi386InterlockedDecrementLong
|
||||
;Exfi386InterlockedExchangeUlong
|
||||
;Exfi386InterlockedIncrementLong
|
||||
;Exi386InterlockedDecrementLong
|
||||
;Exi386InterlockedExchangeUlong
|
||||
;Exi386InterlockedIncrementLong
|
||||
Exfi386InterlockedDecrementLong=@Exfi386InterlockedDecrementLong@4
|
||||
Exfi386InterlockedExchangeUlong=@Exfi386InterlockedExchangeUlong@8
|
||||
Exfi386InterlockedIncrementLong=@Exfi386InterlockedIncrementLong@4
|
||||
Exi386InterlockedDecrementLong=Exi386InterlockedDecrementLong@4
|
||||
Exi386InterlockedExchangeUlong=Exi386InterlockedExchangeUlong@8
|
||||
Exi386InterlockedIncrementLong=Exi386InterlockedIncrementLong@4
|
||||
FsRtlAddLargeMcbEntry=FsRtlAddLargeMcbEntry@28
|
||||
FsRtlAddMcbEntry=FsRtlAddMcbEntry@16
|
||||
FsRtlAddToTunnelCache=FsRtlAddToTunnelCache@32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.34 2001/07/04 20:40:21 chorns Exp $
|
||||
/* $Id: create.c,v 1.35 2001/07/12 17:21:05 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -406,10 +406,11 @@ PsInitializeThread(HANDLE ProcessHandle,
|
|||
}
|
||||
|
||||
|
||||
static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
||||
PNT_TEB *TebPtr,
|
||||
PETHREAD Thread,
|
||||
PINITIAL_TEB InitialTeb)
|
||||
static NTSTATUS
|
||||
PsCreateTeb(HANDLE ProcessHandle,
|
||||
PNT_TEB *TebPtr,
|
||||
PETHREAD Thread,
|
||||
PINITIAL_TEB InitialTeb)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION Info;
|
||||
NTSTATUS Status;
|
||||
|
@ -484,6 +485,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
|||
/* more initialization */
|
||||
Teb.Cid.UniqueThread = Thread->Cid.UniqueThread;
|
||||
Teb.Cid.UniqueProcess = Thread->Cid.UniqueProcess;
|
||||
Teb.CurrentLocale = PsDefaultThreadLocaleId;
|
||||
|
||||
DPRINT("sizeof(NT_TEB) %x\n", sizeof(NT_TEB));
|
||||
|
||||
|
|
272
reactos/ntoskrnl/ps/locale.c
Normal file
272
reactos/ntoskrnl/ps/locale.c
Normal file
|
@ -0,0 +1,272 @@
|
|||
/* $Id: locale.c,v 1.1 2001/07/12 17:21:06 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ps/locale.c
|
||||
* PURPOSE: Locale support
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
/*
|
||||
* Default setting: LANG_NEUTRAL, SUBLANG_NEUTRAL, SORT_DEFAULT
|
||||
*/
|
||||
LCID PsDefaultThreadLocaleId = 0;
|
||||
LCID PsDefaultSystemLocaleId = 0;
|
||||
|
||||
|
||||
#define VALUE_BUFFER_SIZE 256
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
PiInitDefaultLocale(VOID)
|
||||
/*
|
||||
* FUNCTION:
|
||||
* Initializes the default locale.
|
||||
* Reads default locale from registry, if available
|
||||
* ARGUMENTS:
|
||||
* None.
|
||||
* Returns:
|
||||
* None.
|
||||
*/
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
UNICODE_STRING ValueName;
|
||||
HANDLE KeyHandle;
|
||||
ULONG ValueLength;
|
||||
UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
|
||||
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
|
||||
UNICODE_STRING ValueString;
|
||||
ULONG LocaleValue;
|
||||
NTSTATUS Status;
|
||||
|
||||
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
|
||||
|
||||
/* read system locale */
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
|
||||
RtlInitUnicodeString(&ValueName,
|
||||
L"Default");
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_QUERY_VALUE,
|
||||
&ObjectAttributes);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = NtQueryValueKey(KeyHandle,
|
||||
&ValueName,
|
||||
KeyValuePartialInformation,
|
||||
ValueBuffer,
|
||||
VALUE_BUFFER_SIZE,
|
||||
&ValueLength);
|
||||
if ((NT_SUCCESS(Status)) && (ValueInfo->Type == REG_SZ))
|
||||
{
|
||||
ValueString.Length = ValueInfo->DataLength;
|
||||
ValueString.MaximumLength = ValueInfo->DataLength;
|
||||
ValueString.Buffer = (PWSTR)ValueInfo->Data;
|
||||
|
||||
Status = RtlUnicodeStringToInteger(&ValueString,
|
||||
10,
|
||||
&LocaleValue);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("System locale: %08lu\n", LocaleValue);
|
||||
PsDefaultSystemLocaleId = (LCID)LocaleValue;
|
||||
}
|
||||
}
|
||||
NtClose(KeyHandle);
|
||||
}
|
||||
|
||||
/* read default thread locale */
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"\\Registry\\User\\.Default\\Control Panel\\International");
|
||||
RtlInitUnicodeString(&ValueName,
|
||||
L"Locale");
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_QUERY_VALUE,
|
||||
&ObjectAttributes);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = NtQueryValueKey(KeyHandle,
|
||||
&ValueName,
|
||||
KeyValuePartialInformation,
|
||||
ValueBuffer,
|
||||
VALUE_BUFFER_SIZE,
|
||||
&ValueLength);
|
||||
if ((NT_SUCCESS(Status)) && (ValueInfo->Type == REG_SZ))
|
||||
{
|
||||
ValueString.Length = ValueInfo->DataLength;
|
||||
ValueString.MaximumLength = ValueInfo->DataLength;
|
||||
ValueString.Buffer = (PWSTR)ValueInfo->Data;
|
||||
|
||||
Status = RtlUnicodeStringToInteger(&ValueString,
|
||||
10,
|
||||
&LocaleValue);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Thread locale: %08lu\n", LocaleValue);
|
||||
PsDefaultThreadLocaleId = (LCID)LocaleValue;
|
||||
}
|
||||
}
|
||||
NtClose(KeyHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
OUT PLCID DefaultLocaleId)
|
||||
/*
|
||||
* FUNCTION:
|
||||
* Returns the default locale.
|
||||
* ARGUMENTS:
|
||||
* ThreadOrSystem = If TRUE then the locale for this thread is returned,
|
||||
* otherwise the locale for the system is returned.
|
||||
* DefaultLocaleId = Points to a variable that receives the locale id.
|
||||
* Returns:
|
||||
* Status.
|
||||
*/
|
||||
{
|
||||
if (DefaultLocaleId == NULL)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (ThreadOrSystem == TRUE)
|
||||
{
|
||||
/* set thread locale */
|
||||
*DefaultLocaleId = PsDefaultThreadLocaleId;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set system locale */
|
||||
*DefaultLocaleId = PsDefaultSystemLocaleId;
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
|
||||
IN LCID DefaultLocaleId)
|
||||
/*
|
||||
* FUNCTION:
|
||||
* Sets the default locale.
|
||||
* ARGUMENTS:
|
||||
* ThreadOrSystem = If TRUE then the locale for this thread is set,
|
||||
* otherwise the locale for the system is set.
|
||||
* DefaultLocaleId = The locale id to be set.
|
||||
* Returns:
|
||||
* Status.
|
||||
*/
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
UNICODE_STRING ValueName;
|
||||
HANDLE KeyHandle;
|
||||
ULONG ValueLength;
|
||||
WCHAR ValueBuffer[20];
|
||||
HANDLE UserKey = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (ThreadOrSystem == TRUE)
|
||||
{
|
||||
/* thread locale */
|
||||
Status = RtlOpenCurrentUser(KEY_WRITE,
|
||||
&UserKey);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return(Status);
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"Control Panel\\International");
|
||||
RtlInitUnicodeString(&ValueName,
|
||||
L"Locale");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* system locale */
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
|
||||
RtlInitUnicodeString(&ValueName,
|
||||
L"Default");
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
UserKey,
|
||||
NULL);
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_SET_VALUE,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (UserKey != NULL)
|
||||
{
|
||||
NtClose(UserKey);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
ValueLength = swprintf(ValueBuffer,
|
||||
L"%08lu",
|
||||
(ULONG)DefaultLocaleId);
|
||||
ValueLength = (ValueLength + 1) * sizeof(WCHAR);
|
||||
|
||||
Status = NtSetValueKey(KeyHandle,
|
||||
&ValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
ValueBuffer,
|
||||
ValueLength);
|
||||
|
||||
NtClose(KeyHandle);
|
||||
if (UserKey != NULL)
|
||||
{
|
||||
NtClose(UserKey);
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (ThreadOrSystem == TRUE)
|
||||
{
|
||||
/* set thread locale */
|
||||
DPRINT("Thread locale: %08lu\n", DefaultLocaleId);
|
||||
PsDefaultThreadLocaleId = DefaultLocaleId;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set system locale */
|
||||
DPRINT("System locale: %08lu\n", DefaultLocaleId);
|
||||
PsDefaultSystemLocaleId = DefaultLocaleId;
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,9 +1,9 @@
|
|||
/* $Id: psmgr.c,v 1.10 2001/05/01 23:08:20 chorns Exp $
|
||||
/* $Id: psmgr.c,v 1.11 2001/07/12 17:21:06 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ps/psmgr.c
|
||||
* PURPOSE: Process managment
|
||||
* PURPOSE: Process management
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue