Permalink
Browse files

. 修正错误。

  • Loading branch information...
yaya
yaya committed May 9, 2017
1 parent ed9a7c9 commit fce12abf6ae3754650146022eae9b6bae884b2a2
Showing with 25 additions and 43 deletions.
  1. +24 −30 stage2/builtins.c
  2. +1 −13 stage2/disk_io.c
View
@@ -6952,15 +6952,6 @@ get_vol (char* vol_found, int flags)
case ISO_TYPE_RockRidge:
emu_iso_sector_size_2048 = 1;
devread(0x10, 0x28, 0x20, (unsigned long long)(unsigned int)(char *)vol_found, n);
- if (!flags)
- {
- for (i=0; i<0x20; i++)
- {
- if (vol_found[i] == ' ' && (vol_found[i] == vol_found[i+1] || i == 0x19))
- break;
- }
- vol_found[i] = 0;
- }
break;
case ISO_TYPE_Joliet:
if (flags)
@@ -6974,12 +6965,6 @@ get_vol (char* vol_found, int flags)
{
big_to_little ((char *)uni, 0x20);
unicode_to_utf8 ((unsigned short *)uni, (unsigned char *)vol_found, 0x10);
- for (i=0; i<0x20; i++)
- {
- if (vol_found[i] == ' ' && (vol_found[i] == vol_found[i+1] || i == 0x19))
- break;
- }
- vol_found[i] = 0;
}
break;
case ISO_TYPE_udf:
@@ -6989,28 +6974,26 @@ get_vol (char* vol_found, int flags)
{
if (*(BUFFER + 0x70) == 16)
{
- big_to_little ((char *)(BUFFER + 0x71), 0x80);
- unicode_to_utf8 ((unsigned short *)(BUFFER + 0x71), (unsigned char *)vol_found, 0x40);
+ big_to_little ((char *)(BUFFER + 0x71), 30);
+ unicode_to_utf8 ((unsigned short *)(BUFFER + 0x71), (unsigned char *)vol_found, 15);
}
else
{
unsigned char *pa = (unsigned char *)(BUFFER + 0x71);
- while ((*vol_found++ = *pa++));
+ i = 0;
+ while ((*vol_found++ = *pa++) && i++ < 30);
*vol_found = 0;
}
}
else
{
- j = grub_strlen(vol_found);
- for (i = 0; i < j; i++)
- {
- if (*(BUFFER + 0x70) == 16)
- pb[i] = vol_found[i];
- else
- uni[i] = vol_found[i];
- }
- grub_memmove ((unsigned char *)(BUFFER + 0x71),uni,((*(unsigned char *)BUFFER == 16)?(j*2):j));
- grub_memmove ((unsigned char *)(BUFFER + 0x131),uni,((*(unsigned char *)BUFFER == 16)?(j*2):j));
+ i = 0;
+ if (*(BUFFER + 0x70) == 16)
+ while (pb[i] = vol_found[i], i++ <15);
+ else
+ while (uni[i] = vol_found[i], i++ < 30);
+ grub_memmove ((unsigned char *)(BUFFER + 0x71),uni,30);
+ grub_memmove ((unsigned char *)(BUFFER + 0x131),uni,30);
*(unsigned short *)(BUFFER + 8) = grub_crc16 ((unsigned char *)(BUFFER+0x10), *(unsigned short *)(BUFFER+0xa));
unsigned char h = 0;
for (i=0; i<16; i++)
@@ -7026,6 +7009,15 @@ get_vol (char* vol_found, int flags)
}
break;
}
+ if (!flags && iso_type != ISO_TYPE_udf)
+ {
+ for (i=0; i<0x20; i++)
+ {
+ if (vol_found[i] == ' ' && (vol_found[i] == vol_found[i+1] || i == 0x19))
+ break;
+ }
+ vol_found[i] = 0;
+ }
#undef BUFFER
}
else if (grub_memcmp(fsys_table[fsys_type].name, "ntfs", 4) == 0)
@@ -7076,8 +7068,8 @@ get_vol (char* vol_found, int flags)
*(unsigned short *)pb = k;
i--;
}
- devread(*(unsigned long long *)BUFFER+6, 0, 0x400, (unsigned long long)(unsigned int)BUFFER, 0x900ddeed);
- devread(*(unsigned long long *)(BUFFER+8)+6, 0, 0x400, (unsigned long long)(unsigned int)BUFFER, 0x900ddeed);
+ devread(*(unsigned long long *)(FSYS_BUF+0x7e00)+6, 0, 0x400, (unsigned long long)(unsigned int)BUFFER, 0x900ddeed);
+ devread(*(unsigned long long *)(FSYS_BUF+0x7e00+8)+6, 0, 0x400, (unsigned long long)(unsigned int)BUFFER, 0x900ddeed);
}
}
#undef BUFFER
@@ -10487,6 +10479,8 @@ map_func (char *arg, int flags)
sectors_per_track = (hooked_drive_map[j].max_sector) & 0x3F;
}
start_sector += hooked_drive_map[j].start_sector;
+ for (k = 0; (k < DRIVE_MAP_FRAGMENT) && (map_start_sector[k] != 0); k++)
+ map_start_sector[k] += hooked_drive_map[j].start_sector;
}
/* If TO == FROM and whole drive is mapped, and, no map options occur, then delete the entry. */
View
@@ -248,7 +248,6 @@ static int
rawdisk_read (unsigned long drive, unsigned long long sector, unsigned long nsec, unsigned long segment)
{
const unsigned long BADDATA1 = FOUR_CHAR('B','A','D','?');
- const unsigned long BADDATA2 = FOUR_CHAR('b','a','d','.');
unsigned long *plast; /* point to buffer of last sector to be read */
int r;
/* Write "BAD?" data to last sector buffer */
@@ -261,20 +260,9 @@ rawdisk_read (unsigned long drive, unsigned long long sector, unsigned long nsec
/* Check for bad data in last read sector */
if (plast[0]!=BADDATA1 || plast[1]!=BADDATA1 || plast[2]!=BADDATA1 || plast[3]!=BADDATA1)
return 0; // not "BAD?", success
- // "BAD?", Suspicious
- // Write different data to buffer.
- plast[0] = BADDATA2;
- // Read last sector again
- r = biosdisk(BIOSDISK_READ, drive, &buf_geom, sector+(nsec-1), 1, ((unsigned long)plast>>4));
- if (r) // error
- return r;
- // Compare with previous read data
- if (plast[0] != BADDATA1)
- { // Read data changed, error.
+
printf_warning("\nFatal! Inconsistent data read from (0x%X)%ld+%d\n",drive,sector,nsec);
return -1; // error
- }
- return 0; // success
}
/* Read bytes from DRIVE to BUF. The bytes start at BYTE_OFFSET in absolute

0 comments on commit fce12ab

Please sign in to comment.