|
关于GRLDR或GRLDR.MBR改名可以按照GRUBINST的源码来修改.这样子应该可以适应于所有的版本了.
若用GRUBINST它会读取0X1FFA的值和自带的GRLDR.MBR的值对比,如果不一样就提示版本不符,其实目前的改名方法都是一样的.
- if (boot_file)
- {
- unsigned short ofs,len,len1;
- len=strlen(boot_file);
- // Patching the FAT32 boot sector
- ofs=valueat(grub_mbr,0x400+0x1EC,unsigned short) & 0x7FF;
- strcpy(&grub_mbr[0x400+ofs],boot_file_83);
- if (load_seg)
- valueat(grub_mbr,0x400+0x1EA,unsigned short)=load_seg;
- // Patching the FAT12/FAT16 boot sector
- ofs=valueat(grub_mbr,0x600+0x1EC,unsigned short) & 0x7FF;
- strcpy(&grub_mbr[0x600+ofs],boot_file_83);
- if (load_seg)
- valueat(grub_mbr,0x600+0x1EA,unsigned short)=load_seg;
- // Patching the EXT2 boot sector
- ofs=valueat(grub_mbr,0x800+0x1EE,unsigned short) & 0x7FF;
- len1=valueat(grub_mbr,0x800+0x1EE,unsigned short) >> 11;
- if (len>len1)
- {
- char buf[80];
- sprintf(buf,"Boot file name too long for ext2 partition (%d>%d)",len,len1);
- print_apperr(buf);
- close(hd);
- return 1;
- }
- else
- strcpy(&grub_mbr[0x800+ofs],boot_file);
- // Patching the NTFS sector
- ofs=valueat(grub_mbr,0xA00+0x1EC,unsigned short) & 0x7FF;
- len1=valueat(grub_mbr,0xA00+0x1EC,unsigned short) >> 11;
- if (len>len1)
- {
- char buf[80];
- sprintf(buf,"Boot file name too long for ntfs partition (%d>%d)",len,len1);
- print_apperr(buf);
- close(hd);
- return 1;
- }
- else
- strcpy(&grub_mbr[0xA00+ofs],boot_file);
- if (load_seg)
- valueat(grub_mbr,0xA00+0x1EA,unsigned short)=load_seg;
- if (afg & AFG_VERBOSE)
- {
- fprintf(stderr,"Boot file changed to %s\n",boot_file);
- if (load_seg)
- fprintf(stderr,"Load segment changed to %04X\n",load_seg);
- }
- }
复制代码 |
|