View Single Post

Old 09-09-2008, 08:15 AM   #12 (permalink)
ulliklliwi

Disciple
 
ulliklliwi's Avatar
 
Join Date: May 2007
Location: The Code Cave after the JMP Gate
Posts: 546
ulliklliwi has a spectacular aura about
Send a message via MSN to ulliklliwi
Default

PHP Code:
#include <windows.h>
#include <winsock.h>
#include "detours.h"

#pragma comment(lib, "detours.lib")
#pragma comment(lib, "Ws2_32.lib")

typedef int (WINAPItRecv)(SOCKET scharbufint lenint Flag);

    
tRecv oRecv NULL;

DWORD WINAPI SetHooks(LPVOID);
int WINAPI hRecv(SOCKET scharbufint lenint Flag);

BOOL APIENTRY DllMain(HINSTANCE hModuleDWORD  ul_reason_for_callLPVOID lpReserved)
{
    switch(
ul_reason_for_call)
    {
        case 
DLL_PROCESS_ATTACH:
            
CreateThread(00SetHooks000);
        break;
        case 
DLL_PROCESS_DETACH:
        break;
    }
    return 
TRUE;
}
    
// Put me in a Thread;
DWORD WINAPI SetHooks(LPVOID) {
    for (
Sleep(1000); GetModuleHandle("Ws2_32.dll") == NULLSleep(1000))
        continue;

    
oRecv = (tRecv)DetourFunction((PBYTE)RecvhRecv);
}

int WINAPI hRecv(SOCKET scharbufint lenint Flag) {
    
    
// do something b4 you call the RECV
    
int iRet oRecv(sbuflenFlag); // call real function
    // do something after you call RECV
    
return iRet;

Attached Files
File Type: zip detours.zip (65.1 KB, 5 views)

Last edited by ulliklliwi : 09-09-2008 at 07:10 PM.
ulliklliwi 15 0FF11|\|3   Reply With Quote