Writing program to hide partition
The program given next is used to hide the partition using the partition entry of that partition from partition table of MBR. If you want to hide other logical partitions in the extended volume you should access the extended MBRs.
The coding of the program has been given next:
/* Program to hide the partition using Partition table entry of that Partition from MBR */
#include <bios.h>
#include <stdio.h>
int main(void)
{
struct diskinfo_t dinfo;
int result, tohide;
int i;
static char dbuf[512];/* Data Buffer to read-Write the
Sector information */
clrscr();
dinfo.drive = 0x80; /* drive number for First
Hard Disk */
dinfo.head = 0; /* disk head number */
dinfo.track = 0; /* track number */
dinfo.sector = 1; /* sector number */
dinfo.nsectors = 1; /* sector count */
dinfo.buffer = dbuf; /* data buffer */
/* Read the First Sector of the Disk */
result = _bios_disk(_DISK_READ, &dinfo);
if ((result & 0xff00) == 0)
{
printf("The Partition Codes of Four Partition Entries are,
0x%02x, 0x%02x, 0x%02x And 0x%02x.\n",
dbuf[450] & 0xff, dbuf[466] & 0xff,
dbuf[482] & 0xff, dbuf[498] & 0xff);
textcolor(15);
gotoxy(5,5);cprintf("Partition Entry in MBR is as
follows:");
gotoxy(10,7);cprintf("1. "); showtype(dbuf[450] & 0xff);
gotoxy(10,8);cprintf("2. "); showtype(dbuf[466] & 0xff);
gotoxy(10,9);cprintf("3. "); showtype(dbuf[482] & 0xff);
gotoxy(10,10);cprintf("4. "); showtype(dbuf[498] & 0xff);
/* get the User Input for Hiding the Partition */
gotoxy(1,15);
printf("Enter The partition no. you want to hide,
Or Press any other key to Exit... ");
tohide=getche();
switch(tohide)
{
case '1': /* Hide First Partition in partition Table */
dbuf[450] = dbuf[450] +16;
result = _bios_disk(_DISK_WRITE, &dinfo);
break;
case '2': /* Hide second Partition in partition Table */
dbuf[466] = dbuf[466]+16;
result = _bios_disk(_DISK_WRITE, &dinfo);
break;
case '3': /* Hide third Partition in partition Table */
dbuf[482] = dbuf[482] +16;
result = _bios_disk(_DISK_WRITE, &dinfo);
break;
case '4': /* Hide Fourth Partition in partition Table */
dbuf[498] = dbuf[498]+16;
result = _bios_disk(_DISK_WRITE, &dinfo);
break;
default:
exit(0);
}
if ((result & 0xff00) == 0)
{
printf("\n\nThe New Partition Codes of Four Partition
Entries are, 0x%02x, 0x%02x, 0x%02x And 0x%02x.\n",
dbuf[450] & 0xff, dbuf[466] & 0xff,
dbuf[482] & 0xff, dbuf[498] & 0xff);
getch();
}
else
{
printf("Cannot Change the Byte, status = 0x%02x\n",
result);
getch();
}
}
return 0;
}
Comments on coding:
The program reads file system indicator bytes of all four partition entries in partition table of MBR. The function showtype( ) is used to show the name of file system for the corresponding value of file system indicator byte.
The user selects the partition to hide from the menu displayed on the screen and then 16 (0x10) is added to the value of file system indicator byte of that partition to hide it.
The coding of the function showtype( ) is as follows:
/* Function to show the name of file system corresponding to the value of file system indicator byte */
showtype(i)
{
switch (i)
{
case 0x00 :cprintf("Empty"); break;
case 0x01 :cprintf("DOS 12-bit FAT"); break;
case 0x02 :cprintf("XENIX root"); break;
case 0x03 :cprintf("XENIX usr"); break;
case 0x04 :cprintf("DOS 16-bit <32M"); break;
case 0x05 :cprintf("Extended"); break;
case 0x06 :cprintf("DOS 16-bit >=32M"); break;
case 0x07 :cprintf("OS/2 HPFS"); break;
case 0x08 :cprintf("AIX"); break;
case 0x09 :cprintf("AIX bootable"); break;
case 0xa :cprintf("OS/2 Boot Manag"); break;
case 0xb :cprintf("Win95/98/ME FAT32"); break;
case 0xc :cprintf("Win95/98/ME FAT32 (LBA)"); break;
case 0xd :cprintf("Win95 FAT16"); break;
case 0xe :cprintf("Win95 FAT16 (LBA)"); break;
case 0xf :cprintf("Win95 Extended"); break;
case 0x11 :cprintf("Hidden FAT-12");break;
case 0x12 :cprintf("Compaq Diagnostics");break;
case 0x14 :cprintf("Hidden FAT-16 (<32)");break;
case 0x15 :cprintf("Hidden Extended");break;
case 0x16 :cprintf("Hidden FAT-16");break;
case 0x17 :cprintf("NTFS"); break;
case 0x40 :cprintf("Venix 80286"); break;
case 0x51 :cprintf("Novell?"); break;
case 0x52 :cprintf("Microport"); break;
case 0x63 :cprintf("GNU HURD"); break;
case 0x64 :
case 0x65 :cprintf("Novell Netware"); break;
case 0x75 :cprintf("PC/IX"); break;
case 0x80 :cprintf("Old MINIX"); break;
case 0x81 :cprintf("Linux/MINIX"); break;
case 0x82 :cprintf("Linux swap"); break;
case 0x83 :cprintf("Linux native"); break;
case 0x85 :cprintf("Linux Extended"); break;
case 0x93 :cprintf("Amoeba"); break;
case 0x94 :cprintf("Amoeba BBT"); break;
case 0xa5 :cprintf("BSD/386"); break;
case 0xa6 :cprintf("OpenBSD"); break;
case 0xa7 :cprintf("NEXTSTEP"); break;
case 0xb7 :cprintf("BSDI fs"); break;
case 0xb8 :cprintf("BSDI swap"); break;
case 0xc7 :cprintf("Syrinx"); break;
case 0xdb :cprintf("CP/M"); break;
case 0xe1 :cprintf("DOS access"); break;
case 0xe3 :cprintf("DOS R/O"); break;
case 0xf2 :cprintf("DOS secondary"); break;
case 0xff :cprintf("BBT"); break;
default :cprintf("UNKOWN");
}
return 0;
}
|
page 1 | 2 | 3 | 4 | 5 | 6 |
|
|
|