首页
社区
课程
招聘
[讨论]朝闻道,夕可死
发表于: 2006-5-22 11:22 4964

[讨论]朝闻道,夕可死

2006-5-22 11:22
4964
WIN的GUI程序都有个WINPROC,被声明为回调涵数,看一般的注释都说有WIN系统来调用,请问
:
1.到底由WIN中的谁来调用?是KERNEL32.DLL来调用?
2.我猜测这个回调涵数在DispatchMessage中掉用,DispatchMessage怎么知道回调函数在什么地方(回调函数地址)?只是查了很多关于DispatchMessage的说明,对他的原理讲基本是无用的重复滥调,能不能有谁把他的实现流程讲一讲?能否举个例子分析他?
如果有人能够做鞭辟入里的分析,我一定跪求看雪老大加精。

[课程]Linux pwn 探索篇!

收藏
免费 1
支持
分享
最新回复 (4)
雪    币: 207
活跃值: (40)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
与用户交互在user32.dll
2006-5-22 12:07
0
雪    币: 494
活跃值: (629)
能力值: ( LV9,RANK:1210 )
在线值:
发帖
回帖
粉丝
3
注册窗口类的时候,就知道回调函数是什么了
2006-5-22 12:36
0
雪    币: 291
活跃值: (213)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
4
粗略流程, 不够准确, 期待各位大虾的详细分析
DispatchMessageA
{
  _DispatchMessageWorker
  {
     ValidateHwnd
     查找MessageTable
     UserCallWinProcCheckWow
     {
        RtlActivateActivationContextUnsafeFast
        BeginIfHookedUserApiHook
        InternalCallWinProc
     }
  }
}
2006-5-22 13:07
0
雪    币: 1325
活跃值: (507)
能力值: ( LV12,RANK:450 )
在线值:
发帖
回帖
粉丝
5
关键在于HWND,所谓句柄,就是WINDOWS可以据此找到相关内部结构的东东

下面是DispatchMessageWorker函数的开头部分:
LRESULT DispatchMessageWorker(
    MSG *pmsg,
    BOOL fAnsi)
{
    PWND pwnd;
    WPARAM wParamSaved;
    LRESULT lRet;
    BOOL bDoDbcsMessaging = FALSE;

    /*
     * Prevent apps from setting hi 16 bits so we can use them internally.
     */
    if (pmsg->message & RESERVED_MSG_BITS) {
        RIPERR1(ERROR_INVALID_PARAMETER,
                RIP_WARNING,
                "Invalid parameter \"pmsg->message\" (%ld) to DispatchMessageWorker",
                pmsg->message);

        return 0;
    }

    if (pmsg->hwnd != NULL) {
        pwnd = ValidateHwnd(pmsg->hwnd);
        if (pwnd == NULL)
            return 0;
        pmsg->hwnd = HWq(pwnd);     // get full 32-bit HWND in case this came from WoW
    } else {
        pwnd = NULL;
    }
这里出现了一个新的结构PWND pwnd,并且可以从hwnd得到它
    pwnd = ValidateHwnd(pmsg->hwnd);
下面是这个结构的内容:
typedef struct tagWND               *PWND;

typedef struct tagWND {          // wnd
    THRDESKHEAD   head;

    WW;         // WOW-USER common fields. Defined in wowuserp.h
                //  The presence of "state" at the start of this structure is assumed
                //  by the STATEOFFSET macro.

    struct tagWND *spwndNext;    // Handle to the next window
    struct tagWND *spwndParent;  // Backpointer to the parent window.
    struct tagWND *spwndChild;   // Handle to child
    struct tagWND *spwndOwner;   // Popup window owner field

    RECT          rcWindow;     // Window outer rectangle
    RECT          rcClient;     // Client rectangle

    WNDPROC_PWND lpfnWndProc;   // Can be WOW address or standard address

    PCLS          pcls;         // Pointer to window class
    int           cbwndExtra;   // Extra bytes in window

    HRGN          hrgnUpdate;   // Accumulated paint region

    struct tagWND *spwndLastActive; // Last active in owner/ownee list
    PPROPLIST     ppropList;    // Pointer to property list
    PSBINFO        pSBInfo;   // Words used for scrolling

    struct tagMENU *spmenuSys;  // Handle to system menu
    struct tagMENU *spmenu;     // Menu handle or ID
    LARGE_UNICODE_STRING strName;

    ULONG_PTR      dwUserData;   // Reserved for random application data
    HRGN          hrgnClip;     // Clipping region for this window

    HIMC          hImc;         // Associated input context handle

} WND;
2006-5-22 13:33
0
游客
登录 | 注册 方可回帖
返回
//