mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
update arRPC
This commit is contained in:
parent
a532cb9a72
commit
362a116e6a
5 changed files with 10621 additions and 82477 deletions
|
@ -1,7 +1,7 @@
|
||||||
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
|
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
|
||||||
const log = (...args) => console.log(`[${rgb(88, 101, 242, "arRPC")}]`, ...args);
|
const log = (...args) => console.log(`[${rgb(88, 101, 242, "arRPC")}]`, ...args);
|
||||||
|
|
||||||
log("arRPC v3.3.1 ArmCord");
|
log("arRPC v3.4.0 ArmCord");
|
||||||
const RPCServer = require("./server.js");
|
const RPCServer = require("./server.js");
|
||||||
const {mainWindow} = require("../../../ts-out/window.js");
|
const {mainWindow} = require("../../../ts-out/window.js");
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -24,15 +24,19 @@ class ProcessServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async scan() {
|
async scan() {
|
||||||
const startTime = performance.now();
|
// const startTime = performance.now();
|
||||||
const processes = await Native.getProcesses();
|
const processes = await Native.getProcesses();
|
||||||
const ids = [];
|
const ids = [];
|
||||||
|
|
||||||
// log(`got processed in ${(performance.now() - startTime).toFixed(2)}ms`);
|
// log(`got processed in ${(performance.now() - startTime).toFixed(2)}ms`);
|
||||||
|
|
||||||
for (const [pid, _path] of processes) {
|
for (const [pid, _path, args] of processes) {
|
||||||
const path = _path.toLowerCase().replaceAll("\\", "/");
|
const path = _path.toLowerCase().replaceAll("\\", "/");
|
||||||
const toCompare = [path.split("/").pop(), path.split("/").slice(-2).join("/")];
|
const toCompare = [];
|
||||||
|
const splitPath = path.split("/");
|
||||||
|
for (let i = 1; i < splitPath.length; i++) {
|
||||||
|
toCompare.push(splitPath.slice(-i).join("/"));
|
||||||
|
}
|
||||||
|
|
||||||
for (const p of toCompare.slice()) {
|
for (const p of toCompare.slice()) {
|
||||||
// add more possible tweaked paths for less false negatives
|
// add more possible tweaked paths for less false negatives
|
||||||
|
@ -42,7 +46,19 @@ class ProcessServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const {executables, id, name} of DetectableDB) {
|
for (const {executables, id, name} of DetectableDB) {
|
||||||
if (executables?.some((x) => !x.isLauncher && toCompare.some((y) => x.name === y))) {
|
if (
|
||||||
|
executables?.some((x) => {
|
||||||
|
if (x.is_launcher) return false;
|
||||||
|
if (
|
||||||
|
x.name[0] === ">"
|
||||||
|
? x.name.substring(1) !== toCompare[0]
|
||||||
|
: !toCompare.some((y) => x.name === y)
|
||||||
|
)
|
||||||
|
return false;
|
||||||
|
if (args && x.arguments) return args.join(" ").indexOf(x.arguments) > -1;
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
) {
|
||||||
names[id] = name;
|
names[id] = name;
|
||||||
pids[id] = pid;
|
pids[id] = pid;
|
||||||
|
|
||||||
|
@ -50,26 +66,27 @@ class ProcessServer {
|
||||||
if (!timestamps[id]) {
|
if (!timestamps[id]) {
|
||||||
log("detected game!", name);
|
log("detected game!", name);
|
||||||
timestamps[id] = Date.now();
|
timestamps[id] = Date.now();
|
||||||
|
|
||||||
this.handlers.message(
|
|
||||||
{
|
|
||||||
socketId: id
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cmd: "SET_ACTIVITY",
|
|
||||||
args: {
|
|
||||||
activity: {
|
|
||||||
application_id: id,
|
|
||||||
name,
|
|
||||||
timestamps: {
|
|
||||||
start: timestamps[id]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resending this on evry scan is intentional, so that in the case that arRPC scans processes before Discord, existing activities will be sent
|
||||||
|
this.handlers.message(
|
||||||
|
{
|
||||||
|
socketId: id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cmd: "SET_ACTIVITY",
|
||||||
|
args: {
|
||||||
|
activity: {
|
||||||
|
application_id: id,
|
||||||
|
name,
|
||||||
|
timestamps: {
|
||||||
|
start: timestamps[id]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ const getProcesses = async () =>
|
||||||
(pid) =>
|
(pid) =>
|
||||||
+pid > 0 &&
|
+pid > 0 &&
|
||||||
readFile(`/proc/${pid}/cmdline`, "utf8").then(
|
readFile(`/proc/${pid}/cmdline`, "utf8").then(
|
||||||
(path) => [+pid, path.replaceAll("0", "")],
|
(path) => [+pid, path.split("\0")[0], path.split("\0").slice(1)],
|
||||||
() => 0
|
() => 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,28 +34,28 @@ class RPCServer extends EventEmitter {
|
||||||
onConnection(socket) {
|
onConnection(socket) {
|
||||||
socket.send({
|
socket.send({
|
||||||
cmd: "DISPATCH",
|
cmd: "DISPATCH",
|
||||||
evt: "READY",
|
|
||||||
nonce: "initial-ready",
|
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
v: 1,
|
v: 1,
|
||||||
|
config: {
|
||||||
// needed otherwise some stuff errors out parsing json strictly
|
cdn_host: "cdn.discordapp.com",
|
||||||
|
api_endpoint: "//discord.com/api",
|
||||||
|
environment: "production"
|
||||||
|
},
|
||||||
user: {
|
user: {
|
||||||
// mock user data using arRPC app/bot
|
// mock user data using arRPC app/bot
|
||||||
id: "1045800378228281345",
|
id: "1045800378228281345",
|
||||||
username: "arRPC",
|
username: "arrpc",
|
||||||
discriminator: "0000",
|
discriminator: "0",
|
||||||
|
global_name: "arRPC",
|
||||||
avatar: "cfefa4d9839fb4bdf030f91c2a13e95c",
|
avatar: "cfefa4d9839fb4bdf030f91c2a13e95c",
|
||||||
|
avatar_decoration_data: null,
|
||||||
|
bot: false,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
premium_type: 0
|
premium_type: 0
|
||||||
},
|
|
||||||
config: {
|
|
||||||
api_endpoint: "//discord.com/api",
|
|
||||||
cdn_host: "cdn.discordapp.com",
|
|
||||||
environment: "production"
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
evt: "READY",
|
||||||
|
nonce: null
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.socketId = socketId++;
|
socket.socketId = socketId++;
|
||||||
|
@ -130,7 +130,12 @@ class RPCServer extends EventEmitter {
|
||||||
|
|
||||||
socket.send?.({
|
socket.send?.({
|
||||||
cmd,
|
cmd,
|
||||||
data: null,
|
data: {
|
||||||
|
...activity,
|
||||||
|
name: "",
|
||||||
|
application_id: socket.clientId,
|
||||||
|
type: 0
|
||||||
|
},
|
||||||
evt: null,
|
evt: null,
|
||||||
nonce
|
nonce
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue