読者です 読者をやめる 読者になる 読者になる

めいくりぷとのブログ

技術的なことやゲームのことやら・・・

Auto Login

MapleStory C++
static CLogin::UpdateT _CLogin__Update =
reinterpret_cast<CLogin::UpdateT>(ADDRESS_CLogin__Update);
void(__fastcall *CLogin__Update__Hook)(CLogin *) = [](
	CLogin *pLogin) -> void
{
	CAutoHack::GetInstance()->ProcessAutoLogin(pLogin);

	return _CLogin__Update(pLogin);
};

BOOL CAutoHack::ProcessAutoLogin(CLogin *pLogin)
{
	static DWORD start_time = 0;

	if (!this->m_bToggleAutoLogin)
		return FALSE;

	if (start_time == 0)
		start_time = GetTickCount();

	// 3000 ms
	if (GetTickCount() > start_time + 3000)
	{
		start_time = 0;

		if (pLogin->m_nLoginStep == 0)
		{
			CUITitle *pUITitle = CUITitle::GetInstance();
			if (!pUITitle)
				return FALSE;

			pUITitle->m_pEditID.p->SetText(this->m_sLoginID.c_str());
			pUITitle->m_pEditPasswd.p->SetText(this->m_sLoginPW.c_str());
			pUITitle->CFadeWnd.IGObj.vfptr->SetRet(&pUITitle->CFadeWnd.IGObj, 1);
		}
		else if (pLogin->m_nLoginStep == 1)
		{
			pLogin->SendLoginPacket(this->m_nWorldID, this->m_nChannelID, FALSE);
		}
		else if (pLogin->m_nLoginStep == 2)
		{
			if (pLogin->m_nCharCount < 1)
				return FALSE;

			for (int i = 0; i < pLogin->m_nCharCount; i++)
			{
				AvatarData *pData = pLogin->GetSelectedAvatarData();
				if (!pData)
					return FALSE;

				if (strcmp(pData->characterStat.sCharacterName, this->m_sLoginCharacter.c_str()) == 0)
				{
					pLogin->m_nCharSelected = i;
					pLogin->m_bOfflineMode = this->m_bOfflineMode;
					pLogin->m_sSPW.Assign(this->m_sLoginSPW.c_str());
                                        return TRUE;
				}
			}
		}
	}

	return FALSE;
}

^o^