首页
社区
课程
招聘
[求助]如何 写出这个工具
发表于: 2008-10-18 09:45 3657

[求助]如何 写出这个工具

2008-10-18 09:45
3657
由一个 软件 是 别人写好的  我怎么才能知道 他软件的原理 然后再自己写一个类似的工具 ...
http://210.44.195.11/www/jw/xx.rar

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 2110
活跃值: (21)
能力值: (RANK:260 )
在线值:
发帖
回帖
粉丝
2
这个东西是VB的
经过分析,我写出来了。
我只写了显示血量的部分。屏蔽Win键的功能用的是SetWindowsHookEx,钩子类型是低级键盘消息,此代码网上很多,我就没写。

显示血量部分,它的方法是,先RegisterHotKey,在系统中注册HOME和END的热键,在消息处理中,只是简单模拟键盘操作,虚拟键码是0xdb和0xdd。
这两个键码不是Windows标准键码,是暴雪定义的。至于这两个值原作者是如何得到的,就不知道了。我只对这个工具进行逆向得出的结果。

最后我写了个完成同样功能的程序。把以下代码在vc6中编译就行了,是C++代码。
写得丑陋,见笑了。
#include <windows.h>

HINSTANCE        hInst;                                                        // current instance
TCHAR                szTitle[]        = "Demo";                                // The title bar text
TCHAR                szWindowClass[]        = "DemoClass";                                // The title bar text
TCHAR                szHello[]        = "按HOME键显示或隐藏自己的血条\n按END键显示或隐藏敌人的血条\n对魔兽争霸有效";

// Foward declarations of functions included in this code module:
ATOM                        MyRegisterClass(HINSTANCE hInstance);
LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK        About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
        // TODO: Place code here.
        hInst = hInstance; // Store instance handle in our global variable
        MSG msg;

        ATOM homeAtom        = ::GlobalAddAtom( "HOME" );
        ATOM delAtom        = ::GlobalAddAtom( "DEL"  );

        WNDCLASSEX wcex;

        wcex.cbSize = sizeof(WNDCLASSEX);

        wcex.style                = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc        = (WNDPROC)WndProc;
        wcex.cbClsExtra                = 0;
        wcex.cbWndExtra                = 0;
        wcex.hInstance                = hInstance;
        wcex.hIcon                = 0;
        wcex.hCursor                = 0;
        wcex.hbrBackground        = (HBRUSH)(COLOR_WINDOW+1);
        wcex.lpszMenuName        = 0;
        wcex.lpszClassName        = szWindowClass;
        wcex.hIconSm                = 0;

        ::RegisterClassEx(&wcex);
        HWND hWnd        = ::CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

        ::RegisterHotKey( hWnd, homeAtom, 0, VK_HOME );
        ::RegisterHotKey( hWnd, delAtom,  0, VK_END  );

        ShowWindow(hWnd, nCmdShow);
        UpdateWindow(hWnd);

        // Main message loop:
        while (GetMessage(&msg, NULL, 0, 0))
        {
                if ( msg.message == WM_DESTROY )
                {
                        ::UnregisterHotKey( hWnd, homeAtom );
                        ::UnregisterHotKey( hWnd, delAtom  );
                }

                TranslateMessage(&msg);
                DispatchMessage(&msg);
        }

        ::GlobalDeleteAtom( homeAtom );
        ::GlobalDeleteAtom( delAtom  );

        return msg.wParam;
}

//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND        - process the application menu
//  WM_PAINT        - Paint the main window
//  WM_DESTROY        - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        int wmId, wmEvent;
        PAINTSTRUCT ps;
        HDC hdc;

        switch (message)
        {
                case WM_PAINT:
                        hdc = BeginPaint(hWnd, &ps);
                        // TODO: Add any drawing code here...
                        RECT rt;
                        GetClientRect(hWnd, &rt);
                        DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
                        EndPaint(hWnd, &ps);
                        break;
                case WM_DESTROY:
                        PostQuitMessage(0);
                        break;
                case WM_HOTKEY:
                        {
                                UINT        vk        = (UINT) HIWORD(lParam);
                                if ( vk == VK_HOME )                                                // home键按下,显示或隐藏自己部队的血条
                                {
                                        static bool keydown        = false;                        //初始不显示
                                        if ( keydown )
                                        {
                                                keydown = false;
                                                ::keybd_event( 0xdb, 0, KEYEVENTF_KEYUP, 0 );        // 隐藏
                                        }
                                        else
                                        {
                                                keydown = true;
                                                ::keybd_event( 0xdb, 0, 0, 0 );                        // 显示
                                        }

                                        break;
                                }
                                if ( vk == VK_END )                                                // END键,敌人血条
                                {
                                        static bool keydown        = false;

                                        if ( keydown )
                                        {
                                                keydown = false;
                                                ::keybd_event( 0xdd, 0, KEYEVENTF_KEYUP, 0 );
                                        }
                                        else
                                        {
                                                keydown = true;
                                                ::keybd_event( 0xdd, 0, 0, 0 );
                                        }

                                        break;
                                }
                        }

                default:
                        return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
2008-10-18 15:56
0
雪    币: 2110
活跃值: (21)
能力值: (RANK:260 )
在线值:
发帖
回帖
粉丝
3
论坛对TAB进行了处理,代码格式乱了许多,自己用VC整理吧,在VC中全选代码,然后按ALT+F8就行了。

等我整理一下,把分析过程也发一下。
2008-10-18 15:59
0
雪    币: 2110
活跃值: (21)
能力值: (RANK:260 )
在线值:
发帖
回帖
粉丝
4
一下午的功夫,整理了一下分析过程,水平不高,请莫见怪。

http://bbs.pediy.com/showthread.php?p=522951#post522951
2008-10-18 20:55
0
雪    币: 54
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
谢谢 谢谢 谢谢 谢谢
2008-10-19 22:27
0
游客
登录 | 注册 方可回帖
返回
//