永发信息网

求组 c++程序改错

答案:1  悬赏:80  手机版
解决时间 2021-05-07 16:37
  • 提问者网友:我没有何以琛的痴心不悔
  • 2021-05-07 12:09

#include <windows.h>
#include <stdio.h>
#include <tlhelp32.h>
#include <conio.h>
#define W2I_WINDOW_TITLE TEXT("Element Client")
#define W2I_WINDOW_CLASS TEXT("ElementClient Window") 
//#define W2I_WINDOW_TITLE NULL 
//#define W2I_WINDOW_CLASS TEXT("Notepad")  
#define W2I_SENDCALL      0x00588EF0
#define W2I_SENDCALL_ADDR1      (W2I_SENDCALL+0x8E)
#define W2I_SENDCALL_ADDR2      (W2I_SENDCALL+0x8F)
#define BREAK_DR7_FLAG          0x401
int main(int argc, char* argv[])

    HANDLE hW2iProcess;
    DWORD dwW2iProcessId;  
    HWND hW2iWnd; 
    DWORD Count = 0; 
 
    //查找窗口,并且获取窗口进程线程ID 
    hW2iWnd =::FindWindow(W2I_WINDOW_CLASS, W2I_WINDOW_TITLE); 
    if( hW2iWnd>0 && ::GetWindowThreadProcessId(hW2iWnd, &dwW2iProcessId)
        && dwW2iProcessId && ( hW2iProcess = ::OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwW2iProcessId) ) 
        && DebugActiveProcess(dwW2iProcessId) )
    {
        DEBUG_EVENT DebugEv;
        DWORD dwContinueStatus; 
        while(TRUE)
        {
            if(WaitForDebugEvent(&DebugEv, 10))
            {
                dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED;
                switch(DebugEv.dwDebugEventCode) 
                {
                case EXCEPTION_DEBUG_EVENT:
                    {
                        if((DWORD) 
DebugEv.u.Exception.ExceptionRecord.ExceptionAddress==W2I_SENDCALL_ADDR1) 
                        { 
                            HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, DebugEv.dwThreadId);
                            SuspendThread(hThread);  
                            CONTEXT Regs = {0};
                            Regs.ContextFlags =CONTEXT_DEBUG_REGISTERS|CONTEXT_INTEGER;
                            ::GetThreadContext(hThread, &Regs);". 
                            Regs.Dr0 = W2I_SENDCALL_ADDR2;
                            Regs.Dr7 = BREAK_DR7_FLAG;
                            printf("%d\n", Count++); 
                            //Regs.Esi - len Ymw.XA  
                            //Regs.Ecx - buf 4.8.9.xoP 
                            BYTE buf[1024];  
                            SIZE_T len = (Regs.Esi<512 ? Regs.Esi : 512); 
                            if( ReadProcessMemory(hW2iProcess, (void*) Regs.Ecx, buf, len, &len) )
                            {
                                FILE * fp = fopen("Cap.txt", "a+"); 
                                for(SIZE_T i=0; i<len; i++) 
                                {  
                                    printf("%02X ", buf); 
                                    if(fp) 
                                        fprintf(fp, "%02X ", buf);
                                }  
                                printf("\n\n");
                                if(fp) 
                                {
                                    fprintf(fp, "\n\n");
                                    fclose(fp);
                                }
                            }
                            ::SetThreadContext(hThread, &Regs);
                            ResumeThread(hThread);
                            CloseHandle(hThread);
                        }

最佳答案
  • 五星知识达人网友:罪歌
  • 2021-05-07 13:36
编译时有错误?还是运行时有错误?太长了,光看也没用....我现在这台电脑没c++,把问题说清楚点额,我现在没法实验
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯