Skip to content

Instantly share code, notes, and snippets.

@erichelgeson
Last active September 20, 2023 21:53
Show Gist options
  • Save erichelgeson/138ff8420917e99be57b6ce615f3400b to your computer and use it in GitHub Desktop.
Save erichelgeson/138ff8420917e99be57b6ce615f3400b to your computer and use it in GitHub Desktop.
imhex def
#pragma description HFS Device
// https://github.com/JotaRandom/hfsutils/blob/master/libhfs/apple.h#L27
#pragma endian big
#include <std/time.pat>
using MacOSHFSPlusDate = u32 [[format("::format_macos_date")]];
fn format_macos_date(MacOSHFSPlusDate date) {
return std::time::format(std::time::to_utc(date - 2082844800));
};
enum ddType: u16 {
MacOS = 1
};
struct Block0 {
u16 sbSig; // 0x4552 magic
u16 sbBlkSize; // 512
u32 sbBlkCount;
u16 sbDevType; /* reserved */
u16 sbDevId; /* reserved */
u32 sbData; /* reserved */
u16 sbDrvrCount; /* number of driver descriptor entries */
u32 ddBlock; /* first driver's starting block */
u16 ddSize; /* size of the driver, in 512-byte blocks */
ddType ddType; /* driver operating system type (MacOS = 1) */
padding[486]; /* additional drivers, if any */
};
struct Partition {
u16 pmSig; /* partition signature (0x504d or 0x5453) */
padding[2]; /* reserved */
u32 pmMapBlkCnt; /* number of blocks in partition map */
u32 pmPyPartStart; /* first physical block of partition */
u32 pmPartBlkCnt; /* number of blocks in partition */
char pmPartName[32]; /* partition name */
char pmParType[32]; /* partition type */
u32 pmLgDataStart; /* first logical block of data area */
u32 pmDataCnt; /* number of blocks in data area */
u32 pmPartStatus; /* partition status information */
u32 pmLgBootStart; /* first logical block of boot code */
u32 pmBootSize; /* size of boot code, in bytes */
u32 pmBootAddr; /* boot code load address */
u32 pmBootAddr2; /* reserved */
u32 pmBootEntry; /* boot code entry point */
u32 pmBootEntry2; /* reserved */
u32 pmBootCksum; /* boot code checksum */
char pmProcessor[17];/* processor type */
padding[375]; /* reserved */
};
struct hfs_name {
u8 len;
u8 name[32];
};
struct HFS {
Block0 block0;
Partition pm;
Partition driver;
Partition hfs;
};
HFS hfs @ 0x00;
struct SCSIDriver {
u8 driver[hfs.block0.ddSize * 512];
};
// TO
struct HFSVolume {
u8 volume[(hfs.hfs.pmPartBlkCnt * 512)];
};
SCSIDriver scsidriver @ hfs.block0.ddBlock * 512;
// This takes a long time to evaulate on large devices
//HFSVolume vol @ hfs.hfs.pmPyPartStart * 512;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment