whiskers 0.2.0
RP2350 BadUSB Tool
Loading...
Searching...
No Matches
pub_disk.h File Reference

Detailed Description

High-level code for creating a "fake" public-facing disk.

Author
zane

This setup essentially just creates a file on disk that is exposed via the MSC to the host. This newly created disk is saved under PUBDISK_FILENAME and can be copied from device to device. The disk size must be a minimum of 8kb and must be divisible by the sector_size of the fake disk. Note that the code will not automatically find the sector size or sector count and it must be configured through the create_pubdisk() function.

#include "../../hal/file.h"
#include "../../hal/shared.h"

Go to the source code of this file.

Macros

#define PUBDISK_FILENAME   "pubdisk.vdisk"
 The filename in the root directory of the SD card for the virtual disk. This can be anything you want but I keep the .vdisk for the sake of readability.

Functions

bool create_pubdisk (_DISK_INFO *di, uint32_t sector_size, uint32_t sector_count)
 Creates a pubdisk _DISK_INFO object and creates the file if it doesn't already exist.

Function Documentation

◆ create_pubdisk()

bool create_pubdisk ( _DISK_INFO * di,
uint32_t sector_size,
uint32_t sector_count )

Creates a pubdisk _DISK_INFO object and creates the file if it doesn't already exist.

Parameters
*diPointer to a blank _DISK_INFO struct to store the resulting info. This must be passed into the MSC setup for it to be usable. By default, the disk is mounted and writable.
sector_sizeSize of the sector in bytes. Must be a multiple of 512 and no lower than 512.
sector_countNumber of sectors.
Returns
True on succesfully creating/find the file, and false on not being able to. Errno in *di is set on failure.

Note that the disk size must be atleast 8kb. The size of the disk is simply sector_size*sector_count. By default, the user must format the disk and can format it with whatever filesystem they want or some variation of FAT.