The name is sent in QueryHandler.cpp (assuming you are using a branch of TrinityCore and its structure has remained the same):
Code:
void WorldSession::SendNameQueryOpcode(uint64 guid)
{
Player* player = ObjectAccessor::FindPlayer(guid);
CharacterNameData const* nameData = sWorld->GetCharacterNameData(GUID_LOPART(guid));
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data.appendPackGUID(guid);
if (!nameData)
{
data << uint8(1); // name unknown
SendPacket(&data);
return;
}
data << uint8(0); // name known
data << nameData->m_name; // played name
data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
data << uint8(nameData->m_race);
data << uint8(nameData->m_gender);
data << uint8(nameData->m_class);
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL))
{
data << uint8(1); // Name is declined
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << names->name[i];
}
else
data << uint8(0); // Name is not declined
SendPacket(&data);
}
You can send an empty string and the name will not show up. It does however introduce some issues with addons and such.
To prevent the guild name from showing up, you simply have to trick the client into thinking the person is without a guild. That is, sending 0 instead of the guild id. I do not recall where this happens, though.