lib:detours
Permet de décorer les API Windows.
Site GitHub Archive du 09/12/2019 le 07/02/2020
Compilation
Se compile avec nmake.exe
de Visual Studio.
J'ai dû ajouter au CFLAGS
du fichier src/Makefile
/I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" /I "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt"
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.txt · Dernière modification : 2020/02/07 20:32 de root