View Single Post
  #10  
Old 05-11-2016, 09:32
IChooseYou
 
Posts: n/a
I have only used to Detours 1.5 before, and the documentation for 3.0 isn't great. So in case anyone struggles:

PHP Code:
PVOID SetDetourPVOIDppTargetPVOID pHandler )
{
    if ( 
DetourTransactionBegin( ) != NO_ERROR )
        return 
FALSE;

    if ( 
DetourUpdateThreadGetCurrentThread( ) ) != NO_ERROR )
    {
        
DetourTransactionCommit( );
        return 
NULL;
    }

    
PDETOUR_TRAMPOLINE pTrampoline NULL;
    
    if ( 
DetourAttachExppTargetpHandler, &pTrampolineNULLNULL ) != NO_ERROR )
    {
        
DetourTransactionCommit( );
        return 
NULL;        
    }

    if ( 
DetourTransactionCommit( ) != NO_ERROR )
    {
        
DetourTransactionAbort( );
        return 
NULL;
    }

    return 
pTrampoline;

Retouring works the same, call DetourDetach as opposed to DetourAttach/DetourAttachEx

PHP Code:
    g_lpDispatchMessage reinterpret_cast<PVOID*>( 0x14317DCD0 );
    
oDispatchMessage reinterpret_cast<tDispatchMessage>( SetDetour( &g_lpDispatchMessagehkDispatchMessage ) );

    
RemoveDetour( &g_lpDispatchMessagehkDispatchMessage ); 
Reply With Quote
The Following 6 Users Say Thank You to For This Useful Post:
besoeso (05-12-2016), dude719 (05-12-2016), romero (05-26-2016), user_hidden (05-11-2016)