自写FindWindow函数

模拟FindWindow函数,绕过所有用户层HOOK

  1. 分析API函数原理

FindWindowA最外层流程:

进入CALL USER32.77D28242:

进入CALL USER32.77D2C7AC (NtUserFindWindow)

 

进入CALL ntdll.KiFastSystemCall:

  1. 自写FindWindow函数(硬编码)

#pragma pack(1)

typedef struct _UNICODE_STRING {

    USHORT Length;

    USHORT MaximumLength; 

    PWSTR  Buffer;

 

} UNICODE_STRING,*PUNICODE_STRING;

#pragma pack()


__declspec(naked)   void sysFastCall()

{

    __asm

    {

        // 7C92E510 >  8BD4          MOV EDX,ESP

        //7C92E512    0F34            SYSENTER
    
        mov edx,esp

        __emit 0x0f

        __emit 0x34

    }

}

/*

77D28285   .  FF75 18       PUSH DWORD PTR SS:[EBP+18]                    ;  0

77D28288   .  FF75 E8       PUSH DWORD PTR SS:[EBP-18]                    ;  PU_LCatipn

77D2828B   .  FF75 F8       PUSH DWORD PTR SS:[EBP-8]                     ;  NULL

77D2828E   .  FF75 0C       PUSH DWORD PTR SS:[EBP+C]                     ;  0

77D28291   .  FF75 08       PUSH DWORD PTR SS:[EBP+8]                     ;  0

77D28294   .  E8 13450000   CALL USER32.77D2C7AC                          ;  NtUserFindWindow

*/

__declspec(naked) HWND  __stdcall My_FindWindow(int p1,int p2,PUNICODE_STRING pu_classname,PUNICODE_STRING pu_catption,int p5)

{

    __asm

    {

        MOV EAX,0x117A

        call sysFastCall

        RETN 0x14


    }

}


void CTest_APIDlg::OnButtonMyFindwindow()

{

    UNICODE_STRING pu_className,pu_Caption;

    typedef   (__stdcall *PRtlInitUnicodeString)( PUNICODE_STRING , PCWSTR  );

    PRtlInitUnicodeString  RtlInitUnicodeString;

    RtlInitUnicodeString=(PRtlInitUnicodeString)GetProcAddress(GetModuleHandle("ntdll.dll"),"RtlInitUnicodeString");


    RtlInitUnicodeString(&pu_className,L"SciCalc");

    RtlInitUnicodeString(&pu_Caption,L"计算器");
    

    HWND h=My_FindWindow(0,0,&pu_className,&pu_Caption,0);

    ::SendMessage(h,WM_CLOSE,0,0);

}

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值