Skip to content

Commit

Permalink
Merge pull request #3678 from tbr/fix-3535-and-3347
Browse files Browse the repository at this point in the history
Fix issues 3535 (dosbox-x hang on zip-mounted drives) and 3347 (minor bug fix and related)
  • Loading branch information
joncampbell123 committed Aug 31, 2022
2 parents 0031a6f + a754da6 commit 97fbed5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
38 changes: 15 additions & 23 deletions src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,30 +1945,24 @@ static Bitu DOS_21Handler(void) {
}

dos.echo=true;

if(handle >= DOS_FILES) {
DOS_SetError(DOSERR_INVALID_HANDLE);
} else
if(!Files[handle] || !Files[handle]->IsOpen())
if(handle >= DOS_FILES || !Files[handle] || !Files[handle]->IsOpen()) {
DOS_SetError(DOSERR_INVALID_HANDLE);
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT)
{
}
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT) {
fRead = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(4, 26, SegValue(ds), reg_dx, toread) & 0x8000);
#if defined(USE_TTF)
if(fRead && ttf.inUse && reg_bx == WPvga512CHMhandle)
MEM_BlockRead(SegPhys(ds) + reg_dx, dos_copybuf, toread);
fRead &= ttf.inUse && reg_bx == WPvga512CHMhandle;
#endif
}
else
{
if((fRead = DOS_ReadFile(reg_bx, dos_copybuf, &toread)))
MEM_BlockWrite(SegPhys(ds) + reg_dx, dos_copybuf, toread);
else {
fRead = DOS_ReadFile(reg_bx, dos_copybuf, &toread);
}

if (fRead) {
MEM_BlockWrite(SegPhys(ds) + reg_dx, dos_copybuf, toread);
reg_ax=toread;
#if defined(USE_TTF)
if (ttf.inUse && reg_bx == WPvga512CHMhandle){
if (ttf.inUse && reg_bx == WPvga512CHMhandle) {
if (toread == 26 || toread == 2) {
if (toread == 2)
WP5chars = *(uint16_t*)dos_copybuf;
Expand Down Expand Up @@ -2037,17 +2031,15 @@ static Bitu DOS_21Handler(void) {
{
uint32_t handle = RealHandle(reg_bx);

if(handle >= DOS_FILES) {
if(handle >= DOS_FILES || !Files[handle] || !Files[handle]->IsOpen()) {
DOS_SetError(DOSERR_INVALID_HANDLE);
}
else
if(!Files[handle] || !Files[handle]->IsOpen())
DOS_SetError(DOSERR_INVALID_HANDLE);
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT)
{
fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(8, 26, SegValue(ds), reg_dx, towrite) & 0x8000);
}
else fWritten = DOS_WriteFile(reg_bx, dos_copybuf, &towrite);
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT) {
fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(8, 26, SegValue(ds), reg_dx, towrite) & 0x8000);
}
else {
fWritten = DOS_WriteFile(reg_bx, dos_copybuf, &towrite);
}
}
if (fWritten) {
reg_ax=towrite;
Expand Down
4 changes: 2 additions & 2 deletions src/dos/drive_physfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool physfsDrive::FileOpen(DOS_File * * file,const char * name,uint32_t flags) {
return false;
}

*file=new physfsFile(name,hand,0x202,newname,false);
*file=new physfsFile(name,hand,0x2,newname,false);
(*file)->flags=flags; //for the inheritance flag and maybe check for others.
return true;
}
Expand Down Expand Up @@ -449,7 +449,7 @@ bool physfsDrive::FileCreate(DOS_File * * file,const char * name,uint16_t attrib
}

/* Make the 16 bit device information */
*file=new physfsFile(name,hand,0x202,newname,true);
*file=new physfsFile(name,hand,0x2,newname,true);
(*file)->flags=OPEN_READWRITE;
if(!existing_file) {
strcpy(newname,basedir);
Expand Down

0 comments on commit 97fbed5

Please sign in to comment.