From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B40E12035B2C5 for ; Sun, 17 Dec 2017 21:08:27 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2017 21:13:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,420,1508828400"; d="scan'208";a="16862728" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.14]) ([10.239.9.14]) by orsmga001.jf.intel.com with ESMTP; 17 Dec 2017 21:13:11 -0800 To: Rafael Machado , "edk2-devel@lists.01.org" References: From: "Ni, Ruiyu" Message-ID: <82e7b859-9184-bb1c-828f-ecde7772231d@Intel.com> Date: Mon, 18 Dec 2017 13:13:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: UEFI App embedded on another uefi app X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 05:08:27 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 12/15/2017 7:45 PM, Rafael Machado wrote: > Hi Everyone. > > I have a limited space problem at a project. > To solve this we had an idea, but would like to ask to you before expending > time on trying to do it, due to some tight schedule. (We know that the best > is to try before ask, but we do not have time for that now. Sorry for that.) > > The idea is to create a kind of DecompressorApp.efi, that > uses EFI_DECOMPRESS_PROTOCOL > > During the compilation process of the application the tasks would be: > > - Compile App.efi > - Compress App.efi, generating the App.efi.compressed (using > tianoCompress.exe) > - Compile the Decompressor.efi app (with the App.efi.compressed embedded) > - The idea to do this is to add the compressed app as a Binary at > the DecompressorApp.efi .inf file using the [Binaries] tag > > > So during the entrypoint of the Decompressor.efi app, the application will > need to copy the compressed part of the app (App.efi.compressed), to a > buffer, and after that this buffer will be decompressed using the > EFI_DECOMPRESS_PROTOCOL. Finally the execution control is passed to the > App.efi decompressed (not sure how to do that yet). > > So the questions we have for know are: > > - How to detect the App.efi.compressed insyde the loaded app, so we can > have an address to decompress Is your usage case similar to the upx? If the App.efi is compressed and embedded as binary in the application, the application itself should know that the binary should be decompressed and executed. > - How to pass the application executions control to another app, that is in > a buffer (not sure if this can be done with the EFI Boot Service > LoadImage(), since this buffer does not have a valid file device path) Yes you could use LoadImage(). The API also accepts a PE buffer to load. Then you could use StartImage() to execute the PE buffer. Make sure you use the correct entrypoint prototype for the PE buffer. typedef EFI_STATUS (EFIAPI *EFI_IMAGE_ENTRY_POINT)( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ); > > Could you help us on understanding if this is possible? > > Thanks and Regards > Rafael R. Machado > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > -- Thanks, Ray