joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.53k stars 371 forks source link

Builtin DIR excluding some items (Windows) #4974

Open maxpat78 opened 2 months ago

maxpat78 commented 2 months ago

Describe the bug

When mounting a Windows local drive in DosBox-X, a DIR should display the same items you'd find with the Windows CMD prompt. In fact, this does not happen.

Consider the following:

MOUNT C C:\
DIR /A C:\
DIR /A C:\Windows\Sys*

You'll find that the first DIR invocation omits directories like "Config.msi", "Recovery", "System Volume Information"; the second, directories like "System32", "SystemApps", "SyetemResources", "SystemTemp", "SysWOW64".

Having reviewed the sources, this seems related to the ht_temp call (wstat64) returning -1 instead of 0 with such directories.

In fact, those are directories with special NTFS access rights.

An Administrator user surely can call wstat successfully on them, but normal users can typically list them without invoking special privileges (i.e. with Explorer, or CMD itself).

Steps to reproduce the behaviour

See above.

Expected behavior

See above.

What operating system(s) this bug have occurred on?

Windows 11 x64 22H2

What version(s) of DOSBox-X have this bug?

latest commit

Used configuration

Vanilla

Output log

-

Additional information

My first attempt with AdjustTokenPrivileges WIN32 API didn't succeed, something was changed with privilege handling by normal users.

Have you checked that no similar bug report(s) exist?

Code of Conduct & Contributing Guidelines