mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-09 03:41:10 +08:00
Fix CD mount crash when drive is "empty"
This commit is contained in:
parent
98f374ee09
commit
e2617f390c
@ -430,7 +430,7 @@ void CMscdex::ReplaceDrive(CDROM_Interface* newCdrom, uint8_t subUnit) {
|
||||
}
|
||||
|
||||
PhysPt CMscdex::GetDefaultBuffer(void) {
|
||||
if (defaultBufSeg==0) {
|
||||
if (defaultBufSeg==0 && !dos_kernel_disabled) {
|
||||
uint16_t size = (2352*2+15)/16;
|
||||
defaultBufSeg = DOS_GetMemory(size,"MSCDEX default buffer");
|
||||
}
|
||||
@ -1504,7 +1504,8 @@ uint8_t MSCDEX_GetSubUnit(char driveLetter)
|
||||
|
||||
bool MSCDEX_GetVolumeName(uint8_t subUnit, char* name)
|
||||
{
|
||||
return mscdex->GetVolumeName(subUnit,name);
|
||||
if(dos_kernel_disabled) return false;
|
||||
return mscdex->GetVolumeName(subUnit,name);
|
||||
}
|
||||
|
||||
bool MSCDEX_HasMediaChanged(uint8_t subUnit)
|
||||
|
@ -557,24 +557,38 @@ void MenuBrowseCDImage(char drive, int num) {
|
||||
const char *lFilterPatterns[] = {"*.iso","*.cue","*.bin","*.chd","*.mdf","*.gog","*.ins","*.inst","*.ISO","*.CUE","*.BIN","*.CHD","*.MDF","*.GOG","*.INS","*.INST" };
|
||||
const char *lFilterDescription = "CD image files (*.iso, *.cue, *.bin, *.chd, *.mdf, *.gog, *.ins, *.inst)";
|
||||
lTheOpenFileName = tinyfd_openFileDialog("Select a CD image file","", sizeof(lFilterPatterns) / sizeof(lFilterPatterns[0]),lFilterPatterns,lFilterDescription,0);
|
||||
|
||||
bool isempty = std::string(Drives[drive - 'A']->GetInfo() + 9) == "empty";
|
||||
if (lTheOpenFileName) {
|
||||
isoDrive *cdrom = dynamic_cast<isoDrive*>(Drives[drive-'A']);
|
||||
DOS_Drive *newDrive = NULL;
|
||||
int error = -1;
|
||||
uint8_t mediaid = 0xF8;
|
||||
if (cdrom && dos_kernel_disabled) {
|
||||
cdrom->setFileName(lTheOpenFileName);
|
||||
if(isempty) {
|
||||
newDrive = new isoDrive(drive, lTheOpenFileName, mediaid, error, options);
|
||||
if(error) {
|
||||
delete newDrive;
|
||||
systemmessagebox("Error", "Could not mount the selected CD image.", "ok", "error", 1);
|
||||
chdir(Temp_CurrentDir);
|
||||
return;
|
||||
}
|
||||
delete cdrom;
|
||||
cdrom = dynamic_cast<isoDrive*>(newDrive);
|
||||
Drives[drive - 'A'] = cdrom;
|
||||
}
|
||||
} else {
|
||||
uint8_t mediaid = 0xF8;
|
||||
int error = -1;
|
||||
newDrive = new isoDrive(drive, lTheOpenFileName, mediaid, error, options);
|
||||
if (error) {
|
||||
delete newDrive;
|
||||
systemmessagebox("Error","Could not mount the selected CD image.","ok","error", 1);
|
||||
chdir( Temp_CurrentDir );
|
||||
return;
|
||||
}
|
||||
cdrom = dynamic_cast<isoDrive*>(newDrive);
|
||||
Drives[drive - 'A'] = cdrom;
|
||||
}
|
||||
if (cdrom) DriveManager::ChangeDisk(drive-'A', cdrom);
|
||||
if ((!isempty || !dos_kernel_disabled) && cdrom) DriveManager::ChangeDisk(drive-'A', cdrom);
|
||||
}
|
||||
chdir( Temp_CurrentDir );
|
||||
#endif
|
||||
|
@ -1737,7 +1737,8 @@ bool isoDrive::ReadCachedSector(uint8_t** buffer, const uint32_t sector) {
|
||||
}
|
||||
|
||||
inline bool isoDrive :: readSector(uint8_t *buffer, uint32_t sector) const {
|
||||
return CDROM_Interface_Image::images[subUnit]->ReadSector(buffer, false, sector);
|
||||
if(CDROM_Interface_Image::images[subUnit] == nullptr) return false;
|
||||
return CDROM_Interface_Image::images[subUnit]->ReadSector(buffer, false, sector);
|
||||
}
|
||||
|
||||
int isoDrive::readDirEntry(isoDirEntry* de, const uint8_t* data,unsigned int dirIteratorIndex) const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user