查找弹窗软件的全路径名称

这几天开机联网后, 右下角总有弹窗, 弹窗的内容很恶心 :(

不知道哪个软件搞得, 自己打造一个小工具来侦测弹窗软件的全路径名称.

最后找到了, 居然是“牛牛桌面管理大师”, 大师?  我擦, 整个一个流氓...

以后不再用这个软件了~

 

罪证:

弹窗的关闭按钮信息

弹窗信息

弹窗截图就免了.

刚安装此软件时, 用户体验用的挺好. 等用了一段时间, 就出弹窗, 这是啥策略啊?

 

软件做的确实比音速启动贴心, 不过耍流氓可不行.

工具源码下载 : srcWndInfoView_2013_0614.rar

工具代码实现

 

#include <windows.h>
#include <tchar.h> 
#include <Psapi.h>
#pragma comment (lib, "Psapi.lib")

#include <commctrl.h>   ///< for InitCommonControls
#pragma comment(lib, "ComCtl32.lib")

#include "resource.h"

#ifndef tsizeof
#define tsizeof(x) (sizeof((x)) / sizeof(TCHAR))
#endif

#define G_NAME_PROG _T("WndInfoView") ///< 程序名称
#define DINV 3 ///< 突出显示窗口时, 显示的指示窗口相对于源窗口的偏移
#define DW_DESIRED_ACCESS_REMOTE_PROCESS \
        (PROCESS_CREATE_THREAD \
        | PROCESS_QUERY_INFORMATION \
        | PROCESS_VM_OPERATION \
        | PROCESS_VM_WRITE \
        | PROCESS_VM_READ)

INT_PTR WINAPI DialogFunc(HWND hWnd, UINT uMsg, WPARAM wparam, LPARAM lparam);
INT_PTR WINAPI MsgProcess_WmCommand(HWND hWnd, 
                                    UINT uMsg, 
                                    WPARAM wparam, 
                                    LPARAM lparam);
BOOL WINAPI MyCenterWindow(HWND hWnd);
bool WINAPI ShowMsgByYesNo(HWND hWnd, TCHAR *pcInfo, TCHAR *pcTitle);

VOID OnMouseMove(HWND hWnd, POINT &pt);
VOID HighlightWindow(HWND hWnd, bool bDraw);
HWND SmallestWindowFromPoint(CONST POINT pt);
LONGLONG calcRectArea(const RECT & rc); ///< 得到Rect的面积

/// @fn         ViewWndInfo
/// @brief      查看窗口信息
/// @param      HWND hWndInfo, 显示信息的窗口, 将分析结果写到这个窗口
/// @param      HWND hWndObj, 目标软件窗口, 从这个窗口获得信息
void ViewWndInfo(HWND hWndInfo, HWND hWndObj);

HINSTANCE   hInst; ///< 实例句柄

HWND    hWndWasBeCapture; ///< 捕获操作(鼠标左键按下 && 鼠标滑动中)的被捕获窗口
HWND    hCaptureContainer; /**< 捕获器容器窗口 */

HBITMAP hBmpCaptureContainer;   ///< 捕获器容器非捕获状态位图句柄
HBITMAP	hBmpCaptureContainerBG; ///< 捕获器容器捕获状态位图句柄

HCURSOR hCurCapture;    ///< 捕获器光标
HCURSOR hCurCaptureHot; ///< 捕获器加强光标
HCURSOR hCurNormal;     ///< 正常窗口光标

POINT   ptCur;            ///< 当前鼠标位置
bool    bCapturing;        ///< 捕获操作标记: TRUE = 捕获中..., FALSE = 捕获结束

int WINAPI _tWinMain(HINSTANCE hInstance, 
                     HINSTANCE hPrevInstance, 
                     __in TCHAR * lpCmdLine, 
                     int nCmdShow)
{
    HWND    hWnd = NULL;
    DLGPROC lpDlgProc = DialogFunc;
    BOOL    bRc = TRUE;
    int     iRc = 0;
    MSG     msg;

    __try
    {
        bCapturing = FALSE;
        hWndWasBeCapture = NULL;

        hInst = hInstance;
        hWnd = CreateDialogParam(hInstance,
                                MAKEINTRESOURCE(IDD_DIALOG_MAIN),
                                NULL,
                                lpDlgProc,
                                NULL);
        InitCommonControls();

        if (!MyCenterWindow(hWnd))
            __leave;

        ShowWindow(hWnd, SW_SHOW);
        while ((bRc = GetMessage(&msg, 0, 0, 0)) != 0)
        {
            if (!bRc)
                __leave;

            if (!IsDialogMessage(hWnd, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    }

    __finally
    {
        iRc = bRc ? 0 :  - 1;
    }

    return iRc;
}

INT_PTR WINAPI DialogFunc(HWND hWnd, UINT uMsg, WPARAM wparam, LPARAM lparam)
{
    INT_PTR iRc = TRUE;
    RECT rc;

    switch (uMsg)
    {
    case WM_COMMAND:
        {
            iRc = MsgProcess_WmCommand(hWnd, uMsg, wparam, lparam);
        }
        break;

    case WM_INITDIALOG:
        {
            ::SetWindowText(hWnd, G_NAME_PROG);
            hCaptureContainer = ::GetDlgItem(hWnd,IDC_CAPTURE_CONTAINER);

            hBmpCaptureContainer = LoadBitmap(hInst,
                MAKEINTRESOURCE(IDB_BITMAP_CROSS));

            hBmpCaptureContainerBG = LoadBitmap(hInst,
                MAKEINTRESOURCE(IDB_BITMAP_BLANK));

            hCurCapture = LoadCursor(hInst,
                MAKEINTRESOURCE(IDC_CUR_CAPTURE));

            hCurCaptureHot = LoadCursor(hInst,
                MAKEINTRESOURCE(IDC_CUR_CAPTURE_HOT));

            hCurNormal = LoadCursor(NULL, IDC_ARROW);
        }
        break;

    case WM_LBUTTONDOWN:
        {
            ptCur.x = MAKEPOINTS(lparam).x;
            ptCur.y = MAKEPOINTS(lparam).y;
            ::ClientToScreen (hWnd, &ptCur);

            ::GetWindowRect(hCaptureContainer, &rc);

            if (::PtInRect(&rc, ptCur))
            {
                ::SetCursor(hCurCapture);
                ::SendMessage(  hCaptureContainer,
                                STM_SETIMAGE,
                                IMAGE_BITMAP,
                                (LPARAM)hBmpCaptureContainerBG);
                ::SetCapture(hWnd);
                bCapturing = TRUE;
            }
        }
        break;

    case WM_LBUTTONUP:
    case WM_KILLFOCUS:
        if (bCapturing)
        {
            if (hWndWasBeCapture)
                HighlightWindow(hWndWasBeCapture, FALSE);

            hWndWasBeCapture = NULL;

            ::SetCursor(hCurNormal);
            ::SendMessage(  hCaptureContainer,
                            STM_SETIMAGE,
                            IMAGE_BITMAP,
                            (LPARAM)hBmpCaptureContainer);
            ::ReleaseCapture();
            bCapturing = FALSE;
        }
        break;

    case WM_MOUSEMOVE:
        if (bCapturing)
        {
            ptCur.x = MAKEPOINTS(lparam).x;
            ptCur.y = MAKEPOINTS(lparam).y;
            ::ClientToScreen (hWnd, &ptCur);
            OnMouseMove(hWnd, ptCur);
        }
        break;

    case WM_CLOSE:
        {
            if (ShowMsgByYesNo(hWnd, _T("确定退出程序么?"), G_NAME_PROG))
                DestroyWindow(hWnd);
        }
        break;

    case WM_DESTROY:
        {
            PostQuitMessage(0);
        }
        break;

    default:
        {
            iRc = FALSE; ///< let windows process it
        }
        break;
    }

    return iRc;
}

INT_PTR WINAPI MsgProcess_WmCommand(HWND hWnd,
                                    UINT uMsg,
                                    WPARAM wparam,
                                    LPARAM lparam)
{
    INT_PTR iRc = TRUE;

    switch (wparam)
    {
    case IDOK:
        {
            ::PostMessage(hWnd, WM_CLOSE, 0, 0);
        }
    default:
        {
            iRc = FALSE; ///< let windows process it
        }
        break;
    }

    return iRc;
}

bool WINAPI ShowMsgByYesNo(HWND hWnd, TCHAR *pcInfo, TCHAR *pcTitle)
{
    int iRc =   IDYES;

    iRc = ::MessageBox(hWnd, pcInfo, pcTitle, MB_YESNO | MB_ICONINFORMATION);
    return (IDYES == iRc) ? TRUE : FALSE;
}

BOOL WINAPI MyCenterWindow(HWND hWnd)
{
    BOOL    bRc         =   FALSE;
    HWND    hWndParent  =   NULL;
    RECT    rcParent;
    RECT    rcMe;

    __try
    {
        hWndParent = ::GetDesktopWindow();
        if (!::GetWindowRect(hWndParent, &rcParent))
        {
            bRc = FALSE;
            __leave;
        }

        if (!::GetWindowRect(hWnd, &rcMe))
        {
            bRc = FALSE;
            __leave;
        }

        bRc = ::MoveWindow(
            hWnd,
            ((rcParent.right - rcParent.left) - (rcMe.right - rcMe.left)) / 2,
            ((rcParent.bottom - rcParent.top) - (rcMe.bottom - rcMe.top)) / 2, 
            rcMe.right - rcMe.left, 
            rcMe.bottom - rcMe.top,
            TRUE);

        bRc = TRUE;
    }

    __finally
    {
    }

    return bRc;
}

VOID OnMouseMove(HWND hWnd, POINT &pt)
{
    /// @ref HWND hWnd = ::WindowFromPoint (pt);
    DWORD   dwPID           =   0;
    HWND    hWndPtParent    =   SmallestWindowFromPoint(pt);

    ::GetWindowThreadProcessId (hWndPtParent, &dwPID);
    if ((GetCurrentProcessId () == dwPID)
        || (hWndWasBeCapture == hWndPtParent))
    {
        return; ///< don't parse this process
    }

    if (hWndWasBeCapture)
        HighlightWindow(hWndWasBeCapture, FALSE);

    HighlightWindow(hWndPtParent,TRUE);
    hWndWasBeCapture = hWndPtParent;

    ViewWndInfo(hWnd, hWndPtParent);
}

void ViewWndInfo(HWND hWndInfo, HWND hWndObj)
{
    int     iCtrlID         =   0;
    DWORD   dwStyle         =   0;
    DWORD   dwPID           =   0;
    DWORD   dwTID           =   0;
    HWND    hParent         =   NULL;
    RECT    rc;
    _TCHAR  cBuf[_MAX_PATH];    ///< text buffer

    ZeroMemory(cBuf, sizeof(cBuf));
    dwTID = ::GetWindowThreadProcessId (hWndObj, &dwPID);

    /// Insert data into edit ctrl

    /// parent window
    hParent = ::GetParent(hWndObj);
    if (NULL != hParent) 
    {
        /// parent handle
        _stprintf_s(cBuf, tsizeof(cBuf), _T("0x%08X"), hParent);
        ::SetDlgItemText(hWndInfo, IDC_EDIT_HANDLE_P, cBuf);

        /// parent text
        ::GetWindowText(hParent, cBuf, tsizeof(cBuf));
        ::SetDlgItemText(hWndInfo, IDC_EDIT_TEXT_P, cBuf);

        /// parent class name
        ::GetClassName(hParent, cBuf, tsizeof(cBuf));
        ::SetDlgItemText(hWndInfo, IDC_EDIT_CLASS_P, cBuf);
    }
    else
    {
        ::SetDlgItemText(hWndInfo, IDC_EDIT_HANDLE_P,  _T("N/A"));
        ::SetDlgItemText(hWndInfo, IDC_EDIT_TEXT_P, _T("N/A"));
        ::SetDlgItemText(hWndInfo, IDC_EDIT_CLASS_P, _T("N/A"));
    }

    /// window under cursor

    /// window handle
    _stprintf_s(cBuf, tsizeof(cBuf), _T("0x%08X"), hWndObj);
    ::SetDlgItemText(hWndInfo, IDC_EDIT_HANDLE, cBuf);

    /// control ID
    iCtrlID = GetWindowLong(hWndObj, GWL_ID);
    _stprintf_s(cBuf, tsizeof(cBuf), _T("%d"), iCtrlID);
    ::SetDlgItemText(hWndInfo, IDC_EDIT_CTRL_ID, cBuf);

    /// window style
    dwStyle = (DWORD)::GetWindowLong (hWndObj, GWL_STYLE);
    _stprintf_s(cBuf, tsizeof(cBuf), _T("0x%08X"), dwStyle);	
    ::SetDlgItemText(hWndInfo, IDC_EDIT_STYLE, cBuf);

    /// RECT
    ::GetWindowRect(hWndObj, &rc);
    _stprintf_s(cBuf, tsizeof(cBuf), _T("(%d, %d)-(%d, %d) %dx%d"), 
        rc.left, rc.top, rc.right, rc.bottom,
        rc.right - rc.left, rc.bottom - rc.top);
    ::SetDlgItemText(hWndInfo, IDC_EDIT_RECT, cBuf);

    /// thread ID
    _stprintf_s(cBuf, tsizeof(cBuf), _T("0x%08X"), dwTID);
    ::SetDlgItemText(hWndInfo, IDC_EDIT_TID, cBuf);

    /// process ID
    _stprintf_s(cBuf, tsizeof(cBuf), _T("0x%08X"), dwPID);
    ::SetDlgItemText(hWndInfo, IDC_EDIT_PID, cBuf);

    /// class name
    ::GetClassName (hWndObj, cBuf, tsizeof(cBuf));
    ::SetDlgItemText(hWndInfo, IDC_EDIT_CLASS, cBuf);

    if (GetCurrentProcessId () != dwPID)
    {
        ::SetCursor(hCurCaptureHot);

        HANDLE hProcess = OpenProcess(  DW_DESIRED_ACCESS_REMOTE_PROCESS,
                                        FALSE,
                                        dwPID);
        if (hProcess)
        {
            MessageBeep(MB_OK);
            GetModuleFileNameEx(hProcess, 0, cBuf, tsizeof(cBuf));
            CloseHandle(hProcess);
        }
        else 
            _tcscpy_s(cBuf, tsizeof(cBuf), _T(""));
    }

    /// window text
    ::SetDlgItemText(hWndInfo, IDC_EDIT_TEXT,cBuf );
}

VOID HighlightWindow(HWND hWnd, bool bDraw)
{
    HDC     hdc;
    RECT    rc;
    bool    bBorderOn   =   bDraw;

    if (!hWnd || !IsWindow(hWnd))
        return;

    hdc = ::GetWindowDC(hWnd);
    ::GetWindowRect(hWnd, &rc);
    ::OffsetRect(&rc, -rc.left, -rc.top);

    if (!IsRectEmpty(&rc))
    {
        PatBlt( hdc,
                rc.left, 
                rc.top, 
                rc.right - rc.left,
                DINV,
                DSTINVERT);

        PatBlt( hdc,
                rc.left,
                rc.bottom - DINV,
                DINV,
                -(rc.bottom - rc.top - 2 * DINV),
                DSTINVERT);

        PatBlt( hdc,
                rc.right - DINV,
                rc.top + DINV, DINV,
                rc.bottom - rc.top - 2 * DINV,
                DSTINVERT);

        PatBlt( hdc,
                rc.right,
                rc.bottom - DINV,
                -(rc.right - rc.left),
                DINV,
                DSTINVERT);
    }

    ::ReleaseDC(hWnd, hdc);
}

LONGLONG calcRectArea(const RECT & rc)
{
    return (rc.right - rc.left) * (rc.bottom - rc.top);
}

HWND SmallestWindowFromPoint(CONST POINT pt)
{
    RECT    rc;
    RECT    rcTemp;
    HWND    hParent;
    HWND    hWnd;
    HWND    hWndTemp;

    hWnd = ::WindowFromPoint(pt);
    if (hWnd != NULL)
    {
        ::GetWindowRect( hWnd, &rc );
        hParent = ::GetParent( hWnd );

        /// Has window a parent?
        if (hParent)
        {
            /// Search down the Z-Order
            hWndTemp = hWnd;
            do
            {
                hWndTemp = ::GetWindow(hWndTemp, GW_HWNDNEXT);

                /// Search window contains the point, 
                /// hase the same parent, and is visible?
                ::GetWindowRect(hWndTemp, &rcTemp);
                if (::PtInRect(&rcTemp, pt)
                    && (::GetParent(hWndTemp) == hParent)
                    && ::IsWindowVisible(hWndTemp))
                {
                    /// Is it smaller?
                    if (calcRectArea(rcTemp) < calcRectArea(rc))
                    {
                        /// Found new smaller window!
                        hWnd = hWndTemp;
                        ::GetWindowRect(hWnd, &rc);
                    }
                }
            }while (NULL != hWndTemp);
        }
    }

    return hWnd;
}

 

 

<2015-0728>

 

 

今天同事的计算机上弹出了一个Win10升级框, 只有确定按钮, 但是没有取消按钮. 我就推荐了我整的这个工具给他, 将窗口捕获光标拖到那个弹框上, 显示了exe的全路径, 打开任务管理器, 按照名称, 找到了那个弹框程序, 杀掉后, 我很开心~.  很奇怪啊, 别的同事计算机上都没有弹框. 我看到他好像装的是QQ管家.

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值