if (mEfiShellEnvironment2 != NULL) {\r
//\r
// Call EFI Shell version.\r
- // Due to oddity in the EFI shell we want to dereference the ParentHandle here\r
//\r
- CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle,\r
+ // Due to an unfixable bug in the EdkShell implementation, we must\r
+ // dereference "ParentHandle" here:\r
+ //\r
+ // 1. The EFI shell installs the EFI_SHELL_ENVIRONMENT2 protocol,\r
+ // identified by gEfiShellEnvironment2Guid.\r
+ // 2. The Execute() member function takes "ParentImageHandle" as first\r
+ // parameter, with type (EFI_HANDLE*).\r
+ // 3. In the EdkShell implementation, SEnvExecute() implements the\r
+ // Execute() member function. It passes "ParentImageHandle" correctly to\r
+ // SEnvDoExecute().\r
+ // 4. SEnvDoExecute() takes the (EFI_HANDLE*), and passes it directly --\r
+ // without de-referencing -- to the HandleProtocol() boot service.\r
+ // 5. But HandleProtocol() takes an EFI_HANDLE.\r
+ //\r
+ // Therefore we must\r
+ // - de-reference "ParentHandle" here, to mask the bug in\r
+ // SEnvDoExecute(), and\r
+ // - pass the resultant EFI_HANDLE as an (EFI_HANDLE*).\r
+ //\r
+ CmdStatus = (mEfiShellEnvironment2->Execute((EFI_HANDLE *)*ParentHandle,\r
CommandLine,\r
Output));\r
//\r