123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Partition Hiding Software in C,

--------------------------------------------------------------------------------

Description : This program reads partition table of hard disk and collect informations about the various partitions ,to hide a partition it changes the system id of that partition ,so that window will not show you that partition

Code :
/* program to read the partition table of hard disk and can hide and
revele partitions*/
/*
Release date: 1.1.2006

Author: Tapan Kumar Mishra
7th sem ,Electrical Engg.
IGIT Sarang,Orissa
mailid:titu_igit@rediffmail.com

About the program:

This program is a part of my project to read ext2 linux file system
under dos or win98.This program read the partition table of ur hard
disk
and print the informations about it,and can hide and revele the
partitions
by changing the systemid of that partions.

Caution: Modification of the code may leave your disk unusable.
The author is not responsible for any damage or dataloss.

This program is tested under win98.
compile it by Turbo c3
Any comment,feedback,query mail to titu_igit@rediffmail.com
*/

#include<stdio.h>
#include<bios.h>
#include<dos.h>
#include<stdlib.h>

typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;

enum BOOL {TRUE=0,FALSE=1};
struct PARTITIONINFO {
BYTE bootid; /* bootable? 0=no, 128=yes */
BYTE beghead; /* beginning head number */
BYTE begsect; /* beginning sector number */
BYTE begcyl; /* 10 bit nmbr, with high 2 bits put in begsect */
BYTE systid; /* Operating System type indicator code */
BYTE endhead; /* ending head number */
BYTE endsect; /* ending sector number */
BYTE endcyl; /* also a 10 bit nmbr, with same high 2 bit trick */
DWORD relsect; /* first sector relative to start of disk */
DWORD numsect; /* number of sectors in partition */
};

struct DISK_ADD_PACKET {
BYTE recordsize;
BYTE reserved;
WORD count;
DWORD transferadd;
DWORD lowbits;
DWORD highbits;
};
struct MBR{
BYTE codes[446];
struct PARTITIONINFO partition[4];
WORD mbrid;
};
struct driveinfo{
DWORD startsect;
BYTE sysid;
};
WORD ExtentionCheck (BYTE drive)
{
union REGS regs;
regs.h.ah = 0x41;
regs.x.bx = 0x55aa;
regs.h.dl = drive;
int86(0x13,®s,®s);
if(regs.x.bx != 0xaa55)
return FALSE;
return TRUE;
}

WORD ReadSect(BYTE disk, int nsects,DWORD lsects,void* data)
{

union REGS iregs,oregs;
struct SREGS sregs;
int count=0;
struct DISK_ADD_PACKET * p;
p = (struct DISK_ADD_PACKET *)malloc(sizeof(struct DISK_ADD_PACKET));
p->recordsize=sizeof(struct DISK_ADD_PACKET);
p->count=nsects;
p->transferadd=(DWORD)data;
p->lowbits=lsects;
p->highbits=0; /* We dont need to access HD > 2TB */
iregs.h.ah = 0x42;
iregs.h.dl = disk;
iregs.x.si = FP_OFF(p);
sregs.ds = FP_SEG(p);
int86x(0x13,&iregs,&oregs,&sregs);
if(oregs.h.ah==0)
{
free(p);
return TRUE;
}

free(p);
return FALSE;

}
WORD WriteSect(BYTE disk, int nsects,DWORD lsects,void* data)
{

union REGS iregs,oregs;
struct SREGS sregs;
int count=0;
struct DISK_ADD_PACKET * p;
p = (struct DISK_ADD_PACKET *)malloc(sizeof(struct DISK_ADD_PACKET));
p->recordsize=sizeof(struct DISK_ADD_PACKET);
p->count=nsects;
p->transferadd=(DWORD)data;
p->lowbits=lsects;
p->highbits=0; /* We dont need to access HD > 2TB */
iregs.x.ax = 0x4302;
iregs.h.dl = disk;
iregs.x.si = FP_OFF(p);
sregs.ds = FP_SEG(p);
int86x(0x13,&iregs,&oregs,&sregs);
if(oregs.h.ah==0)
{
free(p);
return TRUE;
}

free(p);
return FALSE;

}
DWORD lsect=0;
void main()
{
BYTE disk=0x80;
WORD nsect=1,index=0,i=0,hi,choice;
DWORD extsect;
BYTE hideindex[5],id;
struct MBR *mbr;
struct driveinfo dinfo[10];//max 10 partitions
mbr=(struct MBR *)malloc(sizeof(struct MBR));
if(ExtentionCheck(disk)==FALSE)
{printf("extended int 13 is not supported<BR>);
exit(1);
}


if(ReadSect(disk, nsect, lsect,(char *)mbr)==TRUE)
for(i=0;i<4;i++)
if(mbr->partition[i].systid!=0)
{printpart(mbr,i);
dinfo[index].startsect=lsect;
dinfo[index].sysid=mbr->partition[i].systid;
index++;
}
if(mbr->partition[1].systid==0xf)//0xf for extended partition
{lsect=mbr->partition[1].relsect;
extsect=lsect;
link:
if(ReadSect(disk, nsect, lsect,(char *)mbr)==TRUE)
{printpart(mbr,0);
dinfo[index].startsect=lsect;
dinfo[index].sysid=mbr->partition[0].systid;
index++;
if(index>=10){printf("no of partition exceed max limit");exit(1);}
if(mbr->partition[1].systid!=0)
{lsect=extsect+mbr->partition[1].relsect;
goto link;
}
}

}

printf("


Hide partition(1)<BR>);
printf("Revele partition(2)<BR>);
printf("Quit(3)
Enter your choice(1/2/3):");
hideindex[0]=getche();
choice=atoi(hideindex);
switch(choice)
{
case 1:
printf("
Which drive do u want to hide:(0-%d):",index-1);
scanf("%s",hideindex);
hi=atoi(hideindex);
if(hi<=index)
{
id=dinfo[hi].sysid;
if(id==1||id==4||id==7||id==0xb||id==0xc||id==0xe)
{ lsect=dinfo[hi].startsect;
id+=0x10;
if(ReadSect(disk, nsect, lsect,(char *)mbr)==TRUE)
{mbr->partition[0].systid=id;
if(WriteSect(disk,nsect,lsect,(char *)mbr)==TRUE)
printf("
HIDDEN SUCCESSFULLY");
}
}
else
printf("Cant Hide");
}
break;
case 2:
printf("
Which drive do u want to Revele:(0-%d):",index-1);
scanf("%s",hideindex);
hi=atoi(hideindex);
if(hi<=index)
{
id=dinfo[hi].sysid;
if(id==0x11||id==0x14||id==0x17||id==0x1b||id==0x1c||id==0x1e)
{ lsect=dinfo[hi].startsect;
id-=0x10;
if(ReadSect(disk, nsect, lsect,(char *)mbr)==TRUE)
{mbr->partition[0].systid=id;printf("%x",mbr->partition[0].systid);
if(WriteSect(disk,nsect,lsect,(char *)mbr)==TRUE)
printf("
REVELED SUCCESSFULLY");
}
}
else
printf("Cant Revele<BR>);
}

break;
case 3:
exit(1);break;
default:
printf("
invalid choice");exit(1);
break;
};

}
printpart(struct MBR *mbr,WORD i)
{
BYTE bootable[]="YES";
BYTE id[7];
static BYTE c=0,index=0;
if(c==0)//to execute this for once
{
clrscr();
gotoxy(30,1);
printf("Partition Table");
gotoxy(2,2);
printf("INDEX");
gotoxy(8,2);
printf("SystemID");
gotoxy(17,2);
printf("Bootable");
gotoxy(26,2);
printf("StartingLBA");
gotoxy(38,2);
printf("SIZEINSECTORS");
gotoxy(52,2);
printf("SIZEINGB");
c++;
gotoxy(46,20);
printf("Coded by Tapan Kumar Mishra");
gotoxy(55,21);
printf("7th Sem,Electrical Engg.");
gotoxy(55,22);
printf("IGIT Sarang,Orissa");
gotoxy(46,23);
printf("Email id:titu_igit@rediffmail.com");
}
if(mbr->partition[i].bootid!=0x80)
strcpy(bootable,"NO");
gotoxy(2,3+index);
printf("%d",index);
gotoxy(8,3+index);
systemid((BYTE)mbr->partition[i].systid,id);
printf("%s",id);
gotoxy(17,3+index);
printf("%s",bootable);
gotoxy(26,3+index);
printf("%ld",mbr->partition[i].relsect+lsect);
gotoxy(38,3+index);
printf("%ld<BR>,mbr->partition[i].numsect);
gotoxy(52,3+index);
printf("%5.2fGB",(float)mbr->partition[i].numsect/2097152.0);


index++;
return 0;
}
systemid(BYTE systid,BYTE *id)
{
switch(systid)
{
case 00:
strcpy(id,"empty");
break;
case 01:
strcpy(id,"FAT12");
break;
case 04:
strcpy(id,"FAT16");
break;
case 05:
strcpy(id,"EXTNED");
break;
case 0xb:
strcpy(id,"FAT32");
break;
case 0xc:
strcpy(id,"FAT32");
break;
case 0xE:
strcpy(id,"FAT16");
break;
case 0xf:
strcpy(id,"EXNDED");
break;
case 0x82:
strcpy(id,"SWAP");
break;
case 0x83:
strcpy(id,"EXT2fs");
break;
case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x1b:
case 0x1c:
case 0x1e:
case 0x1f:
strcpy(id,"hidden");
break;
}

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG