Beispiel #1
0
BOOL OOG_SelectCharacter(char* szCharacter)
{
	if(ClientState() != ClientStateMenu)
		return NULL;

	// Select the first control on the character selection screen.
	Control* pControl = findControl(CONTROL_TEXTBOX, (char *)NULL, -1, 237, 178, 72, 93);
	ControlText* cText;

	 while (pControl != NULL)
    {
        if(pControl->dwType == CONTROL_TEXTBOX && pControl->pFirstText != NULL && pControl->pFirstText->pNext != NULL)
            cText = pControl->pFirstText->pNext;
        else
            cText = NULL;

        if(cText != NULL)
        {
			char * szLine = UnicodeToAnsi(cText->wText[0]);
            if(!szLine)
                return FALSE;

            char* cLine = strdup(szLine);
            char* cCharacter = strdup(szCharacter);
            StringToLower(cLine);
            StringToLower(cCharacter);

            if(strlen(szLine) == strlen(szCharacter) && strstr(cLine,cCharacter) != NULL)
            {
                delete[] szLine;
                delete[] cLine;
                delete[] cCharacter;
                if(!clickControl(pControl))
                    return FALSE;

                // OK Button
                pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 627, 572, 128, 35);
                if(pControl)
                {
                    if(!clickControl(pControl))
                        return FALSE;

                    return TRUE;
                }
                else
                    return FALSE;

            }
            else
            {
                delete[] szLine;
                delete[] cLine;
                delete[] cCharacter;
            }
        }
        pControl = pControl->pNext;
    }
    return FALSE;
}
Beispiel #2
0
BOOL OOG_SelectCharacter(const wchar_t* szCharacter) {
    if (ClientState() != ClientStateMenu)
        return NULL;

    // Select the first control on the character selection screen.

    Control* pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 237, 178, 72, 93);
    ControlText* cText;

    while (pControl != NULL) {
        if (pControl->dwType == CONTROL_TEXTBOX && pControl->pFirstText != NULL && pControl->pFirstText->pNext != NULL)
            cText = pControl->pFirstText->pNext;
        else
            cText = NULL;

        if (cText != NULL) {
            if (!cText->wText[0])
                return FALSE;

            wchar_t* cLine = _wcsdup(cText->wText[0]);
            wchar_t* cCharacter = _wcsdup(szCharacter);
            StringToLower(cLine);
            StringToLower(cCharacter);

            if (wcslen(cLine) == wcslen(cCharacter) && wcsstr(cLine, cCharacter) != NULL) {
                free(cLine);
                free(cCharacter);
                if (!clickControl(pControl))
                    return FALSE;

                // OK Button
                // Bobode Sleep(7000);
                pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 627, 572, 128, 35);
                if (pControl) {
                    if (!clickControl(pControl))
                        return FALSE;

                    return TRUE;
                } else
                    return FALSE;

            } else {
                free(cLine);
                free(cCharacter);
            }
        }
        pControl = pControl->pNext;
    }
    return FALSE;
}
Beispiel #3
0
BOOL OOG_CreateCharacter(char* szCharacter, int type, bool hardcore, bool ladder)
{
	if(OOG_GetLocation() != OOG_CHAR_SELECT || strlen(szCharacter) > 15 || type > 6 || type < 0)
		return FALSE;

	// click the create character button
	Control* ctrl = findControl(CONTROL_BUTTON, (char*)NULL, -1, 33, 528, 168, 60);
	if(ctrl)
		clickControl(ctrl);

	// TODO: replace with real time checking code
	int i = 0;
	while((OOG_GetLocation() != OOG_CHARACTER_CREATE) && i++ < 30)
		Sleep(100);

	int locs[7][5] = {
		{100, 337, 80,  330, 4011}, // amazon
		{626, 353, 600, 300, 4010}, // sorceress
		{301, 333, 300, 330, 4009}, // necromancer
		{521, 339, 500, 330, 4008}, // paladin
		{400, 330, 390, 330, 4007}, // barbarian
		{720, 370, 700, 370, 4012}, // druid
		{232, 364, 200, 300, 4013}, // assassin
	};

	ctrl = findControl(CONTROL_IMAGE, (char*)NULL, -1, locs[type][0], locs[type][1], 88, 184);
	if(ctrl)
	{
		clickControl(ctrl, locs[type][2], locs[type][3]);
		Sleep(500);
		clickControl(ctrl, locs[type][2], locs[type][3]);
	}

	// verify that the correct type got selected
	ctrl = findControl(CONTROL_TEXTBOX, (char*)NULL, -1, 0, 180, 800, 100);
	wchar_t* name = D2LANG_GetLocaleText((WORD)locs[type][4]);
	if(_wcsicmp(name, ctrl->pFirstText->wText[0]) != 0)
		return FALSE; // something bad happened?

	// set the name
//	ctrl = findControl();
	// still need to find the name editbox, set the name, and click the various
	// checkboxes and the ok button

	return FALSE;
} 
Beispiel #4
0
bool OOG_JoinGame(const char* name, const char* pass)
{		
	if(ClientState() != ClientStateMenu)
		return FALSE;

	// reject name/password combinations over 15 characters
	if(strlen(name) > 15 || strlen(pass) > 15)
		return FALSE;

	Control* pControl = NULL;

	// Battle.net/open lobby/chat area
	if(!(OOG_GetLocation() == OOG_LOBBY || OOG_GetLocation() == OOG_CHAT || OOG_GetLocation() == OOG_JOIN))
		return FALSE;

	// JOIN button
	if (OOG_GetLocation() != OOG_JOIN)
	{
		pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 652,469,120,20);
		if(!pControl || !clickControl(pControl))
			return FALSE;
		Sleep(100);
	}
	if(OOG_GetLocation() == OOG_JOIN)
	{
		// Game name edit box
		if(name)
			SetControlText(findControl(1, (char *)NULL, -1, 432,148,155,20), name);
		else
			return FALSE;
		// Password edit box
		if(pass)
			SetControlText(findControl(1, (char *)NULL, -1, 606,148,155,20), pass);
		else
			return FALSE;

		// Join Game Button
		pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 594,433,172,32);
		if(!pControl || !clickControl(pControl))
			return FALSE;
	}

	return TRUE;
}
Beispiel #5
0
bool InitHooks(void)
{
	int i = 0;
	while(!Vars.bActive)
	{
		if(i >= 300)
		{
			MessageBox(0, "Failed to set hooks, exiting!", "D2BS", 0);
			return false;
		}

		if(D2GFX_GetHwnd() && (ClientState() == ClientStateMenu || ClientState() == ClientStateInGame))
		{
			if(!Vars.oldWNDPROC)
				Vars.oldWNDPROC = (WNDPROC)SetWindowLong(D2GFX_GetHwnd(), GWL_WNDPROC, (LONG)GameEventHandler);
			if(!Vars.oldWNDPROC)
				continue;

			Vars.uTimer = SetTimer(D2GFX_GetHwnd(), 1, 0, TimerProc);

			DWORD mainThread = GetWindowThreadProcessId(D2GFX_GetHwnd(),0);
			if(mainThread)
			{
				if(!Vars.hKeybHook)
					Vars.hKeybHook = SetWindowsHookEx(WH_KEYBOARD, KeyPress, NULL, mainThread);
				if(!Vars.hMouseHook)
					Vars.hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseMove, NULL, mainThread);
			}
		}
		else
			continue;

		if(Vars.hKeybHook && Vars.hMouseHook)
		{
			if(!ScriptEngine::Startup())
				return false;

			Vars.bActive = TRUE;

			if(ClientState() == ClientStateMenu && Vars.bStartAtMenu)
				clickControl(*p_D2WIN_FirstControl);
		}
		Sleep(50);
		i++;
	}
	return true;
}
Beispiel #6
0
bool OOG_CreateGame(const wchar_t* name, const wchar_t* pass, int difficulty) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    // reject name/password combinations over 15 characters
    if (!name || !pass || wcslen(name) > 15 || wcslen(pass) > 15)
        return FALSE;

    Control* pControl = NULL;

    // Battle.net/open game creation
    OOG_Location loc = OOG_GetLocation();
    if (!(loc == OOG_LOBBY || loc == OOG_CHAT || loc == OOG_DIFFICULTY || loc == OOG_CREATE))
        return FALSE;

    if (loc == OOG_DIFFICULTY) {
        // just click the difficulty button
        Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 297, 272, 35),
                *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 340, 272, 35),
                *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 383, 272, 35);

        switch (difficulty) {
        case 0: // normal button
            if (normal->dwDisabled != 0x0d || !clickControl(normal))
                return FALSE;
            break;
        case 1: // nightmare button
            if (nightmare->dwDisabled != 0x0d || !clickControl(nightmare))
                return FALSE;
            break;
        case 2: // hell button
            if (hell->dwDisabled != 0x0d || !clickControl(hell))
                return FALSE;
            break;
        case 3: // hardest difficulty available
            if (hell->dwDisabled != 0x0d) {
                if (!clickControl(hell))
                    return FALSE;
            } else if (nightmare->dwDisabled != 0x0d) {
                if (!clickControl(nightmare))
                    return FALSE;
            } else if (normal->dwDisabled != 0x0d) {
                if (!clickControl(normal))
                    return FALSE;
            }
            break;
        default:
            return FALSE;
        }
    } else {
        // Create button
        if (loc != OOG_CREATE) {
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 533, 469, 120, 20);
            if (!pControl || !clickControl(pControl))
                return FALSE;
            Sleep(100);
        }
        if (OOG_GetLocation() == OOG_CREATE) {
            // Game name edit box
            if (name)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 162, 158, 20), name);
            else
                return FALSE;
            Sleep(100);

            // Password edit box
            if (pass)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 217, 158, 20), pass);
            else
                return FALSE;
            Sleep(100);
            Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 430, 381, 16, 16),
                    *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 555, 381, 16, 16),
                    *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 698, 381, 16, 16);

            switch (difficulty) {
            case 0: // normal button
                if (normal->dwDisabled == 0x4 || !clickControl(normal))
                    return FALSE;
                break;
            case 1: // nightmare button
                if (nightmare->dwDisabled == 0x4 || !clickControl(nightmare))
                    return FALSE;
                break;
            case 2: // hell button
                if (hell->dwDisabled == 0x4 || !clickControl(hell))
                    return FALSE;
                break;
            case 3: // hardest difficulty available
                if (hell->dwDisabled != 0x4) {
                    if (!clickControl(hell))
                        return FALSE;
                } else if (nightmare->dwDisabled != 0x4) {
                    if (!clickControl(nightmare))
                        return FALSE;
                } else if (normal->dwDisabled != 0x4) {
                    if (!clickControl(normal))
                        return FALSE;
                }
                break;
            default:
                return FALSE;
            }

            // Create Game Button
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 594, 433, 172, 32);
            if (!pControl || !clickControl(pControl))
                return FALSE;
        }
    }

    return TRUE;
}
Beispiel #7
0
BOOL OOG_SelectGateway(const wchar_t* szGateway, size_t strSize) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    if (wcsstr(szGateway, L"ERROR"))
        return FALSE;
    // Select the gateway control.
    Control* pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 391, 272, 25);

    // if the control exists and has the text label, check if it matches the selected gateway
    if (pControl && pControl->wText2) {
        wchar_t* wzLine = _wcsdup(pControl->wText2);
        wchar_t* wzGate = _wcsdup(szGateway);
        StringToLower(wzLine);
        StringToLower(wzGate);

        if (wcsstr(wzLine, wzGate)) {
            // gateway is correct, do nothing and return true
            free(wzLine);
            free(wzGate);
            return TRUE;
        } else {
            free(wzLine);
            // gateway is NOT correct, change gateway to selected gateway if it exists
            // open the gateway select screen
            if (!clickControl(pControl))
                return FALSE;

            int index = 0;
            bool gatefound = false;

            // loop here till we find the right gateway if we can
            pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 257, 500, 292, 160);
            ControlText* cText;
            if (pControl && pControl->pFirstText) {
                cText = pControl->pFirstText;
                while (cText) {
                    wchar_t* wzGatelist = _wcsdup(cText->wText[0]);
                    if (!wzGatelist) {
                        free(wzGate);
                        return FALSE;
                    }

                    StringToLower(wzGatelist);
                    if (wcsstr(wzGatelist, wzGate)) {
                        // chosen gateway IS in the list and matches, cleanup and break the loop
                        free(wzGatelist);
                        free(wzGate);
                        gatefound = true;
                        break;
                    }
                    free(wzGatelist);
                    index++;
                    cText = cText->pNext;
                }
                if (gatefound) {
                    // click the correct gateway using the control plus a default x and a y based on (index*24)+12
                    if (!clickControl(pControl, -1, 344 + ((index * 24) + 12))) {
                        free(wzGate);
                        return FALSE;
                    }
                }
            }

            free(wzGate);

            // OK Button, gateway select screen
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 281, 538, 96, 32);
            if (pControl) {
                if (!clickControl(pControl))
                    return FALSE;
            } else
                return FALSE;

            return TRUE;
        }
    }
    return FALSE;
}
Beispiel #8
0
DWORD Profile::login(char** error)
{
	bool loginComplete = FALSE,	skippedToBnet = TRUE;
	int location = 0;
	char* errorMsg = "";
	Control* pControl = NULL;
	unsigned int timeout = 0;

	/*
		clickedOnce is needed because, when in OOG_OTHER_MULTIPLAYER
		the clickControl () is done twice and the second time it is
		failing because the button is not there anymore.
	*/
	int clickedOnce = false;

	Vars.bBlockKeys = Vars.bBlockMouse = TRUE;

	while(!loginComplete)
	{
		location = OOG_GetLocation();
		switch(location)
		{
			case OOG_D2SPLASH:
				clickControl(*p_D2WIN_FirstControl);
				break;
			case OOG_CHAR_SELECT:
				if (!OOG_SelectCharacter(charname))
					 errorMsg = "Invalid character name";
				break;
			case OOG_MAIN_MENU:
				if(type == PROFILETYPE_SINGLEPLAYER)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,324,272,35)))
						 errorMsg = "Failed to click the Single button?";
				if(type == PROFILETYPE_BATTLENET)
				{
					OOG_SelectGateway(gateway, 256);
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 366, 272, 35)))
						 errorMsg = "Failed to click the 'Battle.net' button?";
				}
				if(isOtherMP(type))
				{
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 433, 272, 35)))
						errorMsg =  "Failed to click the 'Other Multiplayer' button?";
					else
						skippedToBnet = FALSE;
				}
				break;
			case OOG_LOGIN:
				if((type == PROFILETYPE_SINGLEPLAYER || isOtherMP(type)) && skippedToBnet)
				{
					if(!clickControl(findControl(6, "EXIT", -1,33,572,128,35)))
						errorMsg =  "Failed to click the exit button?";
					break;
				}
				pControl = findControl(1, (char *)NULL, -1, 322, 342, 162, 19);
				if(pControl)
					SetControlText(pControl, username);
				else
					errorMsg = "Failed to set the 'Username' text-edit box.";
				// Password text-edit box
				pControl = findControl(1, (char *)NULL, -1, 322, 396, 162, 19);
				if(pControl)
					SetControlText(pControl, password);
				else
					errorMsg = "Failed to set the 'Password' text-edit box.";

				pControl = findControl(6, (char *)NULL, -1, 264, 484, 272, 35);
				if(pControl)
					if(!clickControl(pControl))
						errorMsg ="Failed to click the 'Log in' button?";
				timeout++;
				break;
			case OOG_DIFFICULTY:
				switch(diff)
				{
				case 0:
					// normal button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 297, 272, 35)))
						errorMsg ="Failed to click the 'Normal Difficulty' button?";
					break;
				case 1:
					// nightmare button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 340, 272, 35)))
						errorMsg =  "Failed to click the 'Nightmare Difficulty' button?";
					break;
				case 2:
					// hell button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 383, 272, 35)))
						errorMsg =  "Failed to click the 'Hell Difficulty' button?";
					break;
				default:
					errorMsg =  "Invalid single player difficulty level specified!";
					break;
				}
			case OOG_OTHER_MULTIPLAYER:
				// Open Battle.net
				if (type == PROFILETYPE_OPEN_BATTLENET)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 310, 272, 35)))
						errorMsg = "Failed to click the 'Open Battle.net' button?";
				// TCP/IP Game
				if (isTcpIp(type))
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,350,272,35)) && !clickedOnce)
						errorMsg = "Failed to click the 'TCP/IP Game' button?";
					else
						clickedOnce = true;

				break;
			case OOG_TCP_IP:
				if (type == PROFILETYPE_TCPIP_HOST)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,206,272,35)))
						errorMsg = "Failed to click the 'Host Game' button?";
				if (type == PROFILETYPE_TCPIP_JOIN)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,264,272,35)))
						errorMsg = "Failed to click the 'Join Game' button?";
				break;
			case OOG_ENTER_IP_ADDRESS:
				if (_strcmpi(ip, "")) {
					pControl = findControl(1, (char *)NULL, -1, 300, 268, -1, -1);
					if(pControl) {
						SetControlText(pControl, ip);

						// Click the OK button
						if(!clickControl(findControl(6, (char *)NULL, -1, 421, 337, 96, 32))) {
							errorMsg = "Failed to click the OK button";
						}
					} else
						errorMsg = "Failed to find the 'Host IP Address' text-edit box.";
				} else
					errorMsg = "Could not get the IP address from the profile in the d2bs.ini file.";

				break;
			case OOG_MAIN_MENU_CONNECTING: 
			case OOG_CHARACTER_SELECT_PLEASE_WAIT:
			case OOG_PLEASE_WAIT: 
			case OOG_GATEWAY:
			case OOG_CHARACTER_SELECT_NO_CHARS: 
			case OOG_CONNECTING:
			case OOG_NONE:
				timeout++;
				break;
			case OOG_LOBBY: 
			case OOG_INLINE: 
			case OOG_CHAT: 
			case OOG_CREATE:
			case OOG_JOIN: 
			case OOG_LADDER: 
			case OOG_CHANNEL: 
			case OOG_GAME_EXIST: 
			case OOG_GAME_DOES_NOT_EXIST:	
				loginComplete=TRUE;
				break;
			case OOG_UNABLE_TO_CONNECT:
				errorMsg = "Unable to connect";
				break;
			case OOG_CDKEY_IN_USE:
				errorMsg = "CD-Key in use";
				break;
			case OOG_LOGIN_ERROR:
				errorMsg = "Bad account or password";
				break;
			case OOG_REALM_DOWN:
				errorMsg = "Realm Down";
				break;
			default:
				errorMsg = "Unhandled login location";
				break;				
		}

		if(_strcmpi(errorMsg, ""))
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = errorMsg;
			return 2;
		}

		if((timeout*100) > maxLoginTime)
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = "login time out";
			return 1;
		}

		if(ClientState() == ClientStateInGame)
			loginComplete = TRUE;
		
		Sleep(100);
	}

	Vars.bBlockKeys = Vars.bBlockMouse = FALSE;

	return 0;
}
Beispiel #9
0
BOOL OOG_SelectGateway(char * szGateway, size_t strSize)
{
	if(ClientState() != ClientStateMenu)
		return FALSE;

	if(strstr(szGateway,"ERROR"))
		return FALSE;
	// Select the gateway control.
	Control* pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 264, 391, 272, 25);

	// if the control exists and has the text label, check if it matches the selected gateway
	if(pControl && pControl->wText2)
	{
		char* szLine = UnicodeToAnsi(pControl->wText2);
		if(!szLine)
			return FALSE;

		_strlwr_s(szLine, strlen(szLine)+1);
		_strlwr_s(szGateway, strSize);
		if(strstr(szLine, szGateway))
		{
			// gateway is correct, do nothing and return true
			delete[] szLine;
			return TRUE;
		}
		else
		{
			delete[] szLine;
			// gateway is NOT correct, change gateway to selected gateway if it exists
			// open the gateway select screen
			if(!clickControl(pControl))
				return FALSE;

			int index = 0;
			bool gatefound = false;

			// loop here till we find the right gateway if we can
			pControl = findControl(CONTROL_TEXTBOX, (char *)NULL, -1, 257, 500, 292, 160);
			ControlText* cText;
			if(pControl && pControl->pFirstText)
			{
				cText = pControl->pFirstText;
				while(cText)
				{
					char * szGatelist = UnicodeToAnsi(cText->wText[0]);
					if(!szGatelist)
						return FALSE;

					_strlwr_s(szGatelist, strlen(szGatelist)+1);
					if(strstr(szGatelist, szGateway))
					{
						// chosen gateway IS in the list and matches, cleanup and break the loop
						gatefound = true;
						delete[] szGatelist;
						break;
					}
					delete[] szGatelist;
					index++;
					cText = cText->pNext;
				}
				if(gatefound)
				{
				// click the correct gateway using the control plus a default x and a y based on (index*24)+12
					if(!clickControl(pControl, -1, 344+((index*24)+12)))
						return FALSE;
				}
			}

			// OK Button, gateway select screen
			pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 281, 538, 96, 32);
			if(pControl)
			{
				if(!clickControl(pControl))
					return FALSE;
			}
			else
				return FALSE;

			return TRUE;
		}
	}
	return FALSE;
}