Tired of C# and C++? Here's another way to do it (JavaScript)

10/10/2021 03:24 Otakanikaru#1
So everyone is like C# and C++ coding for Silkroad mainly .. now imagine I'm a web developer doing NodeJS and I have no single "will to" or actual knowledge in these and I'd still wanna do my stuff the way the C guys do..

This is something I've found out very recently and It seems to be giving me a new / much simpler way of injecting game offsets/modifying it by using just node.js / javascript (consider use with electron or nwjs).

In simple words: this runs the client from nodejs script & modifies (only one) offset inside a packed dll hooked up to the client without any issues or delays.

Code:
const mem = require('memoryjs'); // https://github.com/Rob--/memoryjs
const {
  openProcess,
  virtualProtectEx,
  readMemory,
  writeMemory,

  // debugger
  Debugger: debuggerInstance,
  awaitDebugEvent,
  handleDebugEvent,

  TRIGGER_ACCESS,
  TRIGGER_WRITE,

  // Types:
  STRING,
  INT,

  PAGE_EXECUTE_READWRITE,
} = mem;
const path = require('path');
const { spawn } = require('child_process');
const [offset, new_url, executable_name] = [
  1444586564, //modifying offset
  'https://facebook.com/gameshiroi', //the new string
  'sro_client.exe',
];

const setupDebugger = processId => {
  debuggerInstance.attach(processId, false);
  const register = debuggerInstance.setHardwareBreakpoint(processId, offset, TRIGGER_ACCESS, STRING);
  
  debuggerInstance.on(register, (event) => {
    console.log(`debug_event`, { event }); // guess what
  });
};

// call this about each 1-1.5s until it executes properly.. actually this works fine without timeout too.. but who knows what the computer some people have.
const doOverrides = () => {
  const spawnedClient = openProcess(executable_name);
  const { 
    handle, 
    th32ProcessID,
  } = spawnedClient;

  if (handle) {
    virtualProtectEx(handle, offset, new_url.length, PAGE_EXECUTE_READWRITE);
    writeMemory(handle, offset, new_url, STRING); // update the offset
    setupDebugger(th32ProcessID, false); // attach a debugger

    console.log({
      spawnedClient,
      read_result: readMemory(handle, offset, STRING), // read value from offset 
    });

  } else {
    setTimeout(doOverrides, 500);
  }
};

// spawn the client:
spawn(path.join(__dirname, 'client', executable_name), [0, '/34', 0, 0]);
// wait for client to be spawned, then inject
setTimeout(doOverrides, 1500);
Run it with NodeJS directly or make your own wrappers.

note:
Above script is just a proof of concept and you will definitely need to think more about how to setup it for your own needs and what environments would it run at.

Hope you find this useful.
10/10/2021 15:37 kotsh23#2
its can be done ? NICE BOSS
please dont stop releasing stuff like that

test:

I get error when i try to run it
Quote:
C:\Users\kotsh\OneDrive\Desktop\test>node index.js
C:\Users\kotsh\OneDrive\Desktop\test\node_modules\ memoryjs\index.js:189
return memoryjs.virtualProtectEx(handle, address, size, protection);
^

Error: an error occurred calling VirtualProtectEx
at virtualProtectEx (C:\Users\kotsh\OneDrive\Desktop\test\node_modules \memoryjs\index.js:189:23)
at Timeout.doOverrides [as _onTimeout] (C:\Users\kotsh\OneDrive\Desktop\test\index.js:50: 5)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
10/10/2021 16:11 JellyBitz#3
You should start by saying why people use C++ or C# in a Windows enviroment, right?

No offense, but this is pretty similar to use a Python or Java application into a Windows enviroment.
As far as I know, you'll be asking to users to install the Javascript package manager or even more steps to the end user to be able to actually play the game, which is overhelming even for regular users.
10/10/2021 16:50 Otakanikaru#4
Quote:
Originally Posted by JellyBitz View Post
You should start by saying why people use C++ or C# in a Windows enviroment, right?

No offense, but this is pretty similar to use a Python or Java application into a Windows enviroment.
As far as I know, you'll be asking to users to install the Javascript package manager or even more steps to the end user to be able to actually play the game, which is overhelming even for regular users.
You might be just have been totally wrong here..
Check out ElectronJS or NWJS - if you use it together with the sample I've provided you will quite easily end up with a fully HTML5 game launcher (see my old source here: [Only registered and activated users can see links. Click Here To Register...]).

What happens is that these packages get bundled to that launcher and nothing is required from the user to download.
You can turn NodeJS app in a single executable.
I've also tested the script it modifies the data instantly in the client as soon as it is launched, there is no performance cost whatsoever.
10/10/2021 16:56 xTryx#5
how can you be tired of C# ? its really easy in comparison to C++ but still at the end of the day the logic is in every langauge the same