Tugas 6

#include #include #include #include using namespace std; typedef struct { unsigned char first_byte; unsigned char star

Views 133 Downloads 1 File size 24KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

#include #include #include #include

using namespace std; typedef struct { unsigned char first_byte; unsigned char start_chs[3]; unsigned char partition_type; unsigned char end_chs[3]; unsigned long start_sector; unsigned long length_sectors; } __attribute((packed)) PartitionTable;

struct Fat32Entry { unsigned char filename[8]; unsigned char ext[3]; unsigned char attributes; unsigned char reserved[10]; unsigned short modify_time; unsigned short modify_date; unsigned short starting_cluster; unsigned long file_size; };

typedef struct {

unsigned char jmp[3]; char oem[8]; unsigned short sector_size; unsigned char sectors_per_cluster; unsigned short reserved_sectors; unsigned char number_of_fats; unsigned short root_dir_entries; unsigned short total_sectors_short; // jika 0, later field is used unsigned char media_descriptor; unsigned short fat_size_sectors; unsigned short sectors_per_track; unsigned short number_of_heads; unsigned long hidden_sectors; unsigned long total_sectors_long;

unsigned char drive_number; unsigned char current_head; unsigned char boot_signature; unsigned long volume_id; char volume_label[11]; char fs_type[8]; char boot_code[448]; unsigned short boot_sector_signature; } __attribute((packed)) Fat32BootSector;

void baca_struktur(){ FILE *in=fopen("G:\\","rb");

int i; PartitionTable pt[4]; Fat32BootSector bs; struct

Fat32Entry entry ;

fseek(in, 0x00, SEEK_SET); // menuju partition table start

fread(&bs, sizeof(Fat32BootSector), 1, in); printf("\n"); printf(" Struktur File system"); printf("\n"); printf("\n"); printf(" Kode jump: %02X:%02X:%02X\n", bs.jmp[0], bs.jmp[1], bs.jmp[2]); //printf(" Kode OEM: [%.8s]\n", bs.oem); printf(" Sector size: %d\n", bs.sector_size); printf(" Sectors per Cluster: %d\n", bs.sectors_per_cluster); printf(" Reserved Sectors: %d\n", bs.reserved_sectors); printf(" Number of Fats: %d\n", bs.number_of_fats); printf(" Root directory Entries: %d\n", bs.root_dir_entries); printf(" Total Sectors Short: %d\n", bs.total_sectors_short); printf(" Media Descriptor: 0x%02X\n", bs.media_descriptor); printf(" Fat Size Sectors: %d\n", bs.fat_size_sectors); printf(" Sectors Per Track: %d\n", bs.sectors_per_track); printf(" Number of Heads: %d\n", bs.number_of_heads); printf(" Hidden Sectors: %d\n", bs.hidden_sectors); printf(" Total Sectors Long: %d\n", bs.total_sectors_long); printf(" Drive Number: 0x%02X\n", bs.drive_number);

printf(" Current Head: 0x%02X\n", bs.current_head); printf(" Boot Signature: 0x%02X\n", bs.boot_signature); printf(" Volume id: 0x%08X\n", bs.volume_id); printf(" Volume label: [%.11s]\n", bs.volume_label); printf(" Filesystem type: [%.8s]\n", bs.fs_type); printf(" Boot sector signature: 0x%04X\n", bs.boot_sector_signature); }

void baca_filesystem(){ LPCTSTR szHD = "G:\\";; UCHAR szFileSys[255],szVolNameBuff[255]; DWORD dwSerial,dwMFL,dwSysFlags; GetVolumeInformation(szHD, (LPTSTR)szVolNameBuff,255,&dwSerial,&dwMFL,&dwSysFlags, (LPTSTR)szFileSys,255);

if(szVolNameBuff[0] == 0) cout