diff --git a/reactos/ntoskrnl/ex/atom.c b/reactos/ntoskrnl/ex/atom.c new file mode 100644 index 00000000000..be573da2263 --- /dev/null +++ b/reactos/ntoskrnl/ex/atom.c @@ -0,0 +1,225 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/ex/atom.c + * PURPOSE: Executive Atom Functions + * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) + * Gunnar Dalsnes + */ + +/* INCLUDES *****************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ****************************************************************/ + +/* + * FIXME: this is WRONG! The global atom table should live in the WinSta struct + * and accessed through a win32k callout (received in PsEstablishWin32Callouts) + * NOTE: There is a session/win32k global atom table also, but its private to + * win32k. Its used for RegisterWindowMessage() and for window classes. + * -Gunnar + */ +PRTL_ATOM_TABLE GlobalAtomTable; + +/* PRIVATE FUNCTIONS *********************************************************/ + +PRTL_ATOM_TABLE +NTAPI +ExpGetGlobalAtomTable(VOID) +{ + NTSTATUS Status; + + /* Return it if we have one */ + if (GlobalAtomTable) return GlobalAtomTable; + + /* Create it */ + Status = RtlCreateAtomTable(37, &GlobalAtomTable); + + /* If we couldn't create it, return NULL */ + if (!NT_SUCCESS(Status)) return NULL; + + /* Return the newly created one */ + return GlobalAtomTable; +} + +NTSTATUS +NTAPI +RtlpQueryAtomInformation(PRTL_ATOM_TABLE AtomTable, + RTL_ATOM Atom, + PATOM_BASIC_INFORMATION AtomInformation, + ULONG AtomInformationLength, + PULONG ReturnLength) +{ + NTSTATUS Status; + ULONG UsageCount; + ULONG Flags; + ULONG NameLength; + + NameLength = AtomInformationLength - sizeof(ATOM_BASIC_INFORMATION) + sizeof(WCHAR); + Status = RtlQueryAtomInAtomTable(AtomTable, + Atom, + &UsageCount, + &Flags, + AtomInformation->Name, + &NameLength); + + if (!NT_SUCCESS(Status)) return Status; + DPRINT("NameLength: %lu\n", NameLength); + + if (ReturnLength != NULL) + { + *ReturnLength = NameLength + sizeof(ATOM_BASIC_INFORMATION); + } + + if (NameLength + sizeof(ATOM_BASIC_INFORMATION) > AtomInformationLength) + { + return STATUS_INFO_LENGTH_MISMATCH; + } + + AtomInformation->UsageCount = (USHORT)UsageCount; + AtomInformation->Flags = (USHORT)Flags; + AtomInformation->NameLength = (USHORT)NameLength; + + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +RtlpQueryAtomTableInformation(PRTL_ATOM_TABLE AtomTable, + RTL_ATOM Atom, + PATOM_TABLE_INFORMATION AtomInformation, + ULONG AtomInformationLength, + PULONG ReturnLength) +{ + ULONG Length; + NTSTATUS Status; + + Length = sizeof(ATOM_TABLE_INFORMATION); + DPRINT("RequiredLength: %lu\n", Length); + + if (ReturnLength) *ReturnLength = Length; + + if (Length > AtomInformationLength) return STATUS_INFO_LENGTH_MISMATCH; + + Status = RtlQueryAtomListInAtomTable(AtomTable, + (AtomInformationLength - Length) / + sizeof(RTL_ATOM), + &AtomInformation->NumberOfAtoms, + AtomInformation->Atoms); + if (NT_SUCCESS(Status)) + { + ReturnLength += AtomInformation->NumberOfAtoms * sizeof(RTL_ATOM); + if (ReturnLength != NULL) *ReturnLength = Length; + } + + return Status; +} + +/* FUNCTIONS ****************************************************************/ + +/* + * @implemented + */ +NTSTATUS +NTAPI +NtAddAtom(IN PWSTR AtomName, + IN ULONG AtomNameLength, + OUT PRTL_ATOM Atom) +{ + PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable(); + + /* Check for the table */ + if (AtomTable == NULL) return STATUS_ACCESS_DENIED; + + /* FIXME: SEH! */ + + /* Call the worker function */ + return RtlAddAtomToAtomTable(AtomTable, AtomName, Atom); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +NtDeleteAtom(IN RTL_ATOM Atom) +{ + PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable(); + + /* Check for valid table */ + if (AtomTable == NULL) return STATUS_ACCESS_DENIED; + + /* Call worker function */ + return RtlDeleteAtomFromAtomTable(AtomTable, Atom); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +NtFindAtom(IN PWSTR AtomName, + IN ULONG AtomNameLength, + OUT PRTL_ATOM Atom) +{ + PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable(); + + /* Check for valid table */ + if (AtomTable == NULL) return STATUS_ACCESS_DENIED; + + /* FIXME: SEH!!! */ + + /* Call worker function */ + return RtlLookupAtomInAtomTable(AtomTable, AtomName, Atom); +} + +/* + * @implemented + */ +NTSTATUS +NTAPI +NtQueryInformationAtom(RTL_ATOM Atom, + ATOM_INFORMATION_CLASS AtomInformationClass, + PVOID AtomInformation, + ULONG AtomInformationLength, + PULONG ReturnLength) +{ + PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable(); + NTSTATUS Status; + + /* Check for valid table */ + if (AtomTable == NULL) return STATUS_ACCESS_DENIED; + + /* FIXME: SEH! */ + + /* Choose class */ + switch (AtomInformationClass) + { + case AtomBasicInformation: + Status = RtlpQueryAtomInformation(AtomTable, + Atom, + AtomInformation, + AtomInformationLength, + ReturnLength); + break; + + case AtomTableInformation: + Status = RtlpQueryAtomTableInformation(AtomTable, + Atom, + AtomInformation, + AtomInformationLength, + ReturnLength); + break; + + default: + Status = STATUS_INVALID_INFO_CLASS; + } + + /* Return to caller */ + return Status; +} + +/* EOF */ diff --git a/reactos/ntoskrnl/ex/error.c b/reactos/ntoskrnl/ex/error.c index c428499cacf..83a6fd1ac8b 100644 --- a/reactos/ntoskrnl/ex/error.c +++ b/reactos/ntoskrnl/ex/error.c @@ -95,7 +95,6 @@ NTSTATUS STDCALL NtSetDefaultHardErrorPort(IN HANDLE PortHandle) { - KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_UNSUCCESSFUL; @@ -128,4 +127,12 @@ NtSetDefaultHardErrorPort(IN HANDLE PortHandle) return Status; } +VOID +__cdecl +_purecall(VOID) +{ + /* Not supported in Kernel Mode */ + RtlRaiseStatus(STATUS_NOT_IMPLEMENTED); +} + /* EOF */ diff --git a/reactos/ntoskrnl/include/internal/rtl.h b/reactos/ntoskrnl/include/internal/rtl.h index 5cc346f9249..1c764747d74 100644 --- a/reactos/ntoskrnl/include/internal/rtl.h +++ b/reactos/ntoskrnl/include/internal/rtl.h @@ -43,6 +43,15 @@ VOID NTAPI RtlpCreateNlsSection(VOID); +NTSTATUS +NTAPI +RtlQueryAtomListInAtomTable( + IN PRTL_ATOM_TABLE AtomTable, + IN ULONG MaxAtomCount, + OUT ULONG *AtomCount, + OUT RTL_ATOM *AtomList +); + #endif /* __NTOSKRNL_INCLUDE_INTERNAL_NLS_H */ /* EOF */ diff --git a/reactos/ntoskrnl/ntoskrnl.xml b/reactos/ntoskrnl/ntoskrnl.xml index 0b450cf44f2..03b02d45f0d 100644 --- a/reactos/ntoskrnl/ntoskrnl.xml +++ b/reactos/ntoskrnl/ntoskrnl.xml @@ -116,6 +116,7 @@ debug.c + atom.c interlck.S @@ -305,11 +306,9 @@ seh.s - atom.c libsupp.c misc.c nls.c - purecall.c regio.c strtok.c diff --git a/reactos/ntoskrnl/rtl/atom.c b/reactos/ntoskrnl/rtl/atom.c deleted file mode 100644 index cfd6a2fce62..00000000000 --- a/reactos/ntoskrnl/rtl/atom.c +++ /dev/null @@ -1,255 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/atom.c - * PURPOSE: Atom managment - * - * PROGRAMMERS: No programmer listed. - */ - -/* INCLUDES *****************************************************************/ - -#include -#define NDEBUG -#include - - -/* PROTOTYPES ****************************************************************/ - -static PRTL_ATOM_TABLE RtlpGetGlobalAtomTable(VOID); -static NTSTATUS -RtlpQueryAtomInformation(PRTL_ATOM_TABLE AtomTable, - RTL_ATOM Atom, - PATOM_BASIC_INFORMATION AtomInformation, - ULONG AtomInformationLength, - PULONG ReturnLength); -static NTSTATUS -RtlpQueryAtomTableInformation(PRTL_ATOM_TABLE AtomTable, - RTL_ATOM Atom, - PATOM_TABLE_INFORMATION AtomInformation, - ULONG AtomInformationLength, - PULONG ReturnLength); - -extern NTSTATUS STDCALL -RtlQueryAtomListInAtomTable(IN PRTL_ATOM_TABLE AtomTable, - IN ULONG MaxAtomCount, - OUT ULONG *AtomCount, - OUT RTL_ATOM *AtomList); - -/* GLOBALS *******************************************************************/ - -/* FIXME: this is WRONG! The global atom table should live in the WinSta struct - * and accessed thru win32k callouts. - * NOTE: There is a session/win32k global atom table also, but its private to - * win32k. Its used for RegisterWindowMessage() and for window classes. - * -Gunnar - */ -static PRTL_ATOM_TABLE GlobalAtomTable = NULL; - -/* FUNCTIONS *****************************************************************/ - - -/* - * @implemented - */ -NTSTATUS STDCALL -NtAddAtom( - IN PWSTR AtomName, - IN ULONG AtomNameLength, - OUT PRTL_ATOM Atom) -{ - PRTL_ATOM_TABLE AtomTable; - - AtomTable = RtlpGetGlobalAtomTable(); - if (AtomTable == NULL) - return STATUS_ACCESS_DENIED; - - return RtlAddAtomToAtomTable(AtomTable, AtomName, Atom); -} - - -/* - * @implemented - */ -NTSTATUS STDCALL -NtDeleteAtom(IN RTL_ATOM Atom) -{ - PRTL_ATOM_TABLE AtomTable; - - AtomTable = RtlpGetGlobalAtomTable(); - if (AtomTable == NULL) - return STATUS_ACCESS_DENIED; - - return (RtlDeleteAtomFromAtomTable(AtomTable, - Atom)); -} - - -/* - * @implemented - */ -NTSTATUS STDCALL -NtFindAtom(IN PWSTR AtomName, - IN ULONG AtomNameLength, - OUT PRTL_ATOM Atom) -{ - PRTL_ATOM_TABLE AtomTable; - - AtomTable = RtlpGetGlobalAtomTable(); - if (AtomTable == NULL) - return STATUS_ACCESS_DENIED; - - return (RtlLookupAtomInAtomTable(AtomTable, - AtomName, - Atom)); -} - - -/* - * @implemented - */ -NTSTATUS STDCALL -NtQueryInformationAtom(RTL_ATOM Atom, - ATOM_INFORMATION_CLASS AtomInformationClass, - PVOID AtomInformation, - ULONG AtomInformationLength, - PULONG ReturnLength) -{ - PRTL_ATOM_TABLE AtomTable; - NTSTATUS Status; - - AtomTable = RtlpGetGlobalAtomTable(); - if (AtomTable == NULL) - return STATUS_ACCESS_DENIED; - - switch (AtomInformationClass) - { - case AtomBasicInformation: - Status = RtlpQueryAtomInformation(AtomTable, - Atom, - AtomInformation, - AtomInformationLength, - ReturnLength); - break; - - case AtomTableInformation: - Status = RtlpQueryAtomTableInformation(AtomTable, - Atom, - AtomInformation, - AtomInformationLength, - ReturnLength); - break; - - default: - Status = STATUS_INVALID_INFO_CLASS; - } - - return Status; -} - - -/* INTERNAL FUNCTIONS ********************************************************/ - -static PRTL_ATOM_TABLE -RtlpGetGlobalAtomTable(VOID) -{ - NTSTATUS Status; - - if (GlobalAtomTable != NULL) - return GlobalAtomTable; - - Status = RtlCreateAtomTable(37, &GlobalAtomTable); - if (!NT_SUCCESS(Status)) - return NULL; - - return GlobalAtomTable; -} - -static NTSTATUS -RtlpQueryAtomInformation(PRTL_ATOM_TABLE AtomTable, - RTL_ATOM Atom, - PATOM_BASIC_INFORMATION AtomInformation, - ULONG AtomInformationLength, - PULONG ReturnLength) -{ - NTSTATUS Status; - ULONG UsageCount; - ULONG Flags; - ULONG NameLength; - - NameLength = AtomInformationLength - sizeof(ATOM_BASIC_INFORMATION) + sizeof(WCHAR); - Status = RtlQueryAtomInAtomTable(AtomTable, - Atom, - &UsageCount, - &Flags, - AtomInformation->Name, - &NameLength); - - if (!NT_SUCCESS(Status)) - { - return Status; - } - - DPRINT("NameLength: %lu\n", NameLength); - - if (ReturnLength != NULL) - { - *ReturnLength = NameLength + sizeof(ATOM_BASIC_INFORMATION); - } - - if (NameLength + sizeof(ATOM_BASIC_INFORMATION) > AtomInformationLength) - { - return STATUS_INFO_LENGTH_MISMATCH; - } - - AtomInformation->UsageCount = (USHORT)UsageCount; - AtomInformation->Flags = (USHORT)Flags; - AtomInformation->NameLength = (USHORT)NameLength; - - return STATUS_SUCCESS; -} - - -static NTSTATUS -RtlpQueryAtomTableInformation(PRTL_ATOM_TABLE AtomTable, - RTL_ATOM Atom, - PATOM_TABLE_INFORMATION AtomInformation, - ULONG AtomInformationLength, - PULONG ReturnLength) -{ - ULONG Length; - NTSTATUS Status; - - Length = sizeof(ATOM_TABLE_INFORMATION); - - DPRINT("RequiredLength: %lu\n", Length); - - if (ReturnLength != NULL) - { - *ReturnLength = Length; - } - - if (Length > AtomInformationLength) - { - return STATUS_INFO_LENGTH_MISMATCH; - } - - Status = RtlQueryAtomListInAtomTable(AtomTable, - (AtomInformationLength - Length) / sizeof(RTL_ATOM), - &AtomInformation->NumberOfAtoms, - AtomInformation->Atoms); - if (NT_SUCCESS(Status)) - { - ReturnLength += AtomInformation->NumberOfAtoms * sizeof(RTL_ATOM); - - if (ReturnLength != NULL) - { - *ReturnLength = Length; - } - } - - return Status; -} - -/* EOF */ diff --git a/reactos/ntoskrnl/rtl/purecall.c b/reactos/ntoskrnl/rtl/purecall.c deleted file mode 100644 index e905dd0226b..00000000000 --- a/reactos/ntoskrnl/rtl/purecall.c +++ /dev/null @@ -1,22 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/purecall.c - * PURPOSE: No purpose listed. - * - * PROGRAMMERS: Eric Kohl - */ - -/* INCLUDES *****************************************************************/ - -#include - -/* FUNCTIONS ****************************************************************/ - -void _purecall(void) -{ - ExRaiseStatus(STATUS_NOT_IMPLEMENTED); -} - -/* EOF */