From f515069c194f418b74915be4a2e021c2b3ae2c46 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Sat, 9 Oct 2010 02:46:37 +0000 Subject: [PATCH] Fixed update file time error problem. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10913 6f19259b-4bc3-4df7-8a09-765794883524 --- Nt32Pkg/Include/Protocol/WinNtThunk.h | 12 +++++++++- Nt32Pkg/Sec/WinNtThunk.c | 3 ++- .../WinNtSimpleFileSystem.c | 24 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Nt32Pkg/Include/Protocol/WinNtThunk.h b/Nt32Pkg/Include/Protocol/WinNtThunk.h index e63322d6c0..5a5d8290d2 100644 --- a/Nt32Pkg/Include/Protocol/WinNtThunk.h +++ b/Nt32Pkg/Include/Protocol/WinNtThunk.h @@ -1,6 +1,6 @@ /**@file -Copyright (c) 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2010, 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 @@ -676,6 +676,15 @@ BOOL CONST SYSTEMTIME *SystemTime ); +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtLocalFileTimeToFileTime) ( + CONST FILETIME *LocalFileTime, + LPFILETIME FileTime + ); + + typedef WINBASEAPI BOOL @@ -1197,6 +1206,7 @@ typedef struct { // // Win32 Time APIs // + WinNtLocalFileTimeToFileTime LocalFileTimeToFileTime; WinNtFileTimeToLocalFileTime FileTimeToLocalFileTime; WinNtFileTimeToSystemTime FileTimeToSystemTime; WinNtGetSystemTime GetSystemTime; diff --git a/Nt32Pkg/Sec/WinNtThunk.c b/Nt32Pkg/Sec/WinNtThunk.c index 45b2552438..e4589cbfc7 100644 --- a/Nt32Pkg/Sec/WinNtThunk.c +++ b/Nt32Pkg/Sec/WinNtThunk.c @@ -1,6 +1,6 @@ /**@file -Copyright (c) 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2010, 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 @@ -124,6 +124,7 @@ EFI_WIN_NT_THUNK_PROTOCOL mWinNtThunkTable = { MoveFile, SetFileTime, SystemTimeToFileTime, + LocalFileTimeToFileTime, FileTimeToLocalFileTime, FileTimeToSystemTime, GetSystemTime, diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c index 250d4bf536..fd925b9312 100644 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c +++ b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c @@ -1995,6 +1995,7 @@ Returns: Info->FileSize = FileInfo.nFileSizeLow; Info->PhysicalSize = Info->FileSize; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftCreationTime, &FileInfo.ftCreationTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftCreationTime, &SystemTime); Info->CreateTime.Year = SystemTime.wYear; Info->CreateTime.Month = (UINT8) SystemTime.wMonth; @@ -2003,6 +2004,7 @@ Returns: Info->CreateTime.Minute = (UINT8) SystemTime.wMinute; Info->CreateTime.Second = (UINT8) SystemTime.wSecond; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastAccessTime, &FileInfo.ftLastAccessTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastAccessTime, &SystemTime); Info->LastAccessTime.Year = SystemTime.wYear; Info->LastAccessTime.Month = (UINT8) SystemTime.wMonth; @@ -2011,6 +2013,7 @@ Returns: Info->LastAccessTime.Minute = (UINT8) SystemTime.wMinute; Info->LastAccessTime.Second = (UINT8) SystemTime.wSecond; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastWriteTime, &FileInfo.ftLastWriteTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastWriteTime, &SystemTime); Info->ModificationTime.Year = SystemTime.wYear; Info->ModificationTime.Month = (UINT8) SystemTime.wMonth; @@ -2730,6 +2733,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewCreationFileTime, + &NewCreationFileTime + )) { + goto Done; + } + NewLastAccessSystemTime.wYear = NewFileInfo->LastAccessTime.Year; NewLastAccessSystemTime.wMonth = NewFileInfo->LastAccessTime.Month; NewLastAccessSystemTime.wDay = NewFileInfo->LastAccessTime.Day; @@ -2745,6 +2755,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewLastAccessFileTime, + &NewLastAccessFileTime + )) { + goto Done; + } + NewLastWriteSystemTime.wYear = NewFileInfo->ModificationTime.Year; NewLastWriteSystemTime.wMonth = NewFileInfo->ModificationTime.Month; NewLastWriteSystemTime.wDay = NewFileInfo->ModificationTime.Day; @@ -2760,6 +2777,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewLastWriteFileTime, + &NewLastWriteFileTime + )) { + goto Done; + } + if (!PrivateFile->WinNtThunk->SetFileTime ( PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle, &NewCreationFileTime,