From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.151.62.27; helo=mail-in5.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in5.apple.com (mail-out5.apple.com [17.151.62.27]) (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 C3E7C211F888F for ; Wed, 4 Jul 2018 07:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1530716132; x=2394629732; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5uo58K5mDH7S8DqdYO6+ymSzRgWCwwqPX6cRpEvsEJU=; b=MFth9aqUmQY5X3hZmBSx+3NZLmcRLLuahSo0kvhED4DC1hIWWt/3U5Do3UXrUg4i 7N/05U2eKTp9ldwCHGmmJPHVXsBskWRzxYkTFCwnBJ1ioQuG2E0nkHFwXt9ON3Wd pWDsxpMqrvG/7J01H0Ew5b9jgLjSNE1eX/FZIDmlMjR5ZPbG3d+U94ZmB3MfEMvd IE3hJs9Lts/OE4vdu2OkXaY6XtcEjPi06dep4Ms7YzoATkIzr/FueeTu5ISFvpLo YVNJl0/WPfUxiETAkGPiTpoVnns7zpxKF72juJH9DpGDKfTzPQ38B6pKP2HL77PR Sg+nLrmtTqaUMWpJLAF7ZA==; X-AuditID: 11973e13-62dff7000000242c-4d-5b3cdfe31903 Received: from ma1-mtap-s01.corp.apple.com (ma1-mtap-s01.corp.apple.com [17.40.76.5]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail-in5.apple.com (Apple Secure Mail Relay) with SMTP id 66.35.09260.3EFDC3B5; Wed, 4 Jul 2018 07:55:32 -0700 (PDT) MIME-version: 1.0 Received: from ma1-mmpp-sz08.apple.com (ma1-mmpp-sz08.apple.com [17.171.128.176]) by ma1-mtap-s01.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PBC00H1TK4J5G70@ma1-mtap-s01.corp.apple.com>; Wed, 04 Jul 2018 07:55:31 -0700 (PDT) Received: from process_viserion-daemon.ma1-mmpp-sz08.apple.com by ma1-mmpp-sz08.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PBC00A00JW6B200@ma1-mmpp-sz08.apple.com>; Wed, 04 Jul 2018 07:55:31 -0700 (PDT) X-Va-A: X-Va-T-CD: 81bc50dcaed96df73b856fb2bb30cfe8 X-Va-E-CD: 7545989765a9e78649ea81af12926aac X-Va-R-CD: 94f9e3d29bee02b8260e50b5d88da089 X-Va-CD: 0 X-Va-ID: fa1f9db0-2bc9-4d43-833c-c8c5f0071b5f X-V-A: X-V-T-CD: 47b99755e53fe986b2acf0f0e3abb348 X-V-E-CD: 7545989765a9e78649ea81af12926aac X-V-R-CD: 94f9e3d29bee02b8260e50b5d88da089 X-V-CD: 0 X-V-ID: 2b620876-60fd-484d-baac-cdcf434bb36b Received: from process_milters-daemon.ma1-mmpp-sz08.apple.com by ma1-mmpp-sz08.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PBC00A00JVWAX00@ma1-mmpp-sz08.apple.com>; Wed, 04 Jul 2018 07:55:31 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-04_05:,, signatures=0 X-Proofpoint-Scanner-Instance: ma-grpmailp-qapp24.corp.apple.com-10000_instance1 Received: from [17.234.159.180] (unknown [17.234.159.180]) by ma1-mmpp-sz08.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PBC00GNIK4G7L30@ma1-mmpp-sz08.apple.com>; Wed, 04 Jul 2018 07:55:31 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish X-Priority: 3 In-reply-to: <3009b28c.9942.16464937ab3.Coremail.sssky307@163.com> Date: Wed, 04 Jul 2018 07:55:27 -0700 Cc: edk2-devel@lists.01.org Message-id: <22A24D19-CF95-4C30-9939-F2E71DAF3736@apple.com> References: <3009b28c.9942.16464937ab3.Coremail.sssky307@163.com> To: krishnaLee X-Mailer: Apple Mail (2.3445.6.18) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGIsWRmVeSWpSXmKPExsUiqOHDqvvkvk20wf2DjBZ7Dh1ltpjf85rZ gclj8YoprB7ds/+xBDBFcdmkpOZklqUW6dslcGVcufKIveCeXEX/vAesDYxnJLoYOTkkBEwk HpxbxNzFyMUhJLCPSaLj8AQmkASvgKDEj8n3WLoYOTiYBeQlDp6XBQkzC2hJfH/UygJRv5FJ 4mn3JDYIp4tJoq9rFSvEVHaJP792sEDY2hL31nezwtgHNz9mBhkKYn/v9ocIc0ks2HoaqkRX 4svjuVCtbBLrTyxhgrC1JDZ9XMkKYx99vA4ufmH+I0YIm1Pi/JeJ7BDjdSSu7fWAOK2TSeLJ 7wPsEDXZEg9fbWCDsAMkFnSA9IIUTWaS2L93N9ggYQFxiXdnNjFD2MYSFw81gzWwCShLrJj/ AWoQr8SM9qdgh3IKOEn0fzsEdhyLgKpE2/NFTJDQkpZ4OPE4KyRAbSQ2L7kHNl9IwFHiVMNM xgmMSrOQwnoWIqxnIYX1AkbmVYxCuYmZObqZeaZ6iQUFOal6yfm5mxhBCWG6nfAOxtOrrA4x CnAwKvHw3jhtEy3EmlhWXJl7iFGag0VJnPffa+toIYH0xJLU7NTUgtSi+KLSnNTiQ4xMHJxS DYx2G8SnCm4sPW88Q9thQ/qfi7Y/fr5+/iu7+UO8wvPyRS2V7W4c/3pezHsmPF343AN1/kel jbfE5kWLl78xqj5yhjeNw6cq9GzP6Tad9qcq/XGrJmh1f5suzLrqCN87xqg3h5sOb026t762 eHGhTyVr/I7qwOvP5Fo+Xvn7Zco+hrBJ85/pCzoqsRRnJBpqMRcVJwIAsXBKKekCAAA= Subject: Re: question about uefi shell pipe. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 14:55:34 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Krishnal, Thanks for including the code. You are overflowing the buffer. In C sizeof(Buffer) will be 80*25*4*2 since sizeof(UINT16) is 2. Your code is passing in double the size of the buffer. UINT16 Buffer[80*25*4]; //tool's buffer; UINTN BufferSize=sizeof(Buffer); UINTN BufferByteSize=BufferSize*sizeof(UINT16); This should work: UINT16 Buffer[80*25*4]; //tool's buffer; UINTN BufferByteSize = sizeof(Buffer); Thanks, Andrew Fish > On Jul 4, 2018, at 2:15 AM, krishnaLee wrote: > > Hi, > I wrote this shell application(smalltest.efi),did some pipe function test,find some strange result. > boot into shell: > > > # test-1,the follow two command should has the same output ,but infact not the same in QEMU,and the second command failed WriteFile in real machine(AMI bios uefi 2.6): > ls | smalltest.efi > ls | smalltest.efi | smalltest.efi # the ls command directory only has one file(this tool),so the tool's buffer 80x25*4 won't overflow. > > > #test-2 > run smalltest.efi, > just key in some chars and Enter,nothing output,why? > > > my test environment: > UDK2018 + vs2015 > QEMU emulator version 2.10.95 > OVMF_X64.fd( x64,release build) > > > the tool's build command: > D:\edk2-vUDK2018>build -p ShellPkg\ShellPkg.dsc -m ShellPkg\Application2\smalltest\smalltest.inf -a X64 -b RELEASE > > > //--------code---smalltest.c------------- > > > #include > #include > #include > #include //global gST gBS gImageHandle > #include > #include > > > #include > #include > > > > EFI_STATUS > EFIAPI > UefiMain ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > EFI_STATUS status; > EFI_SHELL_PROTOCOL* gShell; > EFI_SHELL_PARAMETERS_PROTOCOL*gParameters; > UINT16 Buffer[80*25*4]; //tool's buffer; > UINTN BufferSize=sizeof(Buffer); > UINTN BufferByteSize=BufferSize*sizeof(UINT16); > > > status=gBS->HandleProtocol(gImageHandle,&gEfiShellParametersProtocolGuid,&gParameters); > if(status!=EFI_SUCCESS) > { > Print(L"locate gEfiShellParametersProtocolGuid failed.\n"); > return status; > } > > > status=gBS->LocateProtocol(&gEfiShellProtocolGuid,NULL,&gShell); > if(status!=EFI_SUCCESS) > { > Print(L"locate gEfiShellProtocolGuid failed.\n"); > return status; > } > > > status=gShell->ReadFile(gParameters->StdIn,&BufferByteSize,(VOID*)Buffer); > if(status!=EFI_SUCCESS) > { > Print(L"read from gParameters->StdIn failed.\n"); > return status; > } > > > status=gShell->WriteFile(gParameters->StdOut,&BufferByteSize,(VOID*)Buffer); > if(status!=EFI_SUCCESS) > { > Print(L"wirte gParameters->StdOut failed\n"); > return status; > } > > > gShell->FlushFile(gParameters->StdOut); > > > return EFI_SUCCESS; > } > > > //--------code---smalltest.inf------------- > > > [Defines] > INF_VERSION = 0x00010005 > BASE_NAME = smalltest > FILE_GUID = 8F7D7B1D-0E1C-4c98-B12E-4EC99C400704 > MODULE_TYPE = UEFI_APPLICATION > VERSION_STRING = 1.0 > ENTRY_POINT = UefiMain > > > [Sources] > smalltest.c > > > [Packages] > MdePkg/MdePkg.dec > > > [Protocols] > gEfiShellProtocolGuid > gEfiShellParametersProtocolGuid > > > [LibraryClasses] > UefiApplicationEntryPoint > UefiLib > //--------code---end---------------------------------------------------------- > > > > > > > thank you, > by krishna. > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel