start packing some binary image structures

This commit is contained in:
2025-02-01 22:12:46 +00:00
parent 4f3fe09440
commit fea949f1f4
2 changed files with 58 additions and 40 deletions

View File

@@ -2,6 +2,7 @@
#define BIN_H_
#include <blue/core/endian.h>
#include "misc.h"
#define EC3_SIGNATURE 0x45433358
@@ -34,7 +35,7 @@
#define EC3_TAG_ENCRYPTED 0x00000004u
/* 32K per cluster group */
#define EC3_CLUSTERS_PER_GROUP 1635
#define EC3_CLUSTERS_PER_GROUP 1637
/* 1K per extent group */
#define EC3_EXTENTS_PER_GROUP 36
@@ -67,47 +68,52 @@
typedef uint8_t ec3_chunk_id[EC3_CHUNK_ID_SIZE];
struct ec3_header {
b_i32 h_magic;
b_i16 h_version;
b_i16 h_cluster_size;
b_i64 h_tag_table_offset;
b_i64 h_extent_table_offset;
b_i64 h_cluster_table_offset;
b_i32 h_tag_count;
b_i32 h_extent_count;
b_i32 h_cluster_group_count;
b_i16 h_compression;
b_i16 h_encryption;
b_i64 h_app_magic;
uint8_t h_reserved[8];
};
PACK(
struct ec3_header {
b_i32 h_magic;
b_i16 h_version;
b_i16 h_cluster_size;
b_i64 h_tag_table_offset;
b_i64 h_extent_table_offset;
b_i64 h_cluster_table_offset;
b_i32 h_tag_count;
b_i32 h_extent_count;
b_i32 h_cluster_group_count;
b_i16 h_compression;
b_i16 h_encryption;
b_i64 h_app_magic;
uint8_t h_reserved[8];
}
);
struct ec3_cluster {
/* cluster identifier */
b_i32 c_id;
/* lower 32-bits of the cluster bounds */
b_i32 c_bounds0;
/* upper 32-bits of the cluster bounds */
b_i32 c_bounds1;
/* CRC-16 of the on-disk cluster data */
b_i16 c_checksum;
/* flags that apply to this cluster */
b_i16 c_flags;
};
PACK(
struct ec3_cluster {
/* cluster identifier */
b_i32 c_id;
/* lower 32-bits of the cluster bounds */
b_i32 c_bounds0;
/* upper 32-bits of the cluster bounds */
b_i32 c_bounds1;
/* CRC-16 of the on-disk cluster data */
b_i16 c_checksum;
/* flags that apply to this cluster */
b_i16 c_flags;
}
);
struct ec3_cluster_group {
/* the number of clusters that this group contains */
b_i16 g_nr_clusters;
uint8_t g_reserved[2];
/* array of clusters contained within the group. */
struct ec3_cluster g_clusters[EC3_CLUSTERS_PER_GROUP];
/* offsets to other cluster groups, relative to the start of the
* cluster group table. the cluster groups form a B-tree. */
b_i32 g_child_offsets[EC3_CLUSTERS_PER_GROUP + 1];
/* pad the group out to an even 32K */
uint8_t g_padding[20];
};
PACK(
struct ec3_cluster_group {
/* the number of clusters that this group contains */
b_i16 g_nr_clusters;
uint8_t g_reserved[2];
/* array of clusters contained within the group. */
struct ec3_cluster g_clusters[EC3_CLUSTERS_PER_GROUP];
/* offsets to other cluster groups, relative to the start of the
* cluster group table. the cluster groups form a B-tree. */
b_i32 g_child_offsets[EC3_CLUSTERS_PER_GROUP + 1];
uint8_t g_padding[20];
}
);
struct ec3_tag_table_entry {
b_i32 tag_type;

12
src/misc.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef MISC_H_
#define MISC_H_
#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif
#endif