X-Git-Url: https://git.wh0rd.org/?p=ICEs.git;a=blobdiff_plain;f=568732%2Fwritepart.c;fp=568732%2Fwritepart.c;h=725b2b1039d6ba920259ad590ce0a6570cbbad1f;hp=0000000000000000000000000000000000000000;hb=bd3239d2bbe0de3a200b266503e3330b1e391489;hpb=dbff64cb4b7530861c2309c794efdd4e0cf47a23 diff --git a/568732/writepart.c b/568732/writepart.c new file mode 100644 index 0000000..725b2b1 --- /dev/null +++ b/568732/writepart.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +struct apartition { + unsigned char flag; + char id[3]; + uint32_t start; + uint32_t size; +} __attribute__((packed)); +struct rootsector { + char unused[0x156]; + struct apartition icdpart[8]; + char unused2[0xc]; + struct apartition part[4]; +} __attribute__((packed)); +typedef struct _PARTITION { + unsigned long start; + char id[4]; + unsigned long rootsec; +} PARTITION; +int partitions; +PARTITION part_table[64]; +static void PART2diskpart(PARTITION * cp, struct apartition *dp, + unsigned long relto) +{ + memcpy(dp->id, cp->id, 3); +} + +void put_boot(int first_ext, int last_ext, PARTITION * master_XGM) +{ + char buffer[sizeof(struct rootsector)]; + struct rootsector *rs = (struct rootsector *)buffer; + struct apartition *pi; + int i, bootable; + PARTITION cont_XGM; + pi = &rs->part[0]; + for (i = 0; i < partitions; ++i) { + if (i == first_ext) { + PART2diskpart(master_XGM, pi, 0); + PART2diskpart(&part_table[i], &rs->part[0], + part_table[i].rootsec); + if (i == last_ext) { + PART2diskpart(&cont_XGM, &rs->part[1], + master_XGM->start); + } + } + } +} + +main() { + printf("%i\n", sizeof(struct rootsector)); + printf("%i %i\n", offsetof(struct rootsector, part[0])); +}