diff options
author | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-15 02:40:18 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-15 02:40:18 +0000 |
commit | 21e3aefed2b24a3875a2d056164e46677089e4bb (patch) | |
tree | 42431613e30e7ef8d62d2c0fd12f9976146a915f | |
parent | d60f6af456a08f186a2b7568eec5279e96547a22 (diff) | |
download | edk2-platforms-21e3aefed2b24a3875a2d056164e46677089e4bb.tar.xz |
Enable write file to USB from Shell in Win7 OS
Signed-off-by: ydong10
Reviewed-by: niruiyu
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13013 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c index e43e6cfef5..1e12dd5204 100644 --- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c +++ b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c @@ -1,6 +1,6 @@ /**@file
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -972,8 +972,10 @@ WinNtBlockIoWriteBlocks ( WIN_NT_BLOCK_IO_PRIVATE *Private;
UINTN BytesWritten;
BOOL Flag;
+ BOOL Locked;
EFI_STATUS Status;
EFI_TPL OldTpl;
+ UINTN BytesReturned;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -984,7 +986,20 @@ WinNtBlockIoWriteBlocks ( goto Done;
}
+ //
+ // According the Windows requirement, first need to lock the volume before
+ // write to it.
+ //
+ Locked = Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL);
+ if (Locked == 0) {
+ DEBUG ((EFI_D_INIT, "ReadBlocks: Lock volume failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
+ Status = WinNtBlockIoError (Private);
+ goto Done;
+ }
Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL);
+ if (Locked != 0) {
+ Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL);
+ }
if (!Flag || (BytesWritten != BufferSize)) {
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
Status = WinNtBlockIoError (Private);
|