From 72c39f8cab47d504ad87db5a859902b5ebbdabfa Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Sat, 8 Jan 2011 14:26:13 +0000 Subject: [PATCH] *Moved every allocation of libntfs now to MEM2 (in mem1 it gets overwritten and so the games didn't work in last rev) Forwarder change: *Ignore MBR partition type and read partition type from boot record sector (Channel will follow later) --- source/devicemounter.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/source/devicemounter.c b/source/devicemounter.c index 4d535598..fa3ecb7d 100644 --- a/source/devicemounter.c +++ b/source/devicemounter.c @@ -53,29 +53,28 @@ int USBDevice_Init() int i; MASTER_BOOT_RECORD mbr; - char ntfsBootSector[512]; + char BootSector[512]; __io_usbstorage.readSectors(0, 1, &mbr); for(i = 0; i < 4; ++i) { - switch(mbr.partitions[i].type) + if(mbr.partitions[i].type == 0) + continue; + + __io_usbstorage.readSectors(le32(mbr.partitions[i].lba_start), 1, BootSector); + + if(*((u16 *) (BootSector + 0x1FE)) == 0x55AA) { - case 0x01: - case 0x04: - case 0x06: - case 0x0b: - case 0x0c: - case 0x0e: + //! Partition typ can be missleading the correct partition format. Stupid lazy ass Partition Editors. + if(memcmp(BootSector + 0x36, "FAT", 3) == 0 || memcmp(BootSector + 0x52, "FAT", 3) == 0) + { fatMount(DeviceName[USB1+i], &__io_usbstorage, le32(mbr.partitions[i].lba_start), CACHE, SECTORS); - break; - case 0x07: - __io_usbstorage.readSectors(le32(mbr.partitions[i].lba_start), 1, ntfsBootSector); - if(strncmp(&ntfsBootSector[0x03], "NTFS", 4) == 0) - ntfsMount(DeviceName[USB1+i], &__io_usbstorage, le32(mbr.partitions[i].lba_start), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER | NTFS_IGNORE_CASE); - break; - default: - break; + } + else if (memcmp(BootSector + 0x03, "NTFS", 4) == 0) + { + ntfsMount(DeviceName[USB1+i], &__io_usbstorage, le32(mbr.partitions[i].lba_start), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER | NTFS_IGNORE_CASE); + } } }