| 28 | // |
| 29 | |
| 30 | EFI_STATUS |
| 31 | GetMemoryFile ( |
| 32 | IN CHAR8 *InputFileName, |
| 33 | OUT EFI_HANDLE *OutputMemoryFile |
| 34 | ) |
| 35 | /*++ |
| 36 | |
| 37 | Routine Description: |
| 38 | |
| 39 | This opens a file, reads it into memory and returns a memory file |
| 40 | object. |
| 41 | |
| 42 | Arguments: |
| 43 | |
| 44 | InputFile Memory file image. |
| 45 | OutputMemoryFile Handle to memory file |
| 46 | |
| 47 | Returns: |
| 48 | |
| 49 | EFI_STATUS |
| 50 | OutputMemoryFile is valid if !EFI_ERROR |
| 51 | |
| 52 | --*/ |
| 53 | { |
| 54 | EFI_STATUS Status; |
| 55 | CHAR8 *InputFileImage; |
| 56 | UINT32 BytesRead; |
| 57 | MEMORY_FILE *NewMemoryFile; |
| 58 | |
| 59 | Status = GetFileImage (InputFileName, &InputFileImage, &BytesRead); |
| 60 | if (EFI_ERROR (Status)) { |
| 61 | return Status; |
| 62 | } |
| 63 | |
| 64 | NewMemoryFile = malloc (sizeof (*NewMemoryFile)); |
| 65 | if (NewMemoryFile == NULL) { |
| 66 | free (InputFileImage); |
| 67 | return EFI_OUT_OF_RESOURCES; |
| 68 | } |
| 69 | |
| 70 | NewMemoryFile->FileImage = InputFileImage; |
| 71 | NewMemoryFile->CurrentFilePointer = InputFileImage; |
| 72 | NewMemoryFile->Eof = InputFileImage + BytesRead; |
| 73 | |
| 74 | *OutputMemoryFile = (EFI_HANDLE)NewMemoryFile; |
| 75 | |
| 76 | CheckMemoryFileState (*OutputMemoryFile); |
| 77 | |
| 78 | return EFI_SUCCESS; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | EFI_STATUS |
no test coverage detected