sonexa Newbie cheater
Reputation: 0
Joined: 19 Sep 2011 Posts: 16
|
Posted: Wed Mar 27, 2013 9:26 am Post subject: 2 hardware breakpoints in the same time |
|
|
Code: | #include <Windows.h>
#include <TlHelp32.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
FILE *stream;
DWORD Address;
const DWORD dwAddress = 0x0041d2b9;
const DWORD dwReturnAddress = dwPangAddress + 0x03;
PVOID hVectoredExceptionHandler = NULL;
LONG WINAPI ExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) {
if(ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP) {
if((DWORD)ExceptionInfo->ExceptionRecord->ExceptionAddress == dwAddress) {
PCONTEXT debug_context = ExceptionInfo->ContextRecord;
Address = debug_context->Esi+0x30;
__asm mov eax, Address
__asm mov dword ptr ds:[eax], 96h
__asm mov eax, 96h
debug_context->Eip = dwReturnAddress;
return EXCEPTION_CONTINUE_EXECUTION;
}
}
return EXCEPTION_CONTINUE_SEARCH;
}
DWORD WINAPI Main(__in PVOID pParameter)
{
hVectoredExceptionHandler = AddVectoredExceptionHandler(1, ExceptionFilter);
if(hVectoredExceptionHandler != NULL)
{
DWORD dwProcessIdentifier = GetCurrentProcessId();
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if(hSnapshot != INVALID_HANDLE_VALUE)
{
THREADENTRY32 ThreadEntry32;
ThreadEntry32.dwSize = sizeof(THREADENTRY32);
if(Thread32First(hSnapshot, &ThreadEntry32))
{
CONTEXT Context;
Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
do
{
if(ThreadEntry32.th32OwnerProcessID == dwProcessIdentifier)
{
HANDLE hThread = OpenThread(THREAD_SET_CONTEXT | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,
FALSE, ThreadEntry32.th32ThreadID);
SuspendThread(hThread);
GetThreadContext(hThread, &Context);
Context.Dr0 = dwAddress;
Context.Dr1 = $04444444;
Context.Dr7 = 1;
SetThreadContext(hThread, &Context);
ResumeThread(hThread);
CloseHandle(hThread);
}
}
while(Thread32Next(hSnapshot, &ThreadEntry32));
}
CloseHandle(hSnapshot);
return 0;
}
#ifdef _DEBUG
else
{
}
#endif
}
#ifdef _DEBUG
else
{
}
#endif
return -1;
}
BOOL WINAPI DllMain(__in HMODULE hModule, __in DWORD dwReason, __in PVOID pReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
if(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Main, NULL, 0, NULL) == NULL)
{
#ifdef _DEBUG
#endif
return FALSE;
}
}
else if(dwReason == DLL_PROCESS_DETACH)
{
if((hVectoredExceptionHandler != NULL) && (RemoveVectoredExceptionHandler(hVectoredExceptionHandler) == 0))
{
#ifdef _DEBUG
#endif
return FALSE;
}
}
return TRUE;
} |
how i can set 2 hardware breakpoints at the same time? like DR0 and DR1?
|
|