Ganz einfach, man schreibe kleines c progrämmchen:
----------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#define DO_READ 0
#define DO_WRITE 1
#define DO_WRITEALL 2
typedef struct
{ unsigned char Head;
unsigned short int SecCyl;
} PosStruct;
typedef struct
{ unsigned char Status;
PosStruct StartSec;
unsigned char PartTyp;
PosStruct EndSec;
unsigned long int SecOffset;
unsigned long int SecCount;
} PartTableStruct;
typedef struct
{ char BootCode[0x1BE];
PartTableStruct PartTable[4];
unsigned short int MagicNum;
} MBRstruct;
char WorkOnSector(char what, unsigned char DriveNum, unsigned char Head,
unsigned short int SecCyl, void *buf)
{ union REGS Regs;
struct SREGS SRegs;
if(what==DO_READ)
Regs.x.ax=0x0201; // Read 1 sector
else
Regs.x.ax=0x0301; // Write 1 sector
Regs.h.dl=DriveNum;
Regs.h.dh=Head;
Regs.x.cx=SecCyl;
Regs.x.bx=FP_OFF(buf);
SRegs.es=FP_SEG(buf);
int86x(0x13, &Regs, &Regs, &SRegs);
return(!Regs.x.cflag);
}
char WorkOnBootSector(char DriveNum, char PartNum, char what, char *filename)
{ unsigned char Head;
MBRstruct MBR;
union REGS Regs;
int fh;
char buf[512];
char MBRwhat=DO_READ;
/* If a write operation is requested we will read the file first */
if(what!=DO_READ)
{ if((fh=open(filename, O_RDONLY | O_BINARY))==-1)
{ printf("Datei %s konnte nicht gelesen werden.\n", filename);
return(1);
}
if(read(fh, buf, 512)<512)
{ printf("Datei %s ist kleiner als 512 Bytes.\n", filename);
close(fh);
return(1);
}
close(fh);
}
DriveNum|=0x80; /* Needed for the BIOS call */
if(PartNum==0) /* Direct operation on the MBR is requested */
{ if(what!=DO_READ)
{ MBRwhat=DO_WRITE;
memcpy(&MBR, buf, 512);
}
if(what==DO_WRITE)
{ /* Extract the partition table from the MBR,
because we must not overwrite it */
if(!WorkOnSector(DO_READ, DriveNum, 0, 1, (void *)buf))
{ printf("Fehler beim Zugriff auf den MBR.\n");
return(1);
}
/* Write the partition table from the actual MBR to the
buffer where the content of the file is stored */
memcpy(&MBR+0x1BE, buf+0x1BE, 64);
}
}
if(!WorkOnSector(MBRwhat, DriveNum, 0, 1, (void *)&MBR))
{ printf("Fehler beim Zugriff auf den MBR.\n");
return(1);
}
if(MBRwhat!=DO_READ) /* Write-operation on MBR was requested */
return(0); /* => we're done */
if(PartNum>0) /* Operation an a partition's boot sector is requested */
{ PartNum-=1;
if(what==DO_WRITE)
{ /* Get the BPB (and the following 6 bytes where information
about the partition is kept), because we must not overwrite it */
char buf2[512];
if(!WorkOnSector(DO_READ, DriveNum,
MBR.PartTable[PartNum].StartSec.Head,
MBR.PartTable[PartNum].StartSec.SecCyl,
(void *)buf2))
{ printf("Fehler beim Zugriff auf den Bootsektor der Partition.\n");
return(1);
}
/* Write the actual BPB to the buffer where the content of the file
is stored */
memcpy(buf+0xB, buf2+0xB, 19);
}
if(!WorkOnSector(what, DriveNum,
MBR.PartTable[PartNum].StartSec.Head,
MBR.PartTable[PartNum].StartSec.SecCyl,
(void *)buf))
{ printf("Fehler beim Zugriff auf den Bootsektor der Partition.\n");
return(1);
}
if(what!=DO_READ) /* Write-operation was requested => we're done */
return(0);
}
else
memcpy(buf, &MBR, 512);
if((fh=open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
S_IREAD | S_IWRITE))==-1)
{ printf("Datei %s konnte nicht zum Schreiben geffnet werden.\n",
filename);
return(1);
}
write(fh, buf, 512);
close(fh);
return(0);
}
int main(int argc, char **args)
{ char DriveNum=0;
char PartNum=0;
char what;
if(argc!=5 || (stricmp(args[1], "READ")!=0 &&
stricmp(args[1], "WRITE")!=0 && stricmp(args[1], "WRITEALL")!=0))
{ printf(
"Syntax: WRKSECT READ|WRITE|WRITEALL \n\n"
"READ/WRITE/WRITEALL: READ=MBR/Bootsektor lesen und in Datei schreiben\n"
" WRITE=Datei lesen und in den MBR/Bootsektor\n"
" schreiben; es wird dabei nur der Startcode\n"
" ?berschrieben, die Partitionstabelle im MBR\n"
" bzw. der BPB im Bootsektor bleibt unverndert\n"
" WRITEALL=Wie WRITE, es wird aber auch die Par-\n"
" titionstabelle bzw. der BPB ?berschrieben\n"
"Festplatten-Nr.: 0=Master am ersten Controller\n"
" 1=Slave am ersten Controller\n"
" 2=Master am zweiten Controller\n"
" 3=Slave am zweiten Controller\n"
"Sektor: 0=MBR der Festplatte\n"
" 1=Bootsektor der ersten Partition\n"
" 2=Bootsektor der zweiten Partition\n"
" 3=Bootsektor der dritten Partition\n"
" 4=Bootsektor der vierten Partition\n"
"Dateiname: Name der Datei in die der MBR/Bootsektor geschrieben werden\n"
" bzw. aus der er gelesen werden soll\n"
);
exit(1);
}
if(stricmp(args[1], "READ")==0)
what=DO_READ;
else if(stricmp(args[1], "WRITE")==0)
what=DO_WRITE;
else
what=DO_WRITEALL;
DriveNum=atoi(args[2]);
if(!(DriveNum>=0 && DriveNum<=3) ||
(DriveNum==0 && strcmp(args[2], "0")!=0))
{ printf("Falsche Laufwerksnummer.\n");
exit(1);
}
PartNum=atoi(args[3]);
if(!(PartNum>=0 && PartNum<=4) ||
(PartNum==0 && strcmp(args[3], "0")!=0))
{ printf("Falsche Partitionsnummer (Erweiterte Partitionen werden "
"nicht unterst?tzt).\n");
exit(1);
}
return(WorkOnBootSector(DriveNum, PartNum, what, args[4]));
}
---------------------------------------------------------------------
das proggy hab ich nach 2min suche bei google gefunden. habs sogar ausprobiert! *geheiligtseimeinelinuxbootdiskettediezumglückeinekopiemeinesmbrsdraufhattedenichdannwiedermitdemlinuxbefehlddreinschreibenkonnte*