OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcStorageLib.c File Reference
#include <Uefi.h>
#include <Guid/FileInfo.h>
#include <Protocol/SimpleFileSystem.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcDevicePathLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcStorageLib.h>
#include <Library/UefiBootServicesTableLib.h>

Go to the source code of this file.

Macros

#define INTERNAL_STORAGE_GUID    { 0x33B5C65A, 0x5B82, 0x403D, {0x87, 0xA5, 0xD4, 0x67, 0x62, 0x50, 0xEC, 0x59} }
 
#define INTERNAL_STORAGE_FILE_GUID    { 0x1237EC17, 0xD3CE, 0x401D, {0xA8, 0x41, 0xB1, 0xD8, 0x18, 0xF8, 0xAF, 0x1A} }
 

Typedefs

struct { 
 
   VENDOR_DEFINED_DEVICE_PATH   Vendor 
 
   EFI_DEVICE_PATH_PROTOCOL   End 
 
DUMMY_BOOT_DEVICE_PATH 
 
struct { 
 
   VENDOR_DEFINED_DEVICE_PATH   Vendor 
 
   VENDOR_DEFINED_DEVICE_PATH   VendorFile 
 
   EFI_DEVICE_PATH_PROTOCOL   End 
 
DUMMY_BOOT_DEVICE_FILE_PATH 
 

Functions

STATIC EFI_STATUS OcStorageInitializeVault (IN OUT OC_STORAGE_CONTEXT *Context, IN VOID *Vault OPTIONAL, IN UINT32 VaultSize, IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL, IN VOID *Signature OPTIONAL, IN UINT32 SignatureSize OPTIONAL)
 
STATIC UINT8 * OcStorageGetDigest (IN OUT OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *Filename)
 
EFI_STATUS OcStorageInitFromFs (OUT OC_STORAGE_CONTEXT *Context, IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem, IN EFI_HANDLE StorageHandle OPTIONAL, IN EFI_DEVICE_PATH_PROTOCOL *StoragePath OPTIONAL, IN CONST CHAR16 *StorageRoot, IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL)
 
VOID OcStorageFree (IN OUT OC_STORAGE_CONTEXT *Context)
 
BOOLEAN OcStorageExistsFileUnicode (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath)
 
VOID * OcStorageReadFileUnicode (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL)
 
EFI_STATUS OcStorageGetInfo (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath OPTIONAL, OUT EFI_HANDLE *StorageHandle OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **StoragePath OPTIONAL, IN BOOLEAN RealPath)
 

Variables

STATIC DUMMY_BOOT_DEVICE_PATH mDummyBootDevicePath
 
STATIC DUMMY_BOOT_DEVICE_FILE_PATH mDummyBootDeviceFilePath
 
STATIC OC_SCHEMA mVaultFilesSchema = OC_SCHEMA_DATAF (NULL, UINT8[SHA256_DIGEST_SIZE])
 
STATIC OC_SCHEMA mVaultNodesSchema []
 
STATIC OC_SCHEMA_INFO mVaultSchema
 

Detailed Description

Copyright (C) 2019, vit9696. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcStorageLib.c.

Macro Definition Documentation

◆ INTERNAL_STORAGE_FILE_GUID

#define INTERNAL_STORAGE_FILE_GUID    { 0x1237EC17, 0xD3CE, 0x401D, {0xA8, 0x41, 0xB1, 0xD8, 0x18, 0xF8, 0xAF, 0x1A} }

Definition at line 55 of file OcStorageLib.c.

◆ INTERNAL_STORAGE_GUID

#define INTERNAL_STORAGE_GUID    { 0x33B5C65A, 0x5B82, 0x403D, {0x87, 0xA5, 0xD4, 0x67, 0x62, 0x50, 0xEC, 0x59} }

Definition at line 52 of file OcStorageLib.c.

Typedef Documentation

◆ [struct]

typedef PACKED struct { ... } DUMMY_BOOT_DEVICE_FILE_PATH

◆ [struct]

typedef PACKED struct { ... } DUMMY_BOOT_DEVICE_PATH

Function Documentation

◆ OcStorageExistsFileUnicode()

BOOLEAN OcStorageExistsFileUnicode ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath )

Check whether file exists.

Parameters
[in]ContextStorage context.
[in]FilePathThe full path to the file on the device.
Return values
TRUEif file is present in vault or ondisk.

Definition at line 340 of file OcStorageLib.c.

◆ OcStorageFree()

VOID OcStorageFree ( IN OUT OC_STORAGE_CONTEXT * Context)

Free storage context resources.

Parameters
[in,out]ContextStorage context.

Definition at line 315 of file OcStorageLib.c.

◆ OcStorageGetDigest()

STATIC UINT8 * OcStorageGetDigest ( IN OUT OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * Filename )

Definition at line 177 of file OcStorageLib.c.

◆ OcStorageGetInfo()

EFI_STATUS OcStorageGetInfo ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath OPTIONAL,
OUT EFI_HANDLE *StorageHandle OPTIONAL,
OUT EFI_DEVICE_PATH_PROTOCOL **StoragePath OPTIONAL,
IN BOOLEAN RealPath )

Definition at line 468 of file OcStorageLib.c.

◆ OcStorageInitFromFs()

EFI_STATUS OcStorageInitFromFs ( OUT OC_STORAGE_CONTEXT * Context,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * FileSystem,
IN EFI_HANDLE StorageHandle OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *StoragePath OPTIONAL,
IN CONST CHAR16 * StorageRoot,
IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL )

Create storage context from UEFI file system at specified path.

Parameters
[out]ContextResulting storage context.
[in]FileSystemStorage file system.
[in]StorageHandleStorage handle, optional.
[in]StoragePathActual storage device path, optional.
[in]StorageRootStorage file system root (e.g. L"\\").
[in]StorageKeyStorage signature verification key, optional.
Return values
EFI_SUCCESSon success.

Definition at line 215 of file OcStorageLib.c.

◆ OcStorageInitializeVault()

STATIC EFI_STATUS OcStorageInitializeVault ( IN OUT OC_STORAGE_CONTEXT * Context,
IN VOID *Vault OPTIONAL,
IN UINT32 VaultSize,
IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL,
IN VOID *Signature OPTIONAL,
IN UINT32 SignatureSize OPTIONAL )

Definition at line 124 of file OcStorageLib.c.

◆ OcStorageReadFileUnicode()

VOID * OcStorageReadFileUnicode ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath,
OUT UINT32 *FileSize OPTIONAL )

Read file from storage with implicit double (2 byte) null termination. Null termination does not affect the returned file size. Depending on the implementation 0 byte files may return null. If storage context was created with valid storage key, then signature checking will be performed

Parameters
[in]ContextStorage context.
[in]FilePathThe full path to the file on the device.
[out]FileSizeThe size of the file read (optional).
Return values
Apointer to a buffer containing file read or NULL.

Definition at line 383 of file OcStorageLib.c.

Variable Documentation

◆ End

EFI_DEVICE_PATH_PROTOCOL End

Definition at line 37 of file OcStorageLib.c.

◆ mDummyBootDeviceFilePath

STATIC DUMMY_BOOT_DEVICE_FILE_PATH mDummyBootDeviceFilePath
Initial value:
= {
.Vendor = {
.Header = {
.Type = HARDWARE_DEVICE_PATH,
.SubType = HW_VENDOR_DP,
.Length = { sizeof (VENDOR_DEFINED_DEVICE_PATH), 0 }
},
},
.VendorFile = {
.Header = {
.Type = HARDWARE_DEVICE_PATH,
.SubType = HW_VENDOR_DP,
.Length = { sizeof (VENDOR_DEFINED_DEVICE_PATH), 0 }
},
},
.End = {
.Type = END_DEVICE_PATH_TYPE,
.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE,
.Length = { END_DEVICE_PATH_LENGTH, 0 }
}
}
#define INTERNAL_STORAGE_GUID
#define INTERNAL_STORAGE_FILE_GUID

Definition at line 78 of file OcStorageLib.c.

◆ mDummyBootDevicePath

STATIC DUMMY_BOOT_DEVICE_PATH mDummyBootDevicePath
Initial value:
= {
.Vendor = {
.Header = {
.Type = HARDWARE_DEVICE_PATH,
.SubType = HW_VENDOR_DP,
.Length = { sizeof (VENDOR_DEFINED_DEVICE_PATH), 0 }
},
},
.End = {
.Type = END_DEVICE_PATH_TYPE,
.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE,
.Length = { END_DEVICE_PATH_LENGTH, 0 }
}
}

Definition at line 60 of file OcStorageLib.c.

◆ mVaultFilesSchema

STATIC OC_SCHEMA mVaultFilesSchema = OC_SCHEMA_DATAF (NULL, UINT8[SHA256_DIGEST_SIZE])

Definition at line 104 of file OcStorageLib.c.

◆ mVaultNodesSchema

STATIC OC_SCHEMA mVaultNodesSchema[]
Initial value:
= {
OC_SCHEMA_MAP_IN ("Files", OC_STORAGE_VAULT, Files, &mVaultFilesSchema),
OC_SCHEMA_INTEGER_IN ("Version", OC_STORAGE_VAULT, Version),
}
UINT32 Version
#define OC_SCHEMA_MAP_IN(Name, Type, Field, ChildSchema)
#define OC_SCHEMA_INTEGER_IN(Name, Type, Field)
STATIC OC_SCHEMA mVaultFilesSchema

WARNING: Field list must be alpabetically ordered here!

Definition at line 111 of file OcStorageLib.c.

◆ mVaultSchema

STATIC OC_SCHEMA_INFO mVaultSchema
Initial value:
= {
}
#define ARRAY_SIZE(Array)
Definition AppleMacEfi.h:34
STATIC OC_SCHEMA mVaultNodesSchema[]

Definition at line 118 of file OcStorageLib.c.

◆ Vendor

VENDOR_DEFINED_DEVICE_PATH Vendor

Definition at line 36 of file OcStorageLib.c.

◆ VendorFile

VENDOR_DEFINED_DEVICE_PATH VendorFile

Definition at line 42 of file OcStorageLib.c.