]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/Sec/SecMain.c
Add Missing invocations to VA_END() for VA_START().
[mirror_edk2.git] / Nt32Pkg / Sec / SecMain.c
index 0504b959f17a3506005dbd1dce4ca3fd96da21fc..a1d43d2eba424c80f0502da518d6e5fdd1202327 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -30,7 +30,9 @@ Abstract:
 \r
 #include "SecMain.h"\r
 \r
-\r
+#ifndef SE_TIME_ZONE_NAME\r
+#define SE_TIME_ZONE_NAME                 TEXT("SeTimeZonePrivilege")\r
+#endif\r
 \r
 NT_PEI_LOAD_FILE_PPI                      mSecNtLoadFilePpi     = { SecWinNtPeiLoadFile };\r
 \r
@@ -42,7 +44,7 @@ EFI_PEI_PROGRESS_CODE_PPI                 mSecStatusCodePpi     = { SecPeiReport
 \r
 NT_FWH_PPI                                mSecFwhInformationPpi = { SecWinNtFdAddress };\r
 \r
-TEMPORARY_RAM_SUPPORT_PPI                 mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};\r
+EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI         mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};\r
 \r
 EFI_PEI_PPI_DESCRIPTOR  gPrivateDispatchTable[] = {\r
   {\r
@@ -121,6 +123,8 @@ SecPrint (
   \r
   _vsnprintf (Buffer, sizeof (Buffer), Format, Marker);\r
 \r
+  va_end (Marker);\r
+\r
   CharCount = strlen (Buffer);\r
   WriteFile (\r
     GetStdHandle (STD_OUTPUT_HANDLE), \r
@@ -155,6 +159,8 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS            Status;\r
+  HANDLE                Token;\r
+  TOKEN_PRIVILEGES      TokenPrivileges;\r
   EFI_PHYSICAL_ADDRESS  InitialStackMemory;\r
   UINT64                InitialStackMemorySize;\r
   UINTN                 Index;\r
@@ -168,6 +174,16 @@ Returns:
   CHAR16                *FirmwareVolumesStr;\r
   UINTN                 *StackPointer;\r
 \r
+  //\r
+  // Enable the privilege so that RTC driver can successfully run SetTime()\r
+  //\r
+  OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token);\r
+  if (LookupPrivilegeValue(NULL, SE_TIME_ZONE_NAME, &TokenPrivileges.Privileges[0].Luid)) {\r
+    TokenPrivileges.PrivilegeCount = 1;\r
+    TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;\r
+    AdjustTokenPrivileges(Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0);\r
+  }\r
+\r
   MemorySizeStr      = (CHAR16 *) PcdGetPtr (PcdWinNtMemorySizeForSecMain);\r
   FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdWinNtFirmwareVolume);\r
 \r
@@ -362,7 +378,7 @@ Returns:
   //\r
   NtFileHandle = CreateFile (\r
                   FileName,\r
-                  GENERIC_READ | GENERIC_WRITE,\r
+                  GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE,\r
                   FILE_SHARE_READ,\r
                   NULL,\r
                   CreationDisposition,\r
@@ -378,7 +394,7 @@ Returns:
   NtMapHandle = CreateFileMapping (\r
                   NtFileHandle,\r
                   NULL,\r
-                  PAGE_READWRITE,\r
+                  PAGE_EXECUTE_READWRITE,\r
                   0,\r
                   MapSize,\r
                   NULL\r
@@ -391,7 +407,7 @@ Returns:
   //\r
   VirtualAddress = MapViewOfFileEx (\r
                     NtMapHandle,\r
-                    FILE_MAP_ALL_ACCESS,\r
+                    FILE_MAP_EXECUTE | FILE_MAP_ALL_ACCESS,\r
                     0,\r
                     0,\r
                     MapSize,\r