Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Questions about Wine on Linux
User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Mon Jun 01, 2020 3:58 pm

All,

Here are the remaining two images for the code enhancements for the "loader.c" file within the "kernelbase" "dll" folder.

Regards,

Craig
Attachments
Loader_5.jpg
Loader_4.jpg

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Sat Jun 06, 2020 5:02 pm

All,

I had an opportunity to do some more analysis on the game programs and how they used the various "Find Resource" and "Get Module Handle" functions in the "loader.c" file and was able to develop a more efficient test and retrieval of the MUI support information in this file. These enhancements supersede the previous code changes I implemented in this source code file and they allow the game programs to load and execute faster. I've attached images of the code changes to the "loader.c" file for your edification. Feel free to analyze and improve upon them.

With that, I believe this is as far as I can go to get a set of features in place to provide rudimentary MUI functionality. Ultimately, we will need to wait on the official addition of MUI support in future releases of Wine. Have fun with the code. It was fun to make these games work in Linux.

Regards,

Craig
Loader_3.jpg
Loader_2.jpg
Loader_1.jpg

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Mon Jun 15, 2020 2:01 pm

Dear DarkShadow44,

Since I've had time to poke around and do lots of low-tech debugging, I did come across an issue that might provide a clue as to why MUI support is not working for Mahjong and the other games that are a part of the Wineaero group. I cannot be certain, but it does appear that the execution of the Mahjong game relies on acquiring data from an XML file stored in the user folder. The name of the file is "MahjongTitans.xml". It is not a typical text file. It appears to contain binary code which to me indicates that it contains resource information. When I added simple trace output to the "ntdll/file.c" function for acquiring file information, the function returns an invalid status. Here is a snippet of the log output.

0024:fixme:file:SetCurrentDirectoryW Setting directory to: L"C:\\users\\craig\\Local Settings\\Application Data"
0024:fixme:file:SetCurrentDirectoryW Setting directory to: L"Microsoft Games"
0024:fixme:file:SetCurrentDirectoryW Setting directory to: L"Mahjong Titans"
0024:fixme:ntdll:NtQueryAttributesFile Checking file attributes >>> L"\\??\\C:\\users\\craig\\Local Settings\\Application Data\\Microsoft Games\\Mahjong Titans\\MahjongTitans.xml"
0024:fixme:ntdll:NtQueryAttributesFile Unix file issues

0024:fixme:file:GetFileAttributesW File name: L"MahjongTitans.xml", invalid attributes
0024:fixme:file:GetFileAttributesW Did not like the file for some reason

The point of failure occurs in the following statement within the "NtQueryAttributesFile" function where is appears to be wanting to open the file:

if (!(status = nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN )))

I tried to manually adjust the file permissions to see if that would help, but nothing seemed to help.

Should this be raised as a bug?

This issue might not be the underlying cause of the program not finding MUI functionality, but not being able to open and read the file would definitely be an issue with the program function.

Regards,

Craig

spoon0042
Level 5
Level 5
Posts: 304
Joined: Thu Dec 24, 2009 11:00 am

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by spoon0042 » Mon Jun 15, 2020 6:46 pm

If the app depends on certain file attributes that could certainly cause issues as afaik that kind of thing is not entirely supported or requires some manual configuration. It may be worth filing a bug or searching for existing bugs on that topic.

User avatar
DarkShadow44
Level 8
Level 8
Posts: 1058
Joined: Tue Nov 22, 2016 5:39 pm

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by DarkShadow44 » Mon Jun 15, 2020 8:42 pm

Hello cschulst,

the question is, why does nt_to_unix_file_name_attr fail?

Would you mind providing your changes as patches instead of screenshots? Then I could check myself.

Regards,
DarkShadow44

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Tue Jun 16, 2020 10:28 am

Dear DarkShadow44,

I was incorrect in that deduction. After actually testing the game program on Windows and then retesting on Linux and watching the folder where that xml file exists, I saw that the game program was actually deleting a backup of the file, renaming the current xml file to be the backup, and then creating a new xml file. So, that was a red herring. The function does actually work. So please disregard my email. Sorry about that.

Anyway, what I think I will do is review the "dll" functions being used by the game program as noted with "Dependency Walker" and maybe try to do some low level debugging in those functions. I can't state for sure, but the issue seems to be with some missing registry information (e.g. with a language pack), Windows version information, or user information. Thanks for getting back to me.

Regards,

Craig

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Tue Jun 16, 2020 8:01 pm

All,

After doing some more testing and outputting of diagnostic data, I do believe somewhere in the game program it is requesting some type of language specific information and when it does not find it, the program falls back to the data in the "Mahjong.exe" file. I was able to actually replicate the garbled window text on my Windows PC by temporarily changing the name of the "en-US" folder to hide the "mui" file. So the bottom line is that when the "mui" file cannot be found, the program falls back to the "exe" file.

From what I could decipher from the code behavior, the game developers constructed their own resource loader functions as there were no documented occurrences of the "Mahjong.exe.mui" file being loaded via a "LoadLibrary" call. If ever the source code were to become available, it would be enlightening to see how they determined the language capabilities and resource loading. But for now, the code changes that provide a reactive acquisition of the "mui" data appears to be a functional workaround. I will periodically check this issue log to see if anyone else has uncovered missing information that fills in the voids. Thanks to everyone for their input.

Regards,

Craig

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Sun Jun 21, 2020 9:48 pm

All,

In doing some more investigation and walking the various game programs through, I did seem to uncover a bit more information. It appears that the programs only use the various iterations of the "LoadLibrary" function to load and assign a module handle to the executable file. Subsequent references evidently happen during the module handle acquisition functionality which possibly is where Wine is still missing some multi-language bits. So having said that, I did do some more program experimentation and was able to reduce the program changes so that they are only contained within file "loader.c" of the "kernelbase" "dll" group. And I applied these enhancements to the "5.11" version of Wine so they are up-to-date. If anyone is interested in seeing the code enhancements, I can grab some "diff" images and paste them into this stream of posts. I noticed just a slightly longer load time, but once the loading of the window was done, the game play was good and all of the text and graphics looked sharp.

I did notice one "knock-on" effect of the code additions. If there are any legitimate resources to be acquired from the executable file, they will not appear. I only found one instance of this with the "Purble Place" game. The icons added to the game summary dialog boxes do not appear. I've attached an example of the standard game dialog from a Windows iteration of the game with the icons and the example of the same dialog box from the version running with Wine. However, there is no effect on the actual game play so this seems a minimal issue. I hope this helps in your investigation of any other multi-language dependent applications.
Dialog_Without_Icons.jpg
Dialog_With_Icons.jpg
Regards,

Craig

nadeloehr
Newbie
Newbie
Posts: 4
Joined: Sat Aug 03, 2019 2:25 pm

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by nadeloehr » Sat Jul 04, 2020 8:49 am

Hi Craig,
could you post your code modifications in a better accessible format? I would suggest you use the git diff command and copypaste its output into a forum post?
Because copying the modifications from images is really tedious :(

Regards,
nadeloehr

User avatar
cschulst
Level 2
Level 2
Posts: 25
Joined: Wed Apr 15, 2020 1:23 pm
Location: United States

Re: Windows 7 Games (Mahjong, Minesweeper, Spider Solitaire, etc.) do not display menu bar (File, Edit, View)

Post by cschulst » Sun Jul 05, 2020 11:41 am

Dear nadeloehr,

I couldn't seem to find a suitable editor to provide a good difference view for cutting and pasting, so I decided to go ahead and set up a simple repository out on GitHub and add the code there. I uploaded the unmodified code for file "loader.c", then applied my coding changes, and committed the changes. You should be able to view and pull down a copy of the updated code from there as it is a public repository. Here is the link:

https://github.com/cschuls/WineMUI.git

FYI, this is the source code file from Wine version 5.12. When the newest Wine development versions have been coming out, I've been refreshing my virtual machine sandbox and applying the code changes to that source code file to try to ensure that there are no regression issues and so far there have been none. If you still are working with an earlier development version of Wine, these changes probably will still work.

A couple of other things to note. I experimented with additional conditional testing so that I could get some of the bitmap resources to show as well and I was successful with that. Since I am not experienced with PE entries and such nor am I an experienced C programmer, I took a more "low-tech" approach to distinguish between language-specific resources and data such as bitmaps by reviewing the range of handle values used by each group of resources. There seemed to be a pattern to the assignment ranges. So that's where you will see the conditional calls to the "GetMUI" function based upon arbitrary handle value ranges. It was not ideal but it seems to work. Also, with the use of the language ID in lieu of the language environment code, the program probably won't crash if a language environment value is not set up. You will see in the code though, that I could not get the function to directly retrieve the locale code to work so again, I dropped back to a bit of a "low-tech" process of using a "switch/case" set. But, it all seems to work. I hope it works for you. :)

With that, this is probably as far as I will go in tweaking the code. However, I will monitor this subject periodically.

Regards,

Craig

Post Reply