Skip to content

Commit

Permalink
OcMiscLib: Align LoadedImage with Shell behaviour for no arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mhaeuser committed Apr 3, 2021
1 parent d3be085 commit ccedcdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ OpenCore Changelog
- Improved OpenCanopy pointer acceleration
- Added more precise control on `AppleEvent` protocol properties and features
- Added dynamic keyboard protocol installation on CrScreenshotDxe
- Support starting UEFI tools with argument support (e.g. `ControlMsrE2`) without arguments from picker

#### v0.6.7
- Fixed ocvalidate return code to be non-zero when issues are found
Expand Down
12 changes: 10 additions & 2 deletions Library/OcMiscLib/ProtocolSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ GetArguments (
OUT CHAR16 ***Argv
)
{
STATIC CHAR16 *StArgv[2] = { L"Self", NULL };

EFI_STATUS Status;
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
Expand All @@ -47,11 +49,17 @@ GetArguments (
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "OCM: LoadedImage cannot be located - %r\n", Status));
}

if (EFI_ERROR (Status) || LoadedImage->LoadOptions == NULL) {
return EFI_NOT_FOUND;
*Argc = 1;
*Argv = StArgv;
return EFI_SUCCESS;
}

STATIC CHAR16 *StArgv[2] = { L"Self", NULL };
StArgv[1] = LoadedImage->LoadOptions;
*Argc = ARRAY_SIZE (StArgv);
*Argv = StArgv;
Expand Down

0 comments on commit ccedcdc

Please sign in to comment.