Exemplo n.º 1
0
int check_FAT(disk_t *disk_car,partition_t *partition,const int verbose)
{
    unsigned char *buffer;
    buffer=(unsigned char *)MALLOC(3*disk_car->sector_size);
    if((unsigned)disk_car->pread(disk_car, buffer, 3 * disk_car->sector_size, partition->part_offset) != 3 * disk_car->sector_size)
    {
        screen_buffer_add("check_FAT: can't read FAT boot sector\n");
        log_error("check_FAT: can't read FAT boot sector\n");
        free(buffer);
        return 1;
    }
    if(test_FAT(disk_car,(const struct fat_boot_sector *)buffer,partition,verbose,0)!=0)
    {
        if(verbose>0)
        {
            log_error("\n\ntest_FAT()\n");
            log_partition(disk_car,partition);
            log_fat_info((const struct fat_boot_sector*)buffer, partition->upart_type,disk_car->sector_size);
        }
        free(buffer);
        return 1;
    }
    set_FAT_info(disk_car,(const struct fat_boot_sector *)buffer,partition);
    /*  screen_buffer_add("Ok\n"); */
    free(buffer);
    return 0;
}
Exemplo n.º 2
0
void ToGetDBR(char* p_file, long l_size, LCN offset)
{
	long i = 0;
	char *buf	= NULL;
	char *temp	= NULL;
	LCN ll_offset = 0;
	
	do 
	{
		buf = p_file + i * SECTOR_SIZE;
		if (!test_NTFS((ntfs_boot_sector*)buf, offset + i * SECTOR_SIZE))
		{
			ll_offset = offset + (i * SECTOR_SIZE);

			temp = (char*)malloc(512);
			memcpy(temp, buf, 512);
			if (InsertDBRList(g_dbr_list_head, temp, 1, g_n_dbr, ll_offset))    // NTFS type is 1)
			{
				//printf ("Found NTFS! AT %lld sectors\n", ll_offset / SECTOR_SIZE);
			}
			ll_offset = 0;
			temp = NULL;
		}
		if(!test_FAT((fat_boot_sector*)buf, offset + i * SECTOR_SIZE))
		{
			ll_offset = offset + (i * SECTOR_SIZE);

			temp = (char*)malloc(512);
			memcpy(temp, buf, 512);
			if (InsertDBRList(g_dbr_list_head, temp, 2, g_n_dbr, ll_offset))    // NTFS type is 2)
			{
				//printf("Found FAT! AT %lld sectors\n", ll_offset / SECTOR_SIZE);
			}
			ll_offset = 0;
			temp = NULL;
		}
		i++;
	} while (i * SECTOR_SIZE < l_size);
}