Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Darn's KalOnline C++ Library

Skilled Illusionist
Joined
Mar 20, 2009
Messages
374
Reaction score
378
My KalOnline C++ Library

hey Folks,
today i wanna share my Library with all of you.

how to use it?
Download the .rar of the lib.
unpack it where you wanna store it. Visual studio open up your project
go to Project properties and link the include/Lib directory at "C++ directorys" to the Include/Lib folder you'
ve just downloaded

after that link the .lib file in your project by using:
#pragma comment(lib, "LunaLib.lib")

and include the header you wanna use for example:
#include <KPlayer.h>
#include <KServer.h>

example what you could do with thease:
Code:
	void __fastcall LevelUp(int* Playerptr, int* edx){
			UNREFERENCED_PARAMETER(edx);
			auto_ptr<KServer> Server;
			auto_ptr<KPlayer> Player(new KPlayer(Playerptr));

			if (LevelEnabled){
				Player->Levelup(LevelInc, LevelStatInc, LevelSkillInc);
			}
			else{ Player->Levelup(1, 5, 1); }


			if (LevelNoticeEnabled && Player->GetLevel() >= LevelNoticeStartLevel){
				if (!LevelNoticeType.compare("Lord_Red")){ Server->SetScreenInfo(ScreenInfoType::Red, Server->string_to_char(Server->ParseString(Playerptr, LevelNoticeText))); }
				else if (!LevelNoticeType.compare("Lord_Blue")){ Server->SetScreenInfo(ScreenInfoType::Blue, Server->string_to_char(Server->ParseString(Playerptr, LevelNoticeText))); }
				else if (!LevelNoticeType.compare("Lord_Orange")){ Server->SetScreenInfo(ScreenInfoType::Orange, Server->string_to_char(Server->ParseString(Playerptr, LevelNoticeText))); }
				else if (!LevelNoticeType.compare("Notice")){ Server->Notice(RGB(LevelNoticeColorR, LevelNoticeColorG, LevelNoticeColorB), Server->string_to_char(Server->ParseString(Playerptr, LevelNoticeText))); }
			}

			if (LevelBuffEnabled){ Player->InsertBuff(LevelBuffID, LevelBuffTime, LevelBuffInc); }

		}

wanna summon a monster?
Code:
[URL=https://forum.ragezone.com/usertag.php?do=list&action=hash&hash=include]#include[/URL]  <KSummon.h>
auto_ptr<KSummon> Summon;

Summon->Monster(Index, X, Y, Map, Amount);

Move to a player:
Code:
if (command->beginWith("/moveto") && this->player->GetAdmin() >= ComMoveto){
		this->SetForward(false);
		int targetm = (0);
		int targetx = (0);
		int targety = (0);

		string _TargetName = this->command->GetStrValue(1);
		const char* TargetName = this->server->string_to_char(_TargetName);

		if(TargetName){
			int *TargetPointer = (int*)Server::CPlayer::FindPlayerbyName(TargetName);
			auto_ptr<KPlayer> _target(new KPlayer(TargetPointer));
			if(_target->isGood()){
				targetm = (_target->GetMap());
				targetx = (_target->GetX());
				targety = (_target->GetY());
				this->player->Teleport(false, targetm, targetx, targety);
				this->player->InfoMessage(TextColor::GREEN_YELLOW, "Moved to %s", _target->GetName());
			}
			else{
				this->player->InfoMessage(TextColor::RED, "The selected player is offline or doesn't exist.");
			}
		}
	}

and there is alot more.



 
Last edited:
Skilled Illusionist
Joined
Mar 20, 2009
Messages
374
Reaction score
378
More Examples:

Project properties Linker -> Input -> Module Definition File -> gdi32.def for Server.....version.def for Engine exports.
Code:
#include <KTools.h>
#include <LunaCore.h>

BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
	std::auto_ptr<LunaCore> Core(new LunaCore());
	std::auto_ptr<IMemory> Memory(new IMemory());

        //Server Exports
	Core->Init(ul_reason_for_call, EXPORTS_TYPE::_SERVER);
        
        //Engine Exports
        //Core->Init(ul_reason_for_call, EXPORTS_TYPE::_CLIENT);

        //Detour
	Core->Register(&(PVOID&)Server::CIOServer::Start, Hooks::CIOServer::Start);
	Core->Register(&(PVOID&)Server::CPlayer::ChatCommand, Hooks::CPlayer::ChatCommand);
	Core->Register(&(PVOID&)Server::CItem::Use, Hooks::CItem::Use);

       //Intercept
	Core->RegisterIntercept(IMemory::_I_CALL, (void*)0x000000, Hooks::CMonster::XXXX, 6);

        //speed hack message
	Memory->Fill(0x00494A0E, IMemory::_I_NOP, 5);
	Memory->Fill(0x00494A90, IMemory::_I_NOP, 5);

	//egggrade no limit
	Memory->Fill(0x0042F215, IMemory::_I_NOP, 5);

	return Core->Run();
}
Main server Replace GDI32.dll with your dll name
Engine Replace Version.dll 2 times
 
Elite Diviner
Joined
May 21, 2015
Messages
448
Reaction score
68
thanks alot :) , helped me too much
u had released some months ago i guess , a boss timer or something like that , i've been searching for it , on google but no results found
 
Elite Diviner
Joined
May 21, 2015
Messages
448
Reaction score
68
honestly , i kept writing (Kalonline Boss ragezone) , (kalonline timer ragezone) and both were sending me to normal kalonline ragezone
thanks alot <3 ;)
 
Joined
Jun 23, 2006
Messages
782
Reaction score
399
:D second link haha
Next time you search for something, try to include the name of the author and most infos you got..
 
Elite Diviner
Joined
May 21, 2015
Messages
448
Reaction score
68
:D second link haha
Next time you search for something, try to include the name of the author and most infos you got..

honestly , i didn't remember the name of the thread so xD
 
Experienced Elementalist
Joined
Sep 29, 2008
Messages
224
Reaction score
436
have fun
 
Last edited by a moderator:
Newbie Spellweaver
Joined
Jul 2, 2016
Messages
93
Reaction score
9
What am I doing wrong?

Code:
#pragma comment(lib, "detours.lib")#pragma comment(lib, "LunaLib.lib")#undef UNICODE#include <cstdio>#include <windows.h>#include <detours.h> #include <process.h>#pragma pack(1)#include <KServer.h>//Our hooked Server Start functionvoid __stdcall Hooked_Start(int start){    Server::CIOServer::Start(start); //Call normal Server start, if we wont do this, the server dont start    Server::Console::WriteBlue("Hello World");    // Call Print Function after Server Start we should see an Hello World in Blue on Console                        }BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){    switch (ul_reason_for_call)    {    case DLL_PROCESS_ATTACH:        {            DetourTransactionBegin();            DetourUpdateThread(GetCurrentThread());            DetourAttach(&(PVOID&)Start, Hooked_Start);            //Insert our function into Mainserver            DetourTransactionCommit();            break;        }    case DLL_PROCESS_DETACH:        {            DetourTransactionBegin();            DetourUpdateThread(GetCurrentThread());            DetourDetach(&(PVOID&)Start, Hooked_Start);            //Detach our function            DetourTransactionCommit();            break;        }    }    return TRUE;}

Error:

'Start' undeclared identifier

The problem is here
DetourAttach(&(PVOID&)Start, Hooked_Start);


edit: figured it out as soon as i posted this....
 
Last edited:
Newbie Spellweaver
Joined
Jul 2, 2016
Messages
93
Reaction score
9
Why cant I do this?

Code:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <Windows.h>
#include <vector>
#include <io.h>
#include <fcntl.h>
#include <fstream>
#include <iostream>
#include <string>


#pragma comment(lib, "LunaLib.lib")
#include <KServer.h>
#include <KPlayer.h>
#include <KItem.h>
#include <LunaCore.h>


#pragma pack(1)




struct SItem {
    int Index;
    int Str;
    int Hp;
    int Int;
    int Wis;
    int Agi;
    int Pwr;
    int Explo;
    int PerEva;
    int PerDef;
    int DmgRed;
    int Acc;
    int Eva;
    int Spd;
    int Seconds;
};


std::vector<SItem> SItemVec;


void __fastcall hook_Use(int* itemptr, int* playerptr){


    auto_ptr<KServer> Server;
    auto_ptr<KPlayer> Player(new KPlayer(playerptr));
    auto_ptr<KItem> Item(new KItem(itemptr));


    if(Player->GetUID()){


    std::ifstream spawnitem;
    spawnitem.open("BuffItems.txt");
    std::string strTemp;
    std::string line;
    if(spawnitem.is_open())
    {
        while (std::getline(spawnitem,line,'(').good())
        {
                SItem buffItem;
                spawnitem >> strTemp >> buffItem.Index >> strTemp >> buffItem.Str >> strTemp >> buffItem.Hp >> strTemp >> buffItem.Int >> strTemp >> buffItem.Wis 
                >> strTemp >> buffItem.Agi >> strTemp >> buffItem.Pwr >> strTemp >> buffItem.Explo >> strTemp >> buffItem.PerEva >> strTemp >> buffItem.PerDef >> strTemp >> buffItem.DmgRed >> 
                strTemp >> buffItem.Acc >> strTemp >> buffItem.Eva >> strTemp >> buffItem.Spd >> strTemp >> buffItem.Seconds;
                SItemVec.push_back(buffItem);
        }
    }
    spawnitem.close();


    for(std::vector<SItem>::iterator it = SItemVec.begin(); it != SItemVec.end(); ++it) 
    {


        if(Item->GetIndex() == it->Index) {
            int strInt1 = 60;
            int hpInt1 = 61;
            int intInt1 = 62;
            int wisInt1 = 63;
            int agiInt1 = 64;
            int pwrInt1 = 51;
            int exploInt1 = 54;
            int perdefInt1 = 58;
            int perevaInt1 = 57;
            int dmgredInt1 = 52;
            int accInt1 = 56;
            int evaInt1 = 57;
            int spdInt1 = 12;


            int strInt2 = 0;
            int hpInt2 = 0;
            int intInt2 = 0;
            int wisInt2 = 0;
            int agiInt2 = 0;
            int pwrInt2 = 0;
            int exploInt2 = 0;
            int perdefInt2 = 0;
            int perevaInt2 = 0;
            int dmgredInt2 = 0;
            int accInt2 = 0;
            int evaInt2 = 0;
            int spdInt2 = 60;


            int BUFF1 = Server::CChar::CreateBuff(strInt1, it->Seconds, it->Str, strInt2);
            int BUFF2 = Server::CChar::CreateBuff(hpInt1, it->Seconds, it->Str, hpInt2);
            int BUFF3 = Server::CChar::CreateBuff(intInt1, it->Seconds, it->Str, intInt2);
            int BUFF4 = Server::CChar::CreateBuff(wisInt1, it->Seconds, it->Str, wisInt2);
            int BUFF5 = Server::CChar::CreateBuff(agiInt1, it->Seconds, it->Str, agiInt2);
            int BUFF6 = Server::CChar::CreateBuff(pwrInt1, it->Seconds, it->Str, pwrInt2);
            int BUFF7 = Server::CChar::CreateBuff(exploInt1, it->Seconds, it->Str, exploInt2);
            int BUFF8 = Server::CChar::CreateBuff(perdefInt1, it->Seconds, it->Str, perdefInt2);
            int BUFF9 = Server::CChar::CreateBuff(perevaInt1, it->Seconds, it->Str, perevaInt2);
            int BUFF10 = Server::CChar::CreateBuff(dmgredInt1, it->Seconds, it->Str, dmgredInt2);
            int BUFF11 = Server::CChar::CreateBuff(accInt1, it->Seconds, it->Str, accInt2);
            int BUFF12 = Server::CChar::CreateBuff(evaInt1, it->Seconds, it->Str, evaInt2);
            int BUFF13 = Server::CChar::CreateBuff(spdInt1, it->Seconds, it->Str, spdInt2);


            Server::CPlayer::AddBuff(playerptr, BUFF1);
            Server::CPlayer::AddBuff(playerptr, BUFF2);
            Server::CPlayer::AddBuff(playerptr, BUFF3);
            Server::CPlayer::AddBuff(playerptr, BUFF4);
            Server::CPlayer::AddBuff(playerptr, BUFF5);
            Server::CPlayer::AddBuff(playerptr, BUFF6);
            Server::CPlayer::AddBuff(playerptr, BUFF7);
            Server::CPlayer::AddBuff(playerptr, BUFF8);
            Server::CPlayer::AddBuff(playerptr, BUFF9);
            Server::CPlayer::AddBuff(playerptr, BUFF10);
            Server::CPlayer::AddBuff(playerptr, BUFF11);
            Server::CPlayer::AddBuff(playerptr, BUFF12);
            Server::CPlayer::AddBuff(playerptr, BUFF13);
        }
    }
    }
}


BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    std::auto_ptr<LunaCore> Core(new LunaCore());
    std::auto_ptr<IMemory> Memory(new IMemory());


        //Server Exports
        Core->Init(ul_reason_for_call, EXPORTS_TYPE::_SERVER);
        
        //Engine Exports
        //Core->Init(ul_reason_for_call, EXPORTS_TYPE::_CLIENT);


    //Detour
    Core->Register(&(PVOID&)Server::CItem::Use, hook_Use);


    //Intercept
    Core->RegisterIntercept(IMemory::_I_CALL, (void*)0x0042CFB0, hook_Use, 2);


    //speed hack message
    Memory->Fill(0x00494A0E, IMemory::_I_NOP, 5);
    Memory->Fill(0x00494A90, IMemory::_I_NOP, 5);


    //egggrade no limit
    Memory->Fill(0x0042F215, IMemory::_I_NOP, 5);


    return Core->Run();
}

Here is my error.
fatal error C1007: unrecognized flag '-sdlMode' in 'p2'
Doesn't tell me poop.
 
Experienced Elementalist
Joined
Mar 15, 2014
Messages
234
Reaction score
95
I do not know how to thank you Clicking Likes button is not enough :w00t:
 
Joined
Jun 23, 2006
Messages
782
Reaction score
399
Found something old, might be useful for some people..
Save as whatever.idc and load it with IDA. It will add some Function names...
 
Newbie Spellweaver
Joined
Jul 26, 2016
Messages
50
Reaction score
5
Re: My KalOnline C++ Library

Awesome !!!! thank you so much , keep going !
 
Back
Top