⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grub-0.95-patch4-emulation

📁 Grub for dos 0.2.0,system loader
💻 95-PATCH4-EMULATION
📖 第 1 页 / 共 5 页
字号:
+2:+	testl	%edx, %edx+	popl	%edx+	popl	%ebx+	jz	2f+	incl	%eax+2:+	movl	%eax, 4(%si)	/* total cylinders */+	movw	$512, 24(%si)	/* bytes per sector */+	xorb	%ah, %ah+	/*clc*/			/* signal success, CF already cleared by XOR */+	jmp	int13_return+error_01_invalid:+	movb	$0x01, %ah	/* unsupported function call */+	stc			/* signal error */+int13_return:+	pushw	%ax		/* save status */+	pushfw 	popw	%ax-	movw	4(%bp), %bp-	addw	$8, %sp+	movw	%ax, 10(%bp)	/* update flags in the stack */+	movw	-2(%bp), %si	/* restore the original SI */+	movl	2(%bp), %eax	/* restore the original EAX */+	movw	(%bp), %bp	/* restore the original BP */+	popw	%ax		/* restore status */+	addw	$20, %sp	/* adjust SP */ 	iret +bound_check:++	/* +	 * check if the request exceeds the boundary of the emulated disk.+	 *+	 * input:	DS:SI+	 * output:	AH=0 no restrictions, all sectors transferred+	 *		AH=1 sectors transferred, but not all+	 *		AH=4 error exit immediately, no sectors transferred+	 *+	 * if S_count=StartLBA=0, then no restrictions+	 * else if 8(%si)>=S_count then error+	 * else if 8(%si)+2(%si)<=S_count then no restrictions+	 * else let 2(%si)=S_count-8(%si),call original int13,signal error+	 *+	 */+	movl	-10(%bp), %eax	/* StartLBA */+	testl	%eax, %eax+	jnz	2f+	movl	-14(%bp), %eax	/* S_count */+	shrl	$1, %eax+	jnz	2f+	clc		/* map whole drive, signal no restrictions */+	popw	%ax+	pushfw+	pushw	%ax+	xorb	%ah, %ah	/* no restrictions, all sectors transferred */+	ret+2:+	movl	12(%si), %eax+	testl	%eax, %eax+	jnz	3f+	movl	-14(%bp), %eax	/* S_count */+	andb	$0xfe, %al+	cmpl	%eax, 8(%si)+	jb	2f+3:+	movb	$4, %ah	/* all sectors exceed the bound, exit immediately */+	xorb	%al, %al	/* no sectors transferred */+	movb	%al, 2(%si)+	stc+	ret+2:+	subl	8(%si), %eax+	pushl	%ebx+	xorl	%ebx, %ebx+	movw	2(%si), %bx+	cmpl	%eax, %ebx+	popl	%ebx+	ja	2f+	clc		/* signal no restrictions */+	popw	%ax+	pushfw+	pushw	%ax+	xorb	%ah, %ah	/* no restrictions, all sectors transferred */+	ret+2:+	movb	%al, 2(%si)+	stc+	popw	%ax+	pushfw+	pushw	%ax+	movb	$1, %ah	/* not all sectors tranferred */+	ret++real_int13_service:++	pushw	%si		/* save SI */+	pushl	%eax		/* save EAX */+	xorw	%ax, %ax+	pushw	%ds+	movw	%ax, %ds+	movw	$0x004c, %si	/* point to int13 vector */+	ldsw	(%si), %si	/* point to int13 service routine */+	cmpb	$0x63, (%si)	/* win98 places ARPL here */+	popw	%ds+	je	2f++	/* in real mode DOS, call original real mode int13 */+	popl	%eax+	popw	%si+	pushfw+	lcall	%cs:*(int13_offset - int13_handler)+	ret+2:+	/* now inside win98, will call protected mode int13 */++	pushl	%ebx		/* save EBX */++	/* set SI to the drive map */+	movw	$(hooked_drive_map - int13_handler), %si+	/* find the drive number from the drive map */+	cld+	subw	$8, %si+2:	+	addw	$8, %si+	lodsl	%cs:(%si), %eax+	testl	%eax, %eax	/* end of map table? */+	movl	%eax, %ebx	/* save the map to EBX */+	jz	2f		/* yes, no map found */+	cmpb	%dl, %ah	/* found the map? */+	jne	2b		/* no, check the next slot */++	/* drive is mapped. check if map a whole drive */+	shrl	$16, %eax+	testb	$62, %ah+	jnz	2b		/* no, check the next slot */+	movl	%cs:(%si), %eax	/* StartLBA */+	testl	%eax, %eax+	jnz	2b		/* no, check the next slot */+	movl	%cs:4(%si), %eax/* S_count */+	shrl	$1, %eax+	jnz	2b		/* no, check the next slot */+2:+	testl	%ebx, %ebx	/* mapped or not mapped ? */+	jz	2f		/* not mapped, do nothing */+	movb	%bl, %dl	/* use the mapped FROM_DRIVE for win98 */+2:+	movb	-6(%bp), %al	/* AL=FROM_DRIVE */+	testb	%al, %al	/* hard drive emulation? */+	jns	2f		/* floppy, jump */+	cmpb	%al, %dl+	jb	2f+	incb	%dl+2:+	popl	%ebx+	popl	%eax+	popw	%si+	int	$0x13+	ret++modify_boot_sectors:++	pushl	%eax+	movw	2(%bp),	%ax	/* get original AX */+	cmpb	$0x02, %ah	/* is it read? */+	jne	4f+	cmpw	$0x0001, %cx	/* read from cylinder 0, sector 1? */+	jne	4f+	testb	%dl, %dl	/* The TO_DRIVE is hard drive? */+	jns	4f		/* no, do nothing */+	cmpw	$0xaa55, %es:0x1fe(%bx)+	jne	4f+	movl	-14(%bp), %eax	/* S_count */+	shrl	$1, %eax+	jz	4f+	movl	-10(%bp), %eax	/* StartLBA */+	testl	%eax, %eax+	jz	4f+	movl	-6(%bp), %eax	/* FROM_DRIVE, TO_DRIVE, H, S */+	testb	%al, %al	/* The FROM_DRIVE is hard drive? */+	jns	modify_floppy	/* no, goto floppy boot record modification */+	testb	%dh, %dh	/* read from head 0? */+	jnz	modify_HD_DOS	/* no, goto HD DOS boot record modification */+	shrl	$16, %eax	/* AL=MaxH, AH=MaxS */+	andb	$63, %ah	/* AH=MaxS */+	cmpb	$1, %ah+	jbe	4f /* do not modify partition table when disable CHS mode */++	pushl	%edx+	pushl	%ecx+	pushw	%si+	pushl	%edi+	pushl	%ebx++	movw	%ax, %di	/* save AX to DI */+	xorl	%ecx, %ecx+	xorl	%edx, %edx+	movb	%ah, %cl+	mulb	%ah		/* AX = AH * AL */+	addw	%ax, %cx	/* CX = sectors per cylinder */+	movl	-10(%bp), %eax	/* EDX:EAX=StartLBA */+	divl	%ecx		/* EAX=cylinders, EDX=remainders */+	cmpl	$1023, %eax+	ja	8f+	shll	$16, %eax	/* cylinders save to hi word */+	movw	%dx, %ax	/* remainders */+	movw	%di, %dx	/* DH=MaxS */+	divb	%dh		/* AL=heads, AH=sectors */+	movl	%eax, %ecx	/* ECX holds CHS differences */+	+	movw	$0x1bf, %si+	addw	%bx, %si+	movw	$8, %di		/* 8 entries in partition table */+5:+	lodsl	%es:(%si), %eax+	testl	%eax, %eax+	jz	6f+	movl	%ecx, %edx+	movl	%eax, %ebx+	shrl	$16, %edx	/* DX=cylinder_difference */+	shrl	$8, %ebx+	shrb	$6, %bl+	xchgb	%bl, %bh	/* BX=old cylinder number */+	cmpw	%dx, %bx+	jb	8f+	subw	%dx, %bx	/* BX=new cylinder number */+	movw	%bx, %dx	/* save BX to DX */+	shll	$16, %ebx	/* save new cylinder number to hi word */++	cmpb	%cl, %al	/* AL=old head number, CL=head_difference */+	jae	7f+	decw	%dx		/* DX holds the new cylinder number */+	jc	6f+	movw	%dx, %bx	/* update BX */+	shll	$16, %ebx	/* save new cylinder number to hi word */+	movb	%cl, %dl+	subb	%al, %dl+	decb	%dl+	movb	-4(%bp), %al	/* AL=MaxH */+	subb	%dl, %al	/* AL holds the new head number */+	jmp	3f+7:+	subb	%cl, %al	/* AL holds the new head number */+3:+	movb	%al, %bl	/* put the new head number to BL */++	andb	$63, %ah+	cmpb	%ch, %ah	/* AH=old sector number, CH=sector_diff */+	ja	7f+	testl	%ebx, %ebx+	jz	6f+	testb	%al, %al+	jnz	3f+	shrl	$16, %ebx+	decw	%bx+	shll	$16, %ebx+	movb	-4(%bp), %al	/* AL=MaxH */+	incb	%al		/* no worry on overflow, see decb followed */+3:+	decb	%al		/* AL holds the new head number */+	subb	%ah, %ch+	movb	-3(%bp), %ah	/* AH=MaxS */+	andb	$63, %ah+7:+	subb	%ch, %ah	/* AH holds the new sector number */+				/* AL holds the new head number */+	shrl	$16, %ebx+	shlb	$6, %bh+	orb	%bh, %ah+	xorb	%bh, %bh+	shll	$16, %ebx+	movw	%ax, %bx+	shrl	$24, %eax+	testw	$1, %di+	jnz	7f+	cmpb	$0x05, %al	/* 0x05 is extended partition */+	je	3f+	cmpb	$0x0f, %al	/* 0x0f is LBA extended partition */+	jne	7f+3:+	xorb	%al, %al	/* disable the extended partition */+7:+	shll	$24, %eax+	orl	%ebx, %eax+	movl	%eax, %es:-4(%si)	/* update the CHS number */+6:+	decw	%di+	jz	8f+	testw	$1, %di+	jnz	7f	/* jnz	5b */+	addw	$8, %si+7:+	jmp	5b+8:+	popl	%ebx+	popl	%edi+	popw	%si+	popl	%ecx+	popl	%edx+4:+	popl	%eax		/* end partition table modification */+	ret++modify_floppy:++	cmpb	$0x00, %dh	/* read from head 0? */+	jne	4b+	xorl	%eax, %eax+	cmpl	%eax, %es:0x1c(%bx)	/* Number of hidden sectors */+	je	4b+	cmpl	$0x33544146, %es:0x52(%bx)	/* FAT32? */+	je	5f+	cmpl	$0x31544146, %es:0x36(%bx)	/* FAT16? */+	jne	4b+	cmpb	$0x80, %es:0x24(%bx)	/* Physical drive number */+	jne	4b+	movb	%al, %es:0x24(%bx)	/* AL=0 means floppy */+	jmp	6f+5:+	cmpb	$0x80, %es:0x40(%bx)	/* Physical drive number */+	jne	4b+	movb	%al, %es:0x40(%bx)	/* AL=0 means floppy */+6:+	movl	%eax, %es:0x1c(%bx)	/* let number of hidden sectors=0 */+	/*movb	$0xf0, %es:0x15(%bx)*/	/* set floppy media descriptor */+	jmp	4b++modify_HD_DOS:++	cmpb	$0x01, %dh	/* read from head 1? */+	jne	4b+	movl	-10(%bp), %eax	/* StartLBA */+	testl	%eax, %eax+	jz	4b+	cmpl	%eax, %es:0x1c(%bx)	/* Number of hidden sectors */+	jbe	4b+	subl	%eax, %es:0x1c(%bx)+	jmp	4b++int13_handler_code_end:+#if 0 	.align	4-drive_map:	.space	(DRIVE_MAP_SIZE + 1) * 2+#else+	.space	(4 - ((int13_handler_code_end - int13_handler) % 4)) % 4+#endif+ENTRY(hooked_drive_map)+	.space	(DRIVE_MAP_SIZE + 1) * 12 /* sizeof(struct drive_map_slot) */+EBIOS_disk_address_packet:+	.byte	0x10	/* packet size, 16 or more */+	.byte	0	/* reserved, must be 0 */+	.byte	0	/* number of sectors, must be from 1 to 127 */+	.byte	0	/* reserved, must be 0 */+	.word	0	/* displacement of memory address */+	.word	0	/* segment of memory address */+	.long	0	/* 64bit, start logical sector number */+	.long	0 int13_handler_end: 	+	. = int13_handler + 0x7f8 /* just help to know the handler routine does not exceed the 0x800 (2KB) size */  	.code32 	 	diff -Naur grub-0.95_ntfs/stage2/builtins.c grub-0.95_emulation/stage2/builtins.c--- grub-0.95_ntfs/stage2/builtins.c	2004-10-22 14:28:49.963498672 +0800+++ grub-0.95_emulation/stage2/builtins.c	2004-10-22 18:27:39.794611048 +0800@@ -74,8 +74,29 @@ int grub_timeout = -1; /* Whether to show the menu or not.  */ int show_menu = 1;+/* Whether the drive map hook is on.  */+static int int13_on_hook = 0; /* The BIOS drive map.  */-static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];+static struct drive_map_slot bios_drive_map[DRIVE_MAP_SIZE + 1];+extern struct drive_map_slot hooked_drive_map[DRIVE_MAP_SIZE + 1];++static int+drive_map_slot_empty (struct drive_map_slot item)+{+	if (*(unsigned long *)(&(item.from_drive))) return 0;+	if (item.start_sector) return 0;+	if (item.sector_count) return 0;+	return 1;+}++static int+drive_map_slot_equal (struct drive_map_slot a, struct drive_map_slot b)+{+	if (*(unsigned long *)(&(a.from_drive)) != *(unsigned long *)(&(b.from_drive))) return 0;+	if (a.start_sector != b.start_sector) return 0;+	if (a.sector_count != b.sector_count) return 0;+	return 1;+}  /* Prototypes for allowing straightfoward calling of builtins functions    inside other functions.  */@@ -128,7 +149,10 @@   grub_printf ("[%d,%d,%d]", sector, offset, length); } -+extern int rawread_ignore_memmove_overflow; /* defined in disk_io.c */+static int query_block_entries = 0;+static unsigned long map_start_sector = 0;+static unsigned long map_num_sectors = 0; /* blocklist */ static int blocklist_func (char *arg, int flags)@@ -138,6 +162,7 @@   int num_sectors = 0;   int num_entries = 0;   int last_length = 0;+  int err;    /* Collect contiguous blocks into one entry as many as possible,      and print the blocklist notation on the screen.  */@@ -154,17 +179,20 @@ 	    } 	  else 	    {-	      if (last_length == SECTOR_SIZE)-		grub_printf ("%s%d+%d", num_entries ? "," : "",+	      if (query_block_entries >= 0)+	        {+		  if (last_length == SECTOR_SIZE)+		    grub_printf ("%s%d+%d", num_entries ? "," : "", 			     start_sector - part_start, num_sectors);-	      else if (num_sectors > 1)-		grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "",+		  else if (num_sectors > 1)+		    grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "", 			     start_sector - part_start, num_sectors-1, 			     start_sector + num_sectors-1 - part_start,  			     last_length);-	      else-		grub_printf ("%s%d[0-%d]", num_entries ? "," : "",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -