CameronRedmore / memory-deck

A Decky Loader plugin that allows scanning and editing of memory values.
GNU General Public License v3.0
37 stars 11 forks source link

[bug] Doesn't work with native linux port? Tropico 5 case #8

Closed Mte90 closed 4 months ago

Mte90 commented 1 year ago

IMG_20221223_224859.jpg Seems that with steamtinkerlaunch in the process list find Tropico.exe so can scan it without troubles (as launch the game differently compared to the screen above when it's just steam). Instead launching with steam find just the path and not a process so the scan is not working.

Probably the issue is there as is not using a process the scan don't work. Maybe a check like if that path is a file or a folder can improve the situation. Why it's happening? I have no idea I don't know so much C++ to understand where it is the issue.

Continue from https://github.com/CameronRedmore/memory-deck/issues/7

HeyItsWaters commented 1 year ago

The process list is generated using Python, not C++ See https://github.com/CameronRedmore/memory-deck/blob/e38ce4c019463a5c854f1dd4a7ab2743b8bae7a5/main.py#L12-L44

For clarification, you're saying if you launch Tropico 5 through the normal SteamOS launcher, the memory-deck plugin does not scan the process (Tropico5) correctly? (Does it scan the process but won't return results? How does it fail?)

But if you launch Tropico 5 through Steam Tinker Launch, you can use memory-deck to scan the process (Tropico5.exe) and it works as expected? You can find and alter values?

Mte90 commented 1 year ago

Yes exactly

For clarification, you're saying if you launch Tropico 5 through the normal SteamOS launcher, the memory-deck plugin does not scan the process (Tropico5) correctly? (Does it scan the process but won't return results? How does it fail?)

But if you launch Tropico 5 through Steam Tinker Launch, you can use memory-deck to scan the process (Tropico5.exe) and it works as expected? You can find and alter values?

I can do some tests on the desktop mode with steam client to see if there is something that can be helpful.

HeyItsWaters commented 1 year ago

Please do, the more information the better, since I don't have that game I can't recreate this exact issue.

I'm interested to know how STL launches the game differently...I wonder if it uses some kind of native version of the game or some kind of native Linux sandbox to run the game...

Whereas SteamOS probably uses Proton (which uses Windows emulation under the hood). This would explain why you see the .exe in the process list (.exe files are typically Windows exectuable files).

I would have guessed that the Proton version would behave more nicely with memory-deck, but who knows.

If you're feeling adventurous, you can launch the Konsole application in desktop mode and run the ~/homebrew/plugins/memory-deck/main.py manually (you will have to "uncomment" code at the bottom of that file) to see if there are any errors. I should really write up some step-by-step instructions on manually running this plugin at somepoint.

Mte90 commented 1 year ago

IMG_20221229_202115.jpg Searching on terminal with the same command reveals the path. Checking that Tropico is a real Linux program and not something that use proton. IMG_20221229_202358.jpg Output of the plugin (maybe with other programs to blacklist) but it's there after selecting no search it is possible. IMG_20221229_202436.jpg IMG_20221229_202502.jpg Also using the different operator, results always 0.

I read online that they crypt maybe values but with something like this I should be able to get something.

HeyItsWaters commented 1 year ago

I'd be really curious if you ran the game in Desktop Mode through the normal Steam Launcher, and used that main.py file I mentioned in my last comment.

Again, you'd have to open the main.py file in a text editor and remove the # from the following lines: https://github.com/CameronRedmore/memory-deck/blob/e38ce4c019463a5c854f1dd4a7ab2743b8bae7a5/main.py#L130-L183

If you can run that while the game is running (python3 main.py), provide it the process ID (which you can get from running ps aux | grep -i tropico in Konsole, it'll be the first number in the output from that) and then search for a value and provide that output here or in a pastebin?

We can chat on Discord if you rather find me there.

Mte90 commented 1 year ago

To search with terminal I was in desktop mode but to test memory deck I was in gaming mode. Maybe memory deck does not work fine with native Linux stuff?

HeyItsWaters commented 1 year ago

Perhaps? I haven't really checked which games are using Proton vs native linux.

Running that main.py file while in desktop mode is like running a slimmed down version of memory-deck.

Mte90 commented 1 year ago

Right now I am using the SD without a keyboard and manipulate a file with the keyboard on screen is not very comfortable. Anyway the pid is the right one, I think that I will check if I have some game linux native to see if that idea is real before to do other tests.

kayon commented 1 year ago

Native Linux games don't work, permission denied. Edit /home/deck/homebrew/plugins/memory-deck/plugin.json add "root" to "flags", then reboot.

"flags": ["debug", "root"],

Mte90 commented 1 year ago

This explains a lot, how did you got the error?

HeyItsWaters commented 1 year ago

@kayon I am also interested in this - where did you see a permission denied error?

Admittedly I haven't really used the plugin on any linux-native games on my Steam Deck, all the games I've tried are being ran through proton.

kayon commented 1 year ago

@kayon I am also interested in this - where did you see a permission denied error?

Admittedly I haven't really used the plugin on any linux-native games on my Steam Deck, all the games I've tried are being ran through proton.

Run main.py through ssh, Permission denied after search. In addition, the search for Float and Double will never result, needs to be modified like this. main.py line: 160, in the method: search_regions

                case "c_float":
                    val.flags |= MatchFlag.FLAG_F32B
                    val.float32_value = float(searchValue)
                case "c_double":
                    val.flags |= MatchFlag.FLAG_F64B
                    val.float64_value = float(searchValue)
                case _:
                    print("Invalid value!")
                    return False
        if val.flags & MatchFlag.FLAG_F32B or val.flags & MatchFlag.FLAG_F64B:
            self.scanmem.globals.options.scan_data_type = ScanDataType.ANYFLOAT
        else:
            self.scanmem.globals.options.scan_data_type = ScanDataType.ANYINTEGER
Mte90 commented 1 year ago

I don't have anymore tropico installed, someone that can test it?

colpocleisis commented 1 year ago

I tested with hollow knight, dead cells and Slay the Spire native ports, can confirm @kayon solution works

HeyItsWaters commented 4 months ago

v0.1.8 has been released to the test Decky store, should hit the production store soon. it should resolve this issue.