29 Status =
gBS->HandleProtocol (
31 &gEfiShellParametersProtocolGuid,
32 (VOID **)&ShellParameters
34 if (EFI_ERROR (Status)) {
38 Argc = ShellParameters->
Argc;
39 Argv = ShellParameters->
Argv;
55 if (mShellProtocol ==
NULL) {
56 Status =
gBS->LocateProtocol (
57 &gEfiShellProtocolGuid,
59 (VOID **)&mShellProtocol
61 if (EFI_ERROR (Status)) {
62 mShellProtocol =
NULL;
66 return mShellProtocol;
89 SHELL_FILE_HANDLE Handle;
95 if (ShellProtocol ==
NULL) {
102 Status = ShellProtocol->OpenFileByName (
107 if (EFI_ERROR (Status)) {
114 Status = ShellProtocol->GetFileSize (Handle, &FileSize);
115 if (EFI_ERROR (Status)) {
116 ShellProtocol->CloseFile (Handle);
120 TempBufferSize = (
UINTN)FileSize;
122 if (TempBuffer ==
NULL) {
123 ShellProtocol->CloseFile (Handle);
124 return EFI_OUT_OF_RESOURCES;
130 Status = ShellProtocol->ReadFile (
135 if (EFI_ERROR (Status)) {
136 ShellProtocol->CloseFile (Handle);
140 ShellProtocol->CloseFile (Handle);
142 *BufferSize = TempBufferSize;
143 *Buffer = TempBuffer;
167 SHELL_FILE_HANDLE Handle;
169 UINTN TempBufferSize;
172 if (ShellProtocol ==
NULL) {
173 return EFI_NOT_FOUND;
179 Status = ShellProtocol->OpenFileByName (
182 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE
184 if (EFI_ERROR (Status)) {
191 FileInfo = ShellProtocol->GetFileInfo (Handle);
193 ShellProtocol->CloseFile (Handle);
194 return EFI_DEVICE_ERROR;
205 Status = ShellProtocol->SetFileInfo (Handle,
FileInfo);
206 if (EFI_ERROR (Status)) {
208 ShellProtocol->CloseFile (Handle);
218 TempBufferSize = BufferSize;
219 Status = ShellProtocol->WriteFile (
224 if (EFI_ERROR (Status)) {
225 ShellProtocol->CloseFile (Handle);
229 ShellProtocol->CloseFile (Handle);
EFI_STATUS ReadFileToBuffer(IN CHAR16 *FileName, OUT UINTN *BufferSize, OUT VOID **Buffer)
EFI_STATUS WriteFileFromBuffer(IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer)
EFI_SHELL_PROTOCOL * GetShellProtocol(VOID)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)