]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enable the SE_TIME_ZONE_NAME privilege for NT32 to fix SetTime function test running...
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Oct 2011 06:57:57 +0000 (06:57 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Oct 2011 06:57:57 +0000 (06:57 +0000)
Fix the GetTime implementation to return the correct Daylight value.

Signed-off-by: niruiyu
Reviewed-by: erictian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12559 6f19259b-4bc3-4df7-8a09-765794883524

Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c
Nt32Pkg/Sec/SecMain.c
Nt32Pkg/Sec/SecMain.inf

index 929ceb55f63afab5e0242f228732023868c7bb43..6a448755033827e32abbd0b013224859383f8a1c 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -109,7 +109,7 @@ Returns:
 \r
   Time->Daylight = 0;\r
   if (TimeZone.StandardDate.wMonth) {\r
-    Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT;\r
+    Time->Daylight = (UINT8) TimeZone.StandardDate.wMonth;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -162,7 +162,10 @@ Returns:
   gWinNt->GetTimeZoneInformation (&TimeZone);\r
   TimeZone.StandardDate.wMonth  = Time->Daylight;\r
   TimeZone.Bias                 = Time->TimeZone;\r
-  gWinNt->SetTimeZoneInformation (&TimeZone);\r
+  Flag = gWinNt->SetTimeZoneInformation (&TimeZone);\r
+  if (!Flag) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
 \r
   SystemTime.wYear          = Time->Year;\r
   SystemTime.wMonth         = Time->Month;\r
index 9048578ef70595cc75dddb9c5afc144a18d4e0aa..0c859a2650d789482023b41c3625291e285a3d32 100644 (file)
@@ -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
@@ -155,6 +157,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 +172,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
index cfb7921f4243aa96686090487746e152d9edd942..e9596b9b137977a66820fb837067f225e131abe1 100644 (file)
@@ -62,7 +62,7 @@
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume\r
   \r
 [BuildOptions]\r
-  MSFT:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib\r
+  MSFT:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib\r
   MSFT:*_*_IA32_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE\r
   MSFT:*_*_IA32_PP_FLAGS == /nologo /E /TC /FIAutoGen.h\r
   MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi\r