#pragma once
class CLLKCheatCore
{
private:
static const int MAX_TYPE = 256;
static const int ROW = 11, COL = 19;
static const int X_START = 25, Y_START = 195;
static const int X_GAP = 32, Y_GAP = 35;
static const int MAP_BASE_ADDR = 0x12a480, REMAIN_ADDR = 0x1163b0;
static TCHAR szTitle[];
public:
CLLKCheatCore(void);
~CLLKCheatCore(void);
public:
BOOL ClearAvailable();
private:
BOOL ReadMap(HWND &);
void Link2Point(HWND &, CPoint &, CPoint &);
private:
BYTE m_map[ROW][COL];
int m_remain;
};
#include "StdAfx.h"
#include "LLKCheatCore.h"
TCHAR CLLKCheatCore::szTitle[] = TEXT("QQ游戏 - 连连看角色版");
CLLKCheatCore::CLLKCheatCore(void)
{
}
CLLKCheatCore::~CLLKCheatCore(void)
{
}
BOOL CLLKCheatCore::ReadMap(HWND &hWnd)
{
BOOL bFlag = TRUE;
if(hWnd != NULL) {
DWORD pid;
GetWindowThreadProcessId(hWnd, &pid);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
if(hProcess != NULL) {
m_remain = 0;
if(!ReadProcessMemory(hProcess, (LPVOID)REMAIN_ADDR, &m_remain, sizeof(m_remain), NULL))
bFlag = FALSE;
if(TRUE == bFlag && m_remain > 0) {
for(int i = 0; i < ROW; ++i) {
if(!ReadProcessMemory(hProcess, (LPVOID)(MAP_BASE_ADDR + COL * i), m_map[i], sizeof(m_map[0]), NULL)) {
bFlag = FALSE;
break;
}
}
}
CloseHandle(hProcess);
} else
bFlag = FALSE;
} else
bFlag = FALSE;
return bFlag;
}
void CLLKCheatCore::Link2Point(HWND &hWnd, CPoint &pt1, CPoint &pt2)
{
if(hWnd != NULL) {
LPARAM lParam = ((Y_START + pt1.y * Y_GAP) << 16) + (X_START + pt1.x * X_GAP);
::SendMessage(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, lParam);
::SendMessage(hWnd, WM_LBUTTONUP, MK_LBUTTON, lParam);
lParam = ((Y_START + pt2.y * Y_GAP) << 16) + (X_START + pt2.x * X_GAP);
::SendMessage(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, lParam);
::SendMessage(hWnd, WM_LBUTTONUP, MK_LBUTTON, lParam);
}
}
BOOL CLLKCheatCore::ClearAvailable()
{
BOOL bFlag;
CArray<CPoint, CPoint> ptArray[MAX_TYPE];
HWND hWnd = ::FindWindow(NULL, szTitle);
if(hWnd != NULL) {
bFlag = ReadMap(hWnd);
if(TRUE == bFlag && m_remain > 0) {
for(int i = 0; i < ROW; i++) {
for(int j = 0; j < COL; j++) {
if(m_map[i][j] != 0) {
int k = m_map[i][j];
ptArray[k].Add(CPoint(j, i));
}
}
}
for(int i = 0; i < MAX_TYPE; i++) {
INT_PTR size = ptArray[i].GetSize();
if(size > 0) {
for(INT_PTR j = 0; j < size - 1; j++) {
for(INT_PTR k = j + 1; k < size; k++) {
CPoint pt1 = ptArray[i].GetAt(j);
CPoint pt2 = ptArray[i].GetAt(k);
Link2Point(hWnd, pt1, pt2);
}
}
}
}
}
} else
bFlag = FALSE;
return bFlag;
}