diff --git a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c index 929ceb55f6..6a44875503 100644 --- a/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c +++ b/Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClock.c @@ -1,6 +1,6 @@ /**@file -Copyright (c) 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -109,7 +109,7 @@ Returns: Time->Daylight = 0; if (TimeZone.StandardDate.wMonth) { - Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT; + Time->Daylight = (UINT8) TimeZone.StandardDate.wMonth; } return EFI_SUCCESS; @@ -162,7 +162,10 @@ Returns: gWinNt->GetTimeZoneInformation (&TimeZone); TimeZone.StandardDate.wMonth = Time->Daylight; TimeZone.Bias = Time->TimeZone; - gWinNt->SetTimeZoneInformation (&TimeZone); + Flag = gWinNt->SetTimeZoneInformation (&TimeZone); + if (!Flag) { + return EFI_DEVICE_ERROR; + } SystemTime.wYear = Time->Year; SystemTime.wMonth = Time->Month; diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c index 9048578ef7..0c859a2650 100644 --- a/Nt32Pkg/Sec/SecMain.c +++ b/Nt32Pkg/Sec/SecMain.c @@ -30,7 +30,9 @@ Abstract: #include "SecMain.h" - +#ifndef SE_TIME_ZONE_NAME +#define SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege") +#endif NT_PEI_LOAD_FILE_PPI mSecNtLoadFilePpi = { SecWinNtPeiLoadFile }; @@ -155,6 +157,8 @@ Returns: --*/ { EFI_STATUS Status; + HANDLE Token; + TOKEN_PRIVILEGES TokenPrivileges; EFI_PHYSICAL_ADDRESS InitialStackMemory; UINT64 InitialStackMemorySize; UINTN Index; @@ -168,6 +172,16 @@ Returns: CHAR16 *FirmwareVolumesStr; UINTN *StackPointer; + // + // Enable the privilege so that RTC driver can successfully run SetTime() + // + OpenProcessToken (GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token); + if (LookupPrivilegeValue(NULL, SE_TIME_ZONE_NAME, &TokenPrivileges.Privileges[0].Luid)) { + TokenPrivileges.PrivilegeCount = 1; + TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0); + } + MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdWinNtMemorySizeForSecMain); FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdWinNtFirmwareVolume); diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf index cfb7921f42..e9596b9b13 100644 --- a/Nt32Pkg/Sec/SecMain.inf +++ b/Nt32Pkg/Sec/SecMain.inf @@ -62,7 +62,7 @@ gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume [BuildOptions] - 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 + 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 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 MSFT:*_*_IA32_PP_FLAGS == /nologo /E /TC /FIAutoGen.h MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi