All,

I am developing an efi loader and having problem to write an allocated mem
or text to a file on efi partition. I can create and del but I am not able
to write a file. I have checked all doc but example with declaration was
not found. Please, help with an example(or correct my one)...regards
Gab..

here my code:


static CHAR16 *PATH = L"\\TEST\\test.txt

EFI_STATUS SavePass(EFI_DEVICE_PATH **LoaderDevicePath2)
{
EFI_FILE_IO_INTERFACE *Device_unit;

EFI_FILE_HANDLE efi_hand_root,pass_file;

EFI_HANDLE* efi_hand_array;

UINTN handler,i;

EFI_STATUS ferr,err;


UINTN Size,wsize;
VOID *OsKernelBuffer = NULL;
*LoaderDevicePath2 = (EFI_DEVICE_PATH *)NULL;

Size=0x00000012;

BS->AllocatePool(EfiLoaderData, Size, &OsKernelBuffer);


wsize=sizeof(OsKernelBuffer);


      err =
efi_hand_root->Open(efi_hand_root,&pass_file,PATH,EFI_FILE_MODE_WRITE |
EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ,0);  //THIS IS OK. ITS CREATE IS
SUCCESS

    if(err == EFI_SUCCESS)

        {



        Print(L"[*] File Opened..\r\n");


        ferr=efi_hand_root->Write(efi_hand_root,wsize,OsKernelBuffer); //IT
returns with 8000000000002 means  EFI_INVALID_PARAMETER


        Print(L"\nPress [ENTER] to continue...\n");
        Input(NULL,Keypass,10);

        Print(L"Write ERROR: %lX \r\n",ferr);
        if(ferr == EFI_SUCCESS)
            {
            efi_hand_root->Flush(pass_file);
            efi_hand_root->Close(pass_file);


            Print(L"[*] Write Success...\r\n");
            }

        efi_hand_root->Close(pass_file);

        *LoaderDevicePath2 = FileDevicePath(efi_hand_array[i],PATH);


        break;

        }



        break;

        }


    }



FreePool(OsKernelBuffer);

return err;
}
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to