Hello there..

IM having a problem with detours automatically calling "int WINAPI my_send". I need to be able to call this from my GUI, That i call externally from the WINAPI MainThread.

IM new to c++ but have been programming in various languages for years. So far ive got pretty far without the need of help. But all this DLL stuff is blowing my mind hehe.

Can someone please explain how i would stop "int WINAPI my_send". Been automatically called when the dll is loaded. So i can then call from my GUI.

Thank you very much.

Gavin




Code:
void WINAPI MainThread( )
{
    //This function will run when we attach the DLL
    Main(); //located in Form1.cpp, This will load the form and display it
}


//------------------------------------------------------------------
DETOUR_TRAMPOLINE(int WINAPI real_send(SOCKET Socket, char * buffer, int strlen, int flags),send);

//int WINAPI my_send(SOCKET Socket, char FAR* buffer, int strlen, int flags);

int WINAPI my_send(SOCKET Socket, char FAR* buffer, int strlen, int flags){
 
    send(Socket,packet,10,0);
	Sleep(500);
	send(Socket,packet2,10,0);

return real_send(Socket, buffer, strlen, flags);
}
//------------------------------------------------------------------

//------------------------------------------------------------------
HINSTANCE hinst;

__declspec( dllexport ) LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
        return CallNextHookEx(0, nCode, wParam, lParam);
}; 
//------------------------------------------------------------------



BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
{
    switch ( dwReason ) {
        case DLL_PROCESS_ATTACH:

            DisableThreadLibraryCalls(hModule);

            if ( CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainThread, NULL, 0, NULL) == NULL ) {


				return FALSE;
            }

			  //------------------------------------------------------------------
                DetourFunctionWithTrampoline((PBYTE)real_send,(PBYTE)my_send);
                break;
		      //------------------------------------------------------------------
           break;
            
        case DLL_PROCESS_DETACH:
           //------------------------------------------------------------------
			DetourRemove((PBYTE)real_send,(PBYTE)my_send);
	   //------------------------------------------------------------------
			break;

        case DLL_THREAD_ATTACH:
            break;

        case DLL_THREAD_DETACH:
            break;
    }
    return TRUE;
}