Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Investigate Overlay #8

Open
sekwah41 opened this issue Nov 5, 2021 · 66 comments
Open

Investigate Overlay #8

sekwah41 opened this issue Nov 5, 2021 · 66 comments

Comments

@sekwah41
Copy link
Owner

sekwah41 commented Nov 5, 2021

See what other features e.g. the overlay and how they work.

May not be able to get it working though may be able to add info on how to get it working directly in wine?

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 5, 2021

Even if its just to learn something from the both of them, compare how the mac one works vs windows

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 6, 2021

Could possibly look into running command line and run the overlay exe within the wine prefix.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 6, 2021

May be able to use /proc/%processid%/environ to find what to run the process with to get it running in the same environment

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 6, 2021

px aux | grep "C:/Riot Games/League of Legends/LeagueClient.exe"

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 7, 2021

image
Managed to spawn task manager from within the same instance remotely, need to try to find why the overlay exe is crashing

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 7, 2021

The overlay injector process seems to be able to spawn in wine just fine using the below code

const child_process = require('child_process');

const test = child_process.spawn('mobalytics_overlay.exe');

const {stdout, stderr} = test;
            if (stdout) {
                stdout.on('data', (data) => {
                    console.log(`stout data, data: ${data}`);
                });
                stdout.on('close', (code, signal) => {
                    console.log(`stout was closed, code: ${code}, signal: ${signal}`);
                });
                stdout.on('error', (err) => {
                    console.log(`stout error: ${err}`);
                });
                stdout.on('exit', (code, signal) => {
                    console.log(`stout exit, code: ${code}, signal: ${signal}`);
                });
                stdout.on('message', (message) => {
                    console.log(`stout, message: ${message}`);
                });
            }
            if (stderr) {
                stderr.on('data', (data) => {
                    console.log(`stderr, data: ${data}`);
                });
                stderr.on('close', (code, signal) => {
                    console.log(`stderr was closed, code: ${code}, signal: ${signal}`);
                });
                stderr.on('error', (err) => {
                    console.log(`stderr error: ${err}`);
                });
                stderr.on('exit', (code, signal) => {
                    console.log(`stderr exit, code: ${code}, signal: ${signal}`);
                });
                stderr.on('message', (message) => {
                    console.log(`stderr, message: ${message}`);
                });
            }
            test.on('close', (code, signal) => {
                console.log(`was closed, code: ${code}, signal: ${signal}`);
            });
            test.on('error', (err) => {
                console.log(`error: ${err}`);
            });
            test.on('exit', (code, signal) => {
                console.log(`exit, code: ${code}, signal: ${signal}`);
            });
            test.on('message', (message) => {
                console.log(`exit, message: ${message}`);
            });
            test.on('spawn', (message) => {
                console.log(`overlay injector spawned`, {message});
            });
            

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 7, 2021

At least the spawn events are triggered, need to look to create a connection layer and possibly create a new process spawner exe file using https://www.npmjs.com/package/pkg with NODE_SKIP_PLATFORM_CHECK=1 to skip the main checks

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 7, 2021

Look for the best way to spawn and pipe the data back into the other side.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 8, 2021

To test it you must use export NODE_SKIP_PLATFORM_CHECK=1 and set NODE_SKIP_PLATFORM_CHECK=1 to make sure pkg will run in wine

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 8, 2021

Easiest way to test rapidly. Create a node script which you run directly trying to test the exe. Just raw everything.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 8, 2021

const info = child_process_1.spawn(command, {
        shell: true,
        stdio: ['pipe', 'inherit', 'inherit'],
        env: {
            ...leagueVariables,
            NODE_SKIP_PLATFORM_CHECK: "1"
        }
    });

You can spawn processes fine inside if you have console.log outputs. However you lose access to stdout and stderr, you didn't have access anyway because of wine.

Look to make a socket pipe for any that are needed and just look for the spawn other events.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 9, 2021

More of it is now running, possibly try moving the files within the file system first and see if it fixes wine: Read access denied for device L"\??\Z:\", FS volume label and serial are not available

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 9, 2021

https://forum.winehq.org/viewtopic.php?f=8&t=33574 may be similar error

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 9, 2021

In the most recent edits league stutters (I assume its while its injecting) just need to connect the sdout and other parts now hopefully :D

Seems the error was it was trying to run from the wrong directory

@sekwah41
Copy link
Owner Author

The next part is trying to figure out what electron_overlay provides

@sekwah41
Copy link
Owner Author

Look into https://nodejs.org/api/net.html#netcreateconnectionpath-connectlistener and using it to connect info back to the other side. Possibly try to create an IPC module restructurer.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 10, 2021

The module is creatable when the module is enabled in windows.

The main reason the overlay app can't just be run in windows is the fact that the visuals are entirely fucked for electron.

Take a look to see if it may be easier to wrap a larger part of the program in this rather than small parts. Though from now on it doesn't seem like processes but ipc messages and function calls.

Though this module at least has to be in league otherwise it cant read the league memory.

@sekwah41
Copy link
Owner Author

@sekwah41
Copy link
Owner Author

For now instead of IPC use sockets on specific ports then try to connect in and out of wine

@sekwah41
Copy link
Owner Author

possibly try connecting everything through one socket for now and add an identifier at the start. Or use env args to state the ports to connect through.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 10, 2021

Seems nexe has some of its own problems but it fixes the problem of the sdout. Should be able to use the already existing stuff to communicate with it :D though make a compat layer for the overlay provider

@sekwah41
Copy link
Owner Author

Error with nexe instead is `Processes utils | stderr, data: node:internal/modules/cjs/loader:1183
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: /home/sekwah/.config/mobalytics-desktop/moba-extra-resources/overlay-module/1.0.0/win/electron_overlay.node: invalid ELF header
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/home/sekwah/.config/mobalytics-desktop/moba-extra-resources/overlay-module/1.0.0/win/src/overlay-provider/provider-connector.js:5:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'ERR_DLOPEN_FAILED'
}
`
Need to figure out why opening this file causes this error and how to properly handle process.cwd() (as its not the terminal working directory its the main parent process one?)

@sekwah41
Copy link
Owner Author

When switching to node windows x64-14 it seems to get Error: EINVAL: invalid argument, lstat 'Z:'

@sekwah41
Copy link
Owner Author

Using a lower version of node with pkg seems to remove the issues of pkg (though havent checked importing yet)

@sekwah41
Copy link
Owner Author

image
now thats actually useful feedback, 100% recommend pkg over nexe

@sekwah41
Copy link
Owner Author

Seems the issue may be because its on the wrong drive C:\ -> Z:\ in wine

@sekwah41
Copy link
Owner Author

Copying files to a temp folder seems to do the trick

@sekwah41
Copy link
Owner Author

image

@sekwah41
Copy link
Owner Author

Problem is uv_pipe_open issue is back, using pkg helped and seems to be better when not using wine and this specific use case

@sekwah41
Copy link
Owner Author

the problem is with nexe that it seems to detect that its linux and fuck everything up

@sekwah41
Copy link
Owner Author

Looking at all the events being send its getting ALL of the data. I just need to force spawn the overlay and recode any parts which are being dodgy.

@sekwah41
Copy link
Owner Author

image
Heck yea :D

@sekwah41
Copy link
Owner Author

Seems to be something in lol-overlay-window or base-overlay-window.

@sekwah41
Copy link
Owner Author

game-overlay-manager createOverlayWindow isnt even called

@sekwah41
Copy link
Owner Author

ensureOverlayWindow in game-overlay-manager does get called

@sekwah41
Copy link
Owner Author

so does createOverlayWindow making a lol overlay window

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 14, 2021

The overlay window is deffo made using ensureOverlayWindow

@sekwah41
Copy link
Owner Author

The overlay window controller is being made but not the this.window 🤔

@sekwah41
Copy link
Owner Author

Need to find why the overlay window objects exist but not the window variable inside

@sekwah41
Copy link
Owner Author

If its found that the windows one wont work try looking at the mac overlay as it may not need the injection

@sekwah41
Copy link
Owner Author

The problems may not lie in the lol overlay as the .create function is not called. It may be to do with the base overlay or something else not being able to get size data or process id's.

@sekwah41
Copy link
Owner Author

There seems to be an error with the overlay server path. Going to try sockets too.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 14, 2021

May need to convert the overlay-server to connect to a port and then pipe the data from

//const CLIENT_PATH = '\\\\.\\pipe\\MOBA-OVERLAY-CLIENT-';
//const SERVER_PATH = '\\\\.\\pipe\\MOBA-OVERLAY-SERVER';

to the ports

@sekwah41
Copy link
Owner Author

Look to make a proxy on two unused ports for each of these files then rewrite how the base-overlay-server connects so that the injector written by mobalytics properly is connected.

@sekwah41
Copy link
Owner Author

Probably best to not rewrite the logic but to connect our own logic to where it is expecting the data. That way it can be handled solely in our connector classes.

@sekwah41
Copy link
Owner Author

Finally found why all the logs were not going to console, now can debug a lot more :D

@sekwah41
Copy link
Owner Author

Proxy is now working one way. Need to now pipe the data and dynamically create the connections going the other way.

@sekwah41
Copy link
Owner Author

May need to seperate the process injector to another process. Or you may be able to just keep the process around and running.

@sekwah41
Copy link
Owner Author

now the errors are trying to get the tmp files for specific processes.

2021-11-15T03:26:52.880Z error: Overlay server | connection to injector error, app name: league of legends.exe pid: 1604 {"error":{"errno":-2,"code":"ENOENT","syscall":"connect","address":"/tmp/MOBA-OVERLAY-CLIENT-1604"}}

@sekwah41
Copy link
Owner Author

An econnreset is happening likely due to this

@sekwah41
Copy link
Owner Author

Need to look into why translateInputEvent is returning empty data, though for now no input is better so fixed the crash error. Looking into making it interact after rendering is working.

@sekwah41
Copy link
Owner Author

sekwah41 commented Nov 15, 2021

The client constantly keeps trying to recreate the connections, so making it lazily is no issue, just need to use the connector to set it up on a free port and presto we should be good :D

@sekwah41
Copy link
Owner Author

For some reason, 'get-port' is suddenly messing up.

2021-11-21T23:52:34.639Z error: Uncaught promise exception error:  Cannot find package 'get-port' imported from /home/sekwah/.projects/mobalinux/dist/linux-unpacked/resources/app.asar/electron-src/moba-desktop/src/game-overlay/league-helper.js
Did you mean to import get-port/index.js? {"code":"ERR_MODULE_NOT_FOUND","stack":"Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'get-port' imported from /home/sekwah/.projects/mobalinux/dist/linux-unpacked/resources/app.asar/electron-src/moba-desktop/src/game-overlay/league-helper.js\nDid you mean to import get-port/index.js?\n    at packageResolve (internal/modules/esm/resolve.js:655:9)\n    at moduleResolve (internal/modules/esm/resolve.js:696:18)\n    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)\n    at Loader.resolve (internal/modules/esm/loader.js:88:40)\n    at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)\n    at Loader.import (internal/modules/esm/loader.js:176:28)\n    at importModuleDynamically (internal/modules/cjs/loader.js:1018:27)\n    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)\n    at Object.<anonymous> (/home/sekwah/.projects/mobalinux/dist/linux-unpacked/resources/app.asar/electron-src/moba-desktop/src/game-overlay/league-helper.js:4:23)\n    at Module._compile (internal/modules/cjs/loader.js:1083:30)"}
error Command failed with exit code 1.

@sekwah41
Copy link
Owner Author

Need to look into whats causing the new promise issues.

@sekwah41
Copy link
Owner Author

sekwah41 commented Dec 6, 2021

Looks like most things are now connected, however there is a problem with the frame buffers being serialised. Data exists however the logic in sendFrameBuffer in base-overlay-provider errors on the OverlayIPC.Event.createEvent line.

Need to check the data being passed in and possibly try to preview one of the bitmap buffers.

@sekwah41
Copy link
Owner Author

sekwah41 commented Dec 9, 2021

For now it is not a priority though it seems pretty close to possibly working. I will have to focus on my other projects for now but ill still try to tinker with this :D

@fabifont
Copy link

Hi @sekwah41 , are you still working on this issue? It would be a great thing if you manage to have the in-game overlay working as it would be the first overlay for LoL working in Linux.

@sekwah41
Copy link
Owner Author

sekwah41 commented Apr 1, 2023

I can re-try the steps I made to see if I can get further. Last time I got pretty and managed to inject processes within the wine process to get data back, though I would need to still push the overlay data back or find another way of rendering it on top hopefully not going back within wine to avoid as much fps loss.

Ill add some tasks onto my organiser and see when i get around to it or have a weekend to experiment :)

@fabifont
Copy link

fabifont commented Apr 1, 2023

I can re-try the steps I made to see if I can get further. Last time I got pretty and managed to inject processes within the wine process to get data back, though I would need to still push the overlay data back or find another way of rendering it on top hopefully not going back within wine to avoid as much fps loss.

Ill add some tasks onto my organiser and see when i get around to it or have a weekend to experiment :)

Amazing. I think that also a wine version could be fine because at least we would have a working overlay even if there will be less FPS (I think this is also negligible, I hope in 2023 almost everyone should be capable to run League of Legends without FPS problems)

@sekwah41
Copy link
Owner Author

sekwah41 commented Apr 1, 2023

Not sure how dodgy the stuff I was doing was so thats why I was trying to figure out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants