#include #include using namespace std; bool status = false; #define PLAYER_EXP 0x005FB924 #define PLAYER_LEVEL 0x005FB920 #define STATUS_TEXT 0x007531D8 #define STATUS_TIMER 0x007531D4 LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); bool printExp(); unsigned long getExpForLv(const int& lv) { return (int)((50*lv*lv*lv)/3 - 100 * lv * lv + (850*lv) / 3 - 200); } HANDLE hProcess; int statusLen = 40; char szClassName[ ] = "Exp viewer by Froboo"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int iCmdShow) { HWND hWnd; hWnd = FindWindow("tibiaclient", NULL); if(!hWnd) { MessageBox(NULL,"Could not find tibia.exe.","ERROR",MB_OK | MB_ICONINFORMATION); return 0; } DWORD procid; GetWindowThreadProcessId(hWnd, &procid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, procid); if(!hProcess) { MessageBox(NULL,"Could not find process.","ERROR",MB_OK | MB_ICONINFORMATION); return 0; } HWND hwnd; MSG messages; WNDCLASSEX wincl; DWORD dwExStyle; DWORD dwStyle; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; if (!RegisterClassEx (&wincl)) return 0; dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; hwnd = CreateWindowEx ( dwExStyle, szClassName, "Exp viewer by Froboo", dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, 230, 100, HWND_DESKTOP, NULL, hThisInstance, NULL ); if (!status) ShowWindow(hwnd, SW_HIDE); else ShowWindow(hwnd, SW_SHOW); BOOL done = false; while(!done) { if (PeekMessage(&messages,NULL,0,0,PM_REMOVE)) { if (messages.message==WM_QUIT) { done = true; } else { TranslateMessage(&messages); DispatchMessage(&messages); } } else { if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F1)) { ShowWindow(hwnd, SW_SHOW); HWND hWnd; hWnd = FindWindow("tibiaclient", NULL); if(!hWnd) { MessageBox(NULL,"Could not find tibia.exe.","ERROR",MB_OK | MB_ICONINFORMATION); return false; } DWORD procid; GetWindowThreadProcessId(hWnd, &procid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, procid); if(!hProcess) { MessageBox(NULL,"Could not find process.","ERROR",MB_OK | MB_ICONINFORMATION); return false; } int tempLen = 80; string text = "Shutting down exp calc by Froboo"; int count, m = 0; for(count =0; count < text.length(); count++) { int l = STATUS_TEXT + m; WriteProcessMemory(hProcess, (LPVOID)l, &text[count], 255, NULL); m++; } WriteProcessMemory(hProcess, (LPVOID)STATUS_TIMER, &tempLen, 4, NULL); CloseHandle(hProcess); done = true; } else { if (GetAsyncKeyState(VK_END)) { if (!printExp()) done = true; } if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F2)) { if (!status) { ShowWindow(hwnd, SW_SHOW); status = true; Sleep(200); } else { ShowWindow(hwnd, SW_HIDE); status = false; Sleep(200); } } } } } return messages.wParam; } LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CLOSE: { PostQuitMessage(0); return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } default: return DefWindowProc (hwnd, message, wParam, lParam); } return 0; } bool printExp() { HWND hWnd; hWnd = FindWindow("tibiaclient", NULL); if(!hWnd) { MessageBox(NULL,"Could not find tibia.exe.","ERROR",MB_OK | MB_ICONINFORMATION); return false; } DWORD procid; GetWindowThreadProcessId(hWnd, &procid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, procid); if(!hProcess) { MessageBox(NULL,"Could not find process.","ERROR",MB_OK | MB_ICONINFORMATION); return false; } long level, exp; ReadProcessMemory(hProcess, (LPVOID)PLAYER_LEVEL, &level, 4, NULL); ReadProcessMemory(hProcess, (LPVOID)PLAYER_EXP, &exp, 4, NULL); char expforlevel[255]; unsigned long experience = getExpForLv(level + 1) - exp; sprintf(expforlevel, "Experience left to level %d: %d", level+1, experience); string text; text = expforlevel; int count, m = 0; for(count =0; count < text.length(); count++) { int l = STATUS_TEXT + m; WriteProcessMemory(hProcess, (LPVOID)l, &text[count], 255, NULL); m++; } WriteProcessMemory(hProcess, (LPVOID)STATUS_TIMER, &statusLen, 4, NULL); CloseHandle(hProcess); return true; }