diff --git a/reactos/include/ntdll/csr.h b/reactos/include/ntdll/csr.h index 5b9ef47fa59..d57f1ad2338 100644 --- a/reactos/include/ntdll/csr.h +++ b/reactos/include/ntdll/csr.h @@ -1,4 +1,4 @@ -/* $Id: csr.h,v 1.3 2000/04/25 23:22:52 ea Exp $ +/* $Id: csr.h,v 1.4 2001/05/02 22:22:23 ekohl Exp $ * */ @@ -12,12 +12,9 @@ NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply, ULONG Length, ULONG ReplyLength); -NTSTATUS -STDCALL -CsrSetPriorityClass ( - HANDLE hProcess, - DWORD * PriorityClass - ); +NTSTATUS STDCALL CsrNewThread(VOID); +NTSTATUS STDCALL CsrSetPriorityClass(HANDLE Process, + PULONG PriorityClass); #endif /* __INCLUDE_NTDLL_CSR_H */ diff --git a/reactos/lib/ntdll/csr/api.c b/reactos/lib/ntdll/csr/api.c index 583c1b30db7..8ec3d0ebb2e 100644 --- a/reactos/lib/ntdll/csr/api.c +++ b/reactos/lib/ntdll/csr/api.c @@ -1,4 +1,4 @@ -/* $Id: api.c,v 1.8 2000/06/29 23:35:27 dwelch Exp $ +/* $Id: api.c,v 1.9 2001/05/02 22:23:00 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,10 +23,11 @@ static HANDLE WindowsApiPort; /* FUNCTIONS *****************************************************************/ -NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request, - PCSRSS_API_REPLY Reply, - ULONG Length, - ULONG ReplyLength) +NTSTATUS STDCALL +CsrClientCallServer(PCSRSS_API_REQUEST Request, + PCSRSS_API_REPLY Reply, + ULONG Length, + ULONG ReplyLength) { NTSTATUS Status; @@ -45,7 +46,8 @@ NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request, return(Status); } -NTSTATUS STDCALL CsrClientConnectToServer(VOID) +NTSTATUS STDCALL +CsrClientConnectToServer(VOID) { NTSTATUS Status; UNICODE_STRING PortName; @@ -84,14 +86,20 @@ NTSTATUS STDCALL CsrClientConnectToServer(VOID) return(STATUS_SUCCESS); } - -NTSTATUS STDCALL CsrSetPriorityClass (HANDLE hProcess, - DWORD * PriorityClass) +NTSTATUS STDCALL +CsrNewThread(VOID) { - /* FIXME: call csrss to get hProcess' priority */ - *PriorityClass = CSR_PRIORITY_CLASS_NORMAL; + return (NtRegisterThreadTerminatePort(WindowsApiPort)); +} - return (STATUS_NOT_IMPLEMENTED); +NTSTATUS STDCALL +CsrSetPriorityClass(HANDLE Process, + PULONG PriorityClass) +{ + /* FIXME: call csrss to get hProcess' priority */ + *PriorityClass = CSR_PRIORITY_CLASS_NORMAL; + + return (STATUS_NOT_IMPLEMENTED); } /* EOF */ diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index cc251d80c85..468fa4c4f85 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.69 2001/02/10 22:23:07 ekohl Exp $ +; $Id: ntdll.def,v 1.70 2001/05/02 22:23:47 ekohl Exp $ ; ; ReactOS Operating System ; @@ -15,7 +15,7 @@ CsrClientCallServer@16 CsrClientConnectToServer@0 ;CsrFreeCaptureBuffer ;CsrIdentifyAlertableThread -;CsrNewThread +CsrNewThread@0 ;CsrProbeForRead ;CsrProbeForWrite CsrSetPriorityClass@8 @@ -400,7 +400,7 @@ RtlFindSetBits@12 RtlFindSetBitsAndClear@12 RtlFirstFreeAce@8 ;RtlFlushPropertySet -;RtlFormatCurrentUserKeyPath +RtlFormatCurrentUserKeyPath@4 ;RtlFormatMessage@36 RtlFreeAnsiString@4 ;RtlFreeHandle diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index c0f2aee4ce0..6169bc42293 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.58 2001/02/10 22:23:07 ekohl Exp $ +; $Id: ntdll.edf,v 1.59 2001/05/02 22:23:47 ekohl Exp $ ; ; ReactOS Operating System ; @@ -15,7 +15,7 @@ CsrClientCallServer=CsrClientCallServer@16 CsrClientConnectToServer=CsrClientConnectToServer@0 ;CsrFreeCaptureBuffer ;CsrIdentifyAlertableThread -;CsrNewThread +CsrNewThread=CsrNewThread@0 ;CsrProbeForRead ;CsrProbeForWrite CsrSetPriorityClass=CsrSetPriorityClass@8 @@ -400,7 +400,7 @@ RtlFindLongestRunSet=RtlFindLongestRunSet@8 RtlFindSetBits=RtlFindSetBits@12 RtlFindSetBitsAndClear=RtlFindSetBitsAndClear@12 ;RtlFlushPropertySet -;RtlFormatCurrentUserKeyPath +RtlFormatCurrentUserKeyPath=RtlFormatCurrentUserKeyPath@4 ;RtlFormatMessage RtlFreeAnsiString=RtlFreeAnsiString@4 ;RtlFreeHandle diff --git a/reactos/lib/ntdll/rtl/registry.c b/reactos/lib/ntdll/rtl/registry.c index 59b5f182a7a..5463f0df1ed 100644 --- a/reactos/lib/ntdll/rtl/registry.c +++ b/reactos/lib/ntdll/rtl/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.1 2000/08/11 12:35:47 ekohl Exp $ +/* $Id: registry.c,v 1.2 2001/05/02 22:23:21 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -17,47 +17,93 @@ #include +static NTSTATUS RtlpGetRegistryHandle(ULONG RelativeTo, + PWSTR Path, + BOOLEAN Create, + PHANDLE KeyHandle); + /* FUNCTIONS ***************************************************************/ -NTSTATUS -STDCALL -RtlCheckRegistryKey ( - IN ULONG RelativeTo, - IN PWSTR Path - ) +NTSTATUS STDCALL +RtlCheckRegistryKey(IN ULONG RelativeTo, + IN PWSTR Path) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + HANDLE KeyHandle; + NTSTATUS Status; + + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + FALSE, + &KeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + + NtClose(KeyHandle); + + return STATUS_SUCCESS; } -NTSTATUS -STDCALL -RtlCreateRegistryKey ( - IN ULONG RelativeTo, - IN PWSTR Path - ) +NTSTATUS STDCALL +RtlCreateRegistryKey(IN ULONG RelativeTo, + IN PWSTR Path) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + HANDLE KeyHandle; + NTSTATUS Status; + + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + + NtClose(KeyHandle); + + return STATUS_SUCCESS; } -NTSTATUS -STDCALL -RtlDeleteRegistryValue ( - IN ULONG RelativeTo, - IN PWSTR Path, - IN PWSTR ValueName - ) +NTSTATUS STDCALL +RtlDeleteRegistryValue(IN ULONG RelativeTo, + IN PWSTR Path, + IN PWSTR ValueName) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + HANDLE KeyHandle; + NTSTATUS Status; + UNICODE_STRING Name; + + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&Name, + ValueName); + + NtDeleteValueKey(KeyHandle, + &Name); + + NtClose(KeyHandle); + + return STATUS_SUCCESS; } -NTSTATUS -STDCALL +NTSTATUS STDCALL +RtlFormatCurrentUserKeyPath(PUNICODE_STRING KeyPath) +{ + return STATUS_UNSUCCESSFUL; +} + +/* +NTSTATUS STDCALL +RtlOpenCurrentUser(...) +*/ + +NTSTATUS STDCALL RtlQueryRegistryValues ( IN ULONG RelativeTo, IN PWSTR Path, @@ -71,25 +117,139 @@ RtlQueryRegistryValues ( } -NTSTATUS -STDCALL -RtlWriteRegistryValue ( - IN ULONG RelativeTo, - IN PWSTR Path, - IN PWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength - ) +NTSTATUS STDCALL +RtlWriteRegistryValue(IN ULONG RelativeTo, + IN PWSTR Path, + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + HANDLE KeyHandle; + NTSTATUS Status; + UNICODE_STRING Name; + + Status = RtlpGetRegistryHandle(RelativeTo, + Path, + TRUE, + &KeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&Name, + ValueName); + + NtSetValueKey(KeyHandle, + &Name, + 0, + ValueType, + ValueData, + ValueLength); + + NtClose(KeyHandle); + + return STATUS_SUCCESS; } + NTSTATUS STDCALL RtlpNtMakeTemporaryKey(HANDLE KeyHandle) { return NtDeleteKey(KeyHandle); } + +/* INTERNAL FUNCTIONS ******************************************************/ + +static NTSTATUS +RtlpGetRegistryHandle(ULONG RelativeTo, + PWSTR Path, + BOOLEAN Create, + PHANDLE KeyHandle) +{ + UNICODE_STRING KeyName; + WCHAR KeyBuffer[MAX_PATH]; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + + if (RelativeTo & RTL_REGISTRY_HANDLE) + { + *KeyHandle = (HANDLE)Path; + return STATUS_SUCCESS; + } + + if (RelativeTo & RTL_REGISTRY_OPTIONAL) + RelativeTo &= ~RTL_REGISTRY_OPTIONAL; + + if (RelativeTo >= RTL_REGISTRY_MAXIMUM) + return STATUS_INVALID_PARAMETER; + + KeyName.Length = 0; + KeyName.MaximumLength = MAX_PATH; + KeyName.Buffer = KeyBuffer; + KeyBuffer[0] = 0; + + switch (RelativeTo) + { + case RTL_REGISTRY_SERVICES: + RtlAppendUnicodeToString(&KeyName, + L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); + break; + + case RTL_REGISTRY_CONTROL: + RtlAppendUnicodeToString(&KeyName, + L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\"); + break; + + case RTL_REGISTRY_WINDOWS_NT: + RtlAppendUnicodeToString(&KeyName, + L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\"); + break; + + case RTL_REGISTRY_DEVICEMAP: + RtlAppendUnicodeToString(&KeyName, + L"\\Registry\\Machine\\Hardware\\DeviceMap\\"); + break; + + case RTL_REGISTRY_USER: + Status = RtlFormatCurrentUserKeyPath(&KeyName); + if (!NT_SUCCESS(Status)) + return Status; + break; + } + + if (Path[0] != L'\\') + RtlAppendUnicodeToString(&KeyName, + L"\\"); + + RtlAppendUnicodeToString(&KeyName, + Path); + + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + if (Create == TRUE) + { + Status = NtCreateKey(KeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + 0, + NULL); + } + else + { + Status = NtOpenKey(KeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes); + } + + return Status; +} + + /* EOF */ diff --git a/reactos/lib/ntdll/stubs/stubs.c b/reactos/lib/ntdll/stubs/stubs.c index c5071f488d4..2ab9ee69e7c 100644 --- a/reactos/lib/ntdll/stubs/stubs.c +++ b/reactos/lib/ntdll/stubs/stubs.c @@ -20,10 +20,8 @@ STUB(CsrCaptureMessageString) STUB(CsrCaptureTimeout) STUB(CsrFreeCaptureBuffer) STUB(CsrIdentifyAlertableThread) -STUB(CsrNewThread) STUB(CsrProbeForRead) STUB(CsrProbeForWrite) -STUB(CsrSetPriorityClass) STUB(KiRaiseUserExceptionDispatcher)