关于调试函数 (高分) 请问DebugActiveProcess WaitforDebugEvent ContinueDebugEvent SetThreadContext 这些函数如何使用 MSDN中都是英文没能完全理解 希望能够用这些函数写个例子给我看看 小弟万分感谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CreateProcess(..., DEBUG_PROCESS, ...) or DebugActiveProcess(dwProcessId)DEBUG_EVENT de;BOOL bContinue = TRUE;DWORD dwContinueStatus;while(bContinue){ bContinue = WaitForDebugEvent(&de, INFINITE); switch(de.dwDebugEventCode) { ... default: { dwContinueStatus = DBG_CONTINUE; break; } } ContinueDebugEvent(de.dwProcessId, de.dwThreadId, dwContinueStatus);} 先是DebugActiveProcess,BOOL DebugActiveProcess(DWORD dwProcessId // process to be debugged);参数就一个就是目标进程的ID,可以用我前面说的方法来得到。当开始调试一个进程后,就可以使用WaitForDebugEvent,BOOL WaitForDebugEvent(LPDEBUG_EVENT lpDebugEvent, // pointer to debug event structureDWORD dwMilliseconds // milliseconds to wait for event);来等待DEBUG事件了~DEBUG_EVENT的结构定义是这样的:*************************************************************typedef struct _DEBUG_EVENT { // de DWORD dwDebugEventCode; DWORD dwProcessId; DWORD dwThreadId; union { EXCEPTION_DEBUG_INFO Exception; CREATE_THREAD_DEBUG_INFO CreateThread; CREATE_PROCESS_DEBUG_INFO CreateProcessInfo; EXIT_THREAD_DEBUG_INFO ExitThread; EXIT_PROCESS_DEBUG_INFO ExitProcess; LOAD_DLL_DEBUG_INFO LoadDll; UNLOAD_DLL_DEBUG_INFO UnloadDll; OUTPUT_DEBUG_STRING_INFO DebugString; RIP_INFO RipInfo; } u; } DEBUG_EVENT; typedef struct _EXCEPTION_RECORD { // exr DWORD ExceptionCode; DWORD ExceptionFlags; struct _EXCEPTION_RECORD *ExceptionRecord; PVOID ExceptionAddress; DWORD NumberParameters; DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD; typedef struct _EXCEPTION_DEBUG_INFO { // exdi EXCEPTION_RECORD ExceptionRecord; DWORD dwFirstChance; } EXCEPTION_DEBUG_INFO; *************************************************************在众多事件中,我们关心的只有EXCEPTION_DEBUG_EVENT,当dwDebugEventCode==EXCEPTION_DEBUG_EVENT时,U的结构展开是这样的!ExceptionCode表明了DEBUG事件产生的原因;可能的值中,需要我们关心的只有EXCEPTION_BREAKPOINT。当目标执行到指令INT3时就会触发上面的EXCEPTION_BREAKPOINT时间,所以,我们大可以在SEND/RECV等API入口处放一个INT3指令,当游戏调用该API时就触发了一个调试事件,进程被挂起,然后通知调试进程,这个时候,我们就可以从游戏程序的堆栈中读取参数,甚至修改~~最后,做了一些必要的出来后记得调用ContinueDebugEvent来继续游戏程序的执行~ //遍历进程#include <stdio.h>#include <windows.h>#include <tlhelp32.h>#include <tchar.h>int main(){ HANDLE hSnapshot; PROCESSENTRY32 pe; BOOL bSucceed; TCHAR * szFileName = NULL; DWORD dwProcessID = 0; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); bSucceed = Process32First(hSnapshot, &pe); while(bSucceed) { szFileName = _tcsrchr(pe.szExeFile, '\\'); if(!szFileName) szFileName = pe.szExeFile; else szFileName ++; printf("\n%d\t%s",pe.th32ProcessID,szFileName); //判断创建这个进程的文件是不是explorer.exe if(!_tcsnicmp(szFileName, "Explorer.exe", 12)) { //保存继承的ID dwProcessID = pe.th32ProcessID; break; } //转到下一个进程 bSucceed = Process32Next(hSnapshot, &pe); } CloseHandle(hSnapshot); return 0;}里边可以得到所有的PID,根据自己的需求,钩挂PID,就可以作调试了。 怎么用vb画出下面坐标的轨迹 sql int类型增加问题? vba中怎么判断WORD的当前窗口是不是处于“设计模式”? 我是新手帮忙怎样用VB在PC机上虚拟LED显示屏 。 用winsock在传输文件过程中,把网线等拔掉,就是吊线了,服务器端出错如何避免? "事件程式的宣告與同名事件的描述不相符",請問如何處理 请问怎样求反码和补码 VB的ADO的连接问题? 找个人做老师! 请问如何用VB对一个*.dbf文件添加字段? 為什麽我能用GOOGLE搜索到他們提問的答案,而他們自己卻不行? Excel进程问题.
BOOL bContinue = TRUE;
DWORD dwContinueStatus;while(bContinue)
{
bContinue = WaitForDebugEvent(&de, INFINITE); switch(de.dwDebugEventCode)
{
...
default:
{
dwContinueStatus = DBG_CONTINUE;
break;
}
} ContinueDebugEvent(de.dwProcessId, de.dwThreadId, dwContinueStatus);
}
BOOL DebugActiveProcess(
DWORD dwProcessId // process to be debugged
);
参数就一个就是目标进程的ID,可以用我前面说的方法来得到。当开始调试一个进程后,就可以使用WaitForDebugEvent,
BOOL WaitForDebugEvent(
LPDEBUG_EVENT lpDebugEvent, // pointer to debug event structure
DWORD dwMilliseconds // milliseconds to wait for event
);
来等待DEBUG事件了~
DEBUG_EVENT的结构定义是这样的:
*************************************************************
typedef struct _DEBUG_EVENT { // de
DWORD dwDebugEventCode;
DWORD dwProcessId;
DWORD dwThreadId;
union {
EXCEPTION_DEBUG_INFO Exception;
CREATE_THREAD_DEBUG_INFO CreateThread;
CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
EXIT_THREAD_DEBUG_INFO ExitThread;
EXIT_PROCESS_DEBUG_INFO ExitProcess;
LOAD_DLL_DEBUG_INFO LoadDll;
UNLOAD_DLL_DEBUG_INFO UnloadDll;
OUTPUT_DEBUG_STRING_INFO DebugString;
RIP_INFO RipInfo;
} u;
} DEBUG_EVENT; typedef struct _EXCEPTION_RECORD { // exr
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD; typedef struct _EXCEPTION_DEBUG_INFO { // exdi
EXCEPTION_RECORD ExceptionRecord;
DWORD dwFirstChance;
} EXCEPTION_DEBUG_INFO;
*************************************************************
在众多事件中,我们关心的只有EXCEPTION_DEBUG_EVENT,当dwDebugEventCode==EXCEPTION_DEBUG_EVENT时,U的结构展开是这样的!ExceptionCode表明了DEBUG事件产生的原因;可能的值中,需要我们关心的只有EXCEPTION_BREAKPOINT。当目标执行到指令INT3时就会触发上面的EXCEPTION_BREAKPOINT时间,所以,我们大可以在SEND/RECV等API入口处放一个INT3指令,
当游戏调用该API时就触发了一个调试事件,进程被挂起,然后通知调试进程,这个时候,我们就可以从游戏程序的堆栈中读取参数,
甚至修改~~最后,做了一些必要的出来后记得调用ContinueDebugEvent来继续游戏程序的执行~
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>int main()
{
HANDLE hSnapshot;
PROCESSENTRY32 pe;
BOOL bSucceed;
TCHAR * szFileName = NULL;
DWORD dwProcessID = 0;
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); bSucceed = Process32First(hSnapshot, &pe); while(bSucceed)
{
szFileName = _tcsrchr(pe.szExeFile, '\\');
if(!szFileName)
szFileName = pe.szExeFile;
else
szFileName ++;
printf("\n%d\t%s",pe.th32ProcessID,szFileName);
//判断创建这个进程的文件是不是explorer.exe
if(!_tcsnicmp(szFileName, "Explorer.exe", 12))
{
//保存继承的ID
dwProcessID = pe.th32ProcessID;
break;
}
//转到下一个进程
bSucceed = Process32Next(hSnapshot, &pe);
}
CloseHandle(hSnapshot);
return 0;
}
里边可以得到所有的PID,根据自己的需求,钩挂PID,就可以作调试了。