On Sep 25, 2013, at 6:14 AM, parmeshwr_pra...@dell.com wrote:

> Dell - Internal Use - Confidential
> 
> Hi All,
>  
> I have developed below code, it is crashing the system, can anybody tell me 
> why ? what is solution ?
> EFI_STATUS
>     EFIAPI
> UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE * SystemTable)
> {
>         EFI_STATUS Status;
>         EFI_SCSI_IO_PROTOCOL passthrough;
>         EFI_DRIVER_BINDING_PROTOCOL *This;
>  

Parmeshwr,

Your code examples seem to imply that  local C variables are initialized, they 
are not. You may find this helpful in understanding how local variables work in 
C http://en.wikipedia.org/wiki/Stack_buffer_overflow

In general IN is a comment and it means valid  data is being passed in. You 
need to initialize this data before you pass it in to an EFI call. 


>         gST->ConOut->OutputString(gST->ConOut, L"Mirror started\n");
>  
>         Print(L"ParamTest\n\r");
>         Status =
>             gBS->OpenProtocol(ImageHandle, &gEfiScsiIoProtocolGuid,
>                               (VOID **) & passthrough,

OpenProtocol returns a pointer to a pointer. You are passing in the address of 
a structure. So the first 8 (assuming X64) bytes of passthrough are going to 
contain a pointer to the returned passthrough protocol. So you want 
EFI_SCSI_IO_PROTOCOL *passthrough;

> This->DriverBindingHandle,

This currently points to a random place. So dereferencing This to get  
DriverBindingHandle is just passing in random junk. 

> NULL,
>                               EFI_OPEN_PROTOCOL_BY_DRIVER);
>         if (EFI_ERROR(Status)) {
>                 gST->ConOut->OutputString(gST->ConOut, L"Error\n");
>                 Print(L"Error !!!!!!!\n");
>                 return Status;
>         }
>  
>         Print(L"ParamTest\n\r");
>  
>  
>  
> Best Regards,
> Parmeshwr Prasad
> Tel : +91-9743262018
> <image001.png>
>  
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to