Compare commits
11 Commits
v3.8.2-bin
...
v3.11-bina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c2d0f087 | ||
|
|
e63dfea9dd | ||
|
|
99dd26dbd4 | ||
|
|
a723c2c844 | ||
|
|
89fd3d1fce | ||
|
|
666b979724 | ||
|
|
c2401e5dc5 | ||
|
|
0d998455fa | ||
|
|
b98647d3f2 | ||
|
|
d9aa07aef2 | ||
|
|
46fa56327e |
BIN
BOOTIA32.EFI
BIN
BOOTIA32.EFI
Binary file not shown.
BIN
BOOTX64.EFI
BIN
BOOTX64.EFI
Binary file not shown.
Binary file not shown.
BIN
limine-cd.bin
BIN
limine-cd.bin
Binary file not shown.
@@ -316,34 +316,49 @@ static bool _device_write(const void *_buffer, uint64_t loc, size_t count) {
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
static void usage(const char *name) {
|
||||
printf("Usage: %s <device> [GPT partition index]\n", name);
|
||||
#ifdef IS_WINDOWS
|
||||
system("pause");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ok = EXIT_FAILURE;
|
||||
int force_mbr = 0;
|
||||
const uint8_t *bootloader_img = binary_limine_hdd_bin_data;
|
||||
size_t bootloader_file_size = sizeof(binary_limine_hdd_bin_data);
|
||||
uint8_t orig_mbr[70], timestamp[6];
|
||||
const char *part_ndx = NULL;
|
||||
|
||||
uint32_t endcheck = 0x12345678;
|
||||
uint8_t endbyte = *((uint8_t *)&endcheck);
|
||||
bigendian = endbyte == 0x12;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s <device> [GPT partition index]\n", argv[0]);
|
||||
#ifdef IS_WINDOWS
|
||||
system("pause");
|
||||
#endif
|
||||
usage(argv[0]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
if (strcmp(argv[2], "--force-mbr") == 0) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "--force-mbr") == 0) { // TODO: add to usage
|
||||
if (force_mbr) {
|
||||
puts("Warning: --force-mbr already set");
|
||||
}
|
||||
force_mbr = 1;
|
||||
} else {
|
||||
if (device != NULL) { // [GPT partition index]
|
||||
part_ndx = argv[i]; // TODO: Make this non-positional?
|
||||
} else if ((device = fopen(argv[i], "r+b")) == NULL) { // <device>
|
||||
perror("ERROR");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
device = fopen(argv[1], "r+b");
|
||||
if (device == NULL) {
|
||||
perror("ERROR");
|
||||
fprintf(stderr, "ERROR: No device specified\n");
|
||||
usage(argv[0]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -481,6 +496,15 @@ int main(int argc, char *argv[]) {
|
||||
device_write(hintc, 4, 8);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 3, 4);
|
||||
if (memcmp(hintc, "NTFS", 4) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 4);
|
||||
device_write(hintc, 3, 4);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 54, 3);
|
||||
if (memcmp(hintc, "FAT", 3) == 0) {
|
||||
if (!force_mbr) {
|
||||
@@ -499,6 +523,15 @@ int main(int argc, char *argv[]) {
|
||||
device_write(hintc, 82, 5);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 3, 5);
|
||||
if (memcmp(hintc, "FAT32", 5) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 5);
|
||||
device_write(hintc, 3, 5);
|
||||
}
|
||||
}
|
||||
device_read(&hint16, 1080, sizeof(uint16_t));
|
||||
hint16 = ENDSWAP(hint16);
|
||||
if (hint16 == 0xef53) {
|
||||
@@ -522,9 +555,8 @@ int main(int argc, char *argv[]) {
|
||||
if (gpt == 0 && mbr == 0) {
|
||||
fprintf(stderr, "ERROR: Could not determine if the device has a valid partition table.\n");
|
||||
fprintf(stderr, " Please ensure the device has a valid MBR or GPT.\n");
|
||||
fprintf(stderr, " Alternatively, pass `--force-mbr` at the end of the command to\n");
|
||||
fprintf(stderr, " override these checks. ONLY DO THIS AT YOUR OWN RISK, DATA LOSS\n");
|
||||
fprintf(stderr, " MAY OCCUR!\n");
|
||||
fprintf(stderr, " Alternatively, pass `--force-mbr` to override these checks.\n");
|
||||
fprintf(stderr, " **ONLY DO THIS AT YOUR OWN RISK, DATA LOSS MAY OCCUR!**\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -540,9 +572,9 @@ int main(int argc, char *argv[]) {
|
||||
uint64_t stage2_loc_b = stage2_loc_a + stage2_size_a;
|
||||
|
||||
if (gpt) {
|
||||
if (argc >= 3) {
|
||||
if (part_ndx != NULL) {
|
||||
uint32_t partition_num;
|
||||
sscanf(argv[2], "%" SCNu32, &partition_num);
|
||||
sscanf(part_ndx, "%" SCNu32, &partition_num);
|
||||
partition_num--;
|
||||
if (partition_num > ENDSWAP(gpt_header.number_of_partition_entries)) {
|
||||
fprintf(stderr, "ERROR: Partition number is too large.\n");
|
||||
|
||||
Binary file not shown.
3059
limine-hdd.h
3059
limine-hdd.h
File diff suppressed because it is too large
Load Diff
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.sys
BIN
limine.sys
Binary file not shown.
Reference in New Issue
Block a user