dosbox-staging icon indicating copy to clipboard operation
dosbox-staging copied to clipboard

File locking support for better game compatibility (SHARE.EXE)

Open Grounded0 opened this issue 4 years ago • 10 comments

Are you using the latest Dosbox-Staging Version?

  • [X] I have checked releases and am using the latest release.

Different version than latest?

No response

What Operating System are you using?

No response

If Other OS, please describe

macOS 11.6.2/x86-64

Is your feature request related to a problem? Please describe.

When installing some of the more demanding Windows games this pops up:

Screenshot 2022-09-07 at 17 28 27

This is due to lack of file locking support in DOSBox Staging which affects how both SHARE and VSHARE.386 do file locking.

At least the following games are known to suffer from SHARE.EXE not loaded issue:

  • Comix Zone (1995)
  • Garfield Caught in the Act (1996)
  • Microsoft Flight Simulator 5 - ATC Workshop (1995)
  • Monopoly (1995)
  • Ultimate Yahtzee (1996)

Describe the solution you'd like

I would have previously opposed adding file locking support as a too complex to implement. We've since moved to C++17 which has filesystem library that makes this feature easier to implement and more robust to maintain. The best way to implement is by accessing host OS directory mount directly.

The file locking logic can be pretty easily summed up by a snippet of code from DOSBox-X that has this implemented:

dos_files.cpp:890:

	} else {
		//Test if file exists, but opened in read-write mode (and writeprotected)
		if((((flags&3) != OPEN_READ) || (enable_share_exe && !strncmp(Drives[drive]->GetInfo(),"local directory ",16))) && Drives[drive]->FileExists(fullname))
			DOS_SetError(DOSERR_ACCESS_DENIED);
		else {
			if(!PathExists(name)) DOS_SetError(DOSERR_PATH_NOT_FOUND); 
			else DOS_SetError(DOSERR_FILE_NOT_FOUND);
		}
		return false;
	}

Adding this feature with the upcoming DOS 38h support will make this a general purpose emulator for DOS and Win16 environments. This makes it easier to use for a basic user because running multiple emulators for the same environment can be avoided. This will also attract more users.

Describe alternatives you've considered

There is a method of using fake SHARE but such solutions may lead to data corruption.

The question of is this in the scope of the project arises in this case. My evaluation is that it is based on the Vision page:

https://dosbox-staging.github.io/about/

Screenshot 2022-01-02 at 15 11 23

By utilising C++17 filesystem in implementing i think it passes all the conditions to be a viable, implementable feature. Can be implemented after 0.79 release cycle if there's no resources.

Add any other context or screenshots about the feature request here.

Sample code for C++17 filesystem file locking:

https://stackoverflow.com/a/56348495

#include <sys/stat.h>

bool IsLocked(std::string& thePath)
{
    bool isLocked = false;

    struct stat buf;
    int retval = stat(thePath.c_str(), &buf);     // NOTE: retval could be an error, like ENOENT (file doesn't exist)
    if (0 != (buf.st_flags & UF_IMMUTABLE)) {
        isLocked = true;
         //is immutable
    }

    return isLocked;
}

Code of Conduct & Contributing Guidelines

  • [X] Yes, I agree.

Grounded0 avatar Jan 02 '22 13:01 Grounded0

Screenshot_20220102-212202

Screenshot_20220102-212301

Screenshot_20220102-212601

Screenshot_20220102-212627

Grounded0 avatar Jan 02 '22 19:01 Grounded0

Screenshot 2022-09-08 at 19 39 23 Screenshot 2022-09-08 at 19 39 46 Screenshot 2022-09-08 at 19 40 00

Grounded0 avatar Sep 08 '22 16:09 Grounded0

In addition to productivity applications, Rich ¥Weeds¥ Nagel mentioned another gaming use for SHARE:

Microsoft Flight Simulator 5, the ATC Workshop that comes with the FS5 addon Flight Shop. ATC workshop allows you to create flight "adventures" for FS5 that are totally air traffic controlled.

When I run the utility (FSFSADV.EXE) in Windows 3.11 under DOSBox I get an error message stating the SHARE.EXE hasn't been loaded (see attached screenshot), and then the utility immediately closes/shuts down. The readme for ATC Workshop states that:

WINDOWS 3.1 OWNERS
------------------
The ATC Workshop component of Flight Shop requires SHARE.EXE to be in memory
and configured properly to function. You will need to edit your CONFIG.SYS
file and add or alter the following line:
    
INSTALL=C:\DOS\SHARE.EXE /L:25
    
You will not be able to use ATC Workshop without this addition to your 
CONFIG.SYS.
    
If you are using Windows for Workgroups 3.11 or Windows 95 this is not
an issue.

I dug up a copy from my old backups of SHARE.EXE for MS-DOS 6.22 and ran it before starting Windows 3.11 under DOSBox, but get the same error message. Any idea of a workaround for this?

I recently installed my old copy of Microsoft Flight Simulator 2000 Professional, and have been having a blast flying it. FS2000 supports adventures files from the much older Flight Shop that have been converted to the newer FS2000 format (with the AAFConv.exe utility that comes with FS2000), and I thought that it would be fun using some newly created ones. Hoping that I still can 😀

SHARE EXE_Error

Post is Copyright "Public domain"; all credit to Rich and Vogons.

kcgen avatar Oct 30 '22 18:10 kcgen

The following games are known to suffer the dreaded share.exe not loaded issue during install:

  • Comix Zone (SEGA)
  • Garfield Caught in the Act (SEGA)
  • Microsoft Flight Simulator 5 - ATC Workshop (Microsoft)
  • Monopoly
  • Ultimate Yahtzee (Hasbro)

nemo93 avatar Mar 25 '23 13:03 nemo93

I'd say this is a good addition as it improves compatibility. Also, the issue can be rightfully seen as a gap in the emulation.

Given it seems it can be done cleanly, and it's a small change, it's a no brainer, isn't it? I don't see any drawbacks, only benefits.

johnnovak avatar Mar 25 '23 22:03 johnnovak