Author: ion
Date: Thu Nov  3 00:30:44 2011
New Revision: 54284

URL: http://svn.reactos.org/svn/reactos?rev=54284&view=rev
Log:
[KERNEL32]: Rearrange and rename some base functions.
[KERNEL32]: Fix some error cases in the helper string functions.
[KERNEL32]: Implement BasepIsRealtimeAllowed.
[KERNEL32]: Don't need RPL_MASK when setting up the CONTEXT, this now matches 
what Windows sets up (and also helps us validate the kernel is doing the right 
thing).

Modified:
    trunk/reactos/dll/win32/kernel32/client/dllmain.c
    trunk/reactos/dll/win32/kernel32/client/environ.c
    trunk/reactos/dll/win32/kernel32/client/fiber.c
    trunk/reactos/dll/win32/kernel32/client/file/filemap.c
    trunk/reactos/dll/win32/kernel32/client/loader.c
    trunk/reactos/dll/win32/kernel32/client/proc.c
    trunk/reactos/dll/win32/kernel32/client/thread.c
    trunk/reactos/dll/win32/kernel32/client/utils.c
    trunk/reactos/dll/win32/kernel32/include/base_x.h
    trunk/reactos/dll/win32/kernel32/include/kernel32.h

Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/dllmain.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -61,60 +61,6 @@
 #define SESSION_DIR L"\\Sessions"
 
 /* FUNCTIONS *****************************************************************/
-
-NTSTATUS
-WINAPI
-BaseGetNamedObjectDirectory(VOID)
-{
-    OBJECT_ATTRIBUTES ObjectAttributes;
-    NTSTATUS Status;
-
-    InitializeObjectAttributes(&ObjectAttributes,
-                               &BaseStaticServerData->NamedObjectDirectory,
-                               OBJ_CASE_INSENSITIVE,
-                               NULL,
-                               NULL);
-
-    Status = NtOpenDirectoryObject(&BaseNamedObjectDirectory,
-                                   DIRECTORY_ALL_ACCESS &
-                                   ~(DELETE | WRITE_DAC | WRITE_OWNER),
-                                   &ObjectAttributes);
-    if (!NT_SUCCESS(Status)) return Status;
-
-    DPRINT("Opened BNO: %lx\n", BaseNamedObjectDirectory);
-    return Status;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-BaseQueryModuleData(IN LPSTR ModuleName,
-                    IN LPSTR Unknown,
-                    IN PVOID Unknown2,
-                    IN PVOID Unknown3,
-                    IN PVOID Unknown4)
-{
-    DPRINT1("BaseQueryModuleData called: %s %s %x %x %x\n",
-            ModuleName,
-            Unknown,
-            Unknown2,
-            Unknown3,
-            Unknown4);
-    return FALSE;
-}
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-BaseProcessInitPostImport(VOID)
-{
-    /* FIXME: Initialize TS pointers */
-    return STATUS_SUCCESS;
-}
 
 BOOL
 WINAPI
@@ -388,9 +334,6 @@
                     RtlDeleteCriticalSection (&ConsoleLock);
                 }
                 RtlDeleteCriticalSection (&BaseDllDirectoryLock);
-
-                /* Close object base directory */
-                NtClose(hBaseDir);
             }
             break;
 

Modified: trunk/reactos/dll/win32/kernel32/client/environ.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/environ.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/environ.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -68,7 +68,7 @@
     Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UniSize * sizeof(WCHAR));
     if (!Buffer)
     {
-        Status = STATUS_NO_MEMORY;;
+        Status = STATUS_NO_MEMORY;
         goto Quickie;
     }
 

Modified: trunk/reactos/dll/win32/kernel32/client/fiber.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/fiber.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/fiber.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -237,11 +237,11 @@
     Fiber->Context.ContextFlags = (dwFlags & FIBER_FLAG_FLOAT_SWITCH) ? 
CONTEXT_FLOATING_POINT : 0;
 
     /* initialize the context for the fiber */
-    BasepInitializeContext(&Fiber->Context,
-                           lpParameter,
-                           lpStartAddress,
-                           InitialTeb.StackBase,
-                           2);
+    BaseInitializeContext(&Fiber->Context,
+                          lpParameter,
+                          lpStartAddress,
+                          InitialTeb.StackBase,
+                          2);
 
     /* Return the Fiber */
     return Fiber;

Modified: trunk/reactos/dll/win32/kernel32/client/file/filemap.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/file/filemap.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] 
(original)
+++ trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] Thu Nov 
 3 00:30:44 2011
@@ -80,7 +80,7 @@
     if (lpName) RtlInitUnicodeString(&SectionName, lpName);
 
     /* Now convert the object attributes */
-    ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes,
+    ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes,
                                                     lpFileMappingAttributes,
                                                     lpName ? &SectionName : 
NULL);
 
@@ -244,6 +244,7 @@
 /*
  * @implemented
  */
+ /* FIXME: Convert to the new macros */
 HANDLE
 NTAPI
 OpenFileMappingA(DWORD dwDesiredAccess,
@@ -286,6 +287,7 @@
 /*
  * @implemented
  */
+ /* FIXME: Convert to the new macros */
 HANDLE
 NTAPI
 OpenFileMappingW(DWORD dwDesiredAccess,

Modified: trunk/reactos/dll/win32/kernel32/client/loader.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/loader.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/loader.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/loader.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -1175,4 +1175,35 @@
     STUB;
 }
 
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+BaseQueryModuleData(IN LPSTR ModuleName,
+                    IN LPSTR Unknown,
+                    IN PVOID Unknown2,
+                    IN PVOID Unknown3,
+                    IN PVOID Unknown4)
+{
+    DPRINT1("BaseQueryModuleData called: %s %s %x %x %x\n",
+            ModuleName,
+            Unknown,
+            Unknown2,
+            Unknown3,
+            Unknown4);
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+WINAPI
+BaseProcessInitPostImport(VOID)
+{
+    /* FIXME: Initialize TS pointers */
+    return STATUS_SUCCESS;
+}
+
 /* EOF */

Modified: trunk/reactos/dll/win32/kernel32/client/proc.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/proc.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -193,14 +193,14 @@
                      &InitialTeb);
 
     /* Create the Thread's Context */
-    BasepInitializeContext(&Context,
+    BaseInitializeContext(&Context,
                            NtCurrentPeb(),
                            SectionImageInfo->TransferAddress,
                            InitialTeb.StackBase,
                            0);
 
     /* Convert the thread attributes */
-    ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
+    ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
                                                     lpThreadAttributes,
                                                     NULL);
 
@@ -319,7 +319,7 @@
     else if(dwCreationFlags & REALTIME_PRIORITY_CLASS)
     {
         /* Check for Privilege First */
-        if (BasepCheckRealTimePrivilege())
+        if (BasepIsRealtimeAllowed(TRUE))
         {
             ReturnClass = PROCESS_PRIORITY_CLASS_REALTIME;
         }
@@ -2654,7 +2654,7 @@
     }
 
     /* Initialize the process object attributes */
-    ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
+    ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
                                                     lpProcessAttributes,
                                                     NULL);
 

Modified: trunk/reactos/dll/win32/kernel32/client/thread.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/thread.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -149,14 +149,14 @@
     }
 
     /* Create Initial Context */
-    BasepInitializeContext(&Context,
+    BaseInitializeContext(&Context,
                            lpParameter,
                            lpStartAddress,
                            InitialTeb.StackBase,
                            1);
 
     /* initialize the attributes for the thread object */
-    ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
+    ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
                                                     lpThreadAttributes,
                                                     NULL);
 
@@ -171,7 +171,7 @@
                             TRUE);
     if(!NT_SUCCESS(Status))
     {
-        BasepFreeStack(hProcess, &InitialTeb);
+        BaseFreeThreadStack(hProcess, &InitialTeb);
         BaseSetLastNTError(Status);
         return NULL;
     }

Modified: trunk/reactos/dll/win32/kernel32/client/utils.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/utils.c?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -7,7 +7,7 @@
  *                  Pierre Schweitzer (pierre.schweit...@reactos.org)
  */
 
-/* INCLUDES ****************************************************************/
+/* INCLUDES ******************************************************************/
 
 #include <k32.h>
 #ifdef _M_IX86
@@ -19,11 +19,34 @@
 #define NDEBUG
 #include <debug.h>
 
-/* GLOBALS ******************************************************************/
+/* GLOBALS 
********************************************************************/
 
 PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
 
-/* FUNCTIONS ****************************************************************/
+/* FUNCTIONS 
******************************************************************/
+
+NTSTATUS
+WINAPI
+BaseGetNamedObjectDirectory(VOID)
+{
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    NTSTATUS Status;
+
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &BaseStaticServerData->NamedObjectDirectory,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+
+    Status = NtOpenDirectoryObject(&BaseNamedObjectDirectory,
+                                   DIRECTORY_ALL_ACCESS &
+                                   ~(DELETE | WRITE_DAC | WRITE_OWNER),
+                                   &ObjectAttributes);
+    if (!NT_SUCCESS(Status)) return Status;
+
+    DPRINT("Opened BNO: %lx\n", BaseNamedObjectDirectory);
+    return Status;
+}
 
 VOID
 NTAPI
@@ -66,21 +89,29 @@
     NTSTATUS Status;
 
     /* Initialize an ANSI String */
-    if (!NT_SUCCESS(RtlInitAnsiStringEx(&AnsiString, String)))
+    Status = RtlInitAnsiStringEx(&AnsiString, String);
+    if (!NT_SUCCESS(Status))
+    {
+        Status = STATUS_BUFFER_OVERFLOW;
+    }
+    else
+    {
+        /* Convert it */
+        Status = Basep8BitStringToUnicodeString(StaticString, &AnsiString, 
FALSE);
+    }
+
+    if (NT_SUCCESS(Status)) return StaticString;
+
+    if (Status == STATUS_BUFFER_OVERFLOW)
     {
         SetLastError(ERROR_FILENAME_EXCED_RANGE);
-        return NULL;
-    }
-
-    /* Convert it */
-    Status = Basep8BitStringToUnicodeString(StaticString, &AnsiString, FALSE);
-    if (!NT_SUCCESS(Status))
+    }
+    else
     {
         BaseSetLastNTError(Status);
-        return NULL;
-    }
-
-    return StaticString;
+    }
+
+    return NULL;
 }
 
 /*
@@ -93,33 +124,37 @@
 {
     ANSI_STRING AnsiString;
     NTSTATUS Status;
-    
-    DPRINT("Basep8BitStringToDynamicUnicodeString\n");
 
     /* Initialize an ANSI String */
-    if (!NT_SUCCESS(RtlInitAnsiStringEx(&AnsiString, String)))
-    {
-        SetLastError(ERROR_BUFFER_OVERFLOW);
-        return FALSE;
-    }
-     
-    /* Convert it */
-    Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, TRUE); 
   
-
-    /* Handle failure */
+    Status = RtlInitAnsiStringEx(&AnsiString, String);
     if (!NT_SUCCESS(Status))
     {
+        Status = STATUS_BUFFER_OVERFLOW;
+    }
+    else
+    {
+        /* Convert it */
+        Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, 
FALSE);
+    }
+
+    if (NT_SUCCESS(Status)) return TRUE;
+
+    if (Status == STATUS_BUFFER_OVERFLOW)
+    {
+        SetLastError(ERROR_FILENAME_EXCED_RANGE);
+    }
+    else
+    {
         BaseSetLastNTError(Status);
-        return FALSE;
-    }
-
-    /* Return Status */
-    return TRUE;
+    }
+
+    return FALSE;
 }
 
 /*
  * Allocates space from the Heap and converts an Ansi String into it
  */
+ /*NOTE: API IS A HACK */
 VOID
 WINAPI
 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
@@ -127,12 +162,12 @@
 {
     ANSI_STRING AnsiTemp;
     UNICODE_STRING UnicodeTemp;
-    
+
     DPRINT("BasepAnsiStringToHeapUnicodeString\n");
-    
+
     /* First create the ANSI_STRING */
     RtlInitAnsiString(&AnsiTemp, AnsiString);
-    
+
     if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&UnicodeTemp,
                                                 &AnsiTemp,
                                                 TRUE)))
@@ -163,49 +198,48 @@
  */
 POBJECT_ATTRIBUTES
 WINAPI
-BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
-                             IN PSECURITY_ATTRIBUTES SecurityAttributes 
OPTIONAL,
-                             IN PUNICODE_STRING ObjectName)
-{
-    ULONG Attributes = 0;
-    HANDLE RootDirectory = 0;
-    PVOID SecurityDescriptor = NULL;
-    BOOLEAN NeedOba = FALSE;
-    
-    DPRINT("BasepConvertObjectAttributes. Security: %p, Name: %p\n",
+BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
+                           IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
+                           IN PUNICODE_STRING ObjectName)
+{
+    ULONG Attributes;
+    HANDLE RootDirectory;
+    PVOID SecurityDescriptor;
+    DPRINT("BaseFormatObjectAttributes. Security: %p, Name: %p\n",
             SecurityAttributes, ObjectName);
-    
+
     /* Get the attributes if present */
     if (SecurityAttributes)
     {
         Attributes = SecurityAttributes->bInheritHandle ? OBJ_INHERIT : 0;
         SecurityDescriptor = SecurityAttributes->lpSecurityDescriptor;
-        NeedOba = TRUE;
-    }
-    
+    }
+    else
+    {
+        if (!ObjectName) return NULL;
+        Attributes = 0;
+        SecurityDescriptor = NULL;
+    }
+
     if (ObjectName)
     {
         Attributes |= OBJ_OPENIF;
         RootDirectory = hBaseDir;
-        NeedOba = TRUE;
-    }
-    
+    }
+    else
+    {
+        RootDirectory = NULL;
+    }
+
+    /* Create the Object Attributes */
+    InitializeObjectAttributes(ObjectAttributes,
+                               ObjectName,
+                               Attributes,
+                               RootDirectory,
+                               SecurityDescriptor);
     DPRINT("Attributes: %lx, RootDirectory: %lx, SecurityDescriptor: %p\n",
             Attributes, RootDirectory, SecurityDescriptor);
-    
-    /* Create the Object Attributes */
-    if (NeedOba)
-    {
-        InitializeObjectAttributes(ObjectAttributes,
-                                   ObjectName,
-                                   Attributes,
-                                   RootDirectory,
-                                   SecurityDescriptor);
-        return ObjectAttributes;
-    }
-
-    /* Nothing to return */
-    return NULL;    
+    return ObjectAttributes;
 }
 
 /*
@@ -223,10 +257,10 @@
     PIMAGE_NT_HEADERS Headers;
     ULONG_PTR Stack = 0;
     BOOLEAN UseGuard = FALSE;
-    
+
     DPRINT("BasepCreateStack (hProcess: %lx, Max: %lx, Current: %lx)\n",
             hProcess, StackReserve, StackCommit);
-    
+
     /* Get some memory information */
     Status = NtQuerySystemInformation(SystemBasicInformation,
                                       &SystemBasicInfo,
@@ -237,17 +271,17 @@
         DPRINT1("Failure to query system info\n");
         return Status;
     }
-    
+
     /* Use the Image Settings if we are dealing with the current Process */
     if (hProcess == NtCurrentProcess())
     {
         /* Get the Image Headers */
         Headers = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress);
-        
+
         /* If we didn't get the parameters, find them ourselves */
-        StackReserve = (StackReserve) ? 
+        StackReserve = (StackReserve) ?
                         StackReserve : 
Headers->OptionalHeader.SizeOfStackReserve;
-        StackCommit = (StackCommit) ? 
+        StackCommit = (StackCommit) ?
                        StackCommit : Headers->OptionalHeader.SizeOfStackCommit;
     }
     else
@@ -257,7 +291,7 @@
                                         SystemBasicInfo.AllocationGranularity;
         StackCommit = (StackCommit) ? StackCommit : SystemBasicInfo.PageSize;
     }
-    
+
     /* Align everything to Page Size */
     StackReserve = ROUND_UP(StackReserve, 
SystemBasicInfo.AllocationGranularity);
     StackCommit = ROUND_UP(StackCommit, SystemBasicInfo.PageSize);
@@ -265,7 +299,7 @@
     StackCommit = StackReserve;
     #endif
     DPRINT("StackReserve: %lx, StackCommit: %lx\n", StackReserve, StackCommit);
-    
+
     /* Reserve memory for the stack */
     Status = ZwAllocateVirtualMemory(hProcess,
                                      (PVOID*)&Stack,
@@ -278,16 +312,16 @@
         DPRINT1("Failure to reserve stack\n");
         return Status;
     }
-    
+
     /* Now set up some basic Initial TEB Parameters */
     InitialTeb->AllocatedStackBase = (PVOID)Stack;
     InitialTeb->StackBase = (PVOID)(Stack + StackReserve);
     InitialTeb->PreviousStackBase = NULL;
     InitialTeb->PreviousStackLimit = NULL;
-    
+
     /* Update the Stack Position */
     Stack += StackReserve - StackCommit;
-    
+
     /* Check if we will need a guard page */
     if (StackReserve > StackCommit)
     {
@@ -295,7 +329,7 @@
         StackCommit += SystemBasicInfo.PageSize;
         UseGuard = TRUE;
     }
-    
+
     /* Allocate memory for the stack */
     Status = ZwAllocateVirtualMemory(hProcess,
                                      (PVOID*)&Stack,
@@ -308,17 +342,17 @@
         DPRINT1("Failure to allocate stack\n");
         return Status;
     }
-    
+
     /* Now set the current Stack Limit */
     InitialTeb->StackLimit = (PVOID)Stack;
-    
+
     /* Create a guard page */
     if (UseGuard)
     {
         SIZE_T GuardPageSize = SystemBasicInfo.PageSize;
         ULONG Dummy;
-        
-        /* Attempt maximum space possible */        
+
+        /* Attempt maximum space possible */
         Status = ZwProtectVirtualMemory(hProcess,
                                         (PVOID*)&Stack,
                                         &GuardPageSize,
@@ -329,35 +363,35 @@
             DPRINT1("Failure to create guard page\n");
             return Status;
         }
-        
+
         /* Update the Stack Limit keeping in mind the Guard Page */
         InitialTeb->StackLimit = (PVOID)((ULONG_PTR)InitialTeb->StackLimit - 
GuardPageSize);
     }
-    
+
     /* We are done! */
     return STATUS_SUCCESS;
 }
 
 VOID
 WINAPI
-BasepFreeStack(HANDLE hProcess,
-               PINITIAL_TEB InitialTeb)
+BaseFreeThreadStack(IN HANDLE hProcess,
+                    IN PINITIAL_TEB InitialTeb)
 {
     SIZE_T Dummy = 0;
-    
+
     /* Free the Stack */
     NtFreeVirtualMemory(hProcess,
                         &InitialTeb->AllocatedStackBase,
                         &Dummy,
                         MEM_RELEASE);
 }
-               
+
 /*
  * Creates the Initial Context for a Thread or Fiber
  */
 VOID
 WINAPI
-BasepInitializeContext(IN PCONTEXT Context,
+BaseInitializeContext(IN PCONTEXT Context,
                        IN PVOID Parameter,
                        IN PVOID StartAddress,
                        IN PVOID StackAddress,
@@ -365,7 +399,7 @@
 {
 #ifdef _M_IX86
     ULONG ContextFlags;
-    DPRINT("BasepInitializeContext: %p\n", Context);
+    DPRINT("BaseInitializeContext: %p\n", Context);
 
     /* Setup the Initial Win32 Thread Context */
     Context->Eax = (ULONG)StartAddress;
@@ -374,11 +408,11 @@
     /* The other registers are undefined */
 
     /* Setup the Segments */
-    Context->SegFs = KGDT_R3_TEB | RPL_MASK;
-    Context->SegEs = KGDT_R3_DATA | RPL_MASK;
-    Context->SegDs = KGDT_R3_DATA | RPL_MASK;
-    Context->SegCs = KGDT_R3_CODE | RPL_MASK;
-    Context->SegSs = KGDT_R3_DATA | RPL_MASK;
+    Context->SegFs = KGDT_R3_TEB;
+    Context->SegEs = KGDT_R3_DATA;
+    Context->SegDs = KGDT_R3_DATA;
+    Context->SegCs = KGDT_R3_CODE;
+    Context->SegSs = KGDT_R3_DATA;
     Context->SegGs = 0;
 
     /* Set the Context Flags */
@@ -426,7 +460,7 @@
     }
 
 #elif defined(_M_AMD64)
-    DPRINT("BasepInitializeContext: %p\n", Context);
+    DPRINT("BaseInitializeContext: %p\n", Context);
 
     /* Setup the Initial Win32 Thread Context */
     Context->Rax = (ULONG_PTR)StartAddress;
@@ -473,11 +507,24 @@
 /*
  * Checks if the privilege for Real-Time Priority is there
  */
-BOOLEAN
-WINAPI
-BasepCheckRealTimePrivilege(VOID)
-{
-    return TRUE;
+PVOID
+WINAPI
+BasepIsRealtimeAllowed(IN BOOLEAN Keep)
+{
+    ULONG Privilege = SE_INC_BASE_PRIORITY_PRIVILEGE;
+    PVOID State;
+    NTSTATUS Status;
+
+    Status = RtlAcquirePrivilege(&Privilege, TRUE, FALSE, &State);
+    if (!NT_SUCCESS(Status)) return NULL;
+
+    if (Keep)
+    {
+        RtlReleasePrivilege(State);
+        State = (PVOID)TRUE;
+    }
+
+    return State;
 }
 
 /*
@@ -494,9 +541,9 @@
     NTSTATUS Status;
     HANDLE hFile = NULL;
     IO_STATUS_BLOCK IoStatusBlock;
-    
+
     DPRINT("BasepMapFile\n");
-    
+
     /* Zero out the Relative Directory */
     RelativeName.ContainingDirectory = NULL;
 
@@ -511,7 +558,7 @@
 
     DPRINT("ApplicationName %wZ\n", ApplicationName);
     DPRINT("RelativeName %wZ\n", &RelativeName.RelativeName);
-    
+
     /* Did we get a relative name? */
     if (RelativeName.RelativeName.Length)
     {
@@ -538,7 +585,7 @@
         BaseSetLastNTError(Status);
         return Status;
     }
-    
+
     /* Create a section for this file */
     Status = NtCreateSection(hSection,
                              SECTION_ALL_ACCESS,
@@ -548,7 +595,7 @@
                              SEC_IMAGE,
                              hFile);
     NtClose(hFile);
-    
+
     /* Return status */
     DPRINT("Section: %lx for file: %lx\n", *hSection, hFile);
     return Status;

Modified: trunk/reactos/dll/win32/kernel32/include/base_x.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include/base_x.h?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -88,7 +88,7 @@
 // wraps the usual code path required to create an NT object based on a Unicode
 // (Wide) Win32 object creation API.
 //
-// It makes use of BasepConvertObjectAttributes and allows for a custom access
+// It makes use of BaseFormatObjectAttributes and allows for a custom access
 // mode to be used, and also sets the correct error codes in case of a 
collision
 //
 #define CreateNtObjectFromWin32ApiPrologue                                     
 \
@@ -100,7 +100,7 @@
     POBJECT_ATTRIBUTES ObjectAttributes = &LocalAttributes;
 #define CreateNtObjectFromWin32ApiBody(ntobj, sec, name, access, ...)          
 \
     if (name) RtlInitUnicodeString(&ObjectName, name);                         
 \
-    ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes,          
 \
+    ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes,           \
                                                     sec,                       
 \
                                                     name ? &ObjectName : 
NULL); \
     Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, ##__VA_ARGS__);

Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include/kernel32.h?rev=54284&r1=54283&r2=54284&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Thu Nov  3 
00:30:44 2011
@@ -167,7 +167,7 @@
 
 POBJECT_ATTRIBUTES
 WINAPI
-BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
+BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
                              IN PSECURITY_ATTRIBUTES SecurityAttributes 
OPTIONAL,
                              IN PUNICODE_STRING ObjectName);
                              
@@ -180,7 +180,7 @@
                  
 VOID
 WINAPI
-BasepInitializeContext(IN PCONTEXT Context,
+BaseInitializeContext(IN PCONTEXT Context,
                        IN PVOID Parameter,
                        IN PVOID StartAddress,
                        IN PVOID StackAddress,
@@ -202,8 +202,8 @@
                   
 VOID
 WINAPI
-BasepFreeStack(HANDLE hProcess,
-               PINITIAL_TEB InitialTeb);
+BaseFreeThreadStack(IN HANDLE hProcess,
+                    IN PINITIAL_TEB InitialTeb);
 
 __declspec(noreturn)
 VOID
@@ -216,9 +216,9 @@
 WINAPI
 BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
                   
-BOOLEAN
-WINAPI
-BasepCheckRealTimePrivilege(VOID);
+PVOID
+WINAPI
+BasepIsRealtimeAllowed(IN BOOLEAN Keep);
 
 VOID
 WINAPI
@@ -241,6 +241,11 @@
                                               IN BOOLEAN AllocateMemory);
                                                 
 extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
+extern HANDLE BaseNamedObjectDirectory;
+
+NTSTATUS
+WINAPI
+BaseGetNamedObjectDirectory(VOID);
 
 NTSTATUS
 WINAPI


Reply via email to