BOOL AnalyzePBR(HANDLE hLogicalVolume) { const char* pbr_name = "Partition Boot Record"; FAKE_FD fake_fd = { 0 }; FILE* fp = (FILE*)&fake_fd; int i; fake_fd._handle = (char*)hLogicalVolume; set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); if (!is_br(fp)) { uprintf("Volume does not have an x86 %s\n", pbr_name); return FALSE; } if (is_fat_16_br(fp) || is_fat_32_br(fp)) { for (i=0; i<ARRAYSIZE(known_pbr); i++) { if (known_pbr[i].fn(fp)) { uprintf("Drive has a %s %s\n", known_pbr[i].str, pbr_name); return TRUE; } } uprintf("Volume has an unknown FAT16 or FAT32 %s\n", pbr_name); } else { uprintf("Volume has an unknown %s\n", pbr_name); } return TRUE; }
// Returns TRUE if the drive seems bootable, FALSE otherwise BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) { const char* mbr_name = "Master Boot Record"; FILE fake_fd = { 0 }; int i; fake_fd._ptr = (char*)hPhysicalDrive; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; // Might need correction, as we use this method for images and we may not have a target UFD yet if (fake_fd._bufsiz < 512) fake_fd._bufsiz = 512; if (!is_br(&fake_fd)) { uprintf("%s does not have an x86 %s\n", TargetName, mbr_name); return FALSE; } for (i=0; i<ARRAYSIZE(known_mbr); i++) { if (known_mbr[i].fn(&fake_fd)) { uprintf("%s has a %s %s\n", TargetName, known_mbr[i].str, mbr_name); return TRUE; } } uprintf("%s has an unknown %s\n", TargetName, mbr_name); return TRUE; }
BOOL AnalyzePBR(HANDLE hLogicalVolume) { const char* pbr_name = "Partition Boot Record"; FILE fake_fd = { 0 }; int i; fake_fd._ptr = (char*)hLogicalVolume; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; if (!is_br(&fake_fd)) { uprintf("Volume does not have an x86 %s\n", pbr_name); return FALSE; } if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) { for (i=0; i<ARRAYSIZE(known_pbr); i++) { if (known_pbr[i].fn(&fake_fd)) { uprintf("Drive has a %s %s\n", known_pbr[i].str, pbr_name); return TRUE; } } uprintf("Volume has an unknown FAT16 or FAT32 %s\n", pbr_name); } else { uprintf("Volume has an unknown %s\n", pbr_name); } return TRUE; }
// TODO: use an (fn,str) table and simplify this whole thing BOOL AnalyzePBR(HANDLE hLogicalVolume) { FILE fake_fd = { 0 }; fake_fd._ptr = (char*)hLogicalVolume; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; if (!is_br(&fake_fd)) { uprintf("Volume does not have an x86 partition boot record\n"); return FALSE; } if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) { if (entire_fat_16_br_matches(&fake_fd)) { uprintf("Drive has a FAT16 DOS partition boot record\n"); } else if (entire_fat_16_fd_br_matches(&fake_fd)) { uprintf("Drive has a FAT16 FreeDOS partition boot record\n"); } else if (entire_fat_16_ros_br_matches(&fake_fd)) { uprintf("Drive has a FAT16 ReactOS partition boot record\n"); } else if (entire_fat_32_br_matches(&fake_fd)) { uprintf("Drive has a FAT32 DOS partition boot record\n"); } else if (entire_fat_32_nt_br_matches(&fake_fd)) { uprintf("Drive has a FAT32 NT partition boot record\n"); } else if (entire_fat_32_fd_br_matches(&fake_fd)) { uprintf("Drive has a FAT32 FreeDOS partition boot record\n"); } else if (entire_fat_32_ros_br_matches(&fake_fd)) { uprintf("Drive has a FAT32 ReactOS partition boot record\n"); } else { uprintf("Drive has an unknown FAT16 or FAT32 partition boot record\n"); } } else { uprintf("Drive has an unknown partition boot record\n"); } return TRUE; }
int is_syslinux_mbr(FILE *fp) { #include "mbr_syslinux.h" return contains_data(fp, 0x0, mbr_syslinux_0x0, sizeof(mbr_syslinux_0x0)) && is_br(fp); } /* is_syslinux_mbr */
int is_dos_f2_mbr(FILE *fp) { #include "mbr_dos_f2.h" return contains_data(fp, 0x0, mbr_dos_f2_0x0, sizeof(mbr_dos_f2_0x0)) && is_br(fp); } /* is_dos_f2_mbr */
int is_grub4dos_mbr(FILE *fp) { #include "mbr_grub.h" return contains_data(fp, 0x0, mbr_grub_0x0, sizeof(mbr_grub_0x0)) && is_br(fp); } /* is_grub_mbr */
int is_kolibrios_mbr(FILE *fp) { #include "mbr_kolibri.h" return contains_data(fp, 0x0, mbr_kolibri_0x0, sizeof(mbr_kolibri_0x0)) && is_br(fp); } /* is_kolibri_mbr */
int is_reactos_mbr(FILE *fp) { #include "mbr_reactos.h" return contains_data(fp, 0x0, mbr_reactos_0x0, sizeof(mbr_reactos_0x0)) && is_br(fp); } /* is_reactos_mbr */
int is_win7_mbr(FILE *fp) { #include "mbr_win7.h" return contains_data(fp, 0x0, mbr_win7_0x0, MBR_WIN7_LANG_INDEP_LEN) && is_br(fp); } /* is_win7_mbr */
int is_vista_mbr(FILE *fp) { #include "mbr_vista.h" return contains_data(fp, 0x0, mbr_vista_0x0, MBR_VISTA_LANG_INDEP_LEN) && is_br(fp); } /* is_vista_mbr */
int is_2000_mbr(FILE *fp) { #include "mbr_2000.h" return contains_data(fp, 0x0, mbr_2000_0x0, MBR_2000_LANG_INDEP_LEN) && is_br(fp); } /* is_2000_mbr */
int is_95b_mbr(FILE *fp) { #include "mbr_95b.h" return contains_data(fp, 0x0, mbr_95b_0x0, sizeof(mbr_95b_0x0)) && contains_data(fp, 0x0e0, mbr_95b_0x0e0, sizeof(mbr_95b_0x0e0)) && is_br(fp); } /* is_95b_mbr */
// Returns TRUE if the drive seems bootable, FALSE otherwise BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) { const char* mbr_name = "Master Boot Record"; FILE fake_fd = { 0 }; int i; fake_fd._ptr = (char*)hPhysicalDrive; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; if (!is_br(&fake_fd)) { uprintf("%s does not have an x86 %s\n", TargetName, mbr_name); return FALSE; } for (i=0; i<ARRAYSIZE(known_mbr); i++) { if (known_mbr[i].fn(&fake_fd)) { uprintf("%s has a %s %s\n", TargetName, known_mbr[i].str, mbr_name); return TRUE; } } uprintf("%s has an unknown %s\n", TargetName, mbr_name); return TRUE; }
// Returns TRUE if the drive seems bootable, FALSE otherwise BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) { const char* mbr_name = "Master Boot Record"; FAKE_FD fake_fd = { 0 }; FILE* fp = (FILE*)&fake_fd; int i; fake_fd._handle = (char*)hPhysicalDrive; set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); if (!is_br(fp)) { uprintf("%s does not have an x86 %s\n", TargetName, mbr_name); return FALSE; } for (i=0; i<ARRAYSIZE(known_mbr); i++) { if (known_mbr[i].fn(fp)) { uprintf("%s has a %s %s\n", TargetName, known_mbr[i].str, mbr_name); return TRUE; } } uprintf("%s has an unknown %s\n", TargetName, mbr_name); return TRUE; }
void diagnose(FILE *fp, const char *szPath) { if(is_fat_12_fs(fp)) printf(_("%s has a FAT12 file system.\n"), szPath); if(is_fat_16_fs(fp)) printf(_("%s has a FAT16 file system.\n"), szPath); if(is_fat_32_fs(fp)) printf(_("%s has a FAT32 file system.\n"), szPath); if(is_ntfs_fs(fp)) printf(_("%s has a NTFS file system.\n"), szPath); if(is_br(fp)) printf(_("%s has an x86 boot sector,\n"), szPath); else { printf(_("%s has no x86 boot sector\n"), szPath); return; } if(entire_ntfs_br_matches(fp)) { printf( _("it is exactly the kind of NTFS boot record this program\n")); printf( _("would create with the switch -n on a NTFS partition.\n")); } else if(entire_fat_12_br_matches(fp)) { printf( _("it is exactly the kind of FAT12 boot record this program\n")); printf( _("would create with the switch -1 on a floppy.\n")); } else if(is_fat_16_br(fp) || is_fat_32_br(fp)) { if(entire_fat_16_br_matches(fp)) { printf( _("it is exactly the kind of FAT16 DOS boot record this program\n")); printf( _("would create with the switch -6 on a FAT16 partition.\n")); } else if(entire_fat_16_fd_br_matches(fp)) { printf( _("it is exactly the kind of FAT16 FreeDOS boot record this program\n")); printf( _("would create with the switch -5 on a FAT16 partition.\n")); } else if(entire_fat_32_br_matches(fp)) { printf( _("it is exactly the kind of FAT32 DOS boot record this program\n")); printf( _("would create with the switch -3 on a FAT32 partition.\n")); } else if(entire_fat_32_nt_br_matches(fp)) { printf( _("it is exactly the kind of FAT32 NT boot record this program\n")); printf( _("would create with the switch -2 on a FAT32 partition.\n")); } else if(entire_fat_32_fd_br_matches(fp)) { printf( _("it is exactly the kind of FAT32 FreeDOS boot record this program\n")); printf( _("would create with the switch -4 on a FAT32 partition.\n")); } else { printf( _("it seems to be a FAT16 or FAT32 boot record, but it\n")); printf( _("differs from what this program would create with the\n")); printf(_("switch -6, -2 or -3 on a FAT16 or FAT32 partition.\n")); } } else if(is_lilo_br(fp)) { printf(_("it seems to be a LILO boot record, please use lilo to\n")); printf(_("create such boot records.\n")); } else if(is_dos_mbr(fp)) { printf( _("it is a Microsoft DOS/NT/95A master boot record, like the one this\n")); printf( _("program creates with the switch -d on a hard disk device.\n")); } else if(is_dos_f2_mbr(fp)) { printf( _("it is a Microsoft DOS/NT/95A master boot record with the undocumented\n")); printf( _("F2 instruction. You will get equal functionality with the MBR this\n")); printf( _("program creates with the switch -d on a hard disk device.\n")); } else if(is_95b_mbr(fp)) { printf( _("it is a Microsoft 95B/98/98SE/ME master boot record, like the one this\n")); printf( _("program creates with the switch -9 on a hard disk device.\n")); } else if(is_2000_mbr(fp)) { printf( _("it is a Microsoft 2000/XP/2003 master boot record, like the one this\n")); printf( _("program creates with the switch -m on a hard disk device.\n")); } else if(is_vista_mbr(fp)) { printf( _("it is a Microsoft Vista master boot record, like the one this\n")); printf( _("program creates with the switch -i on a hard disk device.\n")); } else if(is_win7_mbr(fp)) { printf( _("it is a Microsoft 7 master boot record, like the one this\n")); printf( _("program creates with the switch -7 on a hard disk device.\n")); } else if(is_syslinux_mbr(fp)) { printf( _("it is a public domain syslinux master boot record, like the one this\n")); printf( _("program creates with the switch -s on a hard disk device.\n")); } else if(is_syslinux_gpt_mbr(fp)) { printf( _("it is a GPL syslinux GPT master boot record, like the one this\n")); printf( _("program creates with the switch -t on a hard disk device.\n")); } else if(is_zero_mbr(fp)) { printf( _("it is a zeroed non-bootable master boot record, like the one this\n")); printf( _("program creates with the switch -z on a hard disk device.\n")); } else printf(_("it is an unknown boot record\n")); } /* diagnose */