扫雷外挂源码

// MineSweeping.cpp: 定义 DLL 的初始化例程。
//

#include "stdafx.h"
#include "MineSweeping.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

//
//TODO:  如果此 DLL 相对于 MFC DLL 是动态链接的,
//        则从此 DLL 导出的任何调入
//        MFC 的函数必须将 AFX_MANAGE_STATE 宏添加到
//        该函数的最前面。
//
//        例如:
//
//        extern "C" BOOL PASCAL EXPORT ExportedFunction()
//        {
//            AFX_MANAGE_STATE(AfxGetStaticModuleState());
//            // 此处为普通函数体
//        }
//
//        此宏先于任何 MFC 调用
//        出现在每个函数中十分重要。  这意味着
//        它必须作为以下项中的第一个语句:
//        出现,甚至先于所有对象变量声明,
//        这是因为它们的构造函数可能生成 MFC
//        DLL 调用。
//
//        有关其他详细信息,
//        请参阅 MFC 技术说明 33 和 58。
//

// CMineSweepingApp

BEGIN_MESSAGE_MAP(CMineSweepingApp, CWinApp)
END_MESSAGE_MAP()


// CMineSweepingApp 构造

CMineSweepingApp::CMineSweepingApp()
{
     // TODO:  在此处添加构造代码,
     // 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的 CMineSweepingApp 对象

CMineSweepingApp theApp;

HWND g_Wnd;

WNDPROC g_OldProc;

PDWORD g_pWidth = (PDWORD)0x01005334;
PDWORD g_pHeight = (PDWORD)0x01005338;
PDWORD g_pMineCount = (PDWORD)0x01005330;
PBYTE g_pBase = (PBYTE)0x1005340;
#define MINE 0x8F
// CMineSweepingApp 初始化

//MOV ECX, DWORD PTR DS : [0x1005334]
//MOV EDX, DWORD PTR DS : [0x1005338]
//LEA EAX, DWORD PTR DS : [ECX + 0x2]
//TEST EAX, EAX
//PUSH ESI
//MOV ESI, EDX
//SHL ESI, 0x5
//LEA ESI, DWORD PTR DS : [ESI + 0x1005360]
//DEC EAX;
//MOV BYTE PTR DS : [EAX + 0x1005340], 0x10
//MOV BYTE PTR DS : [ESI + EAX], 0x10
//JNZ SHORT winmine.01002F03






LRESULT
CALLBACK
WindowProc(
     _In_ HWND hWnd,
     _In_ UINT Msg,
     _In_ WPARAM wParam,
     _In_ LPARAM lParam)
{
     if (Msg == WM_KEYDOWN && wParam == VK_F5)
     {
         OutputDebugString(L"F5");


         int nWidth = *g_pWidth;
         int nHeight = *g_pHeight;
         int nMineCount = *g_pMineCount;

        CString strString;
         strString.Format(L"宽度: %d, 高度: %d ,雷数: %d", nWidth,
             nHeight,nMineCount);
         OutputDebugString(strString.GetBuffer());

        int nFindCount = 0;
         for (size_t y = 1; y < nHeight+1; y++)
         {
             CString strLine;
             for (size_t x = 1; x < nWidth + 1; x++)
             {
                 BYTE byCode = *(PBYTE)((DWORD)g_pBase + x + y * 32);
                 if (byCode == MINE)
                 {
                     nFindCount++;
                     //byCode = 0x8E;
                 }
                 else
                 {
                     int xPos, yPos;
                     xPos = (x << 4) - 4;
                     yPos = (y << 4) + 0x27;
                     //模拟键盘输入
                     SendMessage(hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(xPos, yPos));
                     SendMessage(hWnd, WM_LBUTTONUP, 0, MAKELPARAM(xPos, yPos));
                 }
                 CString strCode;
                 strCode.Format(L"%02x", byCode);
                 strLine += strCode;
             }
             OutputDebugString(strLine.GetBuffer());
         }
         CString strCode;
         strCode.Format(L"雷的个数%d ", nFindCount);
         OutputDebugString(strCode.GetBuffer());
     }
     else if(Msg == WM_MOUSEMOVE)
     {
         int x, y;
         x = LOWORD(lParam);
         y = HIWORD(lParam);
         x = (x + 4) >> 4;
         y = (y - 0x27) >> 4;
         BYTE byCode = *(PBYTE)((DWORD)g_pBase + x + y * 32);
         if (byCode == MINE)
         {
             SetWindowText(hWnd, L"此处有雷");
             //MessageBox(NULL,L"小心这里有雷",NULL,NULL);
         }
         else
         {
             SetWindowText(hWnd, L"扫雷");
         }
     }
     return CallWindowProc(g_OldProc, hWnd, Msg, wParam, lParam);
}

BOOL CMineSweepingApp::InitInstance()
{
     CWinApp::InitInstance();

    //1.通过查找窗口,获取窗口句柄
     g_Wnd = FindWindow(L"扫雷", L"扫雷");
     if (g_Wnd==NULL)
     {
         OutputDebugString(L"窗口句柄获取失败");
         return FALSE;
     }
     //2.设置窗口回调
     g_OldProc = (WNDPROC)SetWindowLong(g_Wnd,
         GWL_WNDPROC, (LONG)WindowProc);
     if (g_OldProc==NULL)
     {
         OutputDebugString(L"设置窗口回调失败");
         return FALSE;
     }

    return TRUE;
}

posted @ 2019-11-13 12:24  Crack_Me  阅读(879)  评论(0编辑  收藏  举报