The binary lets you create different characters (Reaper / Bard / Warlord / Lupeon), which have different “Skills”, that can be set and used.
A Lupeon has only one skill gift, which will open a shell, but skills for him are “blocked” and cannot be directly executed.
Lupeon uses the default implementation of isSkillIsBlocked from the base character, which returns true, while the other characters override the method and return false for it, and execute Skill, if it is set.
A character with a set skill will look like this in memory.
So, for the first LostArk, it’s pretty simple to execute the Lupeons special skill
Create a lupeon (lupeon ctor will set active skill to gift)
Delete lupeon (character chunk will get freed)
Create any other character (since character creation doesn’t initialize active skill, it will still point to Lupeons gift)
In LostArk 2, a dtor was added for each character, in which the active skill for the character will be reset before the object gets freed.
This kills the simple reallocation solution from part 1. But, there’s a new bug in the pickChar method.
The reset function will “destroy the object and takes ownership of it”. Calling this, will free the object, without calling the dtor of it. Exactly what we need.
So the plan for this changes to
Create a lupeon
Create random char
Choose lupeon character (sets active skill to gift)
Choose random char (this frees the lupeon character without calling dtor)
Create another char (this will be placed in the just freed lupeon)