# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MLA -- File I/O Library

- 1
- 2
…
- 10
- 11
- 12
- 13
- 14
…
- 82
- 83

Long File Names
can support up to 255 UCS-2 characters, with the exception of the following characters:
\ / : * ? " < > |
Describing a Drive
Each media device you access will be described by an instance of the FILEIO_DRIVE_CONFIG structure. This structure
contains function pointers and information that will be used to access that drive. You must maintain this structure in memory
as long as the drive is mounted. For more information about this structure and the function pointer types it requires, please
see the Physical Layer Functions topic.
Mounting a Drive
To begin using the File I/O library, you must first use the FILEIO_DriveMount function to mount a drive. This will initialize the
drive and read all of the parameters that the File I/O library needs to access that drive. The first time that you mount a drive
after power-up, that drive's root directory will be set as the current working directory. Each time you mount a drive, you will
specify a single-character drive ID. You can use this drive ID in path strings to specify absolute paths. For an absolute path,
the path must begin with a drive ID (char for short file name paths, uint16_t for long file name paths), followed by a colon,
optionally followed by a delimiter character.
Some physical layers may require the user to specify additional parameters that define which instance of a drive should be
used or how it should be accessed. This information will be passed into the mediaParameters argument in the
FILEIO_DriveMount function. The format of this data will depend on the physical layer used.
When you are finished using a drive, you can unmount it using the FILEIO_DriveUnmount function. This will free the memory
used to store drive information, and perform any media-specific de-initialization. You must close all open files on a drive
before unmounting that drive, or they may become corrupted.
Opening and Closing Files
Before accessing any of the files on your device, you must open them with the FILEIO_Open function. Opening a file will
read the file information from the drive and initialize variables to track the current read/write location in the file. If
FILEIO_Open is successful, it will return true and populate the FILEIO_OBJECT structure that the user has specified. A
pointer to this file object can then be passed into other library functions to perform operations on that file.
After you are finished accessing a file, you must close the file with FILEIO_Close. This will write any cached data to the file
and update the file's information on the media.
User-Implemented Functionality
This library requires the user to implement a function to generate timestamps with the FILEIO_TIMESTAMP format. This
function format must match the FILEIO_TimestampGet definition. Once this function is implemented, you can pass it to the
library with the FILEIO_RegisterTimestampGet function. When modifying or creating files, the library will call this function to
generate a timestamp for that file. The method used to generate the timestamps will be application-dependant (obtained
from the RTCC, user-specified, obtained from an SNTP time server, etc).
Certain physical layers may also require you to implement application-specific functions that will be used by those physical
layers.
1.4 Using the Library MLA - File I/O Library Help How the Library Works
12

- 1
- 2
…
- 10
- 11
- 12
- 13
- 14
…
- 82
- 83