rendered paste body#include <windows.h>#include <stdio.h>#include <string.h>#include <stdarg.h>#include <math.h>#include <malloc.h>#include "proc_tools.h"#define SPADE 1#define CLUB 2#define HEART 3#define DIAMOND 4//Table info for table struct#define TBL_NAME 0#define TBL_LIMIT 1#define TBL_TYPE 2//Table commands for FTP_ControlTable()#define CMD_LEAVE 0#define CMD_AUTOPOSTTOGGLE 1#define CMD_CHECKFOLD 2#define CMD_CALL 3#define CMD_RAISE 4#define CMD_SITOUTNEXT 5#define CMD_GETCHIPS 6#define FTP_MAXTABLES 15#define FTP_MAXFAIL 1//Output types for FTP_Print()#define INF_WARN 0#define INF_MISC 1#define INF_UNKNOWN 2#define INF_TABLE 3typedef struct pk_card { int Suit,Rank; } pk_card;typedef struct table_info{ char *Info[4]; //name,limit,gametype,accountname (TBL_ defines above) HWND Handle; //Handle of table window HWND ChatHandle; //Handle of the FTCChat control in the window unsigned long ChatPID; // RECT WinPos; //Location of each corner of the table window (absolute) int Action; //Are we playing? 0/1 float BB; //Size of the Big Bet ($) at this table float Stack; //Our stack size ($) at this table float Pot; //Current pot size ($) pk_card Cards[5];//Our hole cards int Position; //1-num_seats, decreases by 1 each hand (so UTG would be 1, BB would be max seats)} table_info;//Function pointers for DLL stuffHMODULE hHookDLL;typedef void (*LPSetHook)(void);typedef void (*LPKillHook)(void);typedef MSG *(*LPGetDealerChat)(HWND);//Global variablestable_info *Tables[FTP_MAXTABLES];int ntables,current_table,FTP_MemStealFail;void FTP_Print(int type, char *fmt, ...){ char t; va_list args; char *text = (char *)malloc(strlen(fmt)+1024); va_start(args, fmt); vsprintf(text, fmt, args); switch(type) { case INF_WARN: t = '!'; break; case INF_MISC: t = '-'; break; case INF_UNKNOWN: t = '?'; break; case INF_TABLE: t = 'T'; break; default: t = '.'; } printf("[%c] %s\r\n", t, text); free(text);}//Simple left-click (absolute)void MouseClick(int x, int y){ mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, x, y, 0, 0); Sleep(5); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); Sleep((rand()%50)+50); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);}//Callback to get the FTCChat control from each table windowBOOL CALLBACK cbFindTableChatClass(HWND hwnd, LPARAM lParam){ char tmp[500]; GetClassName(hwnd, tmp, 500); if (strcmp(tmp, "FTCChat") == 0) Tables[ntables]->ChatHandle = hwnd; return TRUE;}//Call-back to find all Full-Tilt Poker tables openBOOL CALLBACK cbFindTableWindow(HWND hwnd, LPARAM lParam){ char tmp[500]; GetWindowText(hwnd, tmp, 500); if (strstr(tmp, "Limit Hold'em - Logged In As ")) FTP_AddTable(hwnd); return TRUE;}int FTP_AddTable(HWND hwnd){ char tmp[500]; int i,x=0,o=0,len=0; RECT r; //Return if hwnd is invalid or already exists in our array if (hwnd == NULL) return 1; for (i=0; i<FTP_MAXTABLES; i++) if (hwnd == Tables[i]->Handle) return 1; for (i=0; i<FTP_MAXTABLES; i++) { if (Tables[i]->Handle <= 0) { GetWindowText(hwnd, tmp, 500); for (i=0; i<500; i++) { if (tmp[i] == '-') { Tables[ntables]->Info[x][o-1] = 0; x++; o=0; i++; } else if (x < 3) Tables[ntables]->Info[x][o++] = tmp[i]; } Tables[ntables]->Action = 0; Tables[ntables]->Position = 0; Tables[ntables]->Stack = 0.0f; Tables[ntables]->Pot = 0.0f; Tables[ntables]->ChatHandle = NULL; Tables[ntables]->ChatPID = 0; //Chop the Big-Bet part from the table Limit len = strlen(Tables[ntables]->Info[TBL_LIMIT]); for (i=0; i<len; i++) { if (Tables[ntables]->Info[TBL_LIMIT][i] == '/') { //Is it a real money table? if (Tables[ntables]->Info[TBL_LIMIT][i+1] == '$') Tables[ntables]->BB = atof(Tables[ntables]->Info[TBL_LIMIT]+i+2); else Tables[ntables]->BB = atof(Tables[ntables]->Info[TBL_LIMIT]+i+1); break; } } //Store window handle and position Tables[ntables]->Handle = hwnd; GetWindowRect(hwnd, &Tables[ntables]->WinPos); //Trigger the callback to get the FTCChat control from the table EnumChildWindows(Tables[ntables]->Handle, cbFindTableChatClass, 0); FTP_Print(INF_MISC, "Found table '%s' (%d,%d)", Tables[ntables]->Info[TBL_NAME], Tables[ntables]->WinPos.top, Tables[ntables]->WinPos.left); ntables++; return 0; } } return 2; //theres no spare table_info structs in the array}//Check to see if theres a button ready to press on the table...int FTP_IsInputRequired(table_info *Target){ long p; if (Target->Handle == NULL) return 0; //Get 1 pixel from where the 'check/fold' button usually is... p = GetPixel(GetWindowDC(Target->Handle), 315, 322); //If the table has been closed, p will be -1. if (p == -1) { FTP_Print(INF_MISC, "Table '%s' was closed.", Target->Info[TBL_NAME]); Target->Handle = NULL; FTP_RewriteTableArray(); } else if (p == 10385408) return 1; return 0;}//Manipulate the buttons on the FTP table window...int FTP_ControlTable(table_info *Target, int Command){ if (Target->Handle == NULL) return 1; SetForegroundWindow(Target->Handle); switch(Command) { case CMD_LEAVE: MouseClick(Target->WinPos.left+465, Target->WinPos.top+12); //If we are seated we'll have to click a dialog box too. if (Target->Action) { Sleep(100); MouseClick(Target->WinPos.left+108, Target->WinPos.top+100); } break; case CMD_AUTOPOSTTOGGLE: MouseClick(Target->WinPos.left+209, Target->WinPos.top+341); break; case CMD_CHECKFOLD: MouseClick(Target->WinPos.left+315, Target->WinPos.top+322); break; case CMD_CALL: //(Changes to Check when checked around to you) MouseClick(Target->WinPos.left+375, Target->WinPos.top+322); break; case CMD_RAISE: //Set raise amount with send keys when window awaits input! MouseClick(Target->WinPos.left+447, Target->WinPos.top+322); break; case CMD_SITOUTNEXT: MouseClick(Target->WinPos.left+209, Target->WinPos.top+330); break; case CMD_GETCHIPS: //Click "Get Chips" button, then click OK in the following dialog. MouseClick(Target->WinPos.left+27, Target->WinPos.top+31); Sleep(100); MouseClick(Target->WinPos.left+119, Target->WinPos.top+361); break; } return 0;}//Attempt to read table chat listbox with SendMessage() and read remote bufferint FTP_AttemptMemSteal(table_info *Target){ char *_tmp, tmp[8096]; HANDLE p; if (Target->Handle == NULL) return 0; GetWindowThreadProcessId(Target->Handle, &Target->ChatPID); p = OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, Target->ChatPID); _tmp = (char *)VirtualAllocEx(p, NULL, 8096, MEM_COMMIT, PAGE_READWRITE); memset(tmp, 0, 8096); WriteProcessMemory(p, _tmp, &tmp, 8096, NULL); SendMessage(Target->ChatHandle, LB_GETTEXT, (WPARAM)0, (LPARAM)_tmp); ReadProcessMemory(p, _tmp, &tmp, 8096, NULL); VirtualFreeEx(p, _tmp, 0, MEM_RELEASE); if (tmp[0] != 0) return 1; FTP_MemStealFail++; return 0;}void FTP_Cleanup(table_info *Target){ free(Target->Info[TBL_NAME]); free(Target->Info[TBL_LIMIT]); free(Target->Info[TBL_TYPE]);}//Get rid of the gaps in the array (caused by closing tables)int FTP_RewriteTableArray(){ int i,x; ntables = 0; for (i=FTP_MAXTABLES-1;i>=0;i--) if (Tables[i]->Handle) { for (x=0; x<i; x++) if (Tables[x]->Handle == NULL) { Tables[x] = Tables[i]; break; } ntables++; } return 0;}void FTP_CheckForNewTables() { EnumWindows(cbFindTableWindow,0); }//------------------------------------------------------------------------------int main(int argc, char **argv){ int temp,i,x,l; ntables = 0; LPSetHook SetHook = NULL; LPKillHook KillHook = NULL; LPGetDealerChat GetDealerChat = NULL; FTP_MemStealFail = 0; printf("[*] FTPlayer - Full-Tilt Poker Interface\r\n"); FTP_Print(INF_MISC, "Allocating memory..."); for (i=0; i<FTP_MAXTABLES; i++) { Tables[i] = (table_info *)malloc(sizeof(table_info)); memset(Tables[i], 0, sizeof(table_info)); Tables[i]->Info[TBL_NAME] = (char *)malloc(100); Tables[i]->Info[TBL_LIMIT] = (char *)malloc(100); Tables[i]->Info[TBL_TYPE] = (char *)malloc(100); memset(Tables[i]->Info[TBL_NAME], 0, 100); memset(Tables[i]->Info[TBL_LIMIT], 0, 100); memset(Tables[i]->Info[TBL_TYPE], 0, 100); } /* //Load the hook DLL and install printf("[-] Loading helper DLL and installing SysMsg hook..."); hHookDLL = LoadLibrary("SysMsgHook.dll"); if (!hHookDLL) return 0; SetHook = (LPSetHook)GetProcAddress(hHookDLL, "SetHook"); if (!SetHook) return 0; KillHook = (LPKillHook)GetProcAddress(hHookDLL, "KillHook"); if (!KillHook) return 0; GetDealerChat = (LPGetDealerChat)GetProcAddress(hHookDLL, "GetDealerChat"); if (!GetDealerChat) return 0; SetHook(); printf("done.\r\n"); */ //Trigger callback function to populate table array (also triggers chat window callback) FTP_Print(INF_MISC, "Searching for tables..."); FTP_CheckForNewTables(); //Display parsed results from callbacks FTP_Print(INF_MISC, "Found %d tables.\r\n Table\t\tLimit\t\tGame Type", ntables); for (i=0; i<ntables; i++) FTP_Print(INF_MISC, "%s\t%s\t%s", Tables[i]->Info[TBL_NAME], Tables[i]->Info[TBL_LIMIT], Tables[i]->Info[TBL_TYPE]); //Main loop begins FTP_Print(INF_MISC, "Main loop starting..."); while(ntables) { FTP_CheckForNewTables(); for(i=0; i<ntables; i++) { //Try first method of chat buffer read if (FTP_MemStealFail < FTP_MAXFAIL && FTP_AttemptMemSteal(Tables[i]) == 0) FTP_Print(INF_WARN, "Memory steal failed at '%s'.", Tables[i]->Info[TBL_NAME]); //Check table for input required... if (FTP_IsInputRequired(Tables[i])) { //Find out what the situation is at the table. //Do-Stuff(tm). FTP_Print(INF_TABLE, "Input required at '%s'.", Tables[i]->Info[TBL_NAME]); } Sleep(50); } Sleep(1000); } //Cleanup time - uninstall the hook, unload DLL, leave tables //KillHook(); //FreeLibrary(hHookDLL); FTP_Print(INF_MISC, "No tables open, cleaning up..."); for (i=0; i<ntables; i++) { FTP_ControlTable(Tables[i], CMD_LEAVE); FTP_Cleanup(Tables[i]); free(Tables[i]); } system("PAUSE"); return 0;}