Register for your free account! | Forgot your password?

You last visited: Today at 16:53

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

Advertisement



[Release] Sro++

Discussion on [Release] Sro++ within the SRO PServer Guides & Releases forum part of the SRO Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2012
Posts: 25
Received Thanks: 142
[Release] Sro++

I've made compatible my old sro stuffs with vSro client 1.188 and coalesced into this small library. It provides hooking packet receive, sending packet and some utility functions.


Documentation


Example code:
Code:
#include "SroPP.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

void printUIText(const wchar_t* codename)
{
	wchar_t buffer[1024];
	swprintf_s(buffer, L"%s -> '%s'", codename, SroPP::Game::GetUIText(codename));
	SroPP::Game::WriteChat(SroPP::ChatGroup::GM, buffer, 255 << 8);
}

//copied from: https://github.com/ProjectHax/ServerStats/blob/master/ServerStats/shared/stream_utility.cpp
#include <sstream>
#include <cctype>
#include <iomanip>
std::string DumpToString(const void* stream, size_t size)
{
	std::stringstream ss;
	auto buffer = static_cast<const unsigned char*>(stream);
	int fields[16];
	size_t index = 0;
	size_t cur = 0;
	size_t total = size;
	if (total == 0 || total % 16)
	{
		total += (16 - (total % 16));
	}
	for (size_t x = 0; x < total; x++)
	{
		fields[index++] = cur < size ? buffer[x] : 0;
		++cur;
		if (index == 16)
		{
			for (size_t y = 0; y < 16; y++)
			{
				if (cur - 16 + y < size)
				{
					ss << std::hex << std::setfill('0') << std::setw(2) << fields[y] << ' ';
				}
				else
				{
					ss << "   ";
				}
			}
			ss << "   ";
			for (size_t y = 0; y < 16; y++)
			{
				if (cur - 16 + y < size)
				{
					int ch = fields[y];
					if (std::isprint(ch) && !std::isspace(ch))
					{
						ss << (char)ch;
					}
					else
					{
						ss << '.';
					}
				}
				else
				{
					ss << '.';
				}
			}
			ss << std::endl;
			index = 0;
		}
	}
	return ss.str();
}

void printPacketDump(const SroPP::Packet& packet)
{
	std::string dump;
	auto appendf = [&dump](const char* format, ...)
	{
		char buf[256];
		va_list ap;
		va_start(ap, format);
		vsprintf_s(buf, format, ap);
		va_end(ap);
		dump.append(buf);
	};

	appendf("[Opcode: %4X] [Size: %Iu bytes]\n", packet.Opcode(), packet.Size());

	char packetBuffer[256];
	size_t bytesToDump = (std::min)(packet.Size(), sizeof(packetBuffer));

	if (bytesToDump > 0)
	{
		packet.Peek(packetBuffer, bytesToDump);
		dump.append(DumpToString(packetBuffer, bytesToDump));
	}

	if (size_t remaining = packet.Size() - bytesToDump)
		appendf("... + %lu bytes\n", remaining);

	dump.append("\n");
	OutputDebugStringA(dump.c_str());
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, void*)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		DisableThreadLibraryCalls(hModule);
		try
		{
			SroPP::Library::BeginInitialize();
			SroPP::PacketHook::RegisterReceive([](const SroPP::Packet& packet) -> bool
			{
				printPacketDump(packet);
				switch (packet.Opcode())
				{
					case 0xb045:
					{
						bool succeed = packet.Read<bool>();
						if (succeed)
						{
							uint32_t uniqueId = packet.Read<uint32_t>();
							wchar_t buffer[256];
							swprintf_s(buffer, L"Selected target ID: %lu", uniqueId);
							SroPP::Game::WriteChat(SroPP::ChatGroup::All, buffer, 0xFF00D8D8);
						}
					}
					break;
					case 0x3026:
					{
						uint8_t type = packet.Read<uint8_t>();
						if (type == 1)
						{
							uint32_t sender = packet.Read<uint32_t>();
							auto message = packet.ReadStringA();
							if (message == ".1")
							{
								printUIText(L"UIIT_MSG_GUILD_JOIN_RESULT");
								printUIText(L"SN_TALK_QTUTORIAL_CH_27");
								printUIText(L"SN_MOB_CH_GYO_CLON");
							}
						}
					}
					break;
				}
				return false;
			});
			SroPP::Library::EndInitialize();
		}
		catch (std::exception &ex)
		{
			MessageBoxA(NULL, ex.what(), "exception", MB_ICONERROR);
		}
	}
	return TRUE;
}
Example code for appending data to end of the login packet:
Code:
std::vector<char> onLoginRequest()
{
#pragma pack(push, 1)
	struct
	{
		uint32_t val1;
	} s;
#pragma pack(pop)
	
	s.val1 = 0x12345678;

	return SroPP::MakeVector(s);
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, void*)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		DisableThreadLibraryCalls(hModule);
		try
		{
			SroPP::Library::BeginInitialize();
			SroPP::PacketHook::RegisterSendLoginRequest(onLoginRequest);
			SroPP::Library::EndInitialize();
		}
		catch (std::exception &ex)
		{
			MessageBoxA(NULL, ex.what(), "exception", MB_ICONERROR);
			return FALSE;
		}
	}
	return TRUE;
}
thanks to pushedx for his attentive helps
Attached Files
File Type: rar SroPP.rar (6.9 KB, 486 views)
File Type: rar SroPP_1.1.rar (7.3 KB, 815 views)
Iwa13 is offline  
Thanks
43 Users
Old 08/14/2015, 19:50   #2
 
elite*gold: 111
Join Date: May 2009
Posts: 617
Received Thanks: 589
llgw ^^
qoaway is offline  
Old 08/14/2015, 19:58   #3
Chat Killer In Duty


 
PortalDark's Avatar
 
elite*gold: 5
Join Date: May 2008
Posts: 16,399
Received Thanks: 6,509
Moved to correct section
PortalDark is offline  
Thanks
1 User
Old 08/14/2015, 20:07   #4
 
Royalblade*'s Avatar
 
elite*gold: 85
Join Date: Feb 2014
Posts: 1,056
Received Thanks: 1,644
not bad dude.

Weeman released something very similar a few years back. Could've used that as a base.
Royalblade* is offline  
Thanks
1 User
Old 08/15/2015, 01:24   #5
 
elite*gold: 0
Join Date: Mar 2015
Posts: 311
Received Thanks: 164
What is this
Gummieֆ' is offline  
Old 08/15/2015, 02:03   #6
 
elite*gold: 1
Join Date: Jul 2015
Posts: 207
Received Thanks: 60
good
B1Q B0SS is offline  
Old 08/15/2015, 02:10   #7
 
elite*gold: 0
Join Date: Mar 2015
Posts: 511
Received Thanks: 32
What does it do if i may ask
thanks for the respond, 2x_o0.
Sonic ` is offline  
Old 08/15/2015, 12:10   #8
 
elite*gold: 111
Join Date: May 2009
Posts: 617
Received Thanks: 589
Quote:
Originally Posted by Aleჯco* View Post
What is this
Quote:
Originally Posted by Bobby` View Post
What does it do if i may ask
thanks for the respond, 2x_o0.

It's a cpp library which allows you make advanced client side edits for your private server
qoaway is offline  
Thanks
1 User
Old 08/15/2015, 14:31   #9
 
elite*gold: 1
Join Date: Aug 2015
Posts: 55
Received Thanks: 19
great
Konami$ is offline  
Old 08/16/2015, 14:32   #10


 
Dracula Untold's Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 1,866
Received Thanks: 517
Same question . what is this?
Dracula Untold is offline  
Old 08/16/2015, 14:36   #11
 
LastThief*'s Avatar
 
elite*gold: 60
Join Date: Feb 2012
Posts: 3,942
Received Thanks: 6,474
If you don't know what is this, get out of the thread this isn't for you.
LastThief* is offline  
Thanks
11 Users
Old 08/31/2015, 13:43   #12
 
elite*gold: 0
Join Date: Aug 2015
Posts: 84
Received Thanks: 17
very useful thanks dude
EraSro is offline  
Old 09/01/2015, 09:08   #13
 
elite*gold: 0
Join Date: Feb 2012
Posts: 25
Received Thanks: 142
updated

Quote:
Ver 1.1
static std::vector<char> MakeVector(T &val)
-Serializes specified value to vector<char>

Arguments
val: Value to be serialized.
Templates
T: A non-pointer and pod type.
Quote:
Ver 1.1
static void RegisterSendLoginRequest<Func>(Func func)
Registers the function that will be called when login packet (0x6102) is written. Allows you to append custom data(e.g. HWID) to end of the login packet. If you previously registered a function, it will be replaced.

Arguments
func: A lambda/function that suitable for vector<char>() call.
Return value of "func" argument: The data that will be appended to end of the login packet (0x6102)
Quote:
Example code for appending data to end of the login packet:
Code:
std::vector<char> onLoginRequest()
{
#pragma pack(push, 1)
	struct
	{
		uint32_t val1;
	} s;
#pragma pack(pop)
	
	s.val1 = 0x12345678;

	return SroPP::MakeVector(s);
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, void*)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		DisableThreadLibraryCalls(hModule);
		try
		{
			SroPP::Library::BeginInitialize();
			SroPP::PacketHook::RegisterSendLoginRequest(onLoginRequest);
			SroPP::Library::EndInitialize();
		}
		catch (std::exception &ex)
		{
			MessageBoxA(NULL, ex.what(), "exception", MB_ICONERROR);
			return FALSE;
		}
	}
	return TRUE;
}
Iwa13 is offline  
Thanks
9 Users
Old 09/05/2015, 01:04   #14
 
elite*gold: 0
Join Date: Jul 2013
Posts: 30
Received Thanks: 8
Really great work, thanks!
farukdgn is offline  
Old 09/11/2015, 21:43   #15
 
elite*gold: 0
Join Date: Jan 2009
Posts: 130
Received Thanks: 102
Quote:
Originally Posted by Royalblade* View Post
not bad dude.

Weeman released something very similar a few years back. Could've used that as a base.
I think you mean Drew. edxSilkroadLoader has some similarities as well as SilkMod.
WeeMan1337 is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 16:53.


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.