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:
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:
and in the last line, you will need to finally free it:
you will also need to add that function to Functions.h:
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- 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 .