Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues 3535 (dosbox-x hang on zip-mounted drives) and 3347 (minor bug fix and related) #3678

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,30 +1941,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 @@ -2033,17 +2027,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 @@ -407,7 +407,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 @@ -447,7 +447,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