lib:detours
Ceci est une ancienne révision du document !
Permet de décorer les API Windows.
Site GitHub Archive du 09/12/2019 le 07/02/2020
Exemple
Exemple pris sur le Wiki du site GitHub.
#include <windows.h> #include <detours.h> // Target pointer for the uninstrumented Sleep API. // static VOID(WINAPI * TrueSleep)(DWORD dwMilliseconds) = Sleep; // Detour function that replaces the Sleep API. // VOID WINAPI TimedSleep(DWORD dwMilliseconds) { // Save the before and after times around calling the Sleep API. DWORD dwBeg = GetTickCount(); TrueSleep(dwMilliseconds); DWORD dwEnd = GetTickCount(); OutputDebugStringW(L"My output string.\n"); } int main() { if (DetourIsHelperProcess()) { return TRUE; } DetourRestoreAfterWith(); DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourAttach(&(PVOID&)TrueSleep, TimedSleep); DetourTransactionCommit(); Sleep(100); Sleep(100); Sleep(100); DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourDetach(&(PVOID&)TrueSleep, TimedSleep); DetourTransactionCommit(); return 0; }
Sortie dans la console :
My output string. My output string. My output string.
lib/detours.1581103845.txt.gz · Dernière modification : 2020/02/07 20:30 de root