Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 13:56

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



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

Discussion on Tired of C# and C++? Here's another way to do it (JavaScript) within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1

 
Otakanikaru's Avatar
 
elite*gold: 133
Join Date: Nov 2013
Posts: 454
Received Thanks: 455
Tired of C# and C++? Here's another way to do it (JavaScript)

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.
Otakanikaru is offline  
Thanks
4 Users
Old 10/10/2021, 15:37   #2
 
elite*gold: 0
Join Date: Jul 2020
Posts: 164
Received Thanks: 15
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)
kotsh23 is offline  
Old 10/10/2021, 16:11   #3
 
JellyBitz's Avatar
 
elite*gold: 0
Join Date: Sep 2018
Posts: 423
Received Thanks: 953
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.
JellyBitz is offline  
Thanks
3 Users
Old 10/10/2021, 16:50   #4

 
Otakanikaru's Avatar
 
elite*gold: 133
Join Date: Nov 2013
Posts: 454
Received Thanks: 455
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: ).

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.
Otakanikaru is offline  
Thanks
1 User
Old 10/10/2021, 16:56   #5
 
elite*gold: 130
Join Date: May 2013
Posts: 399
Received Thanks: 313
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
xTryx is offline  
Reply


Similar Threads Similar Threads
[Trading] WTS/WTT GE5|GE4 and another with merged servers and ITA1|GE7 and another merged too
12/10/2018 - DarkOrbit Trading - 1 Replies
Ge5 100k U Chief Captain Full havoc Full Hércules 10 drones level 16 45 lf 4 level 16 20 bo2 level 16 47 pp need 1 k logfiles for 48 128 k for reset
Tired of bad BG's? Need fast honor? Click here
01/10/2007 - WoW Exploits, Hacks, Tools & Macros - 5 Replies
In silithus it is a world pvp event thing. There is geysuers called silithyst or something like that. If you go to your factions base (horde is south, near bronzebeard encampment, alliance is a bit north and west of that, other side of the path) there is a quest giver there that tells you to get silithyst. now everytime you get silithyst you get 19 honor. This is where the fast part comes in. Get cheat engine and protect it, now if you want further protection search google for a process...
tired of the co ads ?? Well here is your salvation
02/25/2006 - Conquer Online 2 - 5 Replies
Ever wish you could get rid of those pesky stupid ads they added to login screen?? Well here is your answer :D GO to your ini folder and look for file called common.ini and scroll near the bottom under and you will see right below it a line similar to this... http://conqueronline.blablabla/adtext.txt



All times are GMT +1. The time now is 13:56.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.