+ //\r
+ // Replace Argv[0] with the full path of the binary we're executing:\r
+ // If the command line was "foo", the binary might be called "foo.efi".\r
+ // "The first entry in [Argv] is always the full file path of the\r
+ // executable" - UEFI Shell Spec section 2.3\r
+ //\r
+ ImagePath = EfiShellGetFilePathFromDevicePath (DevicePath);\r
+ // The image we're executing isn't necessarily in a filesystem - it might\r
+ // be memory mapped. In this case EfiShellGetFilePathFromDevicePath will\r
+ // return NULL, and we'll leave Argv[0] as UpdateArgcArgv set it.\r
+ if (ImagePath != NULL) {\r
+ if (ShellParamsProtocol.Argv == NULL) {\r
+ // Command line was empty or null.\r
+ // (UpdateArgcArgv sets Argv to NULL when CommandLine is "" or NULL)\r
+ ShellParamsProtocol.Argv = AllocatePool (sizeof (CHAR16 *));\r
+ if (ShellParamsProtocol.Argv == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Cleanup;\r
+ }\r
+ ShellParamsProtocol.Argc = 1;\r
+ } else {\r
+ // Free the string UpdateArgcArgv put in Argv[0];\r
+ FreePool (ShellParamsProtocol.Argv[0]);\r
+ }\r
+ ShellParamsProtocol.Argv[0] = ImagePath;\r
+ }\r
+\r