sekwah41 / mobalytics-repackager

Mobalytics tool for linux
11 stars 3 forks source link

Investigate Overlay #8

Open sekwah41 opened 2 years ago

sekwah41 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago
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 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

The next part is trying to figure out what electron_overlay provides

sekwah41 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

Copying files to a temp folder seems to do the trick

sekwah41 commented 2 years ago

image

sekwah41 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

Seeing as this is taking a while come back to it, try implementing a rest service or some sort of local communication (refferably without sockets) look at the/tmp/MOBA-OVERLAY-CLIENT- /tmp/MOBA-OVERLAY-SERVER and see if that works across clients

sekwah41 commented 2 years ago

Rather than trying to do it the "right" way just get it bloody working first.

Try to use net or whatever to just enable all calls

sekwah41 commented 2 years ago

Major fps issues found though this may be because initMemoryScannerForLoL is called every time. Check that out.

(Quite likely something like that rather than laggy calls as it seems to get worse and worse over time rapidly)

Though killing mobalytics seems to fix it so not sure whats causing the problems especially as we cant see inside the module.

sekwah41 commented 2 years ago

Need to look to pass the data through properly now and await the proper functions so that the data gets set. Look at lol-internal-data/lol-memory-scanner.js

sekwah41 commented 2 years ago

It was an issue of the new code not accepting the async functions, needed to fix that then the init memory scanner stopped lagging

sekwah41 commented 2 years ago

Just need to fix the window as the messages don't go through and then see whats wrong next

sekwah41 commented 2 years ago

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 commented 2 years ago

image Heck yea :D

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

game-overlay-manager createOverlayWindow isnt even called

sekwah41 commented 2 years ago

ensureOverlayWindow in game-overlay-manager does get called

sekwah41 commented 2 years ago

so does createOverlayWindow making a lol overlay window

sekwah41 commented 2 years ago

The overlay window is deffo made using ensureOverlayWindow

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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

sekwah41 commented 2 years ago

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 commented 2 years ago

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.