I can answer this,
src/pokemon.c, line 2495, in function CreateBoxMon:
if (gBaseStats[species].abilities[1])
{
value = personality & 1;
SetBoxMonData(boxMon, MON_DATA_ABILITY_NUM, &value);
}
I actually did it by assigned a flag check, works for both wild and gift...