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!

Core Memory Leaks fixes

Experienced Elementalist
Joined
Nov 19, 2011
Messages
245
Reaction score
160
Here are some of core and pulse/sora memory leaks:

A- Fix for skills/other calls

Wherever you find one of these functions (there might be more, cant remember all of them):
1- CPlayer::FindPlayer
2- CPlayer::ScanPlayer
3- CPlayer::FindPlayerByName
4- CMonster::FindMonster


you need to free its memory using the CSkill::ObjectRelease function (That's how it's named in the released sources).

So for example in Behead.h:

Code:
void __fastcall Behead(IChar IPlayer, int pPacket, int pPos)
{
	if (IPlayer.IsValid())
	{
		int nTargetID = 0; char bType = 0; void *pTarget = 0;
		CPacket::Read((char*)pPacket, (char*)pPos, "bd", &bType, &nTargetID);
		
		if (bType == 1 && nTargetID)
			pTarget = CMonster::FindMonster(nTargetID);
		
		if (pTarget)
		{
			IChar ITarget(pTarget);

			if (IPlayer.IsValid() && ITarget.IsOnline() && CChar::IsGState((int)ITarget.GetOffset(),1))
			{
				if (!IPlayer.IsInRange(ITarget, 300)) {
					[COLOR="#FF0000"]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
					return;
				}

				IPlayer.IncreaseHp(CChar::GetMaxHp((int)IPlayer.GetOffset()) / 10);
				IPlayer.IncreaseMana(CChar::GetMaxMp((int)IPlayer.GetOffset()) / 10);
				CChar::WriteInSight(IPlayer.GetOffset(), 63, "bddbb", 1, IPlayer.GetID(), ITarget.GetID(), 0, 1);
				CChar::WriteInSight(pTarget, 61, "db", ITarget.GetID(), 10);
				CBaseDelete(ITarget.GetOffset(),0);
			}
			[COLOR="#FF0000"]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
		}
	}
}

You would need to do that everywhere you find any of the functions listed above, so you've got some long and boring work ahead ^^.

B- The login leaks

In this part we will focus on ItemFixes.h and on some Pulse dll functions.

Since most functions there hook CSocket::_CSocket, they forgot to free the memory.

Since ItemFixes.h is not really well coded, it's harder to explain.

You will need the following for every function that hooks CSocket::_CSocket in ItemFixes.h so:

1- ModsSendStorageList
2- ModsSendTradeList
3- ModsSendItemInfo
4- FriendList function (Pulse.dll)
5- AssassinList function (Pulse.dll)


We will take ModsSendItemInfo as our function example.

in the first line, you will need to save what you wanna free later:
Code:
char* Inv = Inventory;

and in the last line, you will need to finally free it:
Code:
CIOBuffer::Free(Inv);

you will also need to add that function to Functions.h:
Code:
namespace CIOBuffer
{
	static LONG(__thiscall *Free)(void *thispointer) = (LONG(__thiscall*)(void *thispointerpointer))0x00424040;
}

NOTE: there might be better ways to do it, I did not look through all of the possibilities, if there are, please feel free to let us know about it :).
 
Experienced Elementalist
Joined
Sep 29, 2008
Messages
224
Reaction score
436
no credits to me since i showed it maybe i should not, anyway it happened
 
Junior Spellweaver
Joined
May 14, 2018
Messages
122
Reaction score
36
Thank you for this release, could you explain what the meaning of it? what you mean about "free its memory"?
 
Banned
Banned
Joined
Dec 5, 2018
Messages
5
Reaction score
1
Here are some of core and pulse/sora memory leaks:

A- Fix for skills/other calls

Wherever you find one of these functions (there might be more, cant remember all of them):
1- CPlayer::FindPlayer
2- CPlayer::ScanPlayer
3- CPlayer::FindPlayerByName
4- CMonster::FindMonster


you need to free its memory using the CSkill::ObjectRelease function (That's how it's named in the released sources).

So for example in Behead.h:

Code:
void __fastcall Behead(IChar IPlayer, int pPacket, int pPos)
{
    if (IPlayer.IsValid())
    {
        int nTargetID = 0; char bType = 0; void *pTarget = 0;
        CPacket::Read((char*)pPacket, (char*)pPos, "bd", &bType, &nTargetID);
        
        if (bType == 1 && nTargetID)
            pTarget = CMonster::FindMonster(nTargetID);
        
        if (pTarget)
        {
            IChar ITarget(pTarget);

            if (IPlayer.IsValid() && ITarget.IsOnline() && CChar::IsGState((int)ITarget.GetOffset(),1))
            {
                if (!IPlayer.IsInRange(ITarget, 300)) {
                    [COLOR=#FF0000]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
                    return;
                }

                IPlayer.IncreaseHp(CChar::GetMaxHp((int)IPlayer.GetOffset()) / 10);
                IPlayer.IncreaseMana(CChar::GetMaxMp((int)IPlayer.GetOffset()) / 10);
                CChar::WriteInSight(IPlayer.GetOffset(), 63, "bddbb", 1, IPlayer.GetID(), ITarget.GetID(), 0, 1);
                CChar::WriteInSight(pTarget, 61, "db", ITarget.GetID(), 10);
                CBaseDelete(ITarget.GetOffset(),0);
            }
            [COLOR=#FF0000]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
        }
    }
}

You would need to do that everywhere you find any of the functions listed above, so you've got some long and boring work ahead ^^.

B- The login leaks

In this part we will focus on ItemFixes.h and on some Pulse dll functions.

Since most functions there hook CSocket::_CSocket, they forgot to free the memory.

Since ItemFixes.h is not really well coded, it's harder to explain.

You will need the following for every function that hooks CSocket::_CSocket in ItemFixes.h so:

1- ModsSendStorageList
2- ModsSendTradeList
3- ModsSendItemInfo
4- FriendList function (Pulse.dll)
5- AssassinList function (Pulse.dll)


We will take ModsSendItemInfo as our function example.

in the first line, you will need to save what you wanna free later:
Code:
char* Inv = Inventory;

and in the last line, you will need to finally free it:
Code:
CIOBuffer::Free(Inv);

you will also need to add that function to Functions.h:
Code:
namespace CIOBuffer
{
    static LONG(__thiscall *Free)(void *thispointer) = (LONG(__thiscall*)(void *thispointerpointer))0x00424040;
}

NOTE: there might be better ways to do it, I did not look through all of the possibilities, if there are, please feel free to let us know about it :).

If you scroll through the code of this.. you wil find so many backdoors.. comment this out people.... :( omg so many people trying to kill other servers...........
 
off@kal. - on@gw2/d3 :)
Joined
May 30, 2009
Messages
772
Reaction score
480
you have to ask for a upgrade from 2017 to 2018 engine, x'D as all other server do "publish" their servers with 2018 engine cuz they have a "f1 fix".
funny, and a well stupid community.
 
Junior Spellweaver
Joined
Dec 21, 2008
Messages
191
Reaction score
8
you have to ask for a upgrade from 2017 to 2018 engine, x'D as all other server do "publish" their servers with 2018 engine cuz they have a "f1 fix".
funny, and a well stupid community.

i dont know how this is help me now, but ya this community is poop
 
Joined
Oct 10, 2012
Messages
798
Reaction score
292
you have to ask for a upgrade from 2017 to 2018 engine, x'D as all other server do "publish" their servers with 2018 engine cuz they have a "f1 fix".
funny, and a well stupid community.

person which build this community says its stupid :thumbup1: , ppls like you guys ruining it cause , instead of helping each other , you acting like a loser , all the time someone ask for help , good luck. u droped to the bottom.
 
Junior Spellweaver
Joined
May 14, 2018
Messages
122
Reaction score
36
From 2017 Source who released

F1 fix is already released.
You just has to search sometimes, not that hard tho.
Or, if you tryied, you should say the steps you did and when you got stuck.
And this aint a F1 Fix thread, you can see it clearly on top of the page.
 
Junior Spellweaver
Joined
Aug 19, 2006
Messages
106
Reaction score
162
just answering the "why should i free memory?" question.
simply because c/c++ doesn't have a garbage collector like other high-level programming languages like c# or java.
 
Junior Spellweaver
Joined
Oct 8, 2005
Messages
121
Reaction score
23
Here are some of core and pulse/sora memory leaks:

A- Fix for skills/other calls

Wherever you find one of these functions (there might be more, cant remember all of them):
1- CPlayer::FindPlayer
2- CPlayer::ScanPlayer
3- CPlayer::FindPlayerByName
4- CMonster::FindMonster


you need to free its memory using the CSkill::ObjectRelease function (That's how it's named in the released sources).

So for example in Behead.h:

Code:
void __fastcall Behead(IChar IPlayer, int pPacket, int pPos)
{
	if (IPlayer.IsValid())
	{
		int nTargetID = 0; char bType = 0; void *pTarget = 0;
		CPacket::Read((char*)pPacket, (char*)pPos, "bd", &bType, &nTargetID);
		
		if (bType == 1 && nTargetID)
			pTarget = CMonster::FindMonster(nTargetID);
		
		if (pTarget)
		{
			IChar ITarget(pTarget);

			if (IPlayer.IsValid() && ITarget.IsOnline() && CChar::IsGState((int)ITarget.GetOffset(),1))
			{
				if (!IPlayer.IsInRange(ITarget, 300)) {
					[COLOR="#FF0000"]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
					return;
				}

				IPlayer.IncreaseHp(CChar::GetMaxHp((int)IPlayer.GetOffset()) / 10);
				IPlayer.IncreaseMana(CChar::GetMaxMp((int)IPlayer.GetOffset()) / 10);
				CChar::WriteInSight(IPlayer.GetOffset(), 63, "bddbb", 1, IPlayer.GetID(), ITarget.GetID(), 0, 1);
				CChar::WriteInSight(pTarget, 61, "db", ITarget.GetID(), 10);
				CBaseDelete(ITarget.GetOffset(),0);
			}
			[COLOR="#FF0000"]CSkill::ObjectRelease(pTarget, (int)pTarget + 352);[/COLOR]
		}
	}
}

You would need to do that everywhere you find any of the functions listed above, so you've got some long and boring work ahead ^^.

B- The login leaks

In this part we will focus on ItemFixes.h and on some Pulse dll functions.

Since most functions there hook CSocket::_CSocket, they forgot to free the memory.

Since ItemFixes.h is not really well coded, it's harder to explain.

You will need the following for every function that hooks CSocket::_CSocket in ItemFixes.h so:

1- ModsSendStorageList
2- ModsSendTradeList
3- ModsSendItemInfo
4- FriendList function (Pulse.dll)
5- AssassinList function (Pulse.dll)


We will take ModsSendItemInfo as our function example.

in the first line, you will need to save what you wanna free later:
Code:
char* Inv = Inventory;

and in the last line, you will need to finally free it:
Code:
CIOBuffer::Free(Inv);

you will also need to add that function to Functions.h:
Code:
namespace CIOBuffer
{
	static LONG(__thiscall *Free)(void *thispointer) = (LONG(__thiscall*)(void *thispointerpointer))0x00424040;
}

NOTE: there might be better ways to do it, I did not look through all of the possibilities, if there are, please feel free to let us know about it :).

a little fix mate,
this is how the code look like

PHP:
void __fastcall Behead(IChar IPlayer, int pPacket, int pPos)
{
	if (IPlayer.IsValid())
	{
		int nTargetID = 0; char bType = 0; void *pTarget = 0;
		CPacket::Read((char*)pPacket, (char*)pPos, "bd", &bType, &nTargetID);
		
		if (bType == 1 && nTargetID)
			pTarget = CMonster::FindMonster(nTargetID);
		
		if (pTarget)
		{
			IChar ITarget(pTarget);

			if (IPlayer.IsValid() && ITarget.IsOnline() && CChar::IsGState((int)ITarget.GetOffset(),1))
			{
				if (!IPlayer.IsInRange(ITarget, 300)) {
					return;
				}

				IPlayer.IncreaseHp(CChar::GetMaxHp((int)IPlayer.GetOffset()) / 10);
				IPlayer.IncreaseMana(CChar::GetMaxMp((int)IPlayer.GetOffset()) / 10);
				CChar::WriteInSight(IPlayer.GetOffset(), 63, "bddbb", 1, IPlayer.GetID(), ITarget.GetID(), 0, 1);
				CChar::WriteInSight(pTarget, 61, "db", ITarget.GetID(), 10);
				CBaseDelete(ITarget.GetOffset(),0);
			}
			CSkill::ObjectRelease(pTarget, (int)pTarget + 352);
		}
	}
}
the first row you wrote under the "if (!IPlayer.IsInRange(ITarget, 300))" will release the target and than the skill will not execute .
the last one release the memory from the whole function so its fine .

hope i helped somone :)
 
Experienced Elementalist
Joined
Nov 19, 2011
Messages
245
Reaction score
160
a little fix mate,
this is how the code look like

PHP:
void __fastcall Behead(IChar IPlayer, int pPacket, int pPos)
{
	if (IPlayer.IsValid())
	{
		int nTargetID = 0; char bType = 0; void *pTarget = 0;
		CPacket::Read((char*)pPacket, (char*)pPos, "bd", &bType, &nTargetID);
		
		if (bType == 1 && nTargetID)
			pTarget = CMonster::FindMonster(nTargetID);
		
		if (pTarget)
		{
			IChar ITarget(pTarget);

			if (IPlayer.IsValid() && ITarget.IsOnline() && CChar::IsGState((int)ITarget.GetOffset(),1))
			{
				if (!IPlayer.IsInRange(ITarget, 300)) {
					return;
				}

				IPlayer.IncreaseHp(CChar::GetMaxHp((int)IPlayer.GetOffset()) / 10);
				IPlayer.IncreaseMana(CChar::GetMaxMp((int)IPlayer.GetOffset()) / 10);
				CChar::WriteInSight(IPlayer.GetOffset(), 63, "bddbb", 1, IPlayer.GetID(), ITarget.GetID(), 0, 1);
				CChar::WriteInSight(pTarget, 61, "db", ITarget.GetID(), 10);
				CBaseDelete(ITarget.GetOffset(),0);
			}
			CSkill::ObjectRelease(pTarget, (int)pTarget + 352);
		}
	}
}
the first row you wrote under the "if (!IPlayer.IsInRange(ITarget, 300))" will release the target and than the skill will not execute .
the last one release the memory from the whole function so its fine .

hope i helped somone :)

no you didnt understand the whole point.
you must release it before any return or at the end of the function if it ends fine.

The code you wrote, the releasing will not be done if the Player's range condition is false, therefore there will be a memory leak.

You can also make it work using RAII so it does the whole work for you, simpler ^^.
 
Junior Spellweaver
Joined
Oct 8, 2005
Messages
121
Reaction score
23
no you didnt understand the whole point.
you must release it before any return or at the end of the function if it ends fine.

The code you wrote, the releasing will not be done if the Player's range condition is false, therefore there will be a memory leak.

You can also make it work using RAII so it does the whole work for you, simpler ^^.

good to know , ill read about it!
thanks mate!
 
Back
Top