mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
d60f6af456
commit
21e3aefed2
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue