Can I write on my local file system using EFI

I am working on this project to write files to the local file system as soon as the OS is launched through the EFI application. I need to know if this is possible. And if so, then kindly guide me a little. Thanks

+4
source share
1 answer

OK, I will give you good cheers ...

  • First you list all the FS protocols in the system.

    EFI_BOOT_SERVICES* bs = ...;
    EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
    EFI_HANDLE* handles = NULL;   
    UINTN handleCount = 0;
    
    efiStatus = bs->LocateHandleBuffer(ByProtocol, 
                                       &sfspGuid, 
                                       NULL, 
                                       &handleCount, 
                                       &handles);
    
  • EFI_SIMPLE_FILE_SYSTEM_PROTOCOL , , , ect . / , , . , DP, (), .

    for (index = 0; index < (int)handleCount; ++ index)
    {
        EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
    
        efiStatus = bs->HandleProtocol(
            handles[index],
            &sfspGuid,
            (void**)&fs);
    
  • . .

    EFI_FILE_PROTOCOL* root = NULL;
    ...
    efiStatus = fs->OpenVolume(fs, &root);
    
  • ect... , .

    EFI_FILE_PROTOCOL* token = NULL;
    
    efiStatus = root->Open(
            root, 
            &token,
            L"myfolder\\token.bin",
            EFI_FILE_MODE_READ,
            EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
    

EFI_FILE_PROTOCOL :

  EFI_FILE_OPEN         Open;
  EFI_FILE_CLOSE        Close;
  EFI_FILE_DELETE       Delete;
  EFI_FILE_READ         Read;
  EFI_FILE_WRITE        Write;
  EFI_FILE_GET_POSITION GetPosition;
  EFI_FILE_SET_POSITION SetPosition;
  EFI_FILE_GET_INFO     GetInfo;
  EFI_FILE_SET_INFO     SetInfo;
  EFI_FILE_FLUSH        Flush;
+7

All Articles