Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <TlHelp32.h>
- #include <tchar.h>
- //this program redirect the twitter button func from twitter to google
- DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
- {
- HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
- DWORD dwModuleBaseAddress = 0;
- if (hSnapshot != INVALID_HANDLE_VALUE)
- {
- MODULEENTRY32 ModuleEntry32 = { 0 };
- ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnapshot, &ModuleEntry32))
- {
- do
- {
- if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
- {
- dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
- break;
- }
- } while (Module32Next(hSnapshot, &ModuleEntry32));
- }
- CloseHandle(hSnapshot);
- }
- return dwModuleBaseAddress;
- }
- int main()
- {
- HWND hWnd = FindWindowA(0, "Geometry Dash");
- while (hWnd == NULL)
- {
- std::cout << "Waiting for GD..." << std::endl;
- hWnd = FindWindowA(0, "Geometry Dash");
- Sleep(250);
- system("cls");
- }
- DWORD pId;
- GetWindowThreadProcessId(hWnd, &pId);
- HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, pId);
- if (hProc == NULL)
- {
- std::cout << "Failed to open gd's handle. Please, retry running this program with higher privileges." << std::endl;
- system("pause>nul");
- return -1;
- }
- DWORD bAddr = dwGetModuleBaseAddress(pId, L"GeometryDash.exe");
- byte buffer[] = "https://www.google.com/search?q="; //our custom string
- DWORD addressOfString = (DWORD)VirtualAllocEx(hProc, NULL, sizeof(buffer), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); //allocate space
- WriteProcessMemory(hProc, (LPVOID)addressOfString, buffer, sizeof(buffer), NULL); //write custom string to space
- DWORD old, backup;
- VirtualProtectEx(hProc, (LPVOID)(bAddr + 0x213068), 6, PAGE_EXECUTE_READWRITE, &old); //change protection
- WriteProcessMemory(hProc, (LPVOID)(bAddr + 0x213068), new byte{ 0x20 }, 1, NULL); //change string length to 32 (no null byte)
- WriteProcessMemory(hProc, (LPVOID)(bAddr + 0x213068 + 0x2), &addressOfString, 4, NULL); //change address of pushed string
- VirtualProtectEx(hProc, (LPVOID)(bAddr + 0x213068), 6, old, &backup); //change protection back
- CloseHandle(hProc);
- std::cout << "Hack applied." << std::endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement