15,471
社区成员
发帖
与我相关
我的任务
分享
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "detours.h"
#pragma comment(lib,"detoured")
#pragma comment(lib,"detours")
void _stdcall myTest()
{
}
static VOID (WINAPI * TrueSleep)(DWORD dwMilliseconds) = &::Sleep;
VOID WINAPI DelaySleep(DWORD dwMilliseconds){
TrueSleep(dwMilliseconds+15000);
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
int error;
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DetourTransactionBegin();
DetourUpdateThread(::GetCurrentThread());
DetourAttach(&(PVOID&)TrueSleep, DelaySleep);
error = DetourTransactionCommit();
break;
case DLL_PROCESS_DETACH:
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)TrueSleep, DelaySleep);
error = DetourTransactionCommit();
break;
case DLL_THREAD_ATTACH:
break;
}
return TRUE;
}