Register for your free account! | Forgot your password?

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

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

Advertisement



[Mini-Release] Customizing New Console Commands

Discussion on [Mini-Release] Customizing New Console Commands within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 100
Join Date: Sep 2017
Posts: 1,109
Received Thanks: 903
[Mini-Release] Customizing New Console Commands

Hey there,

Things were a little boring lately, exams, life... This brings us back to developing hard days.

If you're still interested into developing SRO, yo dude, this thread is for you.

Introduction Video

The goal of the thread won't be that useful for servers as a gameplay, I mean, it will be useful as for staff members only, since they should be the only people who use the console.

What Can I Use This For: Basically, you can do more stuff controlling the server if you have got your own filter or emulator, and you know how to do the communication between the client and the server. But remember to check user's primary & content group before doing the command job, or normal players will play around with media, open console and cheat.


Background Work: Well, searching this could be one of the easiest things you may try to find, the first & correct idea should be in your mind is looking for an existing command name in sro_client strings, and yeah, that's it.

Basically, the client has a list of existing commands, it's loaded on sro_client loading. So, we can hook the function that loads commands and load our custom commands with it, pretty simple. Here's a final output of my code,

Note: I used florian's hooking lib to hook, if you wanna use it, you'll find it in the attachments.

IFConsole.h:
Code:
#pragma once
#include <Windows.h>
#include <iostream>
#include <vector>

typedef bool (CALLBACK ConsoleCommandFunc)(class ConsoleCommandData*);
static std::vector<std::pair<const wchar_t*, ConsoleCommandFunc*>> CustomConsoleCommands;

class ConsoleCommandData
{
public:
	char pad_0000[68]; //0x0000
	const wchar_t* FullCommand; //0x0044
};

class CIFConsole
{
public:
	static void InitializeCustomCommands();
	void OnCommandsLoading();
	void AddCommand(std::wstring commandmaintext, ConsoleCommandFunc* func, int a3);
};
IFConsole.cpp:
Code:
#include "IFConsole.h"
#include "hook.h"
#include "Global.h"

static bool CALLBACK MyCuteTestingFunc(ConsoleCommandData* cmddata)
{
	wchar_t buffer[255];
	swprintf_s(buffer, L"Custom Command Debuggging, Command Entered Text: (%s).", cmddata->FullCommand);
	IngameDebug(buffer);
	return true; // return key success
}

void CIFConsole::InitializeCustomCommands(void)
{
	replaceOffset(0x0055A027, addr_from_this(&CIFConsole::OnCommandsLoading));

	CustomConsoleCommands.push_back(std::pair<const wchar_t*, ConsoleCommandFunc*>(L"HelloWorld", MyCuteTestingFunc));
}

void CIFConsole::OnCommandsLoading(void)
{
	for (auto i = CustomConsoleCommands.begin(); i != CustomConsoleCommands.end(); i++)
	{
		this->AddCommand(i->first, i->second, 0);
	}
	reinterpret_cast<void(__thiscall*)(CIFConsole*)>(0x00558910)(this);
}

void CIFConsole::AddCommand(std::wstring commandmaintext, ConsoleCommandFunc* func, int a3)
{
	reinterpret_cast<void(__thiscall*)(CIFConsole*, std::wstring, ConsoleCommandFunc*, int)>(0x00555DB0)(this, commandmaintext, func, a3);
}
Note: Any addresses given above were found on VSRO 1.88 sro_client, so they are most likely different on any other version.
Note: Structures above are for VC80 libs, back when string/wstring was 28 bytes.
Note: Always compile on Release!

Special thanks to: florian0
Attached Files
File Type: rar Hook.rar (915 Bytes, 156 views)
#HB is offline  
Thanks
8 Users
Old 06/01/2019, 23:41   #2
 
elite*gold: 0
Join Date: May 2018
Posts: 244
Received Thanks: 119
Good Work dude
Hercules* is offline  
Old 06/02/2019, 15:38   #3

 
XxGhostSpiriTxX's Avatar
 
elite*gold: 53
Join Date: Jul 2012
Posts: 541
Received Thanks: 190
good job
XxGhostSpiriTxX is offline  
Old 01/11/2020, 18:55   #4
 
concucu's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 215
Received Thanks: 124
@

on VC80 im got errors

Code:
------ Build started: Project: ClientLib, Configuration: Release Win32 ------
  IFConsole.cpp
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C2440: 'initializing' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'int'
          with
          [
              _Ty=std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>,
              _Alloc=std::allocator<std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>>
          ]
          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'int' (or there is no acceptable conversion)
          C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\include\guiddef.h(197): could be 'int operator !=(const GUID &,const GUID &)'
          while trying to match the argument list '(int, std::_Vector_iterator<_Ty,_Alloc>)'
          with
          [
              _Ty=std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>,
              _Alloc=std::allocator<std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>>
          ]
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(85): error C2227: left of '->first' must point to class/struct/union/generic type
          type is 'int'
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(85): error C2227: left of '->second' must point to class/struct/union/generic type
          type is 'int'
========== Build: 0 succeeded, 1 failed, 10 up-to-date, 0 skipped ==========
Code:
void CIFConsole::OnCommandsLoading(void)
{
	/*for (auto i = CustomConsoleCommands.begin(); i != CustomConsoleCommands.end(); i++)
	{
		this->AddCommand(i->first, i->second, 0);
	}*/ -> this got errors

	reinterpret_cast<void(__thiscall*)(CIFConsole*)>(0x00558910)(this);
}
concucu is offline  
Old 01/12/2020, 00:44   #5
 
elite*gold: 100
Join Date: Sep 2017
Posts: 1,109
Received Thanks: 903
Quote:
Originally Posted by concucu View Post
@

on VC80 im got errors
Your errors says you didn't include vector, so it doesn't recognize its type.
#HB is offline  
Old 01/12/2020, 03:50   #6
 
concucu's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 215
Received Thanks: 124
i already include <vector>,
haha i using
Code:
this->AddCommand(L"***", MyCuteTestingFunc, 0);
	this->AddCommand(L"xxxx", MyCuteTestingFunc, 0);
	this->AddCommand(L"xxxxx", MyCuteTestingFunc, 0);
	this->AddCommand(L"xxxxxx", MyCuteTestingFunc, 0);
	this->AddCommand(L"xxxxxxx", MyCuteTestingFunc, 0);
concucu is offline  
Old 01/13/2020, 16:43   #7
 
elite*gold: 100
Join Date: Sep 2017
Posts: 1,109
Received Thanks: 903
Quote:
Originally Posted by concucu View Post
i already include <vector>
Well, maybe your VC++ lib is messed then, or your additional includes. I told you what the error indicates anyways.
#HB is offline  
Old 01/15/2020, 00:20   #8
 
elite*gold: 0
Join Date: Mar 2010
Posts: 568
Received Thanks: 228
good job
Laag#82 is offline  
Old 01/25/2020, 16:00   #9
 
Empire1453's Avatar
 
elite*gold: 0
Join Date: Jan 2020
Posts: 36
Received Thanks: 5
I think it can be used as a new GM ~ notice function
Empire1453 is offline  
Old 10/06/2020, 05:35   #10
 
elite*gold: 0
Join Date: Dec 2012
Posts: 53
Received Thanks: 6
Quote:
Originally Posted by concucu View Post
@

on VC80 im got errors

Code:
------ Build started: Project: ClientLib, Configuration: Release Win32 ------
  IFConsole.cpp
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C2440: 'initializing' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'int'
          with
          [
              _Ty=std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>,
              _Alloc=std::allocator<std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>>
          ]
          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(83): error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'int' (or there is no acceptable conversion)
          C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\include\guiddef.h(197): could be 'int operator !=(const GUID &,const GUID &)'
          while trying to match the argument list '(int, std::_Vector_iterator<_Ty,_Alloc>)'
          with
          [
              _Ty=std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>,
              _Alloc=std::allocator<std::pair<const wchar_t *,ConsoleCommandFunc (__stdcall *)>>
          ]
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(85): error C2227: left of '->first' must point to class/struct/union/generic type
          type is 'int'
..\..\..\..\source\libs\ClientLib\src\IFConsole.cpp(85): error C2227: left of '->second' must point to class/struct/union/generic type
          type is 'int'
========== Build: 0 succeeded, 1 failed, 10 up-to-date, 0 skipped ==========
Code:
void CIFConsole::OnCommandsLoading(void)
{
	/*for (auto i = CustomConsoleCommands.begin(); i != CustomConsoleCommands.end(); i++)
	{
		this->AddCommand(i->first, i->second, 0);
	}*/ -> this got errors

	reinterpret_cast<void(__thiscall*)(CIFConsole*)>(0x00558910)(this);
}

for (std::vector<std:air<const wchar_t*, ConsoleCommandFunc*>>::iterator i = CustomConsoleCommands.begin(); i != CustomConsoleCommands.end(); i++)
{
this->AddCommand(i->first, i->second, 0);
}
reinterpret_cast<void(__thiscall*)(CIFConsole*)>(0 x00558910)(this);
halloway520 is offline  
Thanks
2 Users
Reply


Similar Threads Similar Threads
[Release] Customizing Battle Arena Required Number Of Participants
01/18/2021 - SRO PServer Guides & Releases - 17 Replies
Hey there, I saw a lot of people talking about this, I was interested thinking it's a hard thing to find, like a challenge, you know... I spent a whole day looking into GS, found relations..etc, but I realized atn that it just receives the order from shard manager's schedule, and it doesn't do that participants count check. So I started to look into shard manager, a few hours then, I found it, it wasn't that hard if I worked straight on shard manager. Anyways, there's the addresses...
[RELEASE] Console Commands for Lame Console Look
12/07/2011 - CO2 PServer Guides & Releases - 12 Replies
Well, to avoid any further useless posts on this subject... here are a ton of console based commands that will control the game from the server console. I will not explain what each does, it should be pretty easy to figure out, and I don't intend to answer stupid questions. If its a good question, I will answer it. public static void DoStuff() { bool flag = true; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; ...
Customizing GM Commands
02/16/2010 - Dekaron Private Server - 9 Replies
Hey i was wondering if anyone knows how to mod The GM Commands in the database, i know how to in the .exe, but it can be easily bypass using another .exe so yea. My question, How to delete certain GM commands ?



All times are GMT +1. The time now is 19:50.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.